diff --git a/application/testing/CMakeLists.txt b/application/testing/CMakeLists.txt index 40f33d43b2..77c50d6176 100644 --- a/application/testing/CMakeLists.txt +++ b/application/testing/CMakeLists.txt @@ -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) # Test exit hotkey f3d_test(NAME TestInteractionSimpleExit DATA cow.vtp REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #Escape; @@ -621,6 +622,10 @@ if(F3D_PLUGIN_BUILD_EXODUS) # Test no render animation time. Regex contains a part of the range of the ACCL field. f3d_test(NAME TestNoRenderAnimation DATA small.ex2 ARGS --load-plugins=exodus --animation-time=0.003 REGEXP "-521950, 6.57485" NO_RENDER) + # Test animation time clamping + f3d_test(NAME TestAnimationTimeLimitsHigh DATA small.ex2 ARGS ARGS --load-plugins=exodus --animation-time=10 DEFAULT_LIGHTS) + f3d_test(NAME TestAnimationTimeLimitsLow DATA small.ex2 ARGS ARGS --load-plugins=exodus --animation-time=-5 DEFAULT_LIGHTS) + # Test if the animation-time works when set to zero and time range[0] is less than zero f3d_test(NAME TestTimeRangeLessThanZero DATA negative_range_animated.e ARGS -s --load-plugins=exodus --animation-time=0 DEFAULT_LIGHTS) diff --git a/library/src/animationManager.cxx b/library/src/animationManager.cxx index d28f368db9..9d3c1bb541 100644 --- a/library/src/animationManager.cxx +++ b/library/src/animationManager.cxx @@ -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); diff --git a/testing/baselines/TestAnimationTimeLimitsHigh.png b/testing/baselines/TestAnimationTimeLimitsHigh.png new file mode 100644 index 0000000000..d4e1f56b7c --- /dev/null +++ b/testing/baselines/TestAnimationTimeLimitsHigh.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de563e305ab9843e6748ce39156f998daa0aac5f1f6a1775ae0893ac875a1dd8 +size 6275 diff --git a/testing/baselines/TestAnimationTimeLimitsLow.png b/testing/baselines/TestAnimationTimeLimitsLow.png new file mode 100644 index 0000000000..f506567592 --- /dev/null +++ b/testing/baselines/TestAnimationTimeLimitsLow.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:949859866791be0c4741a8c16b5b4a7d5037cff33ba6d88c157b9b955f0604c7 +size 3717