Skip to content
Open
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 @@ -80,7 +80,7 @@ bool BaseMouseInteractor::removeInteractionPerformer( InteractionPerformer *i)
}
}

void BaseMouseInteractor::updatePosition(SReal )
void BaseMouseInteractor::doUpdatePosition(SReal )
{
for (const auto perf : performers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SOFA_GUI_COMPONENT_API BaseMouseInteractor : public core::BehaviorModel
void addInteractionPerformer(InteractionPerformer *i);
bool removeInteractionPerformer( InteractionPerformer *i);
//Called at each time step: launch all the performers
void updatePosition( SReal dt) override;
void doUpdatePosition( SReal dt) override;
//Propagate an event in case to all the performers
void handleEvent(core::objectmodel::Event *e) override;

Expand Down
37 changes: 33 additions & 4 deletions Sofa/framework/Core/src/sofa/core/BehaviorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,46 @@ class SOFA_CORE_API BehaviorModel : public virtual sofa::core::objectmodel::Base
/// Destructor
~BehaviorModel() override {}

/// Computation of a new simulation step.
virtual void doUpdatePosition(SReal /*dt*/) = 0;

virtual bool doAddBBox(SReal* /*minBBox*/, SReal* /*maxBBox*/)
{
return false;
}

private:
BehaviorModel(const BehaviorModel& n) = delete;
BehaviorModel& operator=(const BehaviorModel& n) = delete;

public:
/// Computation of a new simulation step.
virtual void updatePosition(SReal dt) = 0;

virtual bool addBBox(SReal* /*minBBox*/, SReal* /*maxBBox*/)
/**
* !!! WARNING since v25.12 !!!
*
* The template method pattern has been applied to this part of the API.
* This method calls the newly introduced method "doUpdatePosition" internally,
* which is the method to override from now on.
*
**/
virtual void updatePosition(SReal dt) final
{
return false;
//TODO (SPRINT SED 2025): Component state mechamism
this->doUpdatePosition(dt);
}

/**
* !!! WARNING since v25.12 !!!
*
* The template method pattern has been applied to this part of the API.
* This method calls the newly introduced method "doAddBBox" internally,
* which is the method to override from now on.
*
**/
virtual bool addBBox(SReal* minBBox, SReal* maxBBox) final
{
//TODO (SPRINT SED 2025): Component state mechamism
return this->doAddBBox(minBBox, maxBBox);
}

bool insertInNode( objectmodel::BaseNode* node ) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void MyBehaviorModel::reinit()
{
}

void MyBehaviorModel::updatePosition(double /*dt*/)
void MyBehaviorModel::doUpdatePosition(double /*dt*/)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Sofa/framework/Helper/test/system/TestPluginA/ComponentC.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MyBehaviorModel : public sofa::core::BehaviorModel
public:
virtual void init();
virtual void reinit();
virtual void updatePosition(double dt);
void doUpdatePosition(double dt) override;

protected:
Data<unsigned> customUnsignedData; ///< Example of unsigned data with custom widget
Expand Down
2 changes: 1 addition & 1 deletion applications/plugins/SofaEulerianFluid/Fluid2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void Fluid2D::reset()
init();
}

void Fluid2D::updatePosition(SReal dt)
void Fluid2D::doUpdatePosition(SReal dt)
{
fnext->step(fluid, ftemp, (real)dt);
Grid2D* p = fluid; fluid=fnext; fnext=p;
Expand Down
2 changes: 1 addition & 1 deletion applications/plugins/SofaEulerianFluid/Fluid2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SOFA_EULERIAN_FLUID_API Fluid2D : public sofa::core::BehaviorModel

void reset() override;

void updatePosition(SReal dt) override;
void doUpdatePosition(SReal dt) override;

void draw(const sofa::core::visual::VisualParams* vparams) override;

Expand Down
2 changes: 1 addition & 1 deletion applications/plugins/SofaEulerianFluid/Fluid3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Fluid3D::reset()
init();
}

void Fluid3D::updatePosition(SReal dt)
void Fluid3D::doUpdatePosition(SReal dt)
{
fnext->gravity = getContext()->getGravity()/f_cellwidth.getValue();
fnext->step(fluid, ftemp, (real)dt);
Expand Down
2 changes: 1 addition & 1 deletion applications/plugins/SofaEulerianFluid/Fluid3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SOFA_EULERIAN_FLUID_API Fluid3D : public sofa::core::BehaviorModel

void reset() override;

void updatePosition(SReal dt) override;
void doUpdatePosition(SReal dt) override;

void draw(const sofa::core::visual::VisualParams* vparams) override;

Expand Down
Loading