Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/particleeffects/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h @ 8141

Last change on this file since 8141 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.7 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 CYLINDER_MINKOWSKI_H
17#define CYLINDER_MINKOWSKI_H
18
19#include "btBoxShape.h"
20#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
21#include "LinearMath/btVector3.h"
22
23/// The btCylinderShape class implements a cylinder shape primitive, centered around the origin. Its central axis aligned with the Y axis. btCylinderShapeX is aligned with the X axis and btCylinderShapeZ around the Z axis.
24class btCylinderShape : public btBoxShape
25
26{
27
28protected:
29
30        int     m_upAxis;
31
32public:
33        btCylinderShape (const btVector3& halfExtents);
34       
35        ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
36        void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
37
38        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
39
40        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
41
42        virtual btVector3       localGetSupportingVertex(const btVector3& vec) const
43        {
44
45                btVector3 supVertex;
46                supVertex = localGetSupportingVertexWithoutMargin(vec);
47               
48                if ( getMargin()!=btScalar(0.) )
49                {
50                        btVector3 vecnorm = vec;
51                        if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
52                        {
53                                vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
54                        } 
55                        vecnorm.normalize();
56                        supVertex+= getMargin() * vecnorm;
57                }
58                return supVertex;
59        }
60
61
62        //use box inertia
63        //      virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
64
65
66        int     getUpAxis() const
67        {
68                return m_upAxis;
69        }
70
71        virtual btScalar getRadius() const
72        {
73                return getHalfExtentsWithMargin().getX();
74        }
75
76        //debugging
77        virtual const char*     getName()const
78        {
79                return "CylinderY";
80        }
81
82
83
84};
85
86class btCylinderShapeX : public btCylinderShape
87{
88public:
89        btCylinderShapeX (const btVector3& halfExtents);
90
91        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
92        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
93       
94                //debugging
95        virtual const char*     getName()const
96        {
97                return "CylinderX";
98        }
99
100        virtual btScalar getRadius() const
101        {
102                return getHalfExtentsWithMargin().getY();
103        }
104
105};
106
107class btCylinderShapeZ : public btCylinderShape
108{
109public:
110        btCylinderShapeZ (const btVector3& halfExtents);
111
112        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
113        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
114
115        virtual int     getUpAxis() const
116        {
117                return 2;
118        }
119                //debugging
120        virtual const char*     getName()const
121        {
122                return "CylinderZ";
123        }
124
125        virtual btScalar getRadius() const
126        {
127                return getHalfExtentsWithMargin().getX();
128        }
129
130};
131
132
133#endif //CYLINDER_MINKOWSKI_H
134
Note: See TracBrowser for help on using the repository browser.