consistency

This commit is contained in:
Irlan
2018-04-27 02:38:38 -03:00
parent c3b55d3323
commit bd490d7925
3 changed files with 95 additions and 76 deletions

View File

@ -34,49 +34,40 @@ struct qhList
struct qhHalfEdge;
struct qhVertex;
enum qhFaceMark
{
e_visible,
e_invisible
};
struct qhFace
{
enum State
{
e_invisible,
e_visible,
e_unknown,
e_deleted
};
qhFace* freeNext;
qhFace* prev;
qhFace* next;
qhHalfEdge* edge;
qhList<qhVertex> conflictList;
State state;
b3Vec3 center;
b3Plane plane;
qhFaceMark mark;
u32 GetVertexCount() const;
u32 GetEdgeCount() const;
qhHalfEdge* FindHalfEdge(const qhVertex* v1, const qhVertex* v2) const;
void ComputeCenterAndPlane();
//
qhFace* freeNext;
bool active;
};
struct qhHalfEdge
{
enum State
{
e_used,
e_deleted
};
State state;
qhHalfEdge* freeNext;
qhVertex* tail;
qhHalfEdge* prev;
@ -84,18 +75,24 @@ struct qhHalfEdge
qhHalfEdge* twin;
qhFace* face;
//
qhHalfEdge* freeNext;
bool active;
};
struct qhVertex
{
qhVertex* freeNext;
qhVertex* prev;
qhVertex* next;
b3Vec3 position;
qhFace* conflictFace;
//
qhVertex* freeNext;
bool active;
};
// A convex hull builder.
@ -128,6 +125,7 @@ public:
private:
bool BuildInitialHull(const b3Vec3* vertices, u32 count);
qhFace* AddFace(qhVertex* v1, qhVertex* v2, qhVertex* v3);
qhFace* RemoveFace(qhFace* face);
qhVertex* FindEyeVertex() const;
void AddVertex(qhVertex* v);

View File

@ -162,12 +162,16 @@ inline const qhList<qhFace>& qhHull::GetFaceList() const
inline qhVertex* qhHull::AllocateVertex()
{
qhVertex* v = m_freeVertices;
B3_ASSERT(v->active == false);
v->active = true;
m_freeVertices = v->freeNext;
return v;
}
inline void qhHull::FreeVertex(qhVertex* v)
{
//B3_ASSERT(v->active == true);
v->active = false;
v->freeNext = m_freeVertices;
m_freeVertices = v;
}
@ -175,14 +179,16 @@ inline void qhHull::FreeVertex(qhVertex* v)
inline qhHalfEdge* qhHull::AllocateEdge()
{
qhHalfEdge* e = m_freeEdges;
e->state = qhHalfEdge::e_used;
B3_ASSERT(e->active == false);
e->active = true;
m_freeEdges = e->freeNext;
return e;
}
inline void qhHull::FreeEdge(qhHalfEdge* e)
{
e->state = qhHalfEdge::e_deleted;
//B3_ASSERT(e->active == true);
e->active = false;
e->freeNext = m_freeEdges;
m_freeEdges = e;
}
@ -190,13 +196,16 @@ inline void qhHull::FreeEdge(qhHalfEdge* e)
inline qhFace* qhHull::AllocateFace()
{
qhFace* f = m_freeFaces;
B3_ASSERT(f->active == false);
f->active = true;
m_freeFaces = f->freeNext;
return f;
}
inline void qhHull::FreeFace(qhFace* f)
{
f->state = qhFace::e_deleted;
//B3_ASSERT(f->active == true);
f->active = false;
f->freeNext = m_freeFaces;
m_freeFaces = f;
}