31 if (enableDynamicAabbTree)
38 m_children.reserve(initialChildCapacity);
57 child.m_transform = localTransform;
58 child.m_childShape = shape;
59 child.m_childShapeType = shape->getShapeType();
60 child.m_childMargin = shape->getMargin();
64 shape->getAabb(localTransform, localAabbMin, localAabbMax);
65 for (
int i = 0; i < 3; i++)
79 size_t index = m_children.size();
83 m_children.push_back(child);
88 m_children[childIndex].m_transform = newChildTransform;
94 m_children[childIndex].m_childShape->getAabb(newChildTransform, localAabbMin, localAabbMax);
101 if (shouldRecalculateLocalAabb)
110 btAssert(childShapeIndex >= 0 && childShapeIndex < m_children.size());
115 m_children.swap(childShapeIndex, m_children.size() - 1);
117 m_children[childShapeIndex].m_node->dataAsInt = childShapeIndex;
118 m_children.pop_back();
126 for (
int i = m_children.size() - 1; i >= 0; i--)
146 for (
int j = 0; j < m_children.size(); j++)
149 m_children[j].m_childShape->getAabb(m_children[j].
m_transform, localAabbMin, localAabbMax);
150 for (
int i = 0; i < 3; i++)
167 if (!m_children.size())
169 localHalfExtents.setValue(0, 0, 0);
170 localCenter.setValue(0, 0, 0);
178 btVector3 extent = localHalfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
179 aabbMin =
center - extent;
180 aabbMax =
center + extent;
189 getAabb(ident, aabbMin, aabbMax);
197 inertia[0] = mass / (
btScalar(12.0)) * (ly * ly + lz * lz);
198 inertia[1] = mass / (
btScalar(12.0)) * (lx * lx + lz * lz);
199 inertia[2] = mass / (
btScalar(12.0)) * (lx * lx + ly * ly);
204 int n = m_children.size();
210 for (k = 0; k < n; k++)
213 center += m_children[k].m_transform.getOrigin() * masses[k];
214 totalMass += masses[k];
220 principal.setOrigin(
center);
223 for (k = 0; k < n; k++)
226 m_children[k].m_childShape->calculateLocalInertia(masses[k], i);
236 j =
t.getBasis() * j;
245 j[0].setValue(o2, 0, 0);
246 j[1].setValue(0, o2, 0);
247 j[2].setValue(0, 0, o2);
253 tensor[0] += masses[k] * j[0];
254 tensor[1] += masses[k] * j[1];
255 tensor[2] += masses[k] * j[2];
258 tensor.diagonalize(principal.getBasis(),
btScalar(0.00001), 20);
259 inertia.setValue(tensor[0][0], tensor[1][1], tensor[2][2]);
264 for (
int i = 0; i < m_children.size(); i++)
267 btVector3 childScale = m_children[i].m_childShape->getLocalScaling();
270 m_children[i].m_childShape->setLocalScaling(childScale);
271 childTrans.setOrigin((childTrans.getOrigin()) * scaling /
m_localScaling);
287 for (
int index = 0; index < m_children.size(); index++)
293 child.m_childShape->getAabb(child.m_transform, localAabbMin, localAabbMax);
296 size_t index2 = index;
322 if (!serializer->
findPointer(m_children[i].m_childShape))
325 const char* structType = m_children[i].m_childShape->serialize(chunk->
m_oldPtr, serializer);
330 m_children[i].m_transform.serializeFloat(memPtr->
m_transform);
334 return "btCompoundShapeData";
typedef float(TangentPoint)[2]
NSNotificationCenter * center
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
virtual void setLocalScaling(const btVector3 &scaling)
in case we receive negative scaling
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
@ COMPOUND_SHAPE_PROXYTYPE
int m_updateRevision
internal update revision number. It will be increased when the object changes. This allows some subsy...
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
virtual btScalar getMargin() const =0
btCompoundShape(bool enableDynamicAabbTree=true, const int initialChildCapacity=0)
btTransform & getChildTransform(int index)
void calculatePrincipalAxisTransform(const btScalar *masses, btTransform &principal, btVector3 &inertia) const
btCollisionShape * m_childShape
void createAabbTreeFromChildren()
void updateChildTransform(int childIndex, const btTransform &newChildTransform, bool shouldRecalculateLocalAabb=true)
set a new transform for a child, and update internal data structures (local aabb and dynamic tree)
virtual ~btCompoundShape()
virtual void removeChildShape(btCollisionShape *shape)
Remove all children shapes that contain the specified shape.
struct btDbvtNode * m_node
void removeChildShapeByIndex(int childShapeindex)
btScalar m_collisionMargin
btDbvt * m_dynamicAabbTree
virtual void recalculateLocalAabb()
void addChildShape(const btTransform &localTransform, btCollisionShape *shape)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
Data buffer MUST be 16 byte aligned.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
virtual btChunk * allocate(size_t size, int numElements)=0
virtual void * findPointer(void *oldPtr)=0
virtual void * getUniquePointer(void *oldPtr)=0
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btTransformFloatData m_transform
btCollisionShapeData * m_childShape
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btCompoundShapeChildData * m_childShapePtr
btCollisionShapeData m_collisionShapeData
static btDbvtAabbMm FromMM(const btVector3 &mi, const btVector3 &mx)
btDbvtNode * insert(const btDbvtVolume &box, void *data)
void update(btDbvtNode *leaf, int lookahead=-1)
void remove(btDbvtNode *leaf)