switch hull indices to 32-bit indices
This commit is contained in:
@ -24,8 +24,7 @@ class ConvexHull : public Test
|
|||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// Half to avoid generation failure due to many vertices
|
e_count = 256
|
||||||
e_count = B3_MAX_HULL_VERTICES / 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ConvexHull()
|
ConvexHull()
|
||||||
|
@ -24,8 +24,7 @@ class HullCollision : public Collide
|
|||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// Half to avoid generation failure due to many vertices
|
e_count = 256
|
||||||
e_count = B3_MAX_HULL_VERTICES / 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
HullCollision()
|
HullCollision()
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
{
|
{
|
||||||
b3QHull* hull = hulls + i;
|
b3QHull* hull = hulls + i;
|
||||||
|
|
||||||
const u32 count = B3_MAX_HULL_VERTICES / 4;
|
const u32 count = 32;
|
||||||
b3Vec3 points[count];
|
b3Vec3 points[count];
|
||||||
|
|
||||||
for (u32 j = 0; j < count; ++j)
|
for (u32 j = 0; j < count; ++j)
|
||||||
|
@ -21,26 +21,17 @@
|
|||||||
|
|
||||||
#include <bounce/common/geometry.h>
|
#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
|
struct b3Face
|
||||||
{
|
{
|
||||||
u8 edge;
|
u32 edge;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b3HalfEdge
|
struct b3HalfEdge
|
||||||
{
|
{
|
||||||
u8 origin;
|
u32 origin;
|
||||||
u8 twin;
|
u32 twin;
|
||||||
u8 face;
|
u32 face;
|
||||||
u8 next;
|
u32 next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b3Hull
|
struct b3Hull
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
inline b3HalfEdge b3MakeEdge(u32 origin, u32 twin, u32 face, u32 next)
|
inline b3HalfEdge b3MakeEdge(u32 origin, u32 twin, u32 face, u32 next)
|
||||||
{
|
{
|
||||||
b3HalfEdge edge;
|
b3HalfEdge edge;
|
||||||
edge.origin = u8(origin);
|
edge.origin = origin;
|
||||||
edge.twin = u8(twin);
|
edge.twin = twin;
|
||||||
edge.face = u8(face);
|
edge.face = face;
|
||||||
edge.next = u8(next);
|
edge.next = next;
|
||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,25 +20,25 @@
|
|||||||
#define B3_Q_HULL_H
|
#define B3_Q_HULL_H
|
||||||
|
|
||||||
#include <bounce/collision/shapes/hull.h>
|
#include <bounce/collision/shapes/hull.h>
|
||||||
|
#include <bounce/common/template/array.h>
|
||||||
|
|
||||||
// This hull can be constructed from an array of points.
|
// This hull can be constructed from an array of points.
|
||||||
struct b3QHull : public b3Hull
|
struct b3QHull : public b3Hull
|
||||||
{
|
{
|
||||||
b3Vec3 hullVertices[B3_MAX_HULL_VERTICES];
|
b3StackArray<b3Vec3, 256> hullVertices;
|
||||||
b3HalfEdge hullEdges[B3_MAX_HULL_EDGES];
|
b3StackArray<b3HalfEdge, 256> hullEdges;
|
||||||
b3Face hullFaces[B3_MAX_HULL_FACES];
|
b3StackArray<b3Face, 256> hullFaces;
|
||||||
b3Plane hullPlanes[B3_MAX_HULL_FACES];
|
b3StackArray<b3Plane, 256> hullPlanes;
|
||||||
|
|
||||||
b3QHull()
|
b3QHull()
|
||||||
{
|
{
|
||||||
// Zero the counters since the user manipulates via setters
|
vertices = hullVertices.Begin();
|
||||||
vertices = hullVertices;
|
|
||||||
vertexCount = 0;
|
vertexCount = 0;
|
||||||
edges = hullEdges;
|
edges = hullEdges.Begin();
|
||||||
edgeCount = 0;
|
edgeCount = 0;
|
||||||
faces = hullFaces;
|
faces = hullFaces.Begin();
|
||||||
faceCount = 0;
|
faceCount = 0;
|
||||||
planes = hullPlanes;
|
planes = hullPlanes.Begin();
|
||||||
centroid.SetZero();
|
centroid.SetZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,41 +22,27 @@
|
|||||||
#include <bounce/common/template/array.h>
|
#include <bounce/common/template/array.h>
|
||||||
#include <bounce/common/geometry.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.
|
// A combination of features used to uniquely identify a vertex on a feature.
|
||||||
struct b3FeaturePair
|
struct b3FeaturePair
|
||||||
{
|
{
|
||||||
u8 inEdge1; // incoming edge on hull 1
|
u32 inEdge1; // incoming edge on hull 1
|
||||||
u8 inEdge2; // incoming edge on hull 2
|
u32 outEdge1; // outgoing edge on hull 1
|
||||||
u8 outEdge1; // outgoing edge on hull 1
|
u32 inEdge2; // incoming edge on hull 2
|
||||||
u8 outEdge2; // outgoing edge on hull 2
|
u32 outEdge2; // outgoing edge on hull 2
|
||||||
};
|
};
|
||||||
|
|
||||||
inline b3FeaturePair b3MakePair(u32 inEdge1, u32 inEdge2, u32 outEdge1, u32 outEdge2)
|
inline b3FeaturePair b3MakePair(u32 inEdge1, u32 inEdge2, u32 outEdge1, u32 outEdge2)
|
||||||
{
|
{
|
||||||
b3FeaturePair out;
|
b3FeaturePair out;
|
||||||
out.inEdge1 = u8(inEdge1);
|
out.inEdge1 = inEdge1;
|
||||||
out.inEdge2 = u8(inEdge2);
|
out.inEdge2 = inEdge2;
|
||||||
out.outEdge1 = u8(outEdge1);
|
out.outEdge1 = outEdge1;
|
||||||
out.outEdge2 = u8(outEdge2);
|
out.outEdge2 = outEdge2;
|
||||||
return out;
|
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.
|
// A clip vertex.
|
||||||
struct b3ClipVertex
|
struct b3ClipVertex
|
||||||
{
|
{
|
||||||
@ -110,4 +96,4 @@ u32 b3ClipEdgeToFace(b3ClipVertex vOut[2],
|
|||||||
void b3ClipPolygonToFace(b3ClipPolygon& pOut,
|
void b3ClipPolygonToFace(b3ClipPolygon& pOut,
|
||||||
const b3ClipPolygon& pIn, const b3Transform& xf, float32 r, u32 index, const b3Hull* hull);
|
const b3ClipPolygon& pIn, const b3Transform& xf, float32 r, u32 index, const b3Hull* hull);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -20,10 +20,48 @@
|
|||||||
#define B3_MANIFOLD_H
|
#define B3_MANIFOLD_H
|
||||||
|
|
||||||
#include <bounce/common/math/vec2.h>
|
#include <bounce/common/math/vec2.h>
|
||||||
#include <bounce/common/geometry.h>
|
#include <bounce/dynamics/contacts/collide/clip.h>
|
||||||
|
|
||||||
#define B3_NULL_TRIANGLE (0xFFFFFFFF)
|
#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.
|
// A contact manifold point.
|
||||||
struct b3ManifoldPoint
|
struct b3ManifoldPoint
|
||||||
{
|
{
|
||||||
@ -31,8 +69,7 @@ struct b3ManifoldPoint
|
|||||||
b3Vec3 localPoint1; // local point on the first shape without its radius
|
b3Vec3 localPoint1; // local point on the first shape without its radius
|
||||||
b3Vec3 localPoint2; // local point on the other shape without its radius
|
b3Vec3 localPoint2; // local point on the other shape without its radius
|
||||||
|
|
||||||
u32 triangleKey; // triangle identifier
|
b3ManifoldPointKey key; // point identifier
|
||||||
u32 key; // point identifier
|
|
||||||
|
|
||||||
float32 normalImpulse; // normal impulse
|
float32 normalImpulse; // normal impulse
|
||||||
u32 persisting; // is this point persistent?
|
u32 persisting; // is this point persistent?
|
||||||
|
@ -19,41 +19,24 @@
|
|||||||
#include <bounce/collision/shapes/qhull.h>
|
#include <bounce/collision/shapes/qhull.h>
|
||||||
#include <bounce/quickhull/qh_hull.h>
|
#include <bounce/quickhull/qh_hull.h>
|
||||||
|
|
||||||
#define B3_NULL_HULL_FEATURE 0xFF
|
template <class T>
|
||||||
|
|
||||||
// Used to map pointers to indices
|
|
||||||
// If more performance is required then a use hash-map
|
|
||||||
template<class T, u32 N>
|
|
||||||
struct b3UniqueStackArray
|
struct b3UniqueStackArray
|
||||||
{
|
{
|
||||||
b3UniqueStackArray()
|
u32 PushBack(const T& e)
|
||||||
{
|
{
|
||||||
count = 0;
|
for (u32 i = 0; i < elements.Count(); ++i)
|
||||||
}
|
|
||||||
|
|
||||||
// Return value index if added
|
|
||||||
// Return N if the array is full
|
|
||||||
u32 PushBack(const T& value)
|
|
||||||
{
|
|
||||||
for (u32 i = 0; i < count; ++i)
|
|
||||||
{
|
{
|
||||||
if (values[i] == value)
|
if (elements[i] == e)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == N)
|
elements.PushBack(e);
|
||||||
{
|
return elements.Count() - 1;
|
||||||
return N;
|
|
||||||
}
|
|
||||||
|
|
||||||
values[count++] = value;
|
|
||||||
return count - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
T values[N];
|
b3StackArray<T, 256> elements;
|
||||||
u32 count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -287,22 +270,9 @@ void b3QHull::Set(const b3Vec3* points, u32 count, bool simplify)
|
|||||||
b3Free(ps);
|
b3Free(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hull.GetVertexList().count > B3_MAX_HULL_VERTICES)
|
|
||||||
{
|
|
||||||
// Vertex excess
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hull.GetFaceList().count > B3_MAX_HULL_FACES)
|
|
||||||
{
|
|
||||||
// Face excess
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the constructed hull into a run-time hull.
|
// Convert the constructed hull into a run-time hull.
|
||||||
b3UniqueStackArray<qhVertex*, B3_MAX_HULL_VERTICES> vs;
|
b3UniqueStackArray<qhVertex*> vs;
|
||||||
b3UniqueStackArray<qhHalfEdge*, B3_MAX_HULL_EDGES> es;
|
b3UniqueStackArray<qhHalfEdge*> es;
|
||||||
u32 fs_count = 0;
|
|
||||||
|
|
||||||
// Add vertices to the map
|
// Add vertices to the map
|
||||||
for (qhVertex* vertex = hull.GetVertexList().head; vertex != NULL; vertex = vertex->next)
|
for (qhVertex* vertex = hull.GetVertexList().head; vertex != NULL; vertex = vertex->next)
|
||||||
@ -310,13 +280,9 @@ void b3QHull::Set(const b3Vec3* points, u32 count, bool simplify)
|
|||||||
vs.PushBack(vertex);
|
vs.PushBack(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add faces and half-edges to the map
|
// Add half-edges to the map
|
||||||
for (qhFace* face = hull.GetFaceList().head; face != NULL; face = face->next)
|
for (qhFace* face = hull.GetFaceList().head; face != NULL; face = face->next)
|
||||||
{
|
{
|
||||||
// Add face
|
|
||||||
B3_ASSERT(fs_count < B3_MAX_HULL_FACES);
|
|
||||||
++fs_count;
|
|
||||||
|
|
||||||
// Add half-edges
|
// Add half-edges
|
||||||
qhHalfEdge* begin = face->edge;
|
qhHalfEdge* begin = face->edge;
|
||||||
qhHalfEdge* edge = begin;
|
qhHalfEdge* edge = begin;
|
||||||
@ -324,59 +290,54 @@ void b3QHull::Set(const b3Vec3* points, u32 count, bool simplify)
|
|||||||
{
|
{
|
||||||
// Add half-edge
|
// Add half-edge
|
||||||
u32 iedge = es.PushBack(edge);
|
u32 iedge = es.PushBack(edge);
|
||||||
if (iedge == B3_MAX_HULL_EDGES)
|
|
||||||
{
|
|
||||||
// Half-edge excess
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add half-edge just after its twin
|
// Add half-edge just after its twin
|
||||||
u32 itwin = es.PushBack(edge->twin);
|
u32 itwin = es.PushBack(edge->twin);
|
||||||
if (itwin == B3_MAX_HULL_EDGES)
|
|
||||||
{
|
|
||||||
// Half-edge excess
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
edge = edge->next;
|
edge = edge->next;
|
||||||
} while (edge != begin);
|
} while (edge != begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hullVertices.Resize(hull.GetVertexList().count);
|
||||||
|
hullEdges.Resize(es.elements.Count());
|
||||||
|
hullFaces.Resize(hull.GetFaceList().count);
|
||||||
|
hullPlanes.Resize(hull.GetFaceList().count);
|
||||||
|
|
||||||
// Build and link the features
|
// Build and link the features
|
||||||
u32 iface = 0;
|
u32 iface = 0;
|
||||||
for (qhFace* face = hull.GetFaceList().head; face != NULL; face = face->next)
|
for (qhFace* face = hull.GetFaceList().head; face != NULL; face = face->next)
|
||||||
{
|
{
|
||||||
// Build and link the half-edges
|
// Build and link the half-edges
|
||||||
b3Face* hface = faces + iface;
|
b3Face* hface = hullFaces.Get(iface);
|
||||||
|
|
||||||
planes[iface] = face->plane;
|
hullPlanes[iface] = face->plane;
|
||||||
|
|
||||||
qhHalfEdge* begin = face->edge;
|
qhHalfEdge* begin = face->edge;
|
||||||
hface->edge = (u8)es.PushBack(begin);
|
hface->edge = es.PushBack(begin);
|
||||||
|
|
||||||
qhHalfEdge* edge = begin;
|
qhHalfEdge* edge = begin;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
qhVertex* v = edge->tail;
|
qhVertex* v = edge->tail;
|
||||||
u8 iv = (u8)vs.PushBack(v);
|
u32 iv = vs.PushBack(v);
|
||||||
vertices[iv] = v->position;
|
hullVertices[iv] = v->position;
|
||||||
|
|
||||||
u8 iedge = (u8)es.PushBack(edge);
|
u32 iedge = es.PushBack(edge);
|
||||||
b3HalfEdge* hedge = edges + iedge;
|
b3HalfEdge* hedge = hullEdges.Get(iedge);
|
||||||
hedge->face = u8(iface);
|
hedge->face = iface;
|
||||||
hedge->origin = iv;
|
hedge->origin = iv;
|
||||||
|
|
||||||
qhHalfEdge* twin = edge->twin;
|
qhHalfEdge* twin = edge->twin;
|
||||||
u8 itwin = (u8)es.PushBack(twin);
|
u32 itwin = es.PushBack(twin);
|
||||||
b3HalfEdge* htwin = edges + itwin;
|
b3HalfEdge* htwin = hullEdges.Get(itwin);
|
||||||
htwin->twin = iedge;
|
htwin->twin = iedge;
|
||||||
|
|
||||||
hedge->twin = itwin;
|
hedge->twin = itwin;
|
||||||
|
|
||||||
qhHalfEdge* next = edge->next;
|
qhHalfEdge* next = edge->next;
|
||||||
u8 inext = (u8)es.PushBack(next);
|
u32 inext = es.PushBack(next);
|
||||||
|
|
||||||
edges[iedge].next = inext;
|
hullEdges[iedge].next = inext;
|
||||||
|
|
||||||
edge = next;
|
edge = next;
|
||||||
} while (edge != begin);
|
} while (edge != begin);
|
||||||
@ -384,14 +345,9 @@ void b3QHull::Set(const b3Vec3* points, u32 count, bool simplify)
|
|||||||
++iface;
|
++iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
B3_ASSERT(vs.count <= B3_MAX_HULL_VERTICES);
|
vertexCount = hullVertices.Count();
|
||||||
vertexCount = vs.count;
|
edgeCount = hullEdges.Count();
|
||||||
|
faceCount = hullFaces.Count();
|
||||||
B3_ASSERT(es.count <= B3_MAX_HULL_EDGES);
|
|
||||||
edgeCount = es.count;
|
|
||||||
|
|
||||||
B3_ASSERT(fs_count <= B3_MAX_HULL_FACES);
|
|
||||||
faceCount = fs_count;
|
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
Validate();
|
Validate();
|
||||||
|
@ -85,7 +85,6 @@ static void b3BuildEdgeContact(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N);
|
||||||
manifold.points[0].localPoint1 = b3MulT(xf1, c1);
|
manifold.points[0].localPoint1 = b3MulT(xf1, c1);
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
manifold.points[0].key = b3MakeKey(pair);
|
manifold.points[0].key = b3MakeKey(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +130,6 @@ static void b3BuildFaceContact(b3Manifold& manifold,
|
|||||||
mp->localNormal1 = b3MulT(xf1.rotation, n1);
|
mp->localNormal1 = b3MulT(xf1.rotation, n1);
|
||||||
mp->localPoint1 = b3MulT(xf1, c1);
|
mp->localPoint1 = b3MulT(xf1, c1);
|
||||||
mp->localPoint2 = b3MulT(xf2, c2);
|
mp->localPoint2 = b3MulT(xf2, c2);
|
||||||
mp->triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
mp->key = b3MakeKey(clipEdge1[i].pair);
|
mp->key = b3MakeKey(clipEdge1[i].pair);
|
||||||
|
|
||||||
++pointCount;
|
++pointCount;
|
||||||
@ -193,9 +191,10 @@ void b3CollideCapsuleAndHull(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N1);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N1);
|
||||||
manifold.points[0].localPoint1 = b3MulT(xf1, gjk.point1);
|
manifold.points[0].localPoint1 = b3MulT(xf1, gjk.point1);
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, gjk.point2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, gjk.point2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 0;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,13 +233,11 @@ void b3CollideCapsuleAndCapsule(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n1);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n1);
|
||||||
manifold.points[0].localPoint1 = b3MulT(xf1, clipEdge1[0].position);
|
manifold.points[0].localPoint1 = b3MulT(xf1, clipEdge1[0].position);
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, cp1);
|
manifold.points[0].localPoint2 = b3MulT(xf2, cp1);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
manifold.points[0].key = b3MakeKey(clipEdge1[0].pair);
|
manifold.points[0].key = b3MakeKey(clipEdge1[0].pair);
|
||||||
|
|
||||||
manifold.points[1].localNormal1 = b3MulT(xf1.rotation, n2);
|
manifold.points[1].localNormal1 = b3MulT(xf1.rotation, n2);
|
||||||
manifold.points[1].localPoint1 = b3MulT(xf1, clipEdge1[1].position);
|
manifold.points[1].localPoint1 = b3MulT(xf1, clipEdge1[1].position);
|
||||||
manifold.points[1].localPoint2 = b3MulT(xf2, cp2);
|
manifold.points[1].localPoint2 = b3MulT(xf2, cp2);
|
||||||
manifold.points[1].triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
manifold.points[1].key = b3MakeKey(clipEdge1[1].pair);
|
manifold.points[1].key = b3MakeKey(clipEdge1[1].pair);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -253,8 +251,9 @@ void b3CollideCapsuleAndCapsule(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, normal);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, normal);
|
||||||
manifold.points[0].localPoint1 = b3MulT(xf1, point1);
|
manifold.points[0].localPoint1 = b3MulT(xf1, point1);
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, point2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, point2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 0;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,6 @@ void b3BuildEdgeContact(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N);
|
||||||
manifold.points[0].localPoint1 = b3MulT(xf1, c1);
|
manifold.points[0].localPoint1 = b3MulT(xf1, c1);
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
manifold.points[0].key = b3MakeKey(pair);
|
manifold.points[0].key = b3MakeKey(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +189,6 @@ void b3BuildFaceContact(b3Manifold& manifold,
|
|||||||
mp->localNormal1 = b3MulT(xf2.rotation, s_normal);
|
mp->localNormal1 = b3MulT(xf2.rotation, s_normal);
|
||||||
mp->localPoint1 = b3MulT(xf2, v2.position);
|
mp->localPoint1 = b3MulT(xf2, v2.position);
|
||||||
mp->localPoint2 = b3MulT(xf1, v1);
|
mp->localPoint2 = b3MulT(xf1, v1);
|
||||||
mp->triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
mp->key = b3MakeKey(pair);
|
mp->key = b3MakeKey(pair);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -198,7 +196,6 @@ void b3BuildFaceContact(b3Manifold& manifold,
|
|||||||
mp->localNormal1 = b3MulT(xf1.rotation, normal);
|
mp->localNormal1 = b3MulT(xf1.rotation, normal);
|
||||||
mp->localPoint1 = b3MulT(xf1, v1);
|
mp->localPoint1 = b3MulT(xf1, v1);
|
||||||
mp->localPoint2 = b3MulT(xf2, v2.position);
|
mp->localPoint2 = b3MulT(xf2, v2.position);
|
||||||
mp->triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
mp->key = b3MakeKey(v2.pair);
|
mp->key = b3MakeKey(v2.pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,6 @@ static void b3RebuildEdgeContact(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, N);
|
||||||
manifold.points[0].localPoint1 = b3MulT(xf1, c1);
|
manifold.points[0].localPoint1 = b3MulT(xf1, c1);
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
|
||||||
manifold.points[0].key = b3MakeKey(pair);
|
manifold.points[0].key = b3MakeKey(pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,9 @@ void b3CollideSphereAndCapsule(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n);
|
||||||
manifold.points[0].localPoint1 = s1->m_center;
|
manifold.points[0].localPoint1 = s1->m_center;
|
||||||
manifold.points[0].localPoint2 = s2->m_centers[0];
|
manifold.points[0].localPoint2 = s2->m_centers[0];
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 0;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,8 +88,9 @@ void b3CollideSphereAndCapsule(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n);
|
||||||
manifold.points[0].localPoint1 = s1->m_center;
|
manifold.points[0].localPoint1 = s1->m_center;
|
||||||
manifold.points[0].localPoint2 = s2->m_centers[1];
|
manifold.points[0].localPoint2 = s2->m_centers[1];
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 0;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -126,6 +128,7 @@ void b3CollideSphereAndCapsule(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n);
|
||||||
manifold.points[0].localPoint1 = s1->m_center;
|
manifold.points[0].localPoint1 = s1->m_center;
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, P);
|
manifold.points[0].localPoint2 = b3MulT(xf2, P);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 2;
|
manifold.points[0].key.key1 = 0;
|
||||||
}
|
manifold.points[0].key.key2 = 0;
|
||||||
|
}
|
@ -52,8 +52,9 @@ void b3CollideSphereAndHull(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, normal);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, normal);
|
||||||
manifold.points[0].localPoint1 = s1->m_center;
|
manifold.points[0].localPoint1 = s1->m_center;
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 0;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -80,6 +81,7 @@ void b3CollideSphereAndHull(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n1);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, n1);
|
||||||
manifold.points[0].localPoint1 = s1->m_center;
|
manifold.points[0].localPoint1 = s1->m_center;
|
||||||
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
manifold.points[0].localPoint2 = b3MulT(xf2, c2);
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 1;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
}
|
}
|
@ -50,6 +50,7 @@ void b3CollideSphereAndSphere(b3Manifold& manifold,
|
|||||||
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, normal);
|
manifold.points[0].localNormal1 = b3MulT(xf1.rotation, normal);
|
||||||
manifold.points[0].localPoint1 = s1->m_center;
|
manifold.points[0].localPoint1 = s1->m_center;
|
||||||
manifold.points[0].localPoint2 = s2->m_center;
|
manifold.points[0].localPoint2 = s2->m_center;
|
||||||
manifold.points[0].triangleKey = B3_NULL_TRIANGLE;
|
manifold.points[0].key.triangleKey = B3_NULL_TRIANGLE;
|
||||||
manifold.points[0].key = 0;
|
manifold.points[0].key.key1 = 0;
|
||||||
|
manifold.points[0].key.key2 = 0;
|
||||||
}
|
}
|
@ -36,16 +36,18 @@ void b3Manifold::Initialize(const b3Manifold& oldManifold)
|
|||||||
tangentImpulse = oldManifold.tangentImpulse;
|
tangentImpulse = oldManifold.tangentImpulse;
|
||||||
motorImpulse = oldManifold.motorImpulse;
|
motorImpulse = oldManifold.motorImpulse;
|
||||||
|
|
||||||
for (u32 i = 0; i < oldManifold.pointCount; ++i)
|
for (u32 i = 0; i < pointCount; ++i)
|
||||||
{
|
{
|
||||||
const b3ManifoldPoint* p1 = oldManifold.points + i;
|
b3ManifoldPoint* p1 = points + i;
|
||||||
for (u32 j = 0; j < pointCount; ++j)
|
|
||||||
|
for (u32 j = 0; j < oldManifold.pointCount; ++j)
|
||||||
{
|
{
|
||||||
b3ManifoldPoint* p2 = points + j;
|
const b3ManifoldPoint* p2 = oldManifold.points + j;
|
||||||
if (p2->triangleKey == p1->triangleKey && p2->key == p1->key)
|
|
||||||
|
if (p2->key == p1->key)
|
||||||
{
|
{
|
||||||
p2->normalImpulse = p1->normalImpulse;
|
p1->normalImpulse = p2->normalImpulse;
|
||||||
p2->persisting = 1;
|
p1->persisting = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ void b3MeshContact::Collide()
|
|||||||
|
|
||||||
for (u32 j = 0; j < manifold->pointCount; ++j)
|
for (u32 j = 0; j < manifold->pointCount; ++j)
|
||||||
{
|
{
|
||||||
manifold->points[j].triangleKey = triangleIndex;
|
manifold->points[j].key.triangleKey = triangleIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
++tempCount;
|
++tempCount;
|
||||||
|
Reference in New Issue
Block a user