Skip to content

Commit dd0111f

Browse files
Change mesh for convex hull in testbed application
1 parent 90062ae commit dd0111f

File tree

7 files changed

+17887
-48
lines changed

7 files changed

+17887
-48
lines changed

include/reactphysics3d/collision/shapes/ConvexMeshShape.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ RP3D_FORCE_INLINE Vector3 ConvexMeshShape::getCentroid() const {
234234
return mConvexMesh->getCentroid() * mScale;
235235
}
236236

237-
238237
// Compute and return the volume of the collision shape
239238
RP3D_FORCE_INLINE decimal ConvexMeshShape::getVolume() const {
240239
return mConvexMesh->getVolume();

include/reactphysics3d/utils/quickhull/QHHalfEdgeStructure.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,9 @@ class QHHalfEdgeStructure {
9999
decimal area; // Area of the face
100100
Array<uint32> conflictPoints; // Array with some remaining points visible from this face that need to be processed
101101

102-
// TODO : DELETE THIS
103-
Set<uint32> vertices;
104-
105102
/// Constructor
106103
Face(MemoryAllocator& allocator)
107-
: nextFace(nullptr), previousFace(nullptr), normal(0, 0, 0), area(0), conflictPoints(allocator, 8), vertices(allocator) {
104+
: nextFace(nullptr), previousFace(nullptr), normal(0, 0, 0), area(0), conflictPoints(allocator, 8) {
108105

109106
}
110107

@@ -120,10 +117,6 @@ class QHHalfEdgeStructure {
120117
normal.setToZero();
121118
uint32 nbVertices = 0;
122119

123-
//std::cout << "Recalculate Face" << std::endl;
124-
//std::cout << "Previous centroid:" << face->centroid.to_string() << std::endl;
125-
//std::cout << "Previous normal:" << face->normal.to_string() << std::endl;
126-
127120
// For each vertex of the face
128121
const QHHalfEdgeStructure::Edge* firstFaceEdge = edge;
129122
const QHHalfEdgeStructure::Edge* faceEdge = firstFaceEdge;
@@ -149,9 +142,6 @@ class QHHalfEdgeStructure {
149142
assert(normalLength > 0);
150143
normal = normal / normalLength;
151144
area = normalLength * decimal(0.5);
152-
153-
//std::cout << "New centroid:" << face->centroid.to_string() << std::endl;
154-
//std::cout << "New normal:" << face->normal.to_string() << std::endl;
155145
}
156146

157147
// Return a string with the vertices of the face
@@ -210,23 +200,14 @@ class QHHalfEdgeStructure {
210200
isValid &= approxEqual(normal.lengthSquare(), 1.0, 0.01);
211201
isValid &= edge->face == this;
212202

213-
// For each edge of the face
214-
vertices.clear();
215-
216203
const QHHalfEdgeStructure::Edge* firstFaceEdge = edge;
217204
const QHHalfEdgeStructure::Edge* faceEdge = firstFaceEdge;
218205
do {
219206

220-
if (vertices.contains(faceEdge->startVertex->externalIndex)) {
221-
return false;
222-
}
223-
224207
if (faceEdge->face != this) {
225208
return false;
226209
}
227210

228-
vertices.add(faceEdge->startVertex->externalIndex);
229-
230211
faceEdge = faceEdge->nextFaceEdge;
231212

232213
} while(faceEdge != firstFaceEdge);

src/collision/ConvexMesh.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,6 @@ bool ConvexMesh::computeFacesNormals(std::vector<Error>& errors) {
222222
mFacesNormals.add(computeFaceNormal(f));
223223
decimal normalLength = mFacesNormals[f].length();
224224

225-
// TODO : DELETE THIS
226-
const decimal abc = mFacesNormals[f].length();
227-
228-
// TODO : Do not use MACHINE_EPSILON here
229225
if (normalLength > MACHINE_EPSILON) {
230226

231227
mFacesNormals[f] /= normalLength;
@@ -272,7 +268,7 @@ decimal ConvexMesh::getVolume() const {
272268
for (uint32 f=0; f < getNbFaces(); f++) {
273269

274270
const HalfEdgeStructure::Face& face = mHalfEdgeStructure.getFace(f);
275-
const decimal faceArea = computeFaceNormal(f).length();
271+
const decimal faceArea = computeFaceNormal(f).length() * decimal(0.5);
276272
const Vector3 faceNormal = mFacesNormals[f];
277273
const Vector3& faceVertex = getVertex(face.faceVertices[0]);
278274

src/utils/quickhull/QuickHull.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ bool QuickHull::computeConvexHull(const VertexArray& vertexArray, PolygonVertexA
118118
// Add the vertex to the hull
119119
addVertexToHull(nextVertexIndex, nextFace, points, convexHull, epsilon, allocator);
120120

121-
//std::cout << " New hull: " << std::endl << convexHull.to_string() << std::endl;
122-
123121
// Get the next vertex candidate
124122
findNextVertexCandidate(points, nextVertexIndex, convexHull, nextFace, epsilon);
125123

@@ -406,10 +404,6 @@ void QuickHull::findHorizon(const Vector3& vertex, QHHalfEdgeStructure::Face* fa
406404
}
407405
else { // We have found a face that is not visible from the vertex
408406

409-
//std::cout << "Face not visible from candidate vertex has vertices : " << nextFace->verticesString() << std::endl;
410-
411-
//std::cout << "New horizon edge: (" << candidateFace.currentEdge->startVertex->externalIndex << ", " << candidateFace.currentEdge->endVertex->externalIndex << ")" << std::endl;
412-
413407
// We add the edge between current face and next face to the array of horizon edges
414408
outHorizonVertices.add(candidateFace.currentEdge->startVertex);
415409
outHorizonVertices.add(candidateFace.currentEdge->endVertex);

0 commit comments

Comments
 (0)