Skip to content

Commit

Permalink
more deprecations (stored pointer to intersection) and remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fredroy committed Mar 18, 2024
1 parent f17acc1 commit fdf45e6
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 4 deletions.
Expand Up @@ -90,6 +90,7 @@ int DiscreteIntersection::computeIntersection(Cube& cube1, Cube& cube2, OutputVe
SOFA_UNUSED(cube1);
SOFA_UNUSED(cube2);
SOFA_UNUSED(contacts);
SOFA_UNUSED(currentIntersection);

return 0;
}
Expand Down
Expand Up @@ -50,6 +50,8 @@ bool MeshDiscreteIntersection::testIntersection(Triangle&, Line&, const sofa::co

int MeshDiscreteIntersection::computeIntersection(Triangle& e1, Line& e2, OutputVector* contacts, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

static_assert(std::is_same_v<Triangle::Coord, Line::Coord>, "Data mismatch");
static_assert(Triangle::Coord::total_size == 3, "Must be a vec type");

Expand Down
Expand Up @@ -58,6 +58,7 @@ class SOFA_COMPONENT_COLLISION_DETECTION_INTERSECTION_API MeshDiscreteIntersecti
template<class T> int computeIntersection(collision::geometry::TSphere<T>&, collision::geometry::Triangle&, OutputVector*);

protected:
SOFA_ATTRIBUTE_DEPRECATED__COLLISION_DETECTION_INTERSECTION_AS_PARAMETER()
DiscreteIntersection* intersection;

};
Expand Down
Expand Up @@ -31,6 +31,8 @@ namespace sofa::component::collision::detection::intersection
template<class T>
bool MeshDiscreteIntersection::testIntersection(collision::geometry::TSphere<T>& sph, collision::geometry::Triangle& triangle, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

const double EPSILON = 0.00001;
//Vertices of the triangle:
const type::Vec3 p0 = triangle.p1();
Expand Down Expand Up @@ -82,6 +84,8 @@ bool MeshDiscreteIntersection::testIntersection(collision::geometry::TSphere<T>&
template<class T>
int MeshDiscreteIntersection::computeIntersection(collision::geometry::TSphere<T>& sph, collision::geometry::Triangle& triangle, OutputVector* contacts, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

const double EPSILON = 0.00001;
//Vertices of the triangle:
const type::Vec3 p0 = triangle.p1();
Expand Down
Expand Up @@ -96,6 +96,7 @@ class SOFA_COMPONENT_COLLISION_DETECTION_INTERSECTION_API MeshMinProximityInters

protected:

SOFA_ATTRIBUTE_DEPRECATED__COLLISION_DETECTION_INTERSECTION_AS_PARAMETER()
MinProximityIntersection* intersection;
};

Expand Down Expand Up @@ -196,7 +197,7 @@ int MeshMinProximityIntersection::computeIntersection(collision::geometry::Trian
}
else
{
msg_warning(intersection) << "Null distance between contact detected";
msg_warning(currentIntersection) << "Null distance between contact detected";
detection->normal= type::Vec3(1,0,0);
}
detection->value -= contactDist;
Expand Down Expand Up @@ -335,7 +336,7 @@ int MeshMinProximityIntersection::computeIntersection(collision::geometry::TSphe
}
else
{
msg_warning(intersection) << "Null distance between contact detected";
msg_warning(currentIntersection) << "Null distance between contact detected";
detection->normal= type::Vec3(1,0,0);
}
detection->value -= contactDist;
Expand Down
Expand Up @@ -360,6 +360,7 @@ bool MeshNewProximityIntersection::testIntersection(collision::geometry::Line& e
{
SOFA_UNUSED(e1);
SOFA_UNUSED(e2);
SOFA_UNUSED(currentIntersection);

msg_warning(intersection) << "Unnecessary call to NewProximityIntersection::testIntersection(Line,Sphere).";
return true;
Expand Down Expand Up @@ -387,6 +388,7 @@ bool MeshNewProximityIntersection::testIntersection(collision::geometry::Triangl
{
SOFA_UNUSED(e1);
SOFA_UNUSED(e2);
SOFA_UNUSED(currentIntersection);

msg_warning(intersection) << "Unnecessary call to NewProximityIntersection::testIntersection(Triangle,Sphere).";
return true;
Expand Down
Expand Up @@ -67,11 +67,15 @@ void NewProximityIntersection::init()

bool NewProximityIntersection::testIntersection(Cube& cube1, Cube& cube2, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

return BaseProximityIntersection::testIntersection(cube1, cube2);
}

int NewProximityIntersection::computeIntersection(Cube& cube1, Cube& cube2, OutputVector* contacts, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

return BaseProximityIntersection::computeIntersection(cube1, cube2, contacts);
}

Expand Down
Expand Up @@ -63,6 +63,7 @@ class SOFA_COMPONENT_COLLISION_DETECTION_INTERSECTION_API RayDiscreteIntersectio

protected:

SOFA_ATTRIBUTE_DEPRECATED__COLLISION_DETECTION_INTERSECTION_AS_PARAMETER()
DiscreteIntersection* intersection;

};
Expand Down
Expand Up @@ -33,6 +33,8 @@ namespace sofa::component::collision::detection::intersection
template<class T>
bool RayDiscreteIntersection::testIntersection(collision::geometry::Ray & ray1, collision::geometry::TSphere<T>& sph2, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

// Center of the sphere
const type::Vec3 sph2Pos(sph2.center());
// Radius of the sphere
Expand All @@ -51,6 +53,8 @@ bool RayDiscreteIntersection::testIntersection(collision::geometry::Ray & ray1,
template<class T>
int RayDiscreteIntersection::computeIntersection(collision::geometry::Ray& ray1, collision::geometry::TSphere<T>& sph2, OutputVector* contacts, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

// Center of the sphere
const type::Vec3 sph2Pos(sph2.center());
// Radius of the sphere
Expand Down
Expand Up @@ -123,12 +123,16 @@ int RayNewProximityIntersection::computeIntersection(Ray &t1, Triangle &t2, Outp

bool RayNewProximityIntersection::testIntersection( Ray& /*rRay*/, RigidSphere&, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

return false;
}


int RayNewProximityIntersection::computeIntersection(Ray& rRay, RigidSphere& rSphere, OutputVector* contacts, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

const Vec3 v3SphereCenter = rSphere.center( );
const SReal fSphereRadii = rSphere.r();

Expand Down
Expand Up @@ -57,6 +57,7 @@ class SOFA_COMPONENT_COLLISION_DETECTION_INTERSECTION_API RayNewProximityInterse
int computeIntersection(collision::geometry::Ray& rRay, collision::geometry::RigidSphere& rSphere, OutputVector*);
protected:

SOFA_ATTRIBUTE_DEPRECATED__COLLISION_DETECTION_INTERSECTION_AS_PARAMETER()
NewProximityIntersection* intersection;
};

Expand Down
Expand Up @@ -44,6 +44,8 @@ TetrahedronDiscreteIntersection::TetrahedronDiscreteIntersection(DiscreteInterse

bool TetrahedronDiscreteIntersection::testIntersection(Tetrahedron&, Point&, const core::collision::Intersection* currentIntersection)
{
SOFA_UNUSED(currentIntersection);

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Core/src/sofa/core/collision/Intersection.h
Expand Up @@ -83,9 +83,9 @@ class ElementIntersector
virtual std::string name() const = 0;

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

/// Table storing associations between types of collision models and intersectors implementing intersection tests
Expand Down

0 comments on commit fdf45e6

Please sign in to comment.