106 for (
int i=0;i<numVectors;i++)
115 for (
int j=0;j<numVectors;j++)
221 CenterCallback() : first(
true), ref(0, 0, 0),
sum(0, 0, 0), volume(0)
225 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
227 (void) triangleIndex;
236 btScalar vol =
btFabs((triangle[0] - ref).triple(triangle[1] - ref, triangle[2] - ref));
237 sum += (
btScalar(0.25) * vol) * ((triangle[0] + triangle[1] + triangle[2] + ref));
244 return (volume > 0) ?
sum / volume : ref;
261 InertiaCallback(
btVector3& center) :
sum(0, 0, 0, 0, 0, 0, 0, 0, 0), center(center)
265 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
267 (void) triangleIndex;
274 for (
int j = 0; j < 3; j++)
276 for (
int k = 0; k <= j; k++)
278 i[j][k] = i[k][j] = volNeg * (
btScalar(0.1) * (a[j] * a[k] + b[j] * b[k] + c[j] * c[k])
279 +
btScalar(0.05) * (a[j] * b[k] + a[k] * b[j] + a[j] * c[k] + a[k] * c[j] + b[j] * c[k] + b[k] * c[j]));
300 CenterCallback centerCallback;
303 btVector3 center = centerCallback.getCenter();
305 volume = centerCallback.getVolume();
307 InertiaCallback inertiaCallback(center);
312 inertia.
setValue(i[0][0], i[1][1], i[2][2]);
static T sum(const btAlignedObjectArray< T > &items)
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
virtual bool isInside(const btVector3 &pt, btScalar tolerance) const
It's not nice to have all this virtual function overhead, so perhaps we can also gather the points on...
btScalar btSqrt(btScalar y)
LocalSupportVertexCallback(const btVector3 &supportVecLocal)
void calculatePrincipalAxisTransform(btTransform &principal, btVector3 &inertia, btScalar &volume) const
computes the exact moment of inertia and the transform from the coordinate system defined by the prin...
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const
const btVector3 & getScaling() const
virtual void getVertex(int i, btVector3 &vtx) const
void setScaling(const btVector3 &scaling)
virtual const btVector3 & getLocalScaling() const
btScalar dot(const btVector3 &v) const
Return the dot product.
virtual btScalar getMargin() const
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
virtual int getNumVertices() const
btVector3 m_supportVertexLocal
virtual void setLocalScaling(const btVector3 &scaling)
btScalar triple(const btVector3 &v1, const btVector3 &v2) const
btVector3 m_supportVecLocal
void diagonalize(btMatrix3x3 &rot, btScalar threshold, int maxSteps)
diagonalizes this matrix by the Jacobi method.
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
class btStridingMeshInterface * m_stridingMesh
virtual void internalProcessTriangleIndex(btVector3 *triangle, int partId, int triangleIndex)
virtual void getPlane(btVector3 &planeNormal, btVector3 &planeSupport, int i) const
btVector3 can be used to represent 3D points and vectors.
btScalar length2() const
Return the length of the vector squared.
The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape.
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
virtual int getNumPlanes() const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
btVector3 GetSupportVertexLocal()
virtual int getNumEdges() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
btConvexTriangleMeshShape(btStridingMeshInterface *meshInterface, bool calcAabb=true)
btScalar btFabs(btScalar x)