Skip to content

Commit

Permalink
Merge pull request #112 from fredroy/202406_cherrypick_changelog_2406
Browse files Browse the repository at this point in the history
Remove compat layer for intersection with v24.12
  • Loading branch information
hugtalbot committed Jun 25, 2024
2 parents 2a15469 + 0ee3173 commit 8fd028f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ class MirrorIntersector : public core::collision::ElementIntersector
return intersector->name() + std::string("<SWAP>");
}

SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
bool canIntersect(core::CollisionElementIterator elem1, core::CollisionElementIterator elem2) override
{
assert(intersector != nullptr);
return intersector->canIntersect(elem2, elem1);
}
SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
int intersect(core::CollisionElementIterator elem1, core::CollisionElementIterator elem2, core::collision::DetectionOutputVector* contacts) override
{
assert(intersector != nullptr);
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Core/src/sofa/core/collision/Intersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class ElementIntersector

virtual std::string name() const = 0;

SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
virtual bool canIntersect(core::CollisionElementIterator, core::CollisionElementIterator) { return false; };
SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
virtual int intersect(core::CollisionElementIterator, core::CollisionElementIterator, DetectionOutputVector*) { return 0; };
};

Expand Down
74 changes: 8 additions & 66 deletions Sofa/framework/Core/src/sofa/core/collision/Intersection.inl
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,6 @@

#include <sofa/version.h>

// remove the conent of this anonymous namespace once the compat layer is deleted
// SOFA_ATTRIBUTE_DEPRECATED("v24.06", "v24.12")
#if (SOFA_VERSION / 100) <= 2406
namespace
{
// SFINAE block of code to detect at compile time if
// - Intersector implements testIntersection(ModelElement1&, ModelElement2&, Intersection*)
// - Intersector implements computeIntersection(ModelElement1&, ModelElement2&, OutputVector*, Intersection*)

template<typename ModelElement1, typename ModelElement2, typename Intersector, typename = void>
struct has_testIntersection_with_Intersection
: std::false_type
{ };

template<typename ModelElement1, typename ModelElement2, typename Intersector, typename = void>
struct has_computeIntersection_with_Intersection
: std::false_type
{ };

// detect at compile time if Intersector implements testIntersection(ModelElement1&, ModelElement2&, Intersection*)
template<typename ModelElement1, typename ModelElement2, typename Intersector>
struct has_testIntersection_with_Intersection<ModelElement1, ModelElement2, Intersector,
std::void_t<decltype(std::declval<Intersector>().testIntersection(
std::declval<ModelElement1&>(),
std::declval<ModelElement2&>(),
std::declval<const sofa::core::collision::Intersection*>()
))>>
: std::true_type
{ };

// detect at compile time if Intersector implements computeIntersection(ModelElement1&, ModelElement2&, OutputVector*, Intersection*)
template<typename ModelElement1, typename ModelElement2, typename Intersector>
struct has_computeIntersection_with_Intersection<ModelElement1, ModelElement2, Intersector,
std::void_t<decltype(std::declval<Intersector>().computeIntersection(
std::declval<ModelElement1&>(),
std::declval<ModelElement2&>(),
std::declval<sofa::core::collision::BaseIntersector::OutputVector*>(),
std::declval<const sofa::core::collision::Intersection*>()
))>>
: std::true_type
{ };
}
#endif

namespace sofa::core::collision
{

Expand All @@ -81,7 +37,7 @@ public:
typedef typename Elem2::Model Model2;
MemberElementIntersector(T* ptr) : impl(ptr) {}
/// Test if 2 elements can collide. Note that this can be conservative (i.e. return true even when no collision is present)
SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
bool canIntersect(core::CollisionElementIterator elem1, core::CollisionElementIterator elem2) override
{
Elem1 e1(elem1);
Expand All @@ -91,16 +47,9 @@ public:

bool canIntersect(core::CollisionElementIterator elem1, core::CollisionElementIterator elem2, const core::collision::Intersection* currentIntersection) override
{
if constexpr (!has_testIntersection_with_Intersection<typename Model1::Element, typename Model2::Element, T>::value)
{
return canIntersect(elem1, elem2);
}
else
{
Elem1 e1(elem1);
Elem2 e2(elem2);
return impl->testIntersection(e1, e2, currentIntersection);
}
Elem1 e1(elem1);
Elem2 e2(elem2);
return impl->testIntersection(e1, e2, currentIntersection);
}

/// Begin intersection tests between two collision models. Return the number of contacts written in the contacts vector.
Expand All @@ -117,7 +66,7 @@ public:
}

/// Compute the intersection between 2 elements.
SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
int intersect(core::CollisionElementIterator elem1, core::CollisionElementIterator elem2, DetectionOutputVector* contacts) override
{
Elem1 e1(elem1);
Expand All @@ -127,16 +76,9 @@ public:

int intersect(core::CollisionElementIterator elem1, core::CollisionElementIterator elem2, DetectionOutputVector* contacts, const core::collision::Intersection* currentIntersection) override
{
if constexpr (!has_computeIntersection_with_Intersection<typename Model1::Element, typename Model2::Element, T>::value)
{
return intersect(elem1, elem2, contacts);
}
else
{
Elem1 e1(elem1);
Elem2 e2(elem2);
return impl->computeIntersection(e1, e2, impl->getOutputVector(e1.getCollisionModel(), e2.getCollisionModel(), contacts), currentIntersection);
}
Elem1 e1(elem1);
Elem2 e2(elem2);
return impl->computeIntersection(e1, e2, impl->getOutputVector(e1.getCollisionModel(), e2.getCollisionModel(), contacts), currentIntersection);
}

std::string name() const override
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Core/src/sofa/core/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
#endif

#ifdef SOFA_BUILD_SOFA_CORE
#define SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER()
#define SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER()
#else
#define SOFA_ATTRIBUTE_DEPRECATED__CORE_INTERSECTION_AS_PARAMETER() \
#define SOFA_ATTRIBUTE_DISABLED__CORE_INTERSECTION_AS_PARAMETER() \
SOFA_ATTRIBUTE_DEPRECATED("v24.06", "v24.12", "Intersection detection methods now needs the Intersection method as a parameter.")
#endif

0 comments on commit 8fd028f

Please sign in to comment.