10#ifdef JPH_CONVEX_BUILDER_DEBUG
38 Edge *prev_edge =
this;
62 void Initialize(
int inIdx0,
int inIdx1,
int inIdx2,
const Vec3 *inPositions);
80#ifdef JPH_CONVEX_BUILDER_DEBUG
127 void DetermineMaxError(Face *&outFaceWithMaxError,
float &outMaxError,
int &outMaxErrorPositionIdx,
float &outCoplanarDistance)
const;
134 static constexpr float cMinTriangleAreaSq = 1.0e-12f;
136#ifdef JPH_CONVEX_BUILDER_DEBUG
138 static constexpr Real cDrawScale = 10;
145 Edge * mNeighbourEdge;
154 float DetermineCoplanarDistance()
const;
161 void GetFaceForPoint(
Vec3Arg inPoint,
const Faces &inFaces, Face *&outFace,
float &outDistSq)
const;
167 float GetDistanceToEdgeSq(
Vec3Arg inPoint,
const Face *inFace)
const;
174 bool AssignPointToFace(
int inPositionIdx,
const Faces &inFaces,
float inToleranceSq);
177 void AddPoint(Face *inFacingFace,
int inIdx,
float inToleranceSq,
Faces &outNewFaces);
180 void GarbageCollectFaces();
186 Face * CreateTriangle(
int inIdx1,
int inIdx2,
int inIdx3);
189 void FreeFace(Face *inFace);
195 static void sLinkFace(Edge *inEdge1, Edge *inEdge2);
198 static void sUnlinkFace(Face *inFace);
202 void FindEdge(Face *inFacingFace,
Vec3Arg inVertex, FullEdges &outEdges)
const;
205 void MergeFaces(Edge *inEdge);
208 void MergeDegenerateFace(Face *inFace,
Faces &ioAffectedFaces);
212 void MergeCoplanarOrConcaveFaces(Face *inFace,
float inToleranceSq,
Faces &ioAffectedFaces);
215 static void sMarkAffected(Face *inFace,
Faces &ioAffectedFaces);
221 void RemoveInvalidEdges(Face *inFace,
Faces &ioAffectedFaces);
226 bool RemoveTwoEdgeFace(Face *inFace,
Faces &ioAffectedFaces)
const;
228#ifdef JPH_ENABLE_ASSERTS
230 void DumpFace(
const Face *inFace)
const;
233 void DumpFaces()
const;
236 void ValidateFace(
const Face *inFace)
const;
239 void ValidateFaces()
const;
242#ifdef JPH_CONVEX_BUILDER_DEBUG
244 void DrawState(
bool inDrawConflictList =
false)
const;
247 void DrawWireFace(
const Face *inFace,
ColorArg inColor)
const;
250 void DrawEdge(
const Edge *inEdge,
ColorArg inColor)
const;
253#ifdef JPH_CONVEX_BUILDER_DUMP_SHAPE
254 void DumpShape()
const;
267 CoplanarList mCoplanarList;
269#ifdef JPH_CONVEX_BUILDER_DEBUG
271 mutable RVec3 mOffset;
#define JPH_NAMESPACE_END
Definition Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:29
float Real
Definition Real.h:27
std::vector< T, STLAllocator< T > > Array
Definition STLAllocator.h:81
Class that holds an RGBA color with 8-bits per component.
Definition Color.h:16
Class that holds the information of an edge.
Definition ConvexHullBuilder.h:28
Edge * mNeighbourEdge
Edge that this edge is connected to.
Definition ConvexHullBuilder.h:46
JPH_OVERRIDE_NEW_DELETE Edge(Face *inFace, int inStartIdx)
Constructor.
Definition ConvexHullBuilder.h:33
Edge * mNextEdge
Next edge of this face.
Definition ConvexHullBuilder.h:45
int mStartIdx
Vertex index in mPositions that indicates the start vertex of this edge.
Definition ConvexHullBuilder.h:47
Face * mFace
Face that this edge belongs to.
Definition ConvexHullBuilder.h:44
Edge * GetPreviousEdge()
Get the previous edge.
Definition ConvexHullBuilder.h:36
Class that holds the information of one face.
Definition ConvexHullBuilder.h:54
Edge * mFirstEdge
First edge of this face.
Definition ConvexHullBuilder.h:77
JPH_OVERRIDE_NEW_DELETE ~Face()
Destructor.
Definition ConvexHullBuilder.cpp:23
void CalculateNormalAndCentroid(const Vec3 *inPositions)
Calculates the centroid and normal for this face.
Definition ConvexHullBuilder.cpp:38
Vec3 mCentroid
Center of the face.
Definition ConvexHullBuilder.h:75
bool IsFacing(Vec3Arg inPosition) const
Check if face inFace is facing inPosition.
Definition ConvexHullBuilder.h:68
bool mRemoved
Flag that indicates that face has been removed (face will be freed later)
Definition ConvexHullBuilder.h:79
float mFurthestPointDistanceSq
Squared distance of furtest point from the conflict list to the face.
Definition ConvexHullBuilder.h:78
void Initialize(int inIdx0, int inIdx1, int inIdx2, const Vec3 *inPositions)
Initialize a face with three indices.
Definition ConvexHullBuilder.cpp:90
Vec3 mNormal
Normal of this face, length is 2 times area of face.
Definition ConvexHullBuilder.h:74
ConflictList mConflictList
Positions associated with this edge (that are closest to this edge). The last position in the list is...
Definition ConvexHullBuilder.h:76
A convex hull builder that tries to create hulls as accurately as possible. Used for offline processi...
Definition ConvexHullBuilder.h:21
ConvexHullBuilder(const Positions &inPositions)
Constructor.
Definition ConvexHullBuilder.cpp:109
const Faces & GetFaces() const
Access to the created faces. Memory is owned by the convex hull builder.
Definition ConvexHullBuilder.h:130
~ConvexHullBuilder()
Destructor.
Definition ConvexHullBuilder.h:93
bool ContainsFace(const Array< int > &inIndices) const
Returns true if the hull contains a polygon with inIndices (counter clockwise indices in mPositions)
Definition ConvexHullBuilder.cpp:263
void GetCenterOfMassAndVolume(Vec3 &outCenterOfMass, float &outVolume) const
Calculate the center of mass and the volume of the current convex hull.
Definition ConvexHullBuilder.cpp:1256
EResult
Result enum that indicates how the hull got created.
Definition ConvexHullBuilder.h:97
@ TooFewFaces
Too few faces in the created hull (signifies precision errors during building)
@ Degenerate
Degenerate hull detected.
@ Success
Hull building finished successfully.
@ TooFewPoints
Too few points to create a hull.
@ MaxVerticesReached
Hull building finished successfully, but the desired accuracy was not reached because the max vertice...
void DetermineMaxError(Face *&outFaceWithMaxError, float &outMaxError, int &outMaxErrorPositionIdx, float &outCoplanarDistance) const
Definition ConvexHullBuilder.cpp:1305
Array< int > ConflictList
Definition ConvexHullBuilder.h:50
Array< Vec3 > Positions
Definition ConvexHullBuilder.h:86
Array< Face * > Faces
Definition ConvexHullBuilder.h:87
int GetNumVerticesUsed() const
Returns the amount of vertices that are currently used by the hull.
Definition ConvexHullBuilder.cpp:248
EResult Initialize(int inMaxVertices, float inTolerance, const char *&outError)
Definition ConvexHullBuilder.cpp:299
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition NonCopyable.h:11
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:637