rollback function def
This commit is contained in:
		| @@ -118,11 +118,11 @@ public: | ||||
| private: | ||||
| 	bool BuildInitialHull(const b3Vec3* vertices, u32 count); | ||||
|  | ||||
| 	qhVertex* NextVertex(); | ||||
| 	qhVertex* FindEyeVertex() const; | ||||
| 	void AddVertex(qhVertex* v); | ||||
|  | ||||
| 	void FindHorizon(qhVertex* eye); | ||||
| 	void FindHorizon(qhVertex* eye, qhHalfEdge* edge); | ||||
| 	void FindHorizon(qhVertex* eye, qhFace* face, qhHalfEdge* begin); | ||||
|  | ||||
| 	void AddNewFaces(qhVertex* eye); | ||||
| 	void MergeFaces(); | ||||
| @@ -137,7 +137,7 @@ private: | ||||
| 	float32 m_tolerance; | ||||
|  | ||||
| 	// Number of Quickhull iterations | ||||
| 	u32 m_iteration; | ||||
| 	u32 m_iterations; | ||||
|  | ||||
| 	// List of faces | ||||
| 	qhList<qhFace> m_faceList;  | ||||
|   | ||||
| @@ -158,7 +158,7 @@ constexpr u32 qhGetBufferSize(u32 pointCount) | ||||
|  | ||||
| inline u32 qhHull::GetIterations() const | ||||
| { | ||||
| 	return m_iteration; | ||||
| 	return m_iterations; | ||||
| } | ||||
|  | ||||
| inline const qhList<qhFace>& qhHull::GetFaceList() const | ||||
|   | ||||
| @@ -19,6 +19,7 @@ | ||||
| #include <bounce/quickhull/qh_hull.h> | ||||
| #include <bounce/common/template/array.h> | ||||
| #include <bounce/common/template/stack.h> | ||||
| #include <bounce/common/template/queue.h> | ||||
| #include <bounce/common/draw.h> | ||||
|  | ||||
| static float32 qhFindAABB(u32 iMin[3], u32 iMax[3], const b3Vec3* vertices, u32 count) | ||||
| @@ -108,19 +109,19 @@ void qhHull::Construct(void* memory, const b3Vec3* vs, u32 count) | ||||
|  | ||||
| 	m_faceList.head = NULL; | ||||
| 	m_faceList.count = 0; | ||||
| 	m_iteration = 0; | ||||
| 	m_iterations = 0; | ||||
|  | ||||
| 	if (!BuildInitialHull(vs, count)) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	qhVertex* eye = NextVertex(); | ||||
| 	qhVertex* eye = FindEyeVertex(); | ||||
| 	while (eye) | ||||
| 	{ | ||||
| 		AddVertex(eye); | ||||
| 		eye = NextVertex(); | ||||
| 		++m_iteration; | ||||
| 		eye = FindEyeVertex(); | ||||
| 		++m_iterations; | ||||
| 	} | ||||
|  | ||||
| 	Validate(); | ||||
| @@ -323,17 +324,15 @@ bool qhHull::BuildInitialHull(const b3Vec3* vertices, u32 vertexCount) | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| qhVertex* qhHull::NextVertex() | ||||
| qhVertex* qhHull::FindEyeVertex() const | ||||
| { | ||||
| 	// Find the point furthest from the current hull. | ||||
| 	float32 d0 = m_tolerance; | ||||
| 	qhVertex* v0 = NULL; | ||||
|  | ||||
| 	qhFace* f = m_faceList.head; | ||||
| 	while (f) | ||||
| 	for (qhFace* f = m_faceList.head; f != NULL; f = f->next) | ||||
| 	{ | ||||
| 		qhVertex* v = f->conflictList.head; | ||||
| 		while (v) | ||||
| 		for (qhVertex* v = f->conflictList.head; v != NULL; v = v->next) | ||||
| 		{ | ||||
| 			float32 d = b3Distance(v->position, f->plane); | ||||
| 			if (d > d0) | ||||
| @@ -341,11 +340,7 @@ qhVertex* qhHull::NextVertex() | ||||
| 				d0 = d; | ||||
| 				v0 = v; | ||||
| 			} | ||||
|  | ||||
| 			v = v->next; | ||||
| 		} | ||||
|  | ||||
| 		f = f->next; | ||||
| 	} | ||||
|  | ||||
| 	return v0; | ||||
| @@ -368,27 +363,29 @@ void qhHull::FindHorizon(qhVertex* eye) | ||||
|  | ||||
| 	// Find the horizon  | ||||
| 	m_horizonCount = 0; | ||||
| 	FindHorizon(eye, eye->conflictFace->edge); | ||||
| 	FindHorizon(eye, eye->conflictFace, eye->conflictFace->edge); | ||||
| } | ||||
|  | ||||
| void qhHull::FindHorizon(qhVertex* eye, qhHalfEdge* begin) | ||||
| void qhHull::FindHorizon(qhVertex* eye, qhFace* face, qhHalfEdge* begin) | ||||
| { | ||||
| 	// Mark face as visible/visited. | ||||
| 	qhFace* face = begin->face; | ||||
| 	// Mark the face  | ||||
| 	face->state = qhFace::e_visible; | ||||
|  | ||||
| 	// | ||||
| 	qhHalfEdge* edge = begin; | ||||
|  | ||||
| 	do | ||||
| 	{ | ||||
| 		qhHalfEdge* adjEdge = edge->twin; | ||||
| 		qhFace* adjFace = adjEdge->face; | ||||
| 		qhHalfEdge* twin = edge->twin; | ||||
| 		qhFace* other = twin->face; | ||||
|  | ||||
| 		if (adjFace->state == qhFace::e_invisible) | ||||
| 		if (other->state == qhFace::e_invisible) | ||||
| 		{ | ||||
| 			if (b3Distance(eye->position, adjFace->plane) > m_tolerance) | ||||
| 			// Is the other face invisible? | ||||
| 			if (b3Distance(eye->position, other->plane) > m_tolerance) | ||||
| 			{ | ||||
| 				FindHorizon(eye, adjEdge); | ||||
| 				// Recurse starting from the twin edge for  | ||||
| 				// ensuring CCW horizon order | ||||
| 				FindHorizon(eye, other, twin); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| @@ -397,7 +394,6 @@ void qhHull::FindHorizon(qhVertex* eye, qhHalfEdge* begin) | ||||
| 		} | ||||
|  | ||||
| 		edge = edge->next; | ||||
|  | ||||
| 	} while (edge != begin); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user