2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
5
This software is provided 'as-is', without any express or implied warranty.
6
In no event will the authors be held liable for any damages arising from the use of this software.
7
Permission is granted to anyone to use this software for any purpose,
8
including commercial applications, and to alter it and redistribute it freely,
9
subject to the following restrictions:
11
1. 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.
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
3. This notice may not be removed or altered from any source distribution.
16
#ifndef BT_CONE_MINKOWSKI_H
17
#define BT_CONE_MINKOWSKI_H
19
#include "btConvexInternalShape.h"
20
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
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.
23
class btConeShape : public btConvexInternalShape
31
btVector3 coneLocalSupport(const btVector3& v) const;
35
btConeShape (btScalar radius,btScalar height);
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;
41
btScalar getRadius() const { return m_radius;}
42
btScalar getHeight() const { return m_height;}
45
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const
48
identity.setIdentity();
49
btVector3 aabbMin,aabbMax;
50
getAabb(identity,aabbMin,aabbMax);
52
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
54
btScalar margin = getMargin();
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);
64
inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
66
// inertia.x() = scaledmass * (y2+z2);
67
// inertia.y() = scaledmass * (x2+z2);
68
// inertia.z() = scaledmass * (x2+y2);
72
virtual const char* getName()const
77
///choose upAxis index
78
void setConeUpIndex(int upIndex);
80
int getConeUpIndex() const
82
return m_coneIndices[1];
85
virtual void setLocalScaling(const btVector3& scaling);
89
///btConeShape implements a Cone shape, around the X axis
90
class btConeShapeX : public btConeShape
93
btConeShapeX(btScalar radius,btScalar height);
96
///btConeShapeZ implements a Cone shape, around the Z axis
97
class btConeShapeZ : public btConeShape
100
btConeShapeZ(btScalar radius,btScalar height);
102
#endif //BT_CONE_MINKOWSKI_H