mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
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:
parent
ec5806a979
commit
372c4ef9c1
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -55,9 +55,8 @@ public:
|
||||
return getUnscaledPoints();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void optimizeConvexHull();
|
||||
|
||||
SIMD_FORCE_INLINE btVector3 getScaledPoint(int i) const
|
||||
{
|
||||
return m_unscaledPoints[i] * m_localScaling;
|
||||
|
Loading…
Reference in New Issue
Block a user