Skip to content

Commit

Permalink
Animation: Fix a small issue with animation and improve animation tes…
Browse files Browse the repository at this point in the history
…ting (#1797)
  • Loading branch information
mwestphal authored Dec 17, 2024
1 parent 33f6192 commit 792c67b
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 29 deletions.
14 changes: 4 additions & 10 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion library/src/animationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionAnimationCycleAnimation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionAnimationFBXBone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionAnimationInvert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions testing/baselines/TestInteractionCycleAnimation.png

This file was deleted.

92 changes: 79 additions & 13 deletions testing/recordings/TestInteractionAnimationInvert.log
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 792c67b

Please sign in to comment.