From 22fd63eeeaca32a7b14d7481430f42c8a434fe42 Mon Sep 17 00:00:00 2001 From: Mathieu Westphal Date: Tue, 17 Dec 2024 07:24:18 +0100 Subject: [PATCH] Animation: Fix a small issue with animation and improve animation testing --- application/testing/CMakeLists.txt | 14 +-- library/src/animationManager.cxx | 7 +- ...TestInteractionAnimationCycleAnimation.png | 3 + .../TestInteractionAnimationFBXBone.png | 3 + .../TestInteractionAnimationInvert.png | 4 +- .../TestInteractionCycleAnimation.png | 3 - ...estInteractionAnimationCycleAnimation.log} | 0 ...og => TestInteractionAnimationFBXBone.log} | 0 .../TestInteractionAnimationInvert.log | 92 ++++++++++++++++--- 9 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 testing/baselines/TestInteractionAnimationCycleAnimation.png create mode 100644 testing/baselines/TestInteractionAnimationFBXBone.png delete mode 100644 testing/baselines/TestInteractionCycleAnimation.png rename testing/recordings/{TestInteractionCycleAnimation.log => TestInteractionAnimationCycleAnimation.log} (100%) rename testing/recordings/{TestInteractionFBXBoneAnimation.log => TestInteractionAnimationFBXBone.log} (100%) diff --git a/application/testing/CMakeLists.txt b/application/testing/CMakeLists.txt index 20c4027614..acc2452150 100644 --- a/application/testing/CMakeLists.txt +++ b/application/testing/CMakeLists.txt @@ -391,6 +391,7 @@ f3d_test(NAME TestInteractionAnimationFast DATA f3d.glb ARGS --animation-progres f3d_test(NAME TestInteractionAnimationSlow DATA f3d.glb ARGS --animation-progress --animation-speed-factor=0.5 INTERACTION)#Space;Wait;Space; f3d_test(NAME TestInteractionAnimationFrameRate DATA f3d.glb ARGS --animation-progress --frame-rate=1 INTERACTION)#Space;Wait;Space; f3d_test(NAME TestInteractionAnimationCameraMovement DATA CameraAnimated.glb ARGS --camera-index=0 --animation-progress INTERACTION)#Space;MouseMovement;Space; +f3d_test(NAME TestInteractionAnimationInvert DATA f3d.glb ARGS --animation-speed-factor=-1 --animation-progress INTERACTION)#Space;Wait;Space; # A verbose test that needs animation index support 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) @@ -575,8 +576,7 @@ if(F3D_PLUGIN_BUILD_ASSIMP) f3d_test(NAME TestDAE DATA duck.dae ARGS --load-plugins=assimp) f3d_test(NAME TestX DATA anim_test.x ARGS --load-plugins=assimp) - # To increase coverage of some specific animation code path when looping - f3d_test(NAME TestInteractionFBXBoneAnimation DATA animation_with_skeleton.fbx ARGS --load-plugins=assimp --camera-position=1.90735e-06,0,11007.8 --camera-focal-point=1.90735e-06,0,-8.9407e-08 --animation-speed-factor=100 INTERACTION NO_BASELINE)#Space;Wait;Space; + f3d_test(NAME TestInteractionAnimationFBXBone DATA animation_with_skeleton.fbx ARGS --load-plugins=assimp --camera-position=0,0,14000 --camera-focal-point=0,0,0 INTERACTION)#Space;Wait;Space; # This test baseline is incorrect because of https://github.com/f3d-app/f3d/issues/603 # It will need to be changed when fixed @@ -641,9 +641,6 @@ if(F3D_PLUGIN_BUILD_EXODUS) # Test animation with generic importer, coloring and a custom scalar range f3d_test(NAME TestAnimationGenericImporterScalarRange DATA small.ex2 ARGS -sb --load-plugins=exodus --animation-time=0.003 --animation-progress --range=0,1e7) - # Test animation with inverted speed factor - f3d_test(NAME TestInteractionAnimationInvert DATA small.ex2 ARGS -sb --load-plugins=exodus --animation-speed-factor=-0.0000001 --animation-time=0.00429998 --animation-progress INTERACTION)#Space;Space; - # Test Generic Importer Verbose animation. Regex contains the time range. f3d_test(NAME TestVerboseAnimationSingleTimestep DATA single_timestep.e ARGS --load-plugins=exodus --verbose NO_BASELINE REGEXP "time range delta is invalid") @@ -825,8 +822,7 @@ f3d_test(NAME TestProgress DATA cow.vtp ARGS --progress NO_BASELINE) f3d_test(NAME TestProgressScene DATA WaterBottle.glb ARGS --progress NO_BASELINE) f3d_test(NAME TestInteractionProgressReload DATA cow.vtp ARGS --progress NO_BASELINE INTERACTION) #Up;Up;Up;Up -# This test is not reliable since depending on the local performance, different frames can be captured -# f3d_test(NAME TestInteractionCycleAnimation DATA InterpolationTest.glb INTERACTION) #WWWWWWWWWWW;Space;Space; +f3d_test(NAME TestInteractionAnimationCycleAnimation DATA InterpolationTest.glb INTERACTION) #WWWWWWWWWWW;Space;Space; f3d_test(NAME TestInteractionCycleAnimationNoAnimation DATA cow.vtp INTERACTION NO_BASELINE) #W f3d_test(NAME TestInteractionDropFiles ARGS -n INTERACTION_CONFIGURE UI)#X;DropEvent cow.vtp;DropEvent dragon.vtu suzanne.stl; @@ -852,9 +848,7 @@ if(VTK_VERSION VERSION_GREATER_EQUAL 9.2.20221220) f3d_test(NAME TestInteractionDropHDRIModifiers INTERACTION_CONFIGURE LONG_TIMEOUT)#CTRL+DropEvent f3d.tif;SHIFT+DropEvent;SHIFT+DropEven palermo.tif;SYYYY # Test interactive animation and dropping HDRI - if(F3D_SANITIZER STREQUAL "none") - f3d_test(NAME TestInteractionAnimationDropHDRI DATA InterpolationTest.glb ARGS --animation-index=-1 --animation-progress INTERACTION_CONFIGURE LONG_TIMEOUT)#Space;DropEvent palermo.hdr;Space; - endif() + f3d_test(NAME TestInteractionAnimationDropHDRI DATA InterpolationTest.glb ARGS --animation-index=-1 --animation-progress INTERACTION_CONFIGURE LONG_TIMEOUT)#Space;DropEvent palermo.hdr;Space; if(F3D_MODULE_EXR) f3d_test(NAME TestInteractionDropHDRIExr INTERACTION_CONFIGURE LONG_TIMEOUT)#X;DropEvent kloofendal.exr;DropEvent dragon.vtu; diff --git a/library/src/animationManager.cxx b/library/src/animationManager.cxx index 0909a6b6ce..f37a13938e 100644 --- a/library/src/animationManager.cxx +++ b/library/src/animationManager.cxx @@ -209,8 +209,13 @@ void animationManager::Tick() // Modulo computation, compute CurrentTime in the time range. if (this->CurrentTime < this->TimeRange[0] || this->CurrentTime > this->TimeRange[1]) { + auto modulo = [](double val, double mod) + { + const double remainder = fmod(val, mod); + return remainder < 0 ? remainder + mod : remainder; + }; this->CurrentTime = this->TimeRange[0] + - std::fmod(this->CurrentTime - this->TimeRange[0], this->TimeRange[1] - this->TimeRange[0]); + modulo(this->CurrentTime - this->TimeRange[0], this->TimeRange[1] - this->TimeRange[0]); } if (this->LoadAtTime(this->CurrentTime)) diff --git a/testing/baselines/TestInteractionAnimationCycleAnimation.png b/testing/baselines/TestInteractionAnimationCycleAnimation.png new file mode 100644 index 0000000000..5580cf5aed --- /dev/null +++ b/testing/baselines/TestInteractionAnimationCycleAnimation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05f82dcac42a6e0fb2cf68ebc22c4198ecf1c34e4df853998850ae92e6ca7062 +size 4658 diff --git a/testing/baselines/TestInteractionAnimationFBXBone.png b/testing/baselines/TestInteractionAnimationFBXBone.png new file mode 100644 index 0000000000..d99e2bab2f --- /dev/null +++ b/testing/baselines/TestInteractionAnimationFBXBone.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58f1ba8a5402f9b456f4e7cc7013683fb0cca5d7edda027ec4b8bcc146935312 +size 1755 diff --git a/testing/baselines/TestInteractionAnimationInvert.png b/testing/baselines/TestInteractionAnimationInvert.png index 15d02798af..f23c55c085 100644 --- a/testing/baselines/TestInteractionAnimationInvert.png +++ b/testing/baselines/TestInteractionAnimationInvert.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9127cd60f41f01100746113853dc5e5f7afe1dd3c19af38460f291961d9cee80 -size 16810 +oid sha256:06c3f2936dcfb6fe02b6ecd768f9a72ed3ff773f854364bea9a6a7030e0263d0 +size 1964 diff --git a/testing/baselines/TestInteractionCycleAnimation.png b/testing/baselines/TestInteractionCycleAnimation.png deleted file mode 100644 index cdb8ca56d2..0000000000 --- a/testing/baselines/TestInteractionCycleAnimation.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:acc9a8430ea6458eb72999b63c096e193a0410fe57b45a45e27c0b433d29720a -size 4781 diff --git a/testing/recordings/TestInteractionCycleAnimation.log b/testing/recordings/TestInteractionAnimationCycleAnimation.log similarity index 100% rename from testing/recordings/TestInteractionCycleAnimation.log rename to testing/recordings/TestInteractionAnimationCycleAnimation.log diff --git a/testing/recordings/TestInteractionFBXBoneAnimation.log b/testing/recordings/TestInteractionAnimationFBXBone.log similarity index 100% rename from testing/recordings/TestInteractionFBXBoneAnimation.log rename to testing/recordings/TestInteractionAnimationFBXBone.log diff --git a/testing/recordings/TestInteractionAnimationInvert.log b/testing/recordings/TestInteractionAnimationInvert.log index 30018c65bb..1b3d7bd15a 100644 --- a/testing/recordings/TestInteractionAnimationInvert.log +++ b/testing/recordings/TestInteractionAnimationInvert.log @@ -1,14 +1,80 @@ # StreamVersion 1.2 -ConfigureEvent 2 1409 0 0 0 0 0 -ExposeEvent 0 1409 0 0 0 0 0 -RenderEvent 0 1409 0 0 0 0 0 -KeyPressEvent 1698 319 0 32 1 space 0 -CharEvent 1698 319 0 32 1 space 0 -KeyReleaseEvent 1698 319 0 32 1 space 0 -TimerEvent 1698 319 0 32 1 space 0 -TimerEvent 1698 319 0 32 1 space 0 -TimerEvent 1698 319 0 32 1 space 0 -TimerEvent 1698 319 0 32 1 space 0 -KeyPressEvent 1698 319 0 32 1 space 0 -CharEvent 1698 319 0 32 1 space 0 -KeyReleaseEvent 1698 319 0 32 1 space 0 +ConfigureEvent 960 1033 0 0 0 0 0 +ExposeEvent 0 1055 0 0 0 0 0 +RenderEvent 0 1055 0 0 0 0 0 +EnterEvent 234 509 0 0 0 0 0 +KeyPressEvent 234 509 0 32 1 space 0 +CharEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +KeyReleaseEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +KeyPressEvent 234 509 0 32 1 space 0 +CharEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +TimerEvent 234 509 0 32 1 space 0 +KeyReleaseEvent 234 509 0 32 1 space 0