Added Pierre Terdiman's 'internal object' optimization to improve performance for separating axis tests.

Make the winding consistent in btConvexHullComputer (and related fixes in btPolyhedralConvexShape), thanks to Ole!
Some fixes in the btPolyhedralContactClipping implementation (never report a penetration deeper than GJK/EPA found, to avoid issues due to its approximate contact normal directions)
Properly visualize btPolyhedralConvexHullShape that have a  btConvexPolyhedron (by calling initializePolyhedralFeatures() method)
This commit is contained in:
erwin.coumans
2011-04-15 18:37:28 +00:00
parent 7d37b3c472
commit 1b305562be
12 changed files with 488 additions and 209 deletions

View File

@@ -1974,17 +1974,21 @@ void btConvexHullInternal::compute(const void* coords, bool doubleCoords, int st
medAxis = 3 - maxAxis - minAxis;
s /= btScalar(10216);
if (((medAxis + 1) % 3) != maxAxis)
{
s *= -1;
}
scaling = s;
if (s[0] > 0)
if (s[0] != 0)
{
s[0] = btScalar(1) / s[0];
}
if (s[1] > 0)
if (s[1] != 0)
{
s[1] = btScalar(1) / s[1];
}
if (s[2] > 0)
if (s[2] != 0)
{
s[2] = btScalar(1) / s[2];
}
@@ -2065,9 +2069,7 @@ btVector3 btConvexHullInternal::toBtVector(const Point32& v)
btVector3 btConvexHullInternal::getBtNormal(Face* face)
{
btVector3 normal = toBtVector(face->dir0).cross(toBtVector(face->dir1));
normal /= ((medAxis + 1 == maxAxis) || (medAxis - 2 == maxAxis)) ? normal.length() : -normal.length();
return normal;
return toBtVector(face->dir0).cross(toBtVector(face->dir1)).normalized();
}
btVector3 btConvexHullInternal::getCoordinates(const Vertex* v)
@@ -2203,15 +2205,15 @@ btScalar btConvexHullInternal::shrink(btScalar amount, btScalar clampAmount)
bool btConvexHullInternal::shiftFace(Face* face, btScalar amount, btAlignedObjectArray<Vertex*> stack)
{
btVector3 origShift = getBtNormal(face) * -amount;
if (scaling[0] > 0)
if (scaling[0] != 0)
{
origShift[0] /= scaling[0];
}
if (scaling[1] > 0)
if (scaling[1] != 0)
{
origShift[1] /= scaling[1];
}
if (scaling[2] > 0)
if (scaling[2] != 0)
{
origShift[2] /= scaling[2];
}

View File

@@ -48,12 +48,12 @@ class btConvexHullComputer
return targetVertex;
}
const Edge* getNextEdgeOfVertex() const // counter-clockwise list of all edges of a vertex
const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex
{
return this + next;
}
const Edge* getNextEdgeOfFace() const // clockwise list of all edges of a face
const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face
{
return (this + reverse)->getNextEdgeOfVertex();
}