Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
17cceea
initial commit to bring back multi-staged collision pipeline
fredroy Dec 9, 2025
e2bb405
clean
fredroy Dec 9, 2025
cfa5f55
wip
fredroy Dec 22, 2025
e9e7d52
set links
fredroy Dec 15, 2025
85002b2
set getresponselist to a static function
fredroy Dec 15, 2025
e48c247
add one unit test on warning with no model and update other tests
fredroy Dec 23, 2025
357ec2b
add into registry
fredroy Dec 24, 2025
8175301
Update Sofa/Component/Collision/Detection/Algorithm/src/sofa/componen…
fredroy Jan 7, 2026
12b0bb5
use rangeloop with structured bindings in getResponseList
fredroy Jan 22, 2026
fc71ec8
set do*() and ctor protected in AbstractSubCollisionPipeline
fredroy Jan 22, 2026
9375d49
put implementations into a cpp for AbstractSubCollisionPipeline
fredroy Jan 22, 2026
c30920d
Update Sofa/Component/Collision/Detection/Algorithm/src/sofa/componen…
fredroy Jan 22, 2026
862cf0c
multipipeline inherits TaskSchedulerUser
fredroy Jan 22, 2026
e47c62b
rename AbstractSubCollisionPipeline to BaseSubCollisionPipeline
fredroy Jan 22, 2026
96aa024
remove sorting the sub pipelines
fredroy Jan 22, 2026
346af12
remove useless code (about parallel computeResponse)
fredroy Jan 22, 2026
3217113
remove possible dereference to null
fredroy Jan 22, 2026
907b2be
rename MultiCollisionPipeline to CompositeCollisionPipeline
fredroy Jan 22, 2026
948d1b8
the compat class CollisionPipeline now inherits CompositeCollisionPip…
fredroy Jan 22, 2026
667a4e4
CollisionPipeline: search from the local node instead of the root node
fredroy Jan 23, 2026
f7338a2
refactoring
fredroy Jan 23, 2026
eccb3d3
Apply suggestions from code review (reformatting)
fredroy Jan 26, 2026
848a7ea
print path instead of the name only
fredroy Jan 27, 2026
24cc25f
add show cases
fredroy Jan 27, 2026
015353b
add regression
fredroy Jan 27, 2026
3ac2add
add comments
fredroy Jan 27, 2026
021e91b
Update Sofa/Component/Collision/Detection/Algorithm/src/sofa/componen…
fredroy Feb 4, 2026
20362c5
fix typo
fredroy Feb 4, 2026
cd2e900
Merge branch 'master' into add_multi_pipeline
hugtalbot Feb 5, 2026
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
6 changes: 6 additions & 0 deletions Sofa/Component/Collision/Detection/Algorithm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ set(SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR "src/sofa/component/coll
set(HEADER_FILES
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/config.h.in
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/init.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BaseSubCollisionPipeline.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BVHNarrowPhase.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceBroadPhase.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceDetection.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CollisionPM.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CompositeCollisionPipeline.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DSAPBox.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CollisionPipeline.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DirectSAP.h
Expand All @@ -19,20 +21,24 @@ set(HEADER_FILES
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/MirrorIntersector.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceDetection.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceNarrowPhase.h
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/SubCollisionPipeline.h
)

set(SOURCE_FILES
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/init.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BaseSubCollisionPipeline.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BVHNarrowPhase.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceBroadPhase.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/BruteForceDetection.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DSAPBox.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CollisionPipeline.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/CompositeCollisionPipeline.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DirectSAP.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/DirectSAPNarrowPhase.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/IncrSAP.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceDetection.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/RayTraceNarrowPhase.cpp
${SOFACOMPONENTCOLLISIONDETECTIONALGORITHM_SOURCE_DIR}/SubCollisionPipeline.cpp
)

sofa_find_package(Sofa.Simulation.Core REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/collision/detection/algorithm/BaseSubCollisionPipeline.h>

#include <sofa/core/visual/VisualParams.h>
#include <sofa/core/collision/Contact.h>

namespace sofa::component::collision::detection::algorithm
{

BaseSubCollisionPipeline::BaseSubCollisionPipeline()
: sofa::core::objectmodel::BaseObject()
{

}

void BaseSubCollisionPipeline::doBwdInit()
{

}

void BaseSubCollisionPipeline::doDraw(const core::visual::VisualParams* vparams)
{
SOFA_UNUSED(vparams);

}

void BaseSubCollisionPipeline::init()
{
this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Loading);

doInit();
}

/**
* @brief Queries all registered contact response types from the Contact factory.
*
* This static method iterates through all contact types registered in the
* Contact::Factory and returns their names. These represent the available
* collision response methods (e.g., "PenalityContactForceField", "FrictionContact").
*
* @return A set of strings containing all registered contact response type names.
*/
std::set< std::string > BaseSubCollisionPipeline::getResponseList()
{
std::set< std::string > listResponse;
for (const auto& [key, creatorPtr] : *core::collision::Contact::Factory::getInstance())
{
listResponse.insert(key);
}
return listResponse;
}

void BaseSubCollisionPipeline::draw(const core::visual::VisualParams* vparams)
{
const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle();

doDraw(vparams);
}

void BaseSubCollisionPipeline::handleEvent(sofa::core::objectmodel::Event* e)
{
doHandleEvent(e);
}

} // namespace sofa::component::collision::detection::algorithm
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/collision/detection/algorithm/config.h>

#include <sofa/core/objectmodel/BaseObject.h>

#include <set>
#include <string>

namespace sofa::core
{
class CollisionModel;
}

namespace sofa::component::collision::detection::algorithm
{

/**
* @brief Abstract base class defining the interface for sub-collision pipelines.
*
* This base class is designed to be used with CompositeCollisionPipeline, which
* aggregates multiple sub-pipelines and can execute them in parallel.
*
* @see SubCollisionPipeline for a concrete implementation
* @see CompositeCollisionPipeline for the aggregator that manages sub-pipelines
*/
class SOFA_COMPONENT_COLLISION_DETECTION_ALGORITHM_API BaseSubCollisionPipeline : public sofa::core::objectmodel::BaseObject
{
public:
SOFA_ABSTRACT_CLASS(BaseSubCollisionPipeline, sofa::core::objectmodel::BaseObject);

protected:
BaseSubCollisionPipeline();

/// @brief Called during initialization. Derived classes must implement validation and setup logic.
virtual void doInit() = 0;

/// @brief Called after all objects are initialized. Default implementation is empty.
virtual void doBwdInit();

/// @brief Called to handle simulation events. Derived classes must implement event processing.
virtual void doHandleEvent(sofa::core::objectmodel::Event* e) = 0;

/// @brief Called during rendering. Default implementation is empty.
virtual void doDraw(const core::visual::VisualParams* vparams);

public:
///@{
/// @name Collision Pipeline Interface
/// These methods define the three-phase collision workflow that derived classes must implement.

/// @brief Clears collision state from the previous time step (contacts, responses).
virtual void computeCollisionReset() = 0;

/// @brief Performs collision detection (bounding tree, broad phase, narrow phase).
virtual void computeCollisionDetection() = 0;

/// @brief Creates collision responses based on detected contacts.
virtual void computeCollisionResponse() = 0;

///@}

/// @brief Returns the list of collision models handled by this sub-pipeline.
virtual std::vector<sofa::core::CollisionModel*> getCollisionModels() = 0;

/// @brief Initializes the component. Marked final to enforce Template Method pattern.
void init() override final;

/// @brief Renders debug visualization. Marked final to enforce Template Method pattern.
void draw(const core::visual::VisualParams* vparams) override final;

/// @brief Processes simulation events. Marked final to enforce Template Method pattern.
void handleEvent(sofa::core::objectmodel::Event* e) override final;

/// @brief Returns all available contact response types registered in the Contact factory.
static std::set< std::string > getResponseList();
};

} // namespace sofa::component::collision::detection::algorithm
Loading
Loading