Skip to content

Commit d05479e

Browse files
Merge pull request #1218 from Mikalai/animation_issue
Fix forward and back animation issue
2 parents 971e164 + f6b2455 commit d05479e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/vsg/animation/Animation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,18 @@ bool Animation::update(double simulationTime)
136136
return x < 0.0 ? y + std::fmod(x, y) : std::fmod(x, y);
137137
};
138138

139-
time = time + (simulationTime - _previousSimulationTime) * speed;
139+
auto samplerTime = time = time + (simulationTime - _previousSimulationTime) * speed;
140+
140141
_previousSimulationTime = simulationTime;
141142

142143
if (mode == REPEAT)
143144
{
144-
time = time_within_period(time, _maxTime);
145+
samplerTime = time = time_within_period(time, _maxTime);
145146
}
146147
else if (mode == FORWARD_AND_BACK)
147148
{
148-
time = time_within_period(time, 2.0 * _maxTime);
149-
if (time > _maxTime) time = 2.0 * _maxTime - time;
149+
samplerTime = time = time_within_period(time, 2.0 * _maxTime);
150+
if (time > _maxTime) samplerTime = 2.0 * _maxTime - time;
150151
}
151152
else
152153
{
@@ -159,7 +160,7 @@ bool Animation::update(double simulationTime)
159160

160161
for (auto sampler : samplers)
161162
{
162-
sampler->update(time);
163+
sampler->update(samplerTime);
163164
}
164165

165166
return true;

0 commit comments

Comments
 (0)