Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h @ 6564

Last change on this file since 6564 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.2 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 CONE_MINKOWSKI_H
17#define CONE_MINKOWSKI_H
18
19#include "btConvexInternalShape.h"
20#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
21
22///The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y axis. The btConeShapeX is aligned around the X axis and btConeShapeZ around the Z axis.
23class btConeShape : public btConvexInternalShape
24
25{
26
27        btScalar m_sinAngle;
28        btScalar m_radius;
29        btScalar m_height;
30        int             m_coneIndices[3];
31        btVector3 coneLocalSupport(const btVector3& v) const;
32
33
34public:
35        btConeShape (btScalar radius,btScalar height);
36       
37        virtual btVector3       localGetSupportingVertex(const btVector3& vec) const;
38        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
39        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
40
41        btScalar getRadius() const { return m_radius;}
42        btScalar getHeight() const { return m_height;}
43
44
45        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const
46        {
47                btTransform identity;
48                identity.setIdentity();
49                btVector3 aabbMin,aabbMax;
50                getAabb(identity,aabbMin,aabbMax);
51
52                btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
53
54                btScalar margin = getMargin();
55
56                btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
57                btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
58                btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
59                const btScalar x2 = lx*lx;
60                const btScalar y2 = ly*ly;
61                const btScalar z2 = lz*lz;
62                const btScalar scaledmass = mass * btScalar(0.08333333);
63
64                inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
65
66//              inertia.x() = scaledmass * (y2+z2);
67//              inertia.y() = scaledmass * (x2+z2);
68//              inertia.z() = scaledmass * (x2+y2);
69        }
70
71
72                virtual const char*     getName()const 
73                {
74                        return "Cone";
75                }
76               
77                ///choose upAxis index
78                void    setConeUpIndex(int upIndex);
79               
80                int     getConeUpIndex() const
81                {
82                        return m_coneIndices[1];
83                }
84};
85
86///btConeShape implements a Cone shape, around the X axis
87class btConeShapeX : public btConeShape
88{
89        public:
90                btConeShapeX(btScalar radius,btScalar height);
91};
92
93///btConeShapeZ implements a Cone shape, around the Z axis
94class btConeShapeZ : public btConeShape
95{
96        public:
97                btConeShapeZ(btScalar radius,btScalar height);
98};
99#endif //CONE_MINKOWSKI_H
100
Note: See TracBrowser for help on using the repository browser.