From efcbc48ae3fbd947529d9782f66fbcddd364d31e Mon Sep 17 00:00:00 2001 From: Adam Kewley Date: Tue, 21 Jan 2025 21:51:06 +0100 Subject: [PATCH] Fix toggling ContactGeometry::Appearance::is_visible has no effect (#3993) * Fix toggling ContactGeometry::Appearance::is_visible has no effect - downstream: https://github.com/ComputationalBiomechanicsLab/opensim-creator/issues/980 * Update CHANGELOG.md (#3993) --- CHANGELOG.md | 2 +- OpenSim/Simulation/Model/ContactHalfSpace.cpp | 7 ++++++- OpenSim/Simulation/Model/ContactMesh.cpp | 10 ++++++++-- OpenSim/Simulation/Model/ContactSphere.cpp | 7 ++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d460f84d8..6dc1ea572b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,7 +54,7 @@ v4.6 - Replace usages of `OpenSim::make_unique` with `std::make_unique` and remove wrapper function now that C++14 is used in OpenSim (#3979). - Add utility method `createVectorLinspaceInterval` for the `std::vector` type and add unit tests. Utilize the new utility method to fix a bug (#3976) in creating the uniformly sampled time interval from the experimental data sampling frequency in `APDMDataReader` and `XsensDataReader` (#3977). - Fix Point Kinematics Reporter variable and initialization error and add unit tests (#3966) - +- `OpenSim::ContactHalfSpace`, `OpenSim::ContactMesh`, and `OpenSim::ContactSphere` now check their associated `Appearance`'s `is_visible` flag when deciding whether to emit their associated decorations (#3993). v4.5.1 ====== diff --git a/OpenSim/Simulation/Model/ContactHalfSpace.cpp b/OpenSim/Simulation/Model/ContactHalfSpace.cpp index 4f463bd025..1579c522f6 100644 --- a/OpenSim/Simulation/Model/ContactHalfSpace.cpp +++ b/OpenSim/Simulation/Model/ContactHalfSpace.cpp @@ -69,7 +69,12 @@ void ContactHalfSpace::generateDecorations(bool fixed, const ModelDisplayHints& // There is no fixed geometry to generate here. if (fixed) { return; } - if (!hints.get_show_contact_geometry()) return; + // Model-wide hints indicate that contact geometry shouldn't be shown. + if (!hints.get_show_contact_geometry()) { return; } + + // The decoration has been toggled off by its `Appearance` block. + if (!get_Appearance().get_visible()) { return; } + // B: base Frame (Body or Ground) // F: PhysicalFrame that this ContactGeometry is connected to // P: the frame defined (relative to F) by the location and orientation diff --git a/OpenSim/Simulation/Model/ContactMesh.cpp b/OpenSim/Simulation/Model/ContactMesh.cpp index 8c23b8d036..40f96aa392 100644 --- a/OpenSim/Simulation/Model/ContactMesh.cpp +++ b/OpenSim/Simulation/Model/ContactMesh.cpp @@ -136,9 +136,15 @@ void ContactMesh::generateDecorations(bool fixed, const ModelDisplayHints& hints // There is no fixed geometry to generate here. if (fixed) { return; } + // Model-wide hints indicate that contact geometry shouldn't be shown. + if (!hints.get_show_contact_geometry()) { return; } + + // The decoration has been toggled off by its `Appearance` block. + if (!get_Appearance().get_visible()) { return; } + // Guard against the case where the Force was disabled or mesh failed to load. - if (_decorativeGeometry == nullptr) return; - if (!hints.get_show_contact_geometry()) return; + if (_decorativeGeometry == nullptr) { return; } + // B: base Frame (Body or Ground) // F: PhysicalFrame that this ContactGeometry is connected to // P: the frame defined (relative to F) by the location and orientation diff --git a/OpenSim/Simulation/Model/ContactSphere.cpp b/OpenSim/Simulation/Model/ContactSphere.cpp index 4a585dd1d7..6ed4e58df9 100644 --- a/OpenSim/Simulation/Model/ContactSphere.cpp +++ b/OpenSim/Simulation/Model/ContactSphere.cpp @@ -86,7 +86,12 @@ void ContactSphere::generateDecorations(bool fixed, const ModelDisplayHints& hin // There is no fixed geometry to generate here. if (fixed) { return; } - if (!hints.get_show_contact_geometry()) return; + // Model-wide hints indicate that contact geometry shouldn't be shown. + if (!hints.get_show_contact_geometry()) { return; } + + // The decoration has been toggled off by its `Appearance` block. + if (!get_Appearance().get_visible()) { return; } + // B: base Frame (Body or Ground) // F: PhysicalFrame that this ContactGeometry is connected to // P: the frame defined (relative to F) by the location and orientation