Changeset 283 for trunk/src/gfx/keyframed_mesh.cc
- Timestamp:
- 07/10/14 20:58:27 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r282 r283 23 23 , m_last_frame( 0 ) 24 24 , m_next_frame( 0 ) 25 , m_time( 0 )26 25 , m_fps( 0 ) 27 26 , m_interpolation( 0.0f ) … … 56 55 m_fps = fps; 57 56 m_active = count > 1; 58 m_time = 0;59 57 m_last_frame = start; 60 58 m_next_frame = (count > 1 ? start + 1 : start ); … … 70 68 } 71 69 72 void keyframed_mesh::update( uint32 ms)70 void nv::keyframed_mesh::update_animation( animation_entry*, uint32 a_anim_time ) 73 71 { 74 72 if ( m_active ) 75 73 { 76 m_time += ms;77 74 uint32 f_diff = (m_stop_frame - m_start_frame); 78 float f_time= 1000 / (float)m_fps;75 float f_time = 1000 / (float)m_fps; 79 76 float f_max = ( m_looping ? ( f_diff + 1 ) : f_diff ) * f_time; 80 float f_pos = m_time / f_time; 81 82 m_last_frame = (uint32)glm::floor( f_pos ) + m_start_frame; 83 m_next_frame = m_last_frame + 1; 84 if ( m_next_frame > m_stop_frame ) 85 { 86 m_next_frame = m_start_frame; 87 } 88 89 if ( m_time >= f_max ) 77 uint32 time = a_anim_time; 78 if ( time >= f_max ) 90 79 { 91 80 if ( m_looping ) 92 81 { 93 uint32 left = m_time - static_cast< uint32 >( f_max ); 94 m_time = 0; 95 update( left ); 82 time = time % static_cast< uint32 >( f_max ); 96 83 } 97 84 else … … 102 89 } 103 90 } 91 float f_pos = time / f_time; 92 93 m_last_frame = (uint32)glm::floor( f_pos ) + m_start_frame; 94 m_next_frame = m_last_frame + 1; 95 if ( m_next_frame > m_stop_frame ) m_next_frame = m_start_frame; 104 96 m_interpolation = f_pos - glm::floor( f_pos ); 105 97 } 106 98 } 99 107 100 108 101 void nv::keyframed_mesh::update( program* a_program ) const … … 148 141 void nv::keyframed_mesh_gpu::update( uint32 ms ) 149 142 { 150 keyframed_mesh::update( ms );143 animated_mesh::update( ms ); 151 144 152 145 if ( m_gpu_last_frame != m_last_frame ) … … 181 174 void nv::keyframed_mesh_cpu::update( uint32 ms ) 182 175 { 183 keyframed_mesh::update( ms );176 animated_mesh::update( ms ); 184 177 185 178 const vertex_pn* data = m_mesh_data->get_channel_data<vertex_pn>();
Note: See TracChangeset
for help on using the changeset viewer.