Fix issues in OpenSim::ExpressionBasedBushingForce::generateDecorations
#3999
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue found when working on a student's model, which contained an
ExpressionBasedBushingForce
. The student had set the visual properties (visual_aspect_ratio
,moment_visual_scale
, andforce_visual_scale
) to zero in order to hide the frame/moment/force decorations that the component emits, but that resulted inNaN
ed geometry being emitted by the component, which then caused weird issues in opensim-creator's renderer.When diagnosing that issue I also noticed that the function emits both of the frame decorations twice: once when
fixed
istrue
and once whenfixed
is false, and theNaN
problem returns if the underlying implementation produces aNaN
or zero-length vector (here,F_GM
). The check againstnormSqr
serves the double-purpose of checking for NaNs and zero-length results.Brief summary of changes
Adds
if
checks etc. to the existing implementation to ensure that it filters out the edge cases.Testing I've completed
Running it via OpenSim Creator
Looking for feedback on...
CHANGELOG.md (choose one)
This change is