Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/Presentation_FS16/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h @ 12373

Last change on this file since 12373 was 8393, checked in by rgrieder, 14 years ago

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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_CONE_MINKOWSKI_H
17#define BT_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        virtual void    setLocalScaling(const btVector3& scaling);
86
87};
88
89///btConeShape implements a Cone shape, around the X axis
90class btConeShapeX : public btConeShape
91{
92        public:
93                btConeShapeX(btScalar radius,btScalar height);
94};
95
96///btConeShapeZ implements a Cone shape, around the Z axis
97class btConeShapeZ : public btConeShape
98{
99        public:
100                btConeShapeZ(btScalar radius,btScalar height);
101};
102#endif //BT_CONE_MINKOWSKI_H
103
Note: See TracBrowser for help on using the repository browser.