Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btCapsuleShape.h @ 2258

Last change on this file since 2258 was 2192, checked in by rgrieder, 16 years ago

Reverted all changes of attempt to update physics branch.

  • Property svn:eol-style set to native
File size: 3.9 KB
RevLine 
[1963]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 BT_CAPSULE_SHAPE_H
17#define BT_CAPSULE_SHAPE_H
18
19#include "btConvexInternalShape.h"
20#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
21
22
23///The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned around the X axis and btCapsuleShapeZ around the Z axis.
24///The total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
25///The btCapsuleShape is a convex hull of two spheres. The btMultiSphereShape is a more general collision shape that takes the convex hull of multiple sphere, so it can also represent a capsule when just using two spheres.
26class btCapsuleShape : public btConvexInternalShape
27{
28protected:
29        int     m_upAxis;
30
31protected:
32        ///only used for btCapsuleShapeZ and btCapsuleShapeX subclasses.
33        btCapsuleShape() : btConvexInternalShape() {m_shapeType = CAPSULE_SHAPE_PROXYTYPE;};
34
35public:
36        btCapsuleShape(btScalar radius,btScalar height);
37
38        ///CollisionShape Interface
39        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
40
41        /// btConvexShape Interface
42        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
43
44        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
45       
46        virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
47        {
48                        btVector3 halfExtents(getRadius(),getRadius(),getRadius());
49                        halfExtents[m_upAxis] = getRadius() + getHalfHeight();
50                        halfExtents += btVector3(getMargin(),getMargin(),getMargin());
51                        btMatrix3x3 abs_b = t.getBasis().absolute(); 
52                        btPoint3 center = t.getOrigin();
53                        btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));             
54                       
55                        aabbMin = center - extent;
56                        aabbMax = center + extent;
57        }
58
59        virtual const char*     getName()const 
60        {
61                return "CapsuleShape";
62        }
63
64        int     getUpAxis() const
65        {
66                return m_upAxis;
67        }
68
69        btScalar        getRadius() const
70        {
71                int radiusAxis = (m_upAxis+2)%3;
72                return m_implicitShapeDimensions[radiusAxis];
73        }
74
75        btScalar        getHalfHeight() const
76        {
77                return m_implicitShapeDimensions[m_upAxis];
78        }
79
80};
81
82///btCapsuleShapeX represents a capsule around the Z axis
83///the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
84class btCapsuleShapeX : public btCapsuleShape
85{
86public:
87
88        btCapsuleShapeX(btScalar radius,btScalar height);
89               
90        //debugging
91        virtual const char*     getName()const
92        {
93                return "CapsuleX";
94        }
95
96       
97
98};
99
100///btCapsuleShapeZ represents a capsule around the Z axis
101///the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
102class btCapsuleShapeZ : public btCapsuleShape
103{
104public:
105        btCapsuleShapeZ(btScalar radius,btScalar height);
106
107                //debugging
108        virtual const char*     getName()const
109        {
110                return "CapsuleZ";
111        }
112
113       
114};
115
116
117
118#endif //BT_CAPSULE_SHAPE_H
Note: See TracBrowser for help on using the repository browser.