Bullet Collision Detection & Physics Library
btCollisionShape.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_COLLISION_SHAPE_H
17#define BT_COLLISION_SHAPE_H
18
23class btSerializer;
24
28{
29protected:
34
35public:
37
38 btCollisionShape() : m_shapeType(INVALID_SHAPE_PROXYTYPE), m_userPointer(0), m_userIndex(-1), m_userIndex2(-1)
39 {
40 }
41
43 {
44 }
45
47 virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const = 0;
48
49 virtual void getBoundingSphere(btVector3 & center, btScalar & radius) const;
50
52 virtual btScalar getAngularMotionDisc() const;
53
54 virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const;
55
58 void calculateTemporalAabb(const btTransform& curTrans, const btVector3& linvel, const btVector3& angvel, btScalar timeStep, btVector3& temporalAabbMin, btVector3& temporalAabbMax) const;
59
61 {
62 return btBroadphaseProxy::isPolyhedral(getShapeType());
63 }
64
66 {
67 return btBroadphaseProxy::isConvex2d(getShapeType());
68 }
69
71 {
72 return btBroadphaseProxy::isConvex(getShapeType());
73 }
75 {
76 return btBroadphaseProxy::isNonMoving(getShapeType());
77 }
79 {
80 return btBroadphaseProxy::isConcave(getShapeType());
81 }
83 {
84 return btBroadphaseProxy::isCompound(getShapeType());
85 }
86
88 {
89 return btBroadphaseProxy::isSoftBody(getShapeType());
90 }
91
94 {
95 return btBroadphaseProxy::isInfinite(getShapeType());
96 }
97
98#ifndef __SPU__
99 virtual void setLocalScaling(const btVector3& scaling) = 0;
100 virtual const btVector3& getLocalScaling() const = 0;
101 virtual void calculateLocalInertia(btScalar mass, btVector3 & inertia) const = 0;
102
103 //debugging support
104 virtual const char* getName() const = 0;
105#endif //__SPU__
106
107 int getShapeType() const
108 {
109 return m_shapeType;
110 }
111
115 {
116 return btVector3(1, 1, 1);
117 }
118 virtual void setMargin(btScalar margin) = 0;
119 virtual btScalar getMargin() const = 0;
120
122 void setUserPointer(void* userPtr)
123 {
124 m_userPointer = userPtr;
125 }
126
127 void* getUserPointer() const
128 {
129 return m_userPointer;
130 }
131 void setUserIndex(int index)
132 {
133 m_userIndex = index;
134 }
135
136 int getUserIndex() const
137 {
138 return m_userIndex;
139 }
140
141 void setUserIndex2(int index)
142 {
143 m_userIndex2 = index;
144 }
145
146 int getUserIndex2() const
147 {
148 return m_userIndex2;
149 }
150
151 virtual int calculateSerializeBufferSize() const;
152
154 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
155
156 virtual void serializeSingleShape(btSerializer * serializer) const;
157};
158
159// clang-format off
160// parser needs * with the name
163{
164 char *m_name;
166 char m_padding[4];
167};
168// clang-format on
170{
171 return sizeof(btCollisionShapeData);
172}
173
174#endif //BT_COLLISION_SHAPE_H
@ INVALID_SHAPE_PROXYTYPE
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
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
virtual void setMargin(btScalar margin)=0
bool isConvex2d() const
void setUserPointer(void *userPtr)
optional user data pointer
bool isCompound() const
int getShapeType() const
bool isConvex() const
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const =0
bool isSoftBody() const
virtual const char * getName() const =0
int getUserIndex() const
virtual const btVector3 & getLocalScaling() const =0
bool isNonMoving() const
virtual btScalar getMargin() const =0
void setUserIndex(int index)
virtual void setLocalScaling(const btVector3 &scaling)=0
void * getUserPointer() const
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
void setUserIndex2(int index)
bool isInfinite() const
isInfinite is used to catch simulation error (aabb check)
virtual int calculateSerializeBufferSize() const
bool isConcave() const
bool isPolyhedral() const
virtual ~btCollisionShape()
int getUserIndex2() const
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
static bool isInfinite(int proxyType)
static bool isCompound(int proxyType)
static bool isSoftBody(int proxyType)
static bool isConvex2d(int proxyType)
static bool isPolyhedral(int proxyType)
static bool isNonMoving(int proxyType)
static bool isConcave(int proxyType)
static bool isConvex(int proxyType)
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64