52 for (
int i = 0; i < 3; i++)
97 for (
int i = 0; i < numVectors; i++)
105 for (
int j = 0; j < numVectors; j++)
194 CenterCallback() : first(
true), ref(0, 0, 0),
sum(0, 0, 0), volume(0)
198 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
209 btScalar vol =
btFabs((triangle[0] - ref).triple(triangle[1] - ref, triangle[2] - ref));
210 sum += (
btScalar(0.25) * vol) * ((triangle[0] + triangle[1] + triangle[2] + ref));
217 return (volume > 0) ?
sum / volume : ref;
232 InertiaCallback(
btVector3& center) :
sum(0, 0, 0, 0, 0, 0, 0, 0, 0), center(center)
236 virtual void internalProcessTriangleIndex(
btVector3* triangle,
int partId,
int triangleIndex)
245 for (
int j = 0; j < 3; j++)
247 for (
int k = 0; k <= j; k++)
249 i[j][k] = i[k][j] = volNeg * (
btScalar(0.1) * (a[j] * a[k] + b[j] * b[k] + c[j] * c[k]) +
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]));
269 CenterCallback centerCallback;
272 btVector3 center = centerCallback.getCenter();
274 volume = centerCallback.getVolume();
276 InertiaCallback inertiaCallback(center);
281 inertia.
setValue(i[0][0], i[1][1], i[2][2]);
@ CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
btScalar btFabs(btScalar x)
static T sum(const btAlignedObjectArray< T > &items)
It's not nice to have all this virtual function overhead, so perhaps we can also gather the points on...
btVector3 m_supportVertexLocal
btVector3 GetSupportVertexLocal()
btVector3 m_supportVecLocal
LocalSupportVertexCallback(const btVector3 &supportVecLocal)
virtual void internalProcessTriangleIndex(btVector3 *triangle, int partId, int triangleIndex)
virtual btScalar getMargin() const
virtual int getNumVertices() const
class btStridingMeshInterface * m_stridingMesh
virtual const btVector3 & getLocalScaling() const
virtual int getNumPlanes() const
btConvexTriangleMeshShape(btStridingMeshInterface *meshInterface, bool calcAabb=true)
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const
virtual void setLocalScaling(const btVector3 &scaling)
virtual bool isInside(const btVector3 &pt, btScalar tolerance) const
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 void getVertex(int i, btVector3 &vtx) const
virtual int getNumEdges() const
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
virtual void getPlane(btVector3 &planeNormal, btVector3 &planeSupport, int i) const
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
void diagonalize(btMatrix3x3 &rot, btScalar threshold, int maxSteps)
diagonalizes this matrix by the Jacobi method.
The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape.
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
const btVector3 & getScaling() const
void setScaling(const btVector3 &scaling)
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
btVector3 can be used to represent 3D points and vectors.
btScalar dot(const btVector3 &v) const
Return the dot product.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btScalar triple(const btVector3 &v1, const btVector3 &v2) const
btScalar length2() const
Return the length of the vector squared.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.