Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Simulation.Core] Apply new factory registration mechanism #5098

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@
namespace sofa::simulation
{

int DefaultAnimationLoopClass = core::RegisterObject("Simulation loop to use in scene without constraints nor contact.")
.add<DefaultAnimationLoop>()
.addDocumentationURL(std::string(sofa::SOFA_DOCUMENTATION_URL) + std::string("components/animationloops/defaultanimationloop/"))
.addDescription(R"(
void registerDefaultAnimationLoop(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Simulation loop, created by default when the user does not define one in the scene. This loop first computes the collision detection and then solves the physics.")
.add<DefaultAnimationLoop>()
.addDocumentationURL(std::string(sofa::SOFA_DOCUMENTATION_URL) + std::string("components/animationloops/defaultanimationloop/"))
.addDescription(R"(
This loop triggers the following steps:
- build and solve all linear systems in the scene : collision and time integration to compute the new values of the dofs
- update the context (dt++)
- update the mappings
- update the bounding box (volume covering all objects of the scene))");
- update the bounding box (volume covering all objects of the scene))"));
}

DefaultAnimationLoop::DefaultAnimationLoop(simulation::Node* _m_node)
: Inherit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ namespace sofa::core::objectmodel {
namespace sofa::simulation
{

int DefaultVisualManagerLoopClass = core::RegisterObject("The simplest Visual Loop Manager, created by default when user do not put on scene")
.add< DefaultVisualManagerLoop >()
;
void registerDefaultVisualManagerLoop(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Manager of the visual loop, created by default when the user does not define one in the scene.")
.add< DefaultVisualManagerLoop >());
}

DefaultVisualManagerLoop::DefaultVisualManagerLoop() :
l_node(initLink("targetNode","Link to the scene's node where the rendering will take place"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ using sofa::helper::system::PluginManager;
namespace sofa::simulation
{

int RequiredPluginClass = core::RegisterObject("Load the required plugins")
.add< RequiredPlugin >();
void registerRequiredPlugin(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Load the SOFA modules and/or plugins required to run a simulation.")
.add< RequiredPlugin >());
}

RequiredPlugin::RequiredPlugin()
: d_pluginName( initData(&d_pluginName, "pluginName", "plugin name (or several names if you need to load different plugins or a plugin with several alternate names)"))
Expand Down
20 changes: 18 additions & 2 deletions Sofa/framework/Simulation/Core/src/sofa/simulation/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,33 @@

#include <sofa/simulation/MainTaskSchedulerRegistry.h>

#include <sofa/core/ObjectFactory.h>

namespace sofa::simulation::core
namespace sofa::simulation
{

extern void registerRequiredPlugin(sofa::core::ObjectFactory* factory);
extern void registerDefaultVisualManagerLoop(sofa::core::ObjectFactory* factory);
extern void registerDefaultAnimationLoop(sofa::core::ObjectFactory* factory);

namespace core
{

static bool s_initialized = false;
static bool s_cleanedUp = false;


SOFA_SIMULATION_CORE_API void init()
{
if (!s_initialized)
{
sofa::core::init();
s_initialized = true;

auto* factory = sofa::core::ObjectFactory::getInstance();
registerRequiredPlugin(factory);
registerDefaultVisualManagerLoop(factory);
registerDefaultAnimationLoop(factory);
}
}

Expand Down Expand Up @@ -73,7 +87,9 @@ static const struct CleanupCheck
}
} check;

} // namespace sofa::simulation::core
} // namespace core

} // namespace sofa::simulation



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,4 @@ Node::SPtr DAGSimulation::createNewNode(const std::string& name)
return sofa::core::objectmodel::New<DAGNode>(name);
}



// Register in the Factory
//int DAGSimulationClass = core::RegisterObject ( "Main simulation algorithm, based on tree graph" )
//.add< DAGSimulation >()
//;


} // namespace sofa::simulation::graph
Loading