From abb0de63e13b3729197fe82c2773d462850661e0 Mon Sep 17 00:00:00 2001 From: bakpaul Date: Thu, 11 Jun 2026 15:23:55 +0200 Subject: [PATCH 1/4] Add scene checking before initRoot when scenechekcing is available --- .../Sofa/Simulation/Submodule_Simulation.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp index cf81ad049..c93490355 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp @@ -43,6 +43,9 @@ using sofa::simulation::Simulation; #include #include #include +#include +#include +#include namespace py = pybind11; @@ -64,7 +67,27 @@ PYBIND11_MODULE(Simulation, simulation) simulation.def("print", [](Node* n){ sofa::simulation::node::print(n); }, sofapython3::doc::simulation::print); simulation.def("animate", [](Node* n, SReal dt=0.0){ sofa::simulation::node::animate(n, dt); },sofapython3::doc::simulation::animate); simulation.def("init", [](Node* n){ sofa::simulation::node::init(n); }, sofapython3::doc::simulation::init); - simulation.def("initRoot", [](Node* n){ sofa::simulation::node::initRoot(n); }, sofapython3::doc::simulation::initRoot); + simulation.def("initRoot", [](Node* n) + { + auto& pluginManager = sofa::helper::system::PluginManager::getInstance(); + auto res = pluginManager.loadPlugin("SceneChecking"); + if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS) + { + sofa::simulation::SceneCheckerVisitor sceneCheckerVisitor; + + for (const auto& sceneCheck : sofa::simulation::SceneCheckMainRegistry::getRegisteredSceneChecks()) + { + sceneCheckerVisitor.addCheck(sceneCheck); + } + + sceneCheckerVisitor.validate(n, nullptr); + } + else + { + msg_warning("Could not load SceneChecking, no scene check will be performed."); + } + sofa::simulation::node::initRoot(n); + }, sofapython3::doc::simulation::initRoot); simulation.def("initVisual", [](Node* n){ n->getVisualLoop()->initStep(sofa::core::visual::VisualParams::defaultInstance()); }, sofapython3::doc::simulation::initVisual); simulation.def("reset", [](Node* n){ sofa::simulation::node::reset(n); }, sofapython3::doc::simulation::reset); From a94ab762ee5f78205afe9bdc857557ca73fa7b02 Mon Sep 17 00:00:00 2001 From: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Date: Wed, 17 Jun 2026 11:49:17 +0200 Subject: [PATCH 2/4] Update bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp Co-authored-by: Frederick Roy --- .../src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp index c93490355..da9ef1581 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp @@ -71,7 +71,7 @@ PYBIND11_MODULE(Simulation, simulation) { auto& pluginManager = sofa::helper::system::PluginManager::getInstance(); auto res = pluginManager.loadPlugin("SceneChecking"); - if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS) + if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS || res == PluginLoadStatus::ALREADY_LOADED) { sofa::simulation::SceneCheckerVisitor sceneCheckerVisitor; From b0888577adfd25db24a2bc329cdd8c2d3ea16ecd Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 18 Jun 2026 06:52:30 +0900 Subject: [PATCH 3/4] fix typo --- .../src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp index da9ef1581..92f58a1e0 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp @@ -71,7 +71,7 @@ PYBIND11_MODULE(Simulation, simulation) { auto& pluginManager = sofa::helper::system::PluginManager::getInstance(); auto res = pluginManager.loadPlugin("SceneChecking"); - if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS || res == PluginLoadStatus::ALREADY_LOADED) + if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS || res == sofa::helper::system::PluginLoadStatus::ALREADY_LOADED) { sofa::simulation::SceneCheckerVisitor sceneCheckerVisitor; From 88e89d5e5a0df7f8dee3e6f944f0b2f6ba48c5ac Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 18 Jun 2026 18:17:43 +0900 Subject: [PATCH 4/4] fix typo again --- .../src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp index 92f58a1e0..bd0f1de54 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation.cpp @@ -71,7 +71,7 @@ PYBIND11_MODULE(Simulation, simulation) { auto& pluginManager = sofa::helper::system::PluginManager::getInstance(); auto res = pluginManager.loadPlugin("SceneChecking"); - if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS || res == sofa::helper::system::PluginLoadStatus::ALREADY_LOADED) + if(res == sofa::helper::system::PluginManager::PluginLoadStatus::SUCCESS || res == sofa::helper::system::PluginManager::PluginLoadStatus::ALREADY_LOADED) { sofa::simulation::SceneCheckerVisitor sceneCheckerVisitor;