From 0fee236c111ea0b511d1ddc7e82cd4a4e6b74128 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 7 Oct 2026 16:13:39 +0200 Subject: [PATCH] [Core] Deprecate `beginIntegration` method in `BaseMechanicalState` --- .../animationloop/ConstraintAnimationLoop.cpp | 5 ----- .../animationloop/FreeMotionAnimationLoop.cpp | 11 ----------- .../Core/src/sofa/core/behavior/BaseMechanicalState.h | 1 + Sofa/framework/Core/src/sofa/core/config.h.in | 7 +++++++ .../Core/src/sofa/simulation/DefaultAnimationLoop.cpp | 4 ---- .../Simulation/Core/src/sofa/simulation/config.h.in | 9 ++++++++- .../MechanicalBeginIntegrationVisitor.cpp | 4 ++-- .../MechanicalBeginIntegrationVisitor.h | 8 ++++++-- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/ConstraintAnimationLoop.cpp b/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/ConstraintAnimationLoop.cpp index 66c5743e5fd..4e763954eb9 100644 --- a/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/ConstraintAnimationLoop.cpp +++ b/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/ConstraintAnimationLoop.cpp @@ -52,9 +52,6 @@ #include using sofa::simulation::mechanicalvisitor::MechanicalVInitVisitor; -#include -using sofa::simulation::mechanicalvisitor::MechanicalBeginIntegrationVisitor; - #include using sofa::simulation::mechanicalvisitor::MechanicalVOpVisitor; @@ -298,8 +295,6 @@ void ConstraintAnimationLoop::freeMotion(const core::ExecParams* params, simulat { SCOPED_TIMER_VARNAME(freeMotionTimer, "Free Motion"); - MechanicalBeginIntegrationVisitor(params, dt).execute(context); - ////////////////// (optional) PREDICTIVE CONSTRAINT FORCES /////////////////////////////////////////////////////////////////////////////////////////// /// When scheme Correction is used, the constraint forces computed at the previous time-step /// are applied during the first motion, so which is no more a "free" motion but a "predictive" motion diff --git a/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/FreeMotionAnimationLoop.cpp b/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/FreeMotionAnimationLoop.cpp index 2f7954ea96b..934e48340f5 100644 --- a/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/FreeMotionAnimationLoop.cpp +++ b/Sofa/Component/AnimationLoop/src/sofa/component/animationloop/FreeMotionAnimationLoop.cpp @@ -51,10 +51,6 @@ #include using sofa::simulation::mechanicalvisitor::MechanicalVInitVisitor; - -#include -using sofa::simulation::mechanicalvisitor::MechanicalBeginIntegrationVisitor; - #include using sofa::simulation::mechanicalvisitor::MechanicalVOpVisitor; @@ -225,13 +221,6 @@ void FreeMotionAnimationLoop::step(const sofa::core::ExecParams* params, SReal d dmsg_info() << "updateInternal performed - beginVisitor called" ; - - // MechanicalBeginIntegrationVisitor - MechanicalBeginIntegrationVisitor beginVisitor(params, dt); - node->execute(&beginVisitor); - - dmsg_info() << "beginVisitor performed - SolveVisitor for freeMotion is called" ; - { SCOPED_TIMER("MechanicalComputeGeometricStiffness"); MechanicalComputeGeometricStiffness geometricStiffnessVisitor(&mop.mparams, cparams.lambda()); diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h b/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h index 8252df17d3c..b02006174cc 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h @@ -178,6 +178,7 @@ class SOFA_CORE_API BaseMechanicalState : public virtual BaseState /// @{ /// Called at the beginning of each integration step. + SOFA_CORE_DEPRECATED_BEGININTEGRATION() virtual void beginIntegration(SReal /*dt*/) { // it is no longer necessary to switch forceId to internalForce here... diff --git a/Sofa/framework/Core/src/sofa/core/config.h.in b/Sofa/framework/Core/src/sofa/core/config.h.in index d022d8f9e02..b4039fdfe98 100644 --- a/Sofa/framework/Core/src/sofa/core/config.h.in +++ b/Sofa/framework/Core/src/sofa/core/config.h.in @@ -153,3 +153,10 @@ SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.12", "Use BaseContext instead of Contex #define SOFA_CORE_DEPRECATED_RESETVEC() \ SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.12", "Use resetVec instead.") #endif + +#ifdef SOFA_BUILD_SOFA_CORE +#define SOFA_CORE_DEPRECATED_BEGININTEGRATION() +#else +#define SOFA_CORE_DEPRECATED_BEGININTEGRATION() \ + SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.12", "`beginIntegration` method was empty for a long time.") +#endif diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp index 28d40dafdae..37f5ed12089 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp @@ -176,10 +176,6 @@ void DefaultAnimationLoop::propagateAnimateBeginEvent(const core::ExecParams* pa void DefaultAnimationLoop::beginIntegration(const core::ExecParams* params, SReal dt) const { propagateIntegrateBeginEvent(params); - - SCOPED_TIMER("beginIntegration"); - mechanicalvisitor::MechanicalBeginIntegrationVisitor beginVisitor(params, dt); - m_node->execute(&beginVisitor); } void DefaultAnimationLoop::propagateIntegrateBeginEvent(const core::ExecParams* params) const diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/config.h.in b/Sofa/framework/Simulation/Core/src/sofa/simulation/config.h.in index 726be46e134..32b57b88bd5 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/config.h.in +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/config.h.in @@ -297,7 +297,7 @@ #else #define SOFA_ATTRIBUTE_DEPRECATED__MECHANICALPROPAGATEDXANDRESETFORCEVISITOR() \ SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.06", "`MechanicalPropagateDxAndResetForceVisitor` was not used. If you need it, use DifferentialOperations::pushforwardTangent.") -#endif +#endif #ifdef SOFA_BUILD_SOFA_SIMULATION_CORE #define SOFA_ATTRIBUTE_DEPRECATED__MECHANICALIDENTITYBLOCKSINJACOBIANVISITOR() @@ -312,3 +312,10 @@ #define SOFA_ATTRIBUTE_DEPRECATED__MECHANICALGETMOMENTUMVISITOR() \ SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.06", "`MechanicalGetMomentumVisitor` was not used.") #endif + +#ifdef SOFA_BUILD_SOFA_SIMULATION_CORE +#define SOFA_ATTRIBUTE_DEPRECATED__MECHANICALBEGININTEGRATIONVISITOR() +#else +#define SOFA_ATTRIBUTE_DEPRECATED__MECHANICALBEGININTEGRATIONVISITOR() \ + SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.06", "This visitor calls a deprecated method `beginIntegration`.") +#endif diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.cpp index 4f9609c9fdf..ee2073f705b 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.cpp @@ -19,7 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ - +#define SOFA_SIMULATION_MECHANICALVISITOR_MECHANICALBEGININTEGRATIONVISITOR_CPP #include #include @@ -39,4 +39,4 @@ Visitor::Result MechanicalBeginIntegrationVisitor::fwdMappedMechanicalState(simu return RESULT_CONTINUE; } -} \ No newline at end of file +} diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.h index 48ee29bc1f4..a5ead16395c 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/mechanicalvisitor/MechanicalBeginIntegrationVisitor.h @@ -23,12 +23,16 @@ #include +#if !defined(SOFA_SIMULATION_MECHANICALVISITOR_MECHANICALBEGININTEGRATIONVISITOR_CPP) +SOFA_HEADER_DEPRECATED_NOT_REPLACED("v26.12", "v27.06") +#endif + namespace sofa::simulation::mechanicalvisitor { /** Visitor used to prepare a time integration step. Typically, does nothing. */ -class SOFA_SIMULATION_CORE_API MechanicalBeginIntegrationVisitor : public BaseMechanicalVisitor +class SOFA_SIMULATION_CORE_API SOFA_ATTRIBUTE_DEPRECATED__MECHANICALBEGININTEGRATIONVISITOR() MechanicalBeginIntegrationVisitor : public BaseMechanicalVisitor { public: SReal dt; @@ -54,4 +58,4 @@ class SOFA_SIMULATION_CORE_API MechanicalBeginIntegrationVisitor : public BaseMe return true; } }; -} \ No newline at end of file +}