Bullet Collision Detection & Physics Library: btCollisionShape.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
19#include "LinearMath/btTransform.h"
20#include "LinearMath/btVector3.h"
21#include "LinearMath/btMatrix3x3.h"
22#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
23class btSerializer;
24
26 ATTRIBUTE_ALIGNED16(class)
27 btCollisionShape
28{
29protected:
30 int m_shapeType;
31 void* m_userPointer;
32 int m_userIndex;
33 int m_userIndex2;
34
35public:
36 BT_DECLARE_ALIGNED_ALLOCATOR();
37
38 btCollisionShape() : m_shapeType(INVALID_SHAPE_PROXYTYPE), m_userPointer(0), m_userIndex(-1), m_userIndex2(-1)
39 {
40 }
41
42 virtual ~btCollisionShape()
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
60 SIMD_FORCE_INLINE bool isPolyhedral() const
61 {
62 return btBroadphaseProxy::isPolyhedral(getShapeType());
63 }
64
65 SIMD_FORCE_INLINE bool isConvex2d() const
66 {
67 return btBroadphaseProxy::isConvex2d(getShapeType());
68 }
69
70 SIMD_FORCE_INLINE bool isConvex() const
71 {
72 return btBroadphaseProxy::isConvex(getShapeType());
73 }
74 SIMD_FORCE_INLINE bool isNonMoving() const
75 {
76 return btBroadphaseProxy::isNonMoving(getShapeType());
77 }
78 SIMD_FORCE_INLINE bool isConcave() const
79 {
80 return btBroadphaseProxy::isConcave(getShapeType());
81 }
82 SIMD_FORCE_INLINE bool isCompound() const
83 {
84 return btBroadphaseProxy::isCompound(getShapeType());
85 }
86
87 SIMD_FORCE_INLINE bool isSoftBody() const
88 {
89 return btBroadphaseProxy::isSoftBody(getShapeType());
90 }
91
93 SIMD_FORCE_INLINE bool isInfinite() const
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
114 virtual btVector3 getAnisotropicRollingFrictionDirection() const
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
162 struct btCollisionShapeData
163{
164 char *m_name;
165 int m_shapeType;
166 char m_padding[4];
167};
168// clang-format on
169 SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const
170{
171 return sizeof(btCollisionShapeData);
172}
173
174#endif //BT_COLLISION_SHAPE_H
btBroadphaseProxy.h
INVALID_SHAPE_PROXYTYPE
@ INVALID_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:76
btMatrix3x3.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:99
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:98
btTransform.h
btVector3.h
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:28
btCollisionShape::setMargin
virtual void setMargin(btScalar margin)=0
btCollisionShape::m_userPointer
void * m_userPointer
Definition: btCollisionShape.h:31
btCollisionShape::isConvex2d
bool isConvex2d() const
Definition: btCollisionShape.h:65
btCollisionShape::setUserPointer
void setUserPointer(void *userPtr)
optional user data pointer
Definition: btCollisionShape.h:122
btCollisionShape::isCompound
bool isCompound() const
Definition: btCollisionShape.h:82
btCollisionShape::m_userIndex
int m_userIndex
Definition: btCollisionShape.h:32
btCollisionShape::btCollisionShape
btCollisionShape()
Definition: btCollisionShape.h:38
btCollisionShape::getShapeType
int getShapeType() const
Definition: btCollisionShape.h:107
btCollisionShape::isConvex
bool isConvex() const
Definition: btCollisionShape.h:70
btCollisionShape::m_userIndex2
int m_userIndex2
Definition: btCollisionShape.h:33
btCollisionShape::getAnisotropicRollingFrictionDirection
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
Definition: btCollisionShape.h:114
btCollisionShape::calculateLocalInertia
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const =0
btCollisionShape::isSoftBody
bool isSoftBody() const
Definition: btCollisionShape.h:87
btCollisionShape::getName
virtual const char * getName() const =0
btCollisionShape::getUserIndex
int getUserIndex() const
Definition: btCollisionShape.h:136
btCollisionShape::BT_DECLARE_ALIGNED_ALLOCATOR
BT_DECLARE_ALIGNED_ALLOCATOR()
btCollisionShape::getLocalScaling
virtual const btVector3 & getLocalScaling() const =0
btCollisionShape::isNonMoving
bool isNonMoving() const
Definition: btCollisionShape.h:74
btCollisionShape::m_shapeType
int m_shapeType
Definition: btCollisionShape.h:30
btCollisionShape::getMargin
virtual btScalar getMargin() const =0
btCollisionShape::setUserIndex
void setUserIndex(int index)
Definition: btCollisionShape.h:131
btCollisionShape::setLocalScaling
virtual void setLocalScaling(const btVector3 &scaling)=0
btCollisionShape::getUserPointer
void * getUserPointer() const
Definition: btCollisionShape.h:127
btCollisionShape::getAabb
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.
btCollisionShape::setUserIndex2
void setUserIndex2(int index)
Definition: btCollisionShape.h:141
btCollisionShape::isInfinite
bool isInfinite() const
isInfinite is used to catch simulation error (aabb check)
Definition: btCollisionShape.h:93
btCollisionShape::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btCollisionShape.h:169
btCollisionShape::isConcave
bool isConcave() const
Definition: btCollisionShape.h:78
btCollisionShape::isPolyhedral
bool isPolyhedral() const
Definition: btCollisionShape.h:60
btCollisionShape::~btCollisionShape
virtual ~btCollisionShape()
Definition: btCollisionShape.h:42
btCollisionShape::getUserIndex2
int getUserIndex2() const
Definition: btCollisionShape.h:146
btSerializer
Definition: btSerializer.h:66
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.
Definition: btVector3.h:82
btBroadphaseProxy::isInfinite
static bool isInfinite(int proxyType)
Definition: btBroadphaseProxy.h:160
btBroadphaseProxy::isCompound
static bool isCompound(int proxyType)
Definition: btBroadphaseProxy.h:150
btBroadphaseProxy::isSoftBody
static bool isSoftBody(int proxyType)
Definition: btBroadphaseProxy.h:155
btBroadphaseProxy::isConvex2d
static bool isConvex2d(int proxyType)
Definition: btBroadphaseProxy.h:165
btBroadphaseProxy::isPolyhedral
static bool isPolyhedral(int proxyType)
Definition: btBroadphaseProxy.h:130
btBroadphaseProxy::isNonMoving
static bool isNonMoving(int proxyType)
Definition: btBroadphaseProxy.h:140
btBroadphaseProxy::isConcave
static bool isConcave(int proxyType)
Definition: btBroadphaseProxy.h:145
btBroadphaseProxy::isConvex
static bool isConvex(int proxyType)
Definition: btBroadphaseProxy.h:135
btCollisionShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition: btCollisionShape.h:163
btCollisionShapeData::m_name
char * m_name
Definition: btCollisionShape.h:164
btCollisionShapeData::m_shapeType
int m_shapeType
Definition: btCollisionShape.h:165
btCollisionShapeData::m_padding
char m_padding[4]
Definition: btCollisionShape.h:166