Add btConvexHullShape::optimizeConvexHull method,

it automatically removes vertices that are not on the convex hull.
It uses the btConvexHullComputer for this.
This commit is contained in:
Erwin Coumans 2016-05-04 13:01:06 -07:00
parent ec5806a979
commit 372c4ef9c1
2 changed files with 15 additions and 7 deletions

View File

@ -22,6 +22,8 @@ subject to the following restrictions:
#include "LinearMath/btQuaternion.h"
#include "LinearMath/btSerializer.h"
#include "btConvexPolyhedron.h"
#include "LinearMath/btConvexHullComputer.h"
btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexAabbCachingShape ()
{
@ -121,10 +123,17 @@ btVector3 btConvexHullShape::localGetSupportingVertex(const btVector3& vec)const
}
void btConvexHullShape::optimizeConvexHull()
{
btConvexHullComputer conv;
conv.compute(&m_unscaledPoints[0].getX(), sizeof(btVector3),m_unscaledPoints.size(),0.f,0.f);
int numVerts = conv.vertices.size();
m_unscaledPoints.resize(0);
for (int i=0;i<numVerts;i++)
{
m_unscaledPoints.push_back(conv.vertices[i]);
}
}

View File

@ -55,9 +55,8 @@ public:
return getUnscaledPoints();
}
void optimizeConvexHull();
SIMD_FORCE_INLINE btVector3 getScaledPoint(int i) const
{
return m_unscaledPoints[i] * m_localScaling;