From c65cf25dd14dcc6a48d2bf3ca6e4e0aa1609819c Mon Sep 17 00:00:00 2001 From: alxbilger Date: Wed, 2 Jun 2021 16:36:35 +0200 Subject: [PATCH] [SofaGeneralMeshCollision] Introduce RayTraceNarrowPhase --- .../collision/RayTraceCollision.scn | 9 +- .../SofaGeneralMeshCollision/CMakeLists.txt | 11 +- .../RayTraceNarrowPhase.cpp | 266 +++++++++++++++++ .../RayTraceNarrowPhase.h | 64 +++++ .../SofaUserInteraction/RayTraceDetection.cpp | 271 +----------------- .../SofaUserInteraction/RayTraceDetection.h | 35 +-- 6 files changed, 345 insertions(+), 311 deletions(-) create mode 100644 modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.cpp create mode 100644 modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.h diff --git a/examples/Components/collision/RayTraceCollision.scn b/examples/Components/collision/RayTraceCollision.scn index 1d0fdf2ddc5..e1def696f40 100644 --- a/examples/Components/collision/RayTraceCollision.scn +++ b/examples/Components/collision/RayTraceCollision.scn @@ -1,10 +1,11 @@ - - - - + + + + + diff --git a/modules/SofaGeneralMeshCollision/CMakeLists.txt b/modules/SofaGeneralMeshCollision/CMakeLists.txt index 30a0f8a6d0f..e6e5d3d81e5 100644 --- a/modules/SofaGeneralMeshCollision/CMakeLists.txt +++ b/modules/SofaGeneralMeshCollision/CMakeLists.txt @@ -17,15 +17,10 @@ list(APPEND HEADER_FILES ${SOFAGENERALMESHCOLLISION_SRC}/DirectSAPNarrowPhase.h ${SOFAGENERALMESHCOLLISION_SRC}/DSAPBox.h ${SOFAGENERALMESHCOLLISION_SRC}/IncrSAP.h - # IntrTriangleOBB.h - # IntrTriangleOBB.inl ${SOFAGENERALMESHCOLLISION_SRC}/MeshDiscreteIntersection.h ${SOFAGENERALMESHCOLLISION_SRC}/MeshDiscreteIntersection.inl ${SOFAGENERALMESHCOLLISION_SRC}/MeshMinProximityIntersection.h - # RigidContactMapper.h - # RigidContactMapper.inl - # SubsetContactMapper.h - # SubsetContactMapper.inl + ${SOFAGENERALMESHCOLLISION_SRC}/RayTraceNarrowPhase.h ${SOFAGENERALMESHCOLLISION_SRC}/TriangleOctree.h ${SOFAGENERALMESHCOLLISION_SRC}/TriangleOctreeModel.h ) @@ -34,11 +29,9 @@ list(APPEND SOURCE_FILES ${SOFAGENERALMESHCOLLISION_SRC}/DirectSAPNarrowPhase.cpp ${SOFAGENERALMESHCOLLISION_SRC}/DSAPBox.cpp ${SOFAGENERALMESHCOLLISION_SRC}/IncrSAP.cpp - # IntrTriangleOBB.cpp ${SOFAGENERALMESHCOLLISION_SRC}/MeshDiscreteIntersection.cpp ${SOFAGENERALMESHCOLLISION_SRC}/MeshMinProximityIntersection.cpp - # RigidContactMapper.cpp - # SubsetContactMapper.cpp + ${SOFAGENERALMESHCOLLISION_SRC}/RayTraceNarrowPhase.cpp ${SOFAGENERALMESHCOLLISION_SRC}/TriangleOctree.cpp ${SOFAGENERALMESHCOLLISION_SRC}/TriangleOctreeModel.cpp ) diff --git a/modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.cpp b/modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.cpp new file mode 100644 index 00000000000..8d09933f583 --- /dev/null +++ b/modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.cpp @@ -0,0 +1,266 @@ +/****************************************************************************** +* 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 . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#include +#include +#include +#include +#include + +namespace sofa::component::collision +{ + +using sofa::core::collision::TDetectionOutputVector; + +int RayTraceNarrowPhaseClass = core::RegisterObject("Collision detection using TriangleOctreeModel").add < RayTraceNarrowPhase > (); + +RayTraceNarrowPhase::RayTraceNarrowPhase() +:bDraw (initData(&bDraw, false, "draw","enable/disable display of results")) +{} + +void RayTraceNarrowPhase::findPairsVolume (CubeCollisionModel * cm1, CubeCollisionModel * cm2) +{ + /*Obtain the CollisionModel at the lowest level, in this case it must be a TriangleOctreeModel */ + + TriangleOctreeModel *tm1 = + dynamic_cast < TriangleOctreeModel * >(cm1->getLast ()); + TriangleOctreeModel *tm2 = + dynamic_cast < TriangleOctreeModel * >(cm2->getLast ()); + if (!tm1 || !tm2) + return; + + + /*construct the octree of both models, when it still doesn't exisits */ + if (!tm1->octreeRoot) + { + + tm1->buildOctree (); + } + + if (!tm2->octreeRoot) + { + + tm2->buildOctree (); + + } + + /* get the output vector for a TriangleOctreeModel, TriangleOctreeModel Collision*/ + /*Get the cube representing the bounding box of both Models */ + // sofa::core::collision::DetectionOutputVector *& contacts=outputsMap[std::make_pair(tm1, tm2)]; + core::collision::DetectionOutputVector*& contacts = this->getDetectionOutputs(tm1, tm2); + + + if (contacts == nullptr) + { + contacts = new + sofa::core::collision::TDetectionOutputVector < + TriangleOctreeModel, TriangleOctreeModel >; + + } + + + + + TDetectionOutputVector < TriangleOctreeModel, + TriangleOctreeModel > *outputs = + static_cast < TDetectionOutputVector < TriangleOctreeModel, + TriangleOctreeModel > *>(contacts); + + Cube cube1 (cm1, 0); + Cube cube2 (cm2, 0); + + + const sofa::defaulttype::Vector3 & minVect2 = cube2.minVect (); + const sofa::defaulttype::Vector3 & maxVect2 = cube2.maxVect (); + int size = tm1->getSize (); + + for (int j = 0; j < size; j++) + { + + /*creates a Triangle for each object being tested */ + Triangle tri1 (tm1, j); + + + /*cosAngle will store the angle between the triangle from t1 and his corresponding in t2 */ + double cosAngle; + /*cosAngle will store the angle between the triangle from t1 and another triangle on t1 that is crossed by the -normal of tri1*/ + double cosAngle2; + /*resTriangle and resTriangle2 will store the triangle result from the trace method */ + int resTriangle = -1; + int resTriangle2 = -1; + sofa::defaulttype::Vector3 trianglePoints[4]; + //bool found = false; + int nPoints = 0; + sofa::defaulttype::Vector3 normau[3]; + /*if it fails to find a correspondence between the triangles it tries the raytracing procedure */ + /*test if this triangle was tested before */ + + /*set the triangle as tested */ + int flags = tri1.flags(); + + /*test only the points related to this triangle */ + if (flags & TriangleCollisionModel::FLAG_P1) + { + normau[nPoints] = tm1->pNorms[tri1.p1Index ()]; + trianglePoints[nPoints++] = tri1.p1 (); + + } + if (flags & TriangleCollisionModel::FLAG_P2) + { + normau[nPoints] = tm1->pNorms[tri1.p2Index ()]; + trianglePoints[nPoints++] = tri1.p2 (); + } + if (flags & TriangleCollisionModel::FLAG_P3) + { + normau[nPoints] = tm1->pNorms[tri1.p3Index ()]; + trianglePoints[nPoints++] = tri1.p3 (); + } + + for (int t = 0; t < nPoints; t++) + { + + sofa::defaulttype::Vector3 point = trianglePoints[t]; + + if ((point[0] < (minVect2[0])) + || (point[0] > maxVect2[0] ) + || (point[1] < minVect2[1] ) + || (point[1] > maxVect2[1] ) + || (point[2] < minVect2[2] ) + || (point[2] > maxVect2[2] )) + continue; + /*res and res2 will store the point of intercection and the distance from the point */ + TriangleOctree::traceResult res, res2; + /*search a triangle on t2 */ + resTriangle = + tm2->octreeRoot-> + trace (point /*+ normau[t] * (contactDistance / 2) */ , + -normau[t], res); + if (resTriangle == -1) + continue; + Triangle triang2 (tm2, resTriangle); + cosAngle = dot (tri1.n (), triang2.n ()); + if (cosAngle > 0) + continue; + /*search a triangle on t1, to be sure that the triangle found on t2 isn't outside the t1 object */ + + /*if there is no triangle in t1 that is crossed by the tri1 normal (resTriangle2==-1), it means that t1 is not an object with a closed volume, so we can't continue. + If the distance from the point to the triangle on t1 is less than the distance to the triangle on t2 it means that the corresponding point is outside t1, and is not a good point */ + resTriangle2 = + tm1->octreeRoot->trace (point, -normau[t], res2); + + + + if (resTriangle2 == -1 || res2.t < res.t) + { + + continue; + } + + + Triangle tri3 (tm1, resTriangle2); + cosAngle2 = dot (tri1.n (), tri3.n ()); + if (cosAngle2 > 0) + continue; + + sofa::defaulttype::Vector3 Q = + (triang2.p1 () * (1.0 - res.u - res.v)) + + (triang2.p2 () * res.u) + (triang2.p3 () * res.v); + + outputs->resize (outputs->size () + 1); + sofa::core::collision::DetectionOutput *detection = &*(outputs->end () - 1); + + + detection->elem = + std::pair < + core::CollisionElementIterator, + core::CollisionElementIterator > (tri1, triang2); + detection->point[0] = point; + + detection->point[1] = Q; + + detection->normal = normau[t]; + + detection->value = -(res.t); + + detection->id = tri1.getIndex()*3+t; + //found = true; + + } + + } + +} + + +void RayTraceNarrowPhase::addCollisionPair (const std::pair < + core::CollisionModel *, + core::CollisionModel * >&cmPair) +{ + CubeCollisionModel *cm1 = dynamic_cast < CubeCollisionModel * >(cmPair.first); + CubeCollisionModel *cm2 = dynamic_cast < CubeCollisionModel * >(cmPair.second); + if (cm1 && cm2) + { + findPairsVolume (cm1, cm2); + findPairsVolume (cm2, cm1); + } +} + + +void RayTraceNarrowPhase::draw (const core::visual::VisualParams* vparams) +{ + if (!bDraw.getValue ()) + return; + + vparams->drawTool()->saveLastState(); + vparams->drawTool()->disableLighting(); + + sofa::helper::types::RGBAColor color(1.0, 0.0, 1.0, 1.0); + vparams->drawTool()->setPolygonMode(0, true); + std::vector vertices; + + const DetectionOutputMap& outputsMap = this->getDetectionOutputs(); + + for (DetectionOutputMap::const_iterator it = outputsMap.begin (); + it != outputsMap.end (); ++it) + { + TDetectionOutputVector < TriangleOctreeModel, + TriangleOctreeModel > *outputs = + static_cast < + sofa::core::collision::TDetectionOutputVector < + TriangleOctreeModel, TriangleOctreeModel > *>(it->second); + for (TDetectionOutputVector < TriangleOctreeModel, + TriangleOctreeModel >::iterator it2 = (outputs)->begin (); + it2 != outputs->end (); ++it2) + { + vertices.push_back(sofa::defaulttype::Vector3(it2->point[0][0], it2->point[0][1],it2->point[0][2])); + vertices.push_back(sofa::defaulttype::Vector3(it2->point[1][0], it2->point[1][1],it2->point[1][2])); + + msg_error() << it2->point[0] << " " << it2->point[0]; + + it2->elem.first.draw(vparams); + it2->elem.second.draw(vparams); + } + } + vparams->drawTool()->drawLines(vertices,3,color); + vparams->drawTool()->restoreLastState(); +} + +} \ No newline at end of file diff --git a/modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.h b/modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.h new file mode 100644 index 00000000000..4787e1929c2 --- /dev/null +++ b/modules/SofaGeneralMeshCollision/src/SofaGeneralMeshCollision/RayTraceNarrowPhase.h @@ -0,0 +1,64 @@ +/****************************************************************************** +* 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 . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#pragma once + +#include + +#include + +namespace sofa::component::collision +{ + +class CubeCollisionModel; + +/** + * \brief It is a Ray Trace based collision detection algorithm + * + * For each point in one object, we trace a ray following the oposite of the point's normal + * up to find a triangle in the other object. Both triangles are tested to evaluate if they are in + * colliding state. It must be used with a TriangleOctreeModel,as an octree is used to traverse the object. + */ +class SOFA_SOFAGENERALMESHCOLLISION_API RayTraceNarrowPhase : public core::collision::NarrowPhaseDetection +{ +public: + SOFA_CLASS(RayTraceNarrowPhase, core::collision::NarrowPhaseDetection); + +private: + Data < bool > bDraw; + +protected: + RayTraceNarrowPhase(); + +public: + void addCollisionPair (const std::pair < core::CollisionModel *, + core::CollisionModel * >&cmPair) override; + + void findPairsVolume (CubeCollisionModel * cm1, CubeCollisionModel * cm2); + + void draw (const core::visual::VisualParams* vparams) override; + void setDraw (bool val) + { + bDraw.setValue (val); + } +}; + +} \ No newline at end of file diff --git a/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.cpp b/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.cpp index 6f4ee83bf21..4539fc89462 100644 --- a/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.cpp +++ b/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.cpp @@ -20,278 +20,13 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#include - -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include - -#include +#include namespace sofa::component::collision { -using namespace sofa::defaulttype; -using namespace sofa::core::collision; -using namespace collision; -using sofa::helper::system::thread::CTime; -using sofa::helper::system::thread::ctime_t; - -int RayTraceDetectionClass = - core:: - RegisterObject - ("Collision detection using TriangleOctreeModel").add < - RayTraceDetection > (); - -using namespace core::objectmodel; - -RayTraceDetection:: -RayTraceDetection ():bDraw (initData - (&bDraw, false, "draw", - "enable/disable display of results")) -{ -} - -void RayTraceDetection::findPairsVolume (CubeCollisionModel * cm1, CubeCollisionModel * cm2) -{ - /*Obtain the CollisionModel at the lowest level, in this case it must be a TriangleOctreeModel */ - - TriangleOctreeModel *tm1 = - dynamic_cast < TriangleOctreeModel * >(cm1->getLast ()); - TriangleOctreeModel *tm2 = - dynamic_cast < TriangleOctreeModel * >(cm2->getLast ()); - if (!tm1 || !tm2) - return; - - - /*construct the octree of both models, when it still doesn't exisits */ - if (!tm1->octreeRoot) - { - - tm1->buildOctree (); - } - - if (!tm2->octreeRoot) - { - - tm2->buildOctree (); - - } - - /* get the output vector for a TriangleOctreeModel, TriangleOctreeModel Collision*/ - /*Get the cube representing the bounding box of both Models */ - // sofa::core::collision::DetectionOutputVector *& contacts=outputsMap[std::make_pair(tm1, tm2)]; - core::collision::DetectionOutputVector*& contacts = this->getDetectionOutputs(tm1, tm2); - - - if (contacts == nullptr) - { - contacts = new - sofa::core::collision::TDetectionOutputVector < - TriangleOctreeModel, TriangleOctreeModel >; - - } - - - - - TDetectionOutputVector < TriangleOctreeModel, - TriangleOctreeModel > *outputs = - static_cast < TDetectionOutputVector < TriangleOctreeModel, - TriangleOctreeModel > *>(contacts); - - Cube cube1 (cm1, 0); - Cube cube2 (cm2, 0); - - - const Vector3 & minVect2 = cube2.minVect (); - const Vector3 & maxVect2 = cube2.maxVect (); - int size = tm1->getSize (); - - for (int j = 0; j < size; j++) - { - - /*creates a Triangle for each object being tested */ - Triangle tri1 (tm1, j); - - - /*cosAngle will store the angle between the triangle from t1 and his corresponding in t2 */ - double cosAngle; - /*cosAngle will store the angle between the triangle from t1 and another triangle on t1 that is crossed by the -normal of tri1*/ - double cosAngle2; - /*resTriangle and resTriangle2 will store the triangle result from the trace method */ - int resTriangle = -1; - int resTriangle2 = -1; - Vector3 trianglePoints[4]; - //bool found = false; - int nPoints = 0; - Vector3 normau[3]; - /*if it fails to find a correspondence between the triangles it tries the raytracing procedure */ - /*test if this triangle was tested before */ - - /*set the triangle as tested */ - int flags = tri1.flags(); - - /*test only the points related to this triangle */ - if (flags & TriangleCollisionModel::FLAG_P1) - { - normau[nPoints] = tm1->pNorms[tri1.p1Index ()]; - trianglePoints[nPoints++] = tri1.p1 (); - - } - if (flags & TriangleCollisionModel::FLAG_P2) - { - normau[nPoints] = tm1->pNorms[tri1.p2Index ()]; - trianglePoints[nPoints++] = tri1.p2 (); - } - if (flags & TriangleCollisionModel::FLAG_P3) - { - normau[nPoints] = tm1->pNorms[tri1.p3Index ()]; - trianglePoints[nPoints++] = tri1.p3 (); - } - - for (int t = 0; t < nPoints; t++) - { - - Vector3 point = trianglePoints[t]; - - if ((point[0] < (minVect2[0])) - || (point[0] > maxVect2[0] ) - || (point[1] < minVect2[1] ) - || (point[1] > maxVect2[1] ) - || (point[2] < minVect2[2] ) - || (point[2] > maxVect2[2] )) - continue; - /*res and res2 will store the point of intercection and the distance from the point */ - TriangleOctree::traceResult res, res2; - /*search a triangle on t2 */ - resTriangle = - tm2->octreeRoot-> - trace (point /*+ normau[t] * (contactDistance / 2) */ , - -normau[t], res); - if (resTriangle == -1) - continue; - Triangle triang2 (tm2, resTriangle); - cosAngle = dot (tri1.n (), triang2.n ()); - if (cosAngle > 0) - continue; - /*search a triangle on t1, to be sure that the triangle found on t2 isn't outside the t1 object */ - - /*if there is no triangle in t1 that is crossed by the tri1 normal (resTriangle2==-1), it means that t1 is not an object with a closed volume, so we can't continue. - If the distance from the point to the triangle on t1 is less than the distance to the triangle on t2 it means that the corresponding point is outside t1, and is not a good point */ - resTriangle2 = - tm1->octreeRoot->trace (point, -normau[t], res2); - - - - if (resTriangle2 == -1 || res2.t < res.t) - { - - continue; - } - - - Triangle tri3 (tm1, resTriangle2); - cosAngle2 = dot (tri1.n (), tri3.n ()); - if (cosAngle2 > 0) - continue; - - Vector3 Q = - (triang2.p1 () * (1.0 - res.u - res.v)) + - (triang2.p2 () * res.u) + (triang2.p3 () * res.v); - - outputs->resize (outputs->size () + 1); - DetectionOutput *detection = &*(outputs->end () - 1); - - - detection->elem = - std::pair < - core::CollisionElementIterator, - core::CollisionElementIterator > (tri1, triang2); - detection->point[0] = point; - - detection->point[1] = Q; - - detection->normal = normau[t]; - - detection->value = -(res.t); - - detection->id = tri1.getIndex()*3+t; - //found = true; - - } - - } - -} - -void RayTraceDetection::addCollisionPair (const std::pair < - core::CollisionModel *, - core::CollisionModel * >&cmPair) -{ - CubeCollisionModel *cm1 = dynamic_cast < CubeCollisionModel * >(cmPair.first); - CubeCollisionModel *cm2 = dynamic_cast < CubeCollisionModel * >(cmPair.second); - if (cm1 && cm2) - { - //ctime_t t0, t1, t2; - /*t0 = */CTime::getRefTime (); - findPairsVolume (cm1, cm2); - - - /*t1 = */CTime::getRefTime (); - - findPairsVolume (cm2, cm1); - /*t2 = */CTime::getRefTime (); - } -} - -void RayTraceDetection::draw (const core::visual::VisualParams* vparams) -{ - if (!bDraw.getValue ()) - return; - - vparams->drawTool()->saveLastState(); - vparams->drawTool()->disableLighting(); - - sofa::helper::types::RGBAColor color(1.0, 0.0, 1.0, 1.0); - vparams->drawTool()->setPolygonMode(0, true); - std::vector vertices; - - const DetectionOutputMap& outputsMap = this->getDetectionOutputs(); - - for (DetectionOutputMap::const_iterator it = outputsMap.begin (); - it != outputsMap.end (); ++it) - { - TDetectionOutputVector < TriangleOctreeModel, - TriangleOctreeModel > *outputs = - static_cast < - sofa::core::collision::TDetectionOutputVector < - TriangleOctreeModel, TriangleOctreeModel > *>(it->second); - for (TDetectionOutputVector < TriangleOctreeModel, - TriangleOctreeModel >::iterator it2 = (outputs)->begin (); - it2 != outputs->end (); ++it2) - { - vertices.push_back(sofa::defaulttype::Vector3(it2->point[0][0], it2->point[0][1],it2->point[0][2])); - vertices.push_back(sofa::defaulttype::Vector3(it2->point[1][0], it2->point[1][1],it2->point[1][2])); - - msg_error() << it2->point[0] << " " << it2->point[0]; - - it2->elem.first.draw(vparams); - it2->elem.second.draw(vparams); - } - } - vparams->drawTool()->drawLines(vertices,3,color); - vparams->drawTool()->restoreLastState(); -} +int RayTraceDetectionClass = core::RegisterObject( + "Collision detection using TriangleOctreeModel").add(); } // namespace sofa::component::collision \ No newline at end of file diff --git a/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.h b/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.h index 5c68bece1b5..92cbac97183 100644 --- a/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.h +++ b/modules/SofaUserInteraction/src/SofaUserInteraction/RayTraceDetection.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -39,37 +39,12 @@ namespace sofa::component::collision * up to find a triangle in the other object. Both triangles are tested to evaluate if they are in * colliding state. It must be used with a TriangleOctreeModel,as an octree is used to traverse the object. */ -class SOFA_SOFAUSERINTERACTION_API RayTraceDetection :public BruteForceBroadPhase, - public core::collision::NarrowPhaseDetection +class SOFA_SOFAUSERINTERACTION_API RayTraceDetection : + public BruteForceBroadPhase, + public RayTraceNarrowPhase { public: - SOFA_CLASS2(RayTraceDetection, BruteForceBroadPhase, core::collision::NarrowPhaseDetection); - -private: - Data < bool > bDraw; - -public: - typedef sofa::helper::vector OutputVector; - -protected: - RayTraceDetection (); - -public: - ////////////////////////////// - /// NARROW PHASE interface /// - ////////////////////////////// - - void addCollisionPair (const std::pair < core::CollisionModel *, - core::CollisionModel * >&cmPair) override; - -public: - void findPairsVolume (CubeCollisionModel * cm1, CubeCollisionModel * cm2); - - void draw (const core::visual::VisualParams* vparams) override; - void setDraw (bool val) - { - bDraw.setValue (val); - } + SOFA_CLASS2(RayTraceDetection, BruteForceBroadPhase, RayTraceNarrowPhase); }; } // namespace sofa::component::collision