2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
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:
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.
16
#ifndef BT_COLLISION_SHAPE_H
17
#define BT_COLLISION_SHAPE_H
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
26
///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
27
class btCollisionShape
35
btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
39
virtual ~btCollisionShape()
43
///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
44
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
46
virtual void getBoundingSphere(btVector3& center,btScalar& radius) const;
48
///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
49
virtual btScalar getAngularMotionDisc() const;
51
virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const;
54
///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep)
55
///result is conservative
56
void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
60
SIMD_FORCE_INLINE bool isPolyhedral() const
62
return btBroadphaseProxy::isPolyhedral(getShapeType());
65
SIMD_FORCE_INLINE bool isConvex2d() const
67
return btBroadphaseProxy::isConvex2d(getShapeType());
70
SIMD_FORCE_INLINE bool isConvex() const
72
return btBroadphaseProxy::isConvex(getShapeType());
74
SIMD_FORCE_INLINE bool isNonMoving() const
76
return btBroadphaseProxy::isNonMoving(getShapeType());
78
SIMD_FORCE_INLINE bool isConcave() const
80
return btBroadphaseProxy::isConcave(getShapeType());
82
SIMD_FORCE_INLINE bool isCompound() const
84
return btBroadphaseProxy::isCompound(getShapeType());
87
SIMD_FORCE_INLINE bool isSoftBody() const
89
return btBroadphaseProxy::isSoftBody(getShapeType());
92
///isInfinite is used to catch simulation error (aabb check)
93
SIMD_FORCE_INLINE bool isInfinite() const
95
return btBroadphaseProxy::isInfinite(getShapeType());
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;
105
virtual const char* getName()const =0 ;
109
int getShapeType() const { return m_shapeType; }
110
virtual void setMargin(btScalar margin) = 0;
111
virtual btScalar getMargin() const = 0;
114
///optional user data pointer
115
void setUserPointer(void* userPtr)
117
m_userPointer = userPtr;
120
void* getUserPointer() const
122
return m_userPointer;
125
virtual int calculateSerializeBufferSize() const;
127
///fills the dataBuffer and returns the struct name (and 0 on failure)
128
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
130
virtual void serializeSingleShape(btSerializer* serializer) const;
134
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
135
struct btCollisionShapeData
142
SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const
144
return sizeof(btCollisionShapeData);
149
#endif //BT_COLLISION_SHAPE_H