Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.h @ 1997

Last change on this file since 1997 was 1963, checked in by rgrieder, 16 years ago

Added Bullet physics engine.

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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 COLLISION_SHAPE_H
17#define COLLISION_SHAPE_H
18
19#include "LinearMath/btTransform.h"
20#include "LinearMath/btVector3.h"
21#include "LinearMath/btMatrix3x3.h"
22#include "LinearMath/btPoint3.h"
23#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
24
25///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
26class btCollisionShape
27{
28protected:
29        int m_shapeType;
30        void* m_userPointer;
31
32public:
33
34        btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
35        {
36        }
37
38        virtual ~btCollisionShape()
39        {
40        }
41
42        ///getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
43        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
44
45        virtual void    getBoundingSphere(btVector3& center,btScalar& radius) const;
46
47        ///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
48        virtual btScalar        getAngularMotionDisc() const;
49
50
51        ///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep)
52        ///result is conservative
53        void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
54
55#ifndef __SPU__
56
57        SIMD_FORCE_INLINE bool  isPolyhedral() const
58        {
59                return btBroadphaseProxy::isPolyhedral(getShapeType());
60        }
61
62        SIMD_FORCE_INLINE bool  isConvex() const
63        {
64                return btBroadphaseProxy::isConvex(getShapeType());
65        }
66        SIMD_FORCE_INLINE bool  isConcave() const
67        {
68                return btBroadphaseProxy::isConcave(getShapeType());
69        }
70        SIMD_FORCE_INLINE bool  isCompound() const
71        {
72                return btBroadphaseProxy::isCompound(getShapeType());
73        }
74
75        ///isInfinite is used to catch simulation error (aabb check)
76        SIMD_FORCE_INLINE bool isInfinite() const
77        {
78                return btBroadphaseProxy::isInfinite(getShapeType());
79        }
80
81       
82        virtual void    setLocalScaling(const btVector3& scaling) =0;
83        virtual const btVector3& getLocalScaling() const =0;
84        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0;
85
86
87//debugging support
88        virtual const char*     getName()const =0 ;
89#endif //__SPU__
90
91       
92        int             getShapeType() const { return m_shapeType; }
93        virtual void    setMargin(btScalar margin) = 0;
94        virtual btScalar        getMargin() const = 0;
95
96       
97        ///optional user data pointer
98        void    setUserPointer(void*  userPtr)
99        {
100                m_userPointer = userPtr;
101        }
102
103        void*   getUserPointer() const
104        {
105                return m_userPointer;
106        }
107
108};     
109
110#endif //COLLISION_SHAPE_H
111
Note: See TracBrowser for help on using the repository browser.