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:
@@ -22,6 +22,8 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "LinearMath/btQuaternion.h"
|
#include "LinearMath/btQuaternion.h"
|
||||||
#include "LinearMath/btSerializer.h"
|
#include "LinearMath/btSerializer.h"
|
||||||
|
#include "btConvexPolyhedron.h"
|
||||||
|
#include "LinearMath/btConvexHullComputer.h"
|
||||||
|
|
||||||
btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexAabbCachingShape ()
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,8 @@ public:
|
|||||||
return getUnscaledPoints();
|
return getUnscaledPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void optimizeConvexHull();
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE btVector3 getScaledPoint(int i) const
|
SIMD_FORCE_INLINE btVector3 getScaledPoint(int i) const
|
||||||
{
|
{
|
||||||
return m_unscaledPoints[i] * m_localScaling;
|
return m_unscaledPoints[i] * m_localScaling;
|
||||||
|
|||||||
Reference in New Issue
Block a user