switch hull indices to 32-bit indices
This commit is contained in:
		| @@ -21,26 +21,17 @@ | ||||
|  | ||||
| #include <bounce/common/geometry.h> | ||||
|  | ||||
| // The maximum number of vertices that a hull can have. | ||||
| #define B3_MAX_HULL_VERTICES (B3_MAX_U8 + 1) | ||||
|  | ||||
| // The maximum number of half-edges a hull can have. | ||||
| #define B3_MAX_HULL_EDGES (B3_MAX_U8 + 1) | ||||
|  | ||||
| // The maximum number of faces and planes a hull can have. | ||||
| #define B3_MAX_HULL_FACES (B3_MAX_U8 + 1) | ||||
|  | ||||
| struct b3Face | ||||
| { | ||||
| 	u8 edge; | ||||
| 	u32 edge; | ||||
| }; | ||||
|  | ||||
| struct b3HalfEdge | ||||
| { | ||||
| 	u8 origin; | ||||
| 	u8 twin; | ||||
| 	u8 face; | ||||
| 	u8 next; | ||||
| 	u32 origin; | ||||
| 	u32 twin; | ||||
| 	u32 face; | ||||
| 	u32 next; | ||||
| }; | ||||
|  | ||||
| struct b3Hull | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| inline b3HalfEdge b3MakeEdge(u32 origin, u32 twin, u32 face, u32 next) | ||||
| { | ||||
| 	b3HalfEdge edge; | ||||
| 	edge.origin = u8(origin); | ||||
| 	edge.twin = u8(twin); | ||||
| 	edge.face = u8(face); | ||||
| 	edge.next = u8(next); | ||||
| 	edge.origin = origin; | ||||
| 	edge.twin = twin; | ||||
| 	edge.face = face; | ||||
| 	edge.next = next; | ||||
| 	return edge; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -20,25 +20,25 @@ | ||||
| #define B3_Q_HULL_H | ||||
|  | ||||
| #include <bounce/collision/shapes/hull.h> | ||||
| #include <bounce/common/template/array.h> | ||||
|  | ||||
| // This hull can be constructed from an array of points. | ||||
| struct b3QHull : public b3Hull | ||||
| { | ||||
| 	b3Vec3 hullVertices[B3_MAX_HULL_VERTICES]; | ||||
| 	b3HalfEdge hullEdges[B3_MAX_HULL_EDGES]; | ||||
| 	b3Face hullFaces[B3_MAX_HULL_FACES]; | ||||
| 	b3Plane hullPlanes[B3_MAX_HULL_FACES]; | ||||
| 	b3StackArray<b3Vec3, 256> hullVertices; | ||||
| 	b3StackArray<b3HalfEdge, 256> hullEdges; | ||||
| 	b3StackArray<b3Face, 256> hullFaces; | ||||
| 	b3StackArray<b3Plane, 256> hullPlanes; | ||||
|  | ||||
| 	b3QHull() | ||||
| 	{ | ||||
| 		// Zero the counters since the user manipulates via setters | ||||
| 		vertices = hullVertices; | ||||
| 		vertices = hullVertices.Begin(); | ||||
| 		vertexCount = 0; | ||||
| 		edges = hullEdges; | ||||
| 		edges = hullEdges.Begin(); | ||||
| 		edgeCount = 0; | ||||
| 		faces = hullFaces; | ||||
| 		faces = hullFaces.Begin(); | ||||
| 		faceCount = 0; | ||||
| 		planes = hullPlanes; | ||||
| 		planes = hullPlanes.Begin(); | ||||
| 		centroid.SetZero(); | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -22,41 +22,27 @@ | ||||
| #include <bounce/common/template/array.h> | ||||
| #include <bounce/common/geometry.h> | ||||
|  | ||||
| #define B3_NULL_EDGE (0xFF) | ||||
| #define B3_NULL_EDGE B3_MAX_U32 | ||||
|  | ||||
| // A combination of features used to uniquely identify a vertex on a feature. | ||||
| struct b3FeaturePair | ||||
| { | ||||
| 	u8 inEdge1; // incoming edge on hull 1 | ||||
| 	u8 inEdge2; // incoming edge on hull 2 | ||||
| 	u8 outEdge1; // outgoing edge on hull 1 | ||||
| 	u8 outEdge2; // outgoing edge on hull 2 | ||||
| 	u32 inEdge1; // incoming edge on hull 1 | ||||
| 	u32 outEdge1; // outgoing edge on hull 1 | ||||
| 	u32 inEdge2; // incoming edge on hull 2 | ||||
| 	u32 outEdge2; // outgoing edge on hull 2 | ||||
| }; | ||||
|  | ||||
| inline b3FeaturePair b3MakePair(u32 inEdge1, u32 inEdge2, u32 outEdge1, u32 outEdge2) | ||||
| { | ||||
| 	b3FeaturePair out; | ||||
| 	out.inEdge1 = u8(inEdge1); | ||||
| 	out.inEdge2 = u8(inEdge2); | ||||
| 	out.outEdge1 = u8(outEdge1); | ||||
| 	out.outEdge2 = u8(outEdge2); | ||||
| 	out.inEdge1 = inEdge1; | ||||
| 	out.inEdge2 = inEdge2; | ||||
| 	out.outEdge1 = outEdge1; | ||||
| 	out.outEdge2 = outEdge2; | ||||
| 	return out; | ||||
| } | ||||
|  | ||||
| // Make a 32-bit key for a feature pair. | ||||
| inline u32 b3MakeKey(const b3FeaturePair& featurePair) | ||||
| { | ||||
| 	union b3FeaturePairKey | ||||
| 	{ | ||||
| 		b3FeaturePair pair; | ||||
| 		u32 key; | ||||
| 	}; | ||||
|  | ||||
| 	b3FeaturePairKey key; | ||||
| 	key.pair = featurePair; | ||||
| 	return key.key; | ||||
| } | ||||
|  | ||||
| // A clip vertex. | ||||
| struct b3ClipVertex | ||||
| { | ||||
| @@ -110,4 +96,4 @@ u32 b3ClipEdgeToFace(b3ClipVertex vOut[2], | ||||
| void b3ClipPolygonToFace(b3ClipPolygon& pOut, | ||||
| 	const b3ClipPolygon& pIn, const b3Transform& xf, float32 r, u32 index, const b3Hull* hull); | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
| @@ -20,10 +20,48 @@ | ||||
| #define B3_MANIFOLD_H | ||||
|  | ||||
| #include <bounce/common/math/vec2.h> | ||||
| #include <bounce/common/geometry.h> | ||||
| #include <bounce/dynamics/contacts/collide/clip.h> | ||||
|  | ||||
| #define B3_NULL_TRIANGLE (0xFFFFFFFF) | ||||
|  | ||||
| // A contact manifold point. | ||||
| struct b3ManifoldPointKey | ||||
| { | ||||
| 	bool operator==(const b3ManifoldPointKey& other) const | ||||
| 	{ | ||||
| 		return triangleKey == other.triangleKey && | ||||
| 			key1 == other.key1 && key2 == other.key2; | ||||
| 	} | ||||
|  | ||||
| 	u32 triangleKey;  | ||||
| 	u64 key1;  | ||||
| 	u64 key2;  | ||||
| }; | ||||
|  | ||||
| inline b3ManifoldPointKey b3MakeKey(const b3FeaturePair& featurePair) | ||||
| { | ||||
| 	struct b3Key128 | ||||
| 	{ | ||||
| 		u64 key1; | ||||
| 		u64 key2; | ||||
| 	}; | ||||
|  | ||||
| 	union b3FeaturePairKey | ||||
| 	{ | ||||
| 		b3FeaturePair pair; | ||||
| 		b3Key128 key; | ||||
| 	}; | ||||
|  | ||||
| 	b3FeaturePairKey fpkey; | ||||
| 	fpkey.pair = featurePair; | ||||
|  | ||||
| 	b3ManifoldPointKey key; | ||||
| 	key.triangleKey = B3_NULL_TRIANGLE; | ||||
| 	key.key1 = fpkey.key.key1; | ||||
| 	key.key2 = fpkey.key.key2; | ||||
| 	return key; | ||||
| } | ||||
|  | ||||
| // A contact manifold point. | ||||
| struct b3ManifoldPoint | ||||
| { | ||||
| @@ -31,8 +69,7 @@ struct b3ManifoldPoint | ||||
| 	b3Vec3 localPoint1; // local point on the first shape without its radius | ||||
| 	b3Vec3 localPoint2; // local point on the other shape without its radius | ||||
|  | ||||
| 	u32 triangleKey; // triangle identifier | ||||
| 	u32 key; // point identifier | ||||
| 	b3ManifoldPointKey key; // point identifier | ||||
|  | ||||
| 	float32 normalImpulse; // normal impulse | ||||
| 	u32 persisting; // is this point persistent? | ||||
|   | ||||
		Reference in New Issue
	
	Block a user