Bullet Collision Detection & Physics Library
btCompoundShape.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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
24#include "btCollisionMargin.h"
26
27//class btOptimizedBvh;
28struct btDbvt;
29
32{
34
40};
41
43{
44 return (c1.m_transform == c2.m_transform &&
45 c1.m_childShape == c2.m_childShape &&
48}
49
57{
58protected:
62
64
67
69
71
72public:
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
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
147 {
148 return m_dynamicAabbTree;
149 }
150
152 {
153 return m_dynamicAabbTree;
154 }
155
156 void createAabbTreeFromChildren();
157
163 void calculatePrincipalAxisTransform(const btScalar* masses, btTransform& principal, btVector3& inertia) const;
164
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
bool operator==(const btCompoundShapeChild &c1, const btCompoundShapeChild &c2)
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:99
#define SIMD_FORCE_INLINE
Definition: btScalar.h:98
int size() const
return the number of elements in the array
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
BT_DECLARE_ALIGNED_ALLOCATOR()
btVector3 m_localAabbMax
btCollisionShape * getChildShape(int index)
const btTransform & getChildTransform(int index) const
btAlignedObjectArray< btCompoundShapeChild > m_children
btVector3 m_localScaling
btTransform & getChildTransform(int index)
btScalar m_collisionMargin
int m_updateRevision
increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be up...
btDbvt * m_dynamicAabbTree
virtual const btVector3 & getLocalScaling() const
virtual const char * getName() const
const btCollisionShape * getChildShape(int index) const
virtual int calculateSerializeBufferSize() const
btVector3 m_localAabbMin
virtual btScalar getMargin() const
int getUpdateRevision() const
const btDbvt * getDynamicAabbTree() const
virtual void setMargin(btScalar margin)
int getNumChildShapes() const
btCompoundShapeChild * getChildList()
btDbvt * getDynamicAabbTree()
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
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
struct btDbvtNode * m_node
btCollisionShape * m_childShape
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btCompoundShapeChildData * m_childShapePtr
btCollisionShapeData m_collisionShapeData
The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes ...
Definition: btDbvt.h:229
for serialization
Definition: btTransform.h:246