Changeset 470 for trunk/src/gfx/keyframed_mesh.cc
- Timestamp:
- 09/17/15 17:19:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gfx/keyframed_mesh.cc
r454 r470 72 72 } 73 73 74 void nv::keyframed_mesh::update_animation( animation_entry* anim, uint32 a_ anim_time )74 void nv::keyframed_mesh::update_animation( animation_entry* anim, uint32 a_ms_anim_time ) 75 75 { 76 76 if ( m_active ) 77 77 { 78 float tick_time = ( static_cast<float>( a_anim_time ) * 0.001f ) * anim->get_frame_rate(); 79 float duration = anim->is_looping() ? anim->get_duration() + 1.0f : anim->get_duration(); 80 if ( tick_time >= duration ) 78 float fframe = ( static_cast<float>( a_ms_anim_time ) * 0.001f ) * anim->get_fps(); 79 uint32 frame = uint32( fframe ); 80 float reminder = fframe - static_cast<float>( frame ); 81 uint32 duration = anim->is_looping() ? anim->get_frame_count() + 1 : anim->get_frame_count(); 82 83 if ( frame >= duration ) 81 84 { 82 85 if ( anim->is_looping() ) 83 86 { 84 tick_time = fmodf( tick_time, duration ); 87 frame = frame % duration; 88 fframe = static_cast<float>( frame ) + reminder; 85 89 } 86 90 else 87 91 { 88 m_active = false;89 m_last_frame = static_cast<uint32>( anim->get_end());90 m_next_frame = m_last_frame;92 m_active = false; 93 m_last_frame = anim->get_end_frame(); 94 m_next_frame = m_last_frame; 91 95 m_interpolation = 0.0f; 92 96 return; 93 97 } 94 98 } 95 m_last_frame = static_cast<uint32>( math::floor( tick_time ) + anim->get_start());99 m_last_frame = frame + anim->get_start_frame(); 96 100 m_next_frame = m_last_frame + 1; 97 if ( m_next_frame > static_cast<uint32>( anim->get_end() ) ) m_next_frame = static_cast<uint32>( anim->get_start());98 m_interpolation = tick_time - math::floor( tick_time );101 if ( m_next_frame > anim->get_end_frame() ) m_next_frame = anim->get_start_frame(); 102 m_interpolation = reminder; 99 103 } 100 104 }
Note: See TracChangeset
for help on using the changeset viewer.