Renamed m_current_time to m_time_current to simplify root bone sampling.
This commit is contained in:
@@ -10,16 +10,18 @@
|
||||
struct AnimSamplerNode : public AnimNode {
|
||||
AnimSamplerNode(AnimationController* animation_controller)
|
||||
: AnimNode(animation_controller),
|
||||
m_time_prev(0.f),
|
||||
m_override_ratio(false),
|
||||
m_anim_ratio(0.f),
|
||||
m_root_bone_index(0) {
|
||||
assert(m_current_time < 100.0f);
|
||||
assert(m_time_current < 100.0f);
|
||||
m_anim_node_type = AnimNodeType::AnimSampler;
|
||||
};
|
||||
virtual ~AnimSamplerNode() {}
|
||||
|
||||
ozz::animation::Animation* m_animation;
|
||||
|
||||
float m_time_prev;
|
||||
bool m_override_ratio;
|
||||
float m_anim_ratio;
|
||||
float m_anim_ratio_prev;
|
||||
@@ -40,22 +42,28 @@ struct AnimSamplerNode : public AnimNode {
|
||||
virtual void UpdateSyncTrack() override {}
|
||||
|
||||
virtual void UpdateTime(float dt) override {
|
||||
m_current_time += dt;
|
||||
if (!m_override_ratio) {
|
||||
if (m_is_time_synced) {
|
||||
m_anim_ratio = m_sync_track.CalcRatioFromSyncTime(m_current_time);
|
||||
float prev_sync_time = m_current_time - dt;
|
||||
if (m_current_time < 0) {
|
||||
prev_sync_time += m_sync_track.m_num_intervals;
|
||||
}
|
||||
m_anim_ratio_prev = m_sync_track.CalcRatioFromSyncTime(prev_sync_time);
|
||||
} else {
|
||||
m_anim_ratio =
|
||||
fmodf((float)m_current_time / m_animation->duration(), 1.0f);
|
||||
m_anim_ratio_prev = fmodf((float)m_current_time / m_animation->duration(), 1.0f);
|
||||
if (m_anim_ratio_prev < 0) {
|
||||
m_anim_ratio_prev += 1.0f;
|
||||
}
|
||||
if (m_override_ratio) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_time_prev = m_time_current;
|
||||
m_time_current += dt;
|
||||
|
||||
if (m_is_time_synced) {
|
||||
m_anim_ratio = m_sync_track.CalcRatioFromSyncTime(m_time_current);
|
||||
float prev_sync_time = m_time_current - dt;
|
||||
if (m_time_current < 0) {
|
||||
prev_sync_time += m_sync_track.m_num_intervals;
|
||||
}
|
||||
m_anim_ratio_prev = m_sync_track.CalcRatioFromSyncTime(prev_sync_time);
|
||||
} else {
|
||||
m_anim_ratio =
|
||||
fmodf((float)m_time_current / m_animation->duration(), 1.0f);
|
||||
m_anim_ratio_prev =
|
||||
fmodf((float)m_time_prev / m_animation->duration(), 1.0f);
|
||||
|
||||
if (m_anim_ratio_prev < 0) {
|
||||
m_anim_ratio_prev += 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user