Skip to content

Commit 4c1332e

Browse files
authored
Merge branch 'master' into hugtalbot-patch-2
2 parents d701c2d + 42b7ff5 commit 4c1332e

File tree

280 files changed

+3653
-2934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+3653
-2934
lines changed

Sofa/Component/Collision/Detection/Algorithm/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ set(SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR "src/sofa/component/coll
66
set(HEADER_FILES
77
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/config.h.in
88
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/init.h
9+
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BaseSubCollisionPipeline.h
910
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BVHNarrowPhase.h
1011
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceBroadPhase.h
1112
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceDetection.h
1213
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CollisionPM.h
14+
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CompositeCollisionPipeline.h
1315
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DSAPBox.h
1416
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CollisionPipeline.h
1517
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DirectSAP.h
@@ -19,20 +21,24 @@ set(HEADER_FILES
1921
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/MirrorIntersector.h
2022
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceDetection.h
2123
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceNarrowPhase.h
24+
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/SubCollisionPipeline.h
2225
)
2326

2427
set(SOURCE_FILES
2528
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/init.cpp
29+
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BaseSubCollisionPipeline.cpp
2630
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BVHNarrowPhase.cpp
2731
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceBroadPhase.cpp
2832
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceDetection.cpp
2933
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DSAPBox.cpp
3034
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CollisionPipeline.cpp
35+
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CompositeCollisionPipeline.cpp
3136
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DirectSAP.cpp
3237
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DirectSAPNarrowPhase.cpp
3338
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/IncrSAP.cpp
3439
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceDetection.cpp
3540
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceNarrowPhase.cpp
41+
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/SubCollisionPipeline.cpp
3642
)
3743

3844
sofa_find_package(Sofa.Simulation.Core REQUIRED)

Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl renamed to Sofa/Component/Collision/Detection/Algorithm/src/sofa/component/collision/detection/algorithm/BaseSubCollisionPipeline.cpp

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,67 @@
2020
* Contact information: [email protected] *
2121
******************************************************************************/
2222
#pragma once
23+
#include <sofa/component/collision/detection/algorithm/BaseSubCollisionPipeline.h>
2324

24-
#include <sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl>
25+
#include <sofa/core/visual/VisualParams.h>
26+
#include <sofa/core/collision/Contact.h>
2527

26-
SOFA_HEADER_DISABLED("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl")
28+
namespace sofa::component::collision::detection::algorithm
29+
{
30+
31+
BaseSubCollisionPipeline::BaseSubCollisionPipeline()
32+
: sofa::core::objectmodel::BaseObject()
33+
{
34+
35+
}
36+
37+
void BaseSubCollisionPipeline::doBwdInit()
38+
{
39+
40+
}
41+
42+
void BaseSubCollisionPipeline::doDraw(const core::visual::VisualParams* vparams)
43+
{
44+
SOFA_UNUSED(vparams);
45+
46+
}
47+
48+
void BaseSubCollisionPipeline::init()
49+
{
50+
this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Loading);
51+
52+
doInit();
53+
}
54+
55+
/**
56+
* @brief Queries all registered contact response types from the Contact factory.
57+
*
58+
* This static method iterates through all contact types registered in the
59+
* Contact::Factory and returns their names. These represent the available
60+
* collision response methods (e.g., "PenalityContactForceField", "FrictionContact").
61+
*
62+
* @return A set of strings containing all registered contact response type names.
63+
*/
64+
std::set< std::string > BaseSubCollisionPipeline::getResponseList()
65+
{
66+
std::set< std::string > listResponse;
67+
for (const auto& [key, creatorPtr] : *core::collision::Contact::Factory::getInstance())
68+
{
69+
listResponse.insert(key);
70+
}
71+
return listResponse;
72+
}
73+
74+
void BaseSubCollisionPipeline::draw(const core::visual::VisualParams* vparams)
75+
{
76+
const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle();
77+
78+
doDraw(vparams);
79+
}
80+
81+
void BaseSubCollisionPipeline::handleEvent(sofa::core::objectmodel::Event* e)
82+
{
83+
doHandleEvent(e);
84+
}
85+
86+
} // namespace sofa::component::collision::detection::algorithm
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Authors: The SOFA Team and external contributors (see Authors.txt) *
19+
* *
20+
* Contact information: [email protected] *
21+
******************************************************************************/
22+
#pragma once
23+
#include <sofa/component/collision/detection/algorithm/config.h>
24+
25+
#include <sofa/core/objectmodel/BaseObject.h>
26+
27+
#include <set>
28+
#include <string>
29+
30+
namespace sofa::core
31+
{
32+
class CollisionModel;
33+
}
34+
35+
namespace sofa::component::collision::detection::algorithm
36+
{
37+
38+
/**
39+
* @brief Abstract base class defining the interface for sub-collision pipelines.
40+
*
41+
* This base class is designed to be used with CompositeCollisionPipeline, which
42+
* aggregates multiple sub-pipelines and can execute them in parallel.
43+
*
44+
* @see SubCollisionPipeline for a concrete implementation
45+
* @see CompositeCollisionPipeline for the aggregator that manages sub-pipelines
46+
*/
47+
class SOFA_COMPONENT_COLLISION_DETECTION_ALGORITHM_API BaseSubCollisionPipeline : public sofa::core::objectmodel::BaseObject
48+
{
49+
public:
50+
SOFA_ABSTRACT_CLASS(BaseSubCollisionPipeline, sofa::core::objectmodel::BaseObject);
51+
52+
protected:
53+
BaseSubCollisionPipeline();
54+
55+
/// @brief Called during initialization. Derived classes must implement validation and setup logic.
56+
virtual void doInit() = 0;
57+
58+
/// @brief Called after all objects are initialized. Default implementation is empty.
59+
virtual void doBwdInit();
60+
61+
/// @brief Called to handle simulation events. Derived classes must implement event processing.
62+
virtual void doHandleEvent(sofa::core::objectmodel::Event* e) = 0;
63+
64+
/// @brief Called during rendering. Default implementation is empty.
65+
virtual void doDraw(const core::visual::VisualParams* vparams);
66+
67+
public:
68+
///@{
69+
/// @name Collision Pipeline Interface
70+
/// These methods define the three-phase collision workflow that derived classes must implement.
71+
72+
/// @brief Clears collision state from the previous time step (contacts, responses).
73+
virtual void computeCollisionReset() = 0;
74+
75+
/// @brief Performs collision detection (bounding tree, broad phase, narrow phase).
76+
virtual void computeCollisionDetection() = 0;
77+
78+
/// @brief Creates collision responses based on detected contacts.
79+
virtual void computeCollisionResponse() = 0;
80+
81+
///@}
82+
83+
/// @brief Returns the list of collision models handled by this sub-pipeline.
84+
virtual std::vector<sofa::core::CollisionModel*> getCollisionModels() = 0;
85+
86+
/// @brief Initializes the component. Marked final to enforce Template Method pattern.
87+
void init() override final;
88+
89+
/// @brief Renders debug visualization. Marked final to enforce Template Method pattern.
90+
void draw(const core::visual::VisualParams* vparams) override final;
91+
92+
/// @brief Processes simulation events. Marked final to enforce Template Method pattern.
93+
void handleEvent(sofa::core::objectmodel::Event* e) override final;
94+
95+
/// @brief Returns all available contact response types registered in the Contact factory.
96+
static std::set< std::string > getResponseList();
97+
};
98+
99+
} // namespace sofa::component::collision::detection::algorithm

0 commit comments

Comments
 (0)