MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / findFarthestFaceForVertex

Method findFarthestFaceForVertex

src/utils/quickhull/QuickHull.cpp:861–890  ·  view source on GitHub ↗

Find the closest face for a given vertex and add this vertex to the conflict list for this face

Source from the content-addressed store, hash-verified

859
860// Find the closest face for a given vertex and add this vertex to the conflict list for this face
861void QuickHull::findFarthestFaceForVertex(uint32 vertexIndex, Array<QHHalfEdgeStructure::Face*>& faces, Array<Vector3>& points, decimal epsilon,
862 Set<QHHalfEdgeStructure::Face*>& deletedFaces) {
863
864 decimal maxDistanceToFace = epsilon;
865 QHHalfEdgeStructure::Face* farthestFace = nullptr;
866
867 // For each new face
868 for (uint32 f=0; f < faces.size(); f++) {
869
870 QHHalfEdgeStructure::Face* face = faces[f];
871
872 // If the face was deleted during merging of concave faces
873 if (deletedFaces.contains(face)) continue;
874
875 const decimal distanceToFace = face->normal.dot(points[vertexIndex] - face->centroid);
876
877 // If the point is in front the face and with a larger distance from the face
878 if (distanceToFace > maxDistanceToFace) {
879 maxDistanceToFace = distanceToFace;
880 farthestFace = face;
881 }
882 }
883
884 // If we have found a farthest face
885 if (farthestFace != nullptr) {
886
887 // Add the vertex to the conflict list of the face
888 farthestFace->conflictPoints.add(vertexIndex);
889 }
890}
891
892// Compute the initial tetrahedron convex hull
893bool QuickHull::computeInitialHull(Array<Vector3>& points, QHHalfEdgeStructure& convexHull,

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.45
containsMethod · 0.45
dotMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected