Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clamp animation time to available range #1504

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ if(VTK_VERSION VERSION_GREATER 9.0.1)
f3d_test(NAME TestInteractionAnimationFrameRate DATA InterpolationTest.glb ARGS --animation-frame-rate=2 --animation-index=-1 INTERACTION NO_BASELINE)#Space;Wait;Space;

# A verbose test that needs animation index support
f3d_test(NAME TestVerboseAnimationWrongAnimationTime DATA BoxAnimated.gltf ARGS --animation-time=10 --verbose REGEXP "Provided time value: 10 is outside of animation time range" NO_BASELINE)
f3d_test(NAME TestVerboseAnimationWrongAnimationTimeHigh DATA BoxAnimated.gltf ARGS --animation-time=10 --verbose REGEXP "animation time 10 is outside of range \\[0, 3\\.70833\\], using 3\\.70833" NO_BASELINE)
f3d_test(NAME TestVerboseAnimationWrongAnimationTimeLow DATA BoxAnimated.gltf ARGS --animation-time=-5 --verbose REGEXP "animation time -5 is outside of range \\[0, 3\\.70833\\], using 0" NO_BASELINE)
mwestphal marked this conversation as resolved.
Show resolved Hide resolved

# Test exit hotkey
f3d_test(NAME TestInteractionSimpleExit DATA cow.vtp REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #Escape;
Expand Down
17 changes: 13 additions & 4 deletions library/src/animationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,21 @@ bool animationManager::LoadAtTime(double timeValue)
{
return false;
}
if (timeValue < this->TimeRange[0] || timeValue > this->TimeRange[1])

/* clamp target time to available range */
if (timeValue < this->TimeRange[0])
{
log::warn("Provided time value: ", timeValue, " is outside of animation time range: [",
this->TimeRange[0], ", ", this->TimeRange[1], "] .");
return false;
log::warn("animation time ", timeValue, " is outside of range [", this->TimeRange[0], ", ",
this->TimeRange[1], "], using ", this->TimeRange[0], ".");
timeValue = this->TimeRange[0];
}
else if (timeValue > this->TimeRange[1])
{
log::warn("animation time ", timeValue, " is outside of range [", this->TimeRange[0], ", ",
this->TimeRange[1], "], using ", this->TimeRange[1], ".");
timeValue = this->TimeRange[1];
}

this->CurrentTime = timeValue;
this->CurrentTimeSet = true;
this->Importer->UpdateTimeStep(this->CurrentTime);
Expand Down