10#ifdef JPH_CONVEX_BUILDER_DEBUG
33 Edge(
Face *inFace,
int inStartIdx) : mFace(inFace), mStartIdx(inStartIdx) { }
38 Edge *prev_edge =
this;
45 Edge * mNextEdge =
nullptr;
46 Edge * mNeighbourEdge =
nullptr;
62 void Initialize(
int inIdx0,
int inIdx1,
int inIdx2,
const Vec3 *inPositions);
65 void CalculateNormalAndCentroid(
const Vec3 *inPositions);
71 return mNormal.Dot(inPosition - mCentroid) > 0.0f;
77 Edge * mFirstEdge =
nullptr;
78 float mFurthestPointDistanceSq = 0.0f;
79 bool mRemoved =
false;
80#ifdef JPH_CONVEX_BUILDER_DEBUG
111 EResult Initialize(
int inMaxVertices,
float inTolerance,
const char *&outError);
114 int GetNumVerticesUsed()
const;
117 bool ContainsFace(
const Array<int> &inIndices)
const;
120 void GetCenterOfMassAndVolume(
Vec3 &outCenterOfMass,
float &outVolume)
const;
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;
257 const Positions & mPositions;
267 CoplanarList mCoplanarList;
269#ifdef JPH_CONVEX_BUILDER_DEBUG
271 mutable RVec3 mOffset;
#define JPH_EXPORT
Definition: Core.h:236
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:31
float Real
Definition: Real.h:27
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
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
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
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
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
EResult
Result enum that indicates how the hull got created.
Definition: ConvexHullBuilder.h:97
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11