Fixed SpeedScale node not properly propagating time.

This commit is contained in:
Martin Felis
2023-04-02 21:24:12 +02:00
parent abf44a875a
commit 7c8b44247b
5 changed files with 50 additions and 10 deletions
+4 -4
View File
@@ -138,7 +138,7 @@ struct NodeDescriptor<Blend2Node> : public NodeDescriptorBase {
Socket* weight_input_socket = FindSocket("Weight", m_inputs);
assert(weight_input_socket != nullptr);
if (GetProperty<bool>("Sync") == true) {
if (GetPropertyValue<bool>("Sync") == true) {
weight_input_socket->m_flags = SocketFlags::SocketFlagAffectsTime;
} else {
weight_input_socket->m_flags = SocketFlags::SocketFlagNone;
@@ -156,8 +156,8 @@ struct SpeedScaleNode : public AnimNode {
float* i_speed_scale = nullptr;
void UpdateTime(float time_last, float time_now) override {
m_time_last = time_last;
m_time_now = time_last + (time_now - time_last) * (*i_speed_scale);
m_time_last = m_time_now;
m_time_now = m_time_last + (time_now - time_last) * (*i_speed_scale);
m_state = AnimNodeEvalState::TimeUpdated;
}
@@ -196,7 +196,7 @@ struct AnimSamplerNode : public AnimNode {
virtual bool Init(AnimGraphContext& context) override;
void UpdateTime(float time_last, float time_now) override {
m_time_last = time_last;
m_time_now = fmodf(time_last + (time_now - time_last), m_animation->duration());
m_time_now = time_now;
m_state = AnimNodeEvalState::TimeUpdated;
}
virtual void Evaluate(AnimGraphContext& context) override;