Blender  V3.3
btCompoundShape.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef BT_COMPOUND_SHAPE_H
17 #define BT_COMPOUND_SHAPE_H
18 
19 #include "btCollisionShape.h"
20 
21 #include "LinearMath/btVector3.h"
22 #include "LinearMath/btTransform.h"
23 #include "LinearMath/btMatrix3x3.h"
24 #include "btCollisionMargin.h"
26 
27 //class btOptimizedBvh;
28 struct btDbvt;
29 
30 ATTRIBUTE_ALIGNED16(struct)
32 {
34 
39  struct btDbvtNode* m_node;
40 };
41 
43 {
44  return (c1.m_transform == c2.m_transform &&
45  c1.m_childShape == c2.m_childShape &&
46  c1.m_childShapeType == c2.m_childShapeType &&
47  c1.m_childMargin == c2.m_childMargin);
48 }
49 
57 {
58 protected:
62 
64 
67 
69 
71 
72 public:
74 
75  explicit btCompoundShape(bool enableDynamicAabbTree = true, const int initialChildCapacity = 0);
76 
77  virtual ~btCompoundShape();
78 
79  void addChildShape(const btTransform& localTransform, btCollisionShape* shape);
80 
82  virtual void removeChildShape(btCollisionShape * shape);
83 
84  void removeChildShapeByIndex(int childShapeindex);
85 
86  int getNumChildShapes() const
87  {
88  return int(m_children.size());
89  }
90 
92  {
93  return m_children[index].m_childShape;
94  }
95  const btCollisionShape* getChildShape(int index) const
96  {
97  return m_children[index].m_childShape;
98  }
99 
101  {
102  return m_children[index].m_transform;
103  }
104  const btTransform& getChildTransform(int index) const
105  {
106  return m_children[index].m_transform;
107  }
108 
110  void updateChildTransform(int childIndex, const btTransform& newChildTransform, bool shouldRecalculateLocalAabb = true);
111 
113  {
114  return &m_children[0];
115  }
116 
118  virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const;
119 
122  virtual void recalculateLocalAabb();
123 
124  virtual void setLocalScaling(const btVector3& scaling);
125 
126  virtual const btVector3& getLocalScaling() const
127  {
128  return m_localScaling;
129  }
130 
131  virtual void calculateLocalInertia(btScalar mass, btVector3 & inertia) const;
132 
133  virtual void setMargin(btScalar margin)
134  {
135  m_collisionMargin = margin;
136  }
137  virtual btScalar getMargin() const
138  {
139  return m_collisionMargin;
140  }
141  virtual const char* getName() const
142  {
143  return "Compound";
144  }
145 
146  const btDbvt* getDynamicAabbTree() const
147  {
148  return m_dynamicAabbTree;
149  }
150 
152  {
153  return m_dynamicAabbTree;
154  }
155 
157 
163  void calculatePrincipalAxisTransform(const btScalar* masses, btTransform& principal, btVector3& inertia) const;
164 
165  int getUpdateRevision() const
166  {
167  return m_updateRevision;
168  }
169 
170  virtual int calculateSerializeBufferSize() const;
171 
173  virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
174 };
175 
176 // clang-format off
177 
180 {
185 };
186 
189 {
191 
193 
195 
197 
198 };
199 
200 // clang-format on
201 
203 {
204  return sizeof(btCompoundShapeData);
205 }
206 
207 #endif //BT_COMPOUND_SHAPE_H
_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
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
virtual void setLocalScaling(const btVector3 &scaling)
Definition: btBox2dShape.h:120
BT_DECLARE_ALIGNED_ALLOCATOR()
btVector3 m_localAabbMin
btCompoundShape(bool enableDynamicAabbTree=true, const int initialChildCapacity=0)
virtual btScalar getMargin() const
virtual const char * getName() const
int getNumChildShapes() const
btTransform & getChildTransform(int index)
virtual int calculateSerializeBufferSize() const
virtual void setMargin(btScalar margin)
int getUpdateRevision() const
btCompoundShapeChild
void calculatePrincipalAxisTransform(const btScalar *masses, btTransform &principal, btVector3 &inertia) const
btCollisionShape * m_childShape
void createAabbTreeFromChildren()
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
CollisionShape Interface.
Definition: btConeShape.h:54
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)
btScalar m_childMargin
virtual ~btCompoundShape()
virtual void removeChildShape(btCollisionShape *shape)
Remove all children shapes that contain the specified shape.
btCollisionShape * getChildShape(int index)
struct btDbvtNode * m_node
btCompoundShapeChild * getChildList()
int m_childShapeType
void removeChildShapeByIndex(int childShapeindex)
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...
btScalar m_collisionMargin
btVector3 m_localAabbMax
btTransform m_transform
btDbvt * m_dynamicAabbTree
virtual void recalculateLocalAabb()
const btDbvt * getDynamicAabbTree() const
SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild &c1, const btCompoundShapeChild &c2)
btVector3 m_localScaling
virtual const btVector3 & getLocalScaling() const
int m_updateRevision
increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be up...
void addChildShape(const btTransform &localTransform, btCollisionShape *shape)
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:285
#define SIMD_FORCE_INLINE
Definition: btScalar.h:280
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
SIMD_FORCE_INLINE int size() const
return the number of elements in the array
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
Definition: btDbvt.h:229
for serialization
Definition: btTransform.h:245