Ignore:
Timestamp:
09/17/15 17:19:14 (10 years ago)
Author:
epyon
Message:
  • animation time definition fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gfx/keyframed_mesh.cc

    r454 r470  
    7272}
    7373
    74 void nv::keyframed_mesh::update_animation( animation_entry* anim, uint32 a_anim_time )
     74void nv::keyframed_mesh::update_animation( animation_entry* anim, uint32 a_ms_anim_time )
    7575{
    7676        if ( m_active )
    7777        {
    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 )
    8184                {
    8285                        if ( anim->is_looping() )
    8386                        {
    84                                 tick_time = fmodf( tick_time, duration );
     87                                frame  = frame % duration;
     88                                fframe = static_cast<float>( frame ) + reminder;
    8589                        }
    8690                        else
    8791                        {
    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;
    9195                                m_interpolation = 0.0f;
    9296                                return;
    9397                        }
    9498                }
    95                 m_last_frame    = static_cast<uint32>( math::floor( tick_time ) + anim->get_start() );
     99                m_last_frame    = frame + anim->get_start_frame();
    96100                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;
    99103        }
    100104}
Note: See TracChangeset for help on using the changeset viewer.