Skip to content

Commit

Permalink
Fix/animation time zero issue (#1263)
Browse files Browse the repository at this point in the history
* Get method for time range added

* Declaration of time range get method

* Bug when animation time = zero fixed

* Formatting fix

* Unnecessary line

* Formatting

* Formatting

* Test data added

* Cmake tests added

* Negative anim time test

* Test baselines added

* Requested argument changes

* Tests passing now
  • Loading branch information
z-shaffer authored Feb 5, 2024
1 parent 936c75c commit 795788d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,12 @@ 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 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)

# Test if a negative animation-time works when time range[0] is less than zero
f3d_test(NAME TestTimeRangeLessThanZeroNegativeAnimationTime DATA negative_range_animated.e ARGS -s --load-plugins=exodus --animation-time=-3 DEFAULT_LIGHTS)

if(NOT F3D_MACOS_BUNDLE)
file(COPY "${F3D_SOURCE_DIR}/plugins/exodus/configs/config.d/" DESTINATION "${CMAKE_BINARY_DIR}/share/f3d/configs/config_build.d")
f3d_test(NAME TestDefaultConfigFileExodus DATA disk_out_ref.ex2 CONFIG config_build LONG_TIMEOUT DEFAULT_LIGHTS)
Expand Down
5 changes: 5 additions & 0 deletions library/private/animationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class animationManager
animationManager(animationManager const&) = delete;
void operator=(animationManager const&) = delete;

/**
* Set a time range pointer to the current time range values
*/
void GetTimeRange(double timeRange[2]);

protected:
/**
* Called by an internal timer to advance one animation tick
Expand Down
7 changes: 7 additions & 0 deletions library/src/animationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,11 @@ bool animationManager::LoadAtTime(double timeValue)
}
return true;
}

//----------------------------------------------------------------------------
void animationManager::GetTimeRange(double timeRange[2])
{
timeRange[0] = this->TimeRange[0];
timeRange[1] = this->TimeRange[1];
}
}
8 changes: 6 additions & 2 deletions library/src/loader_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class loader_impl::internals
&this->Options, &this->Window, this->Interactor, this->GenericImporter);

double animationTime = this->Options.getAsDouble("scene.animation.time");
if (animationTime != 0)
double timeRange[2];
this->AnimationManager.GetTimeRange(timeRange);
if (animationTime != timeRange[0])
{
this->AnimationManager.LoadAtTime(animationTime);
}
Expand Down Expand Up @@ -309,7 +311,9 @@ loader& loader_impl::loadScene(const std::string& filePath)
this->Internals->Interactor, this->Internals->CurrentFullSceneImporter);

double animationTime = this->Internals->Options.getAsDouble("scene.animation.time");
if (animationTime != 0)
double timeRange[2];
this->Internals->AnimationManager.GetTimeRange(timeRange);
if (animationTime != timeRange[0])
{
this->Internals->AnimationManager.LoadAtTime(animationTime);
}
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestTimeRangeLessThanZero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/data/negative_range_animated.e
Git LFS file not shown

0 comments on commit 795788d

Please sign in to comment.