Bullet Collision Detection & Physics Library
btConeShape.h
Go to the documentation of this file.
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
21
25
26{
30 int m_coneIndices[3];
31 btVector3 coneLocalSupport(const btVector3& v) const;
32
33public:
35
37
38 virtual btVector3 localGetSupportingVertex(const btVector3& vec) const;
39 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
40 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors, btVector3* supportVerticesOut, int numVectors) const;
41
42 btScalar getRadius() const { return m_radius; }
43 btScalar getHeight() const { return m_height; }
44
46 {
47 m_radius = radius;
48 }
50 {
51 m_height = height;
52 }
53
55 {
59 getAabb(identity, aabbMin, aabbMax);
60
62
63 btScalar margin = getMargin();
64
65 btScalar lx = btScalar(2.) * (halfExtents.x() + margin);
66 btScalar ly = btScalar(2.) * (halfExtents.y() + margin);
67 btScalar lz = btScalar(2.) * (halfExtents.z() + margin);
68 const btScalar x2 = lx * lx;
69 const btScalar y2 = ly * ly;
70 const btScalar z2 = lz * lz;
71 const btScalar scaledmass = mass * btScalar(0.08333333);
72
73 inertia = scaledmass * (btVector3(y2 + z2, x2 + z2, x2 + y2));
74
75 // inertia.x() = scaledmass * (y2+z2);
76 // inertia.y() = scaledmass * (x2+z2);
77 // inertia.z() = scaledmass * (x2+y2);
78 }
79
80 virtual const char* getName() const
81 {
82 return "Cone";
83 }
84
86 void setConeUpIndex(int upIndex);
87
88 int getConeUpIndex() const
89 {
90 return m_coneIndices[1];
91 }
92
94 {
95 return btVector3(0, 1, 0);
96 }
97
98 virtual void setLocalScaling(const btVector3& scaling);
99
100 virtual int calculateSerializeBufferSize() const;
101
103 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
104};
105
108{
109public:
111
113 {
114 return btVector3(1, 0, 0);
115 }
116
117 //debugging
118 virtual const char* getName() const
119 {
120 return "ConeX";
121 }
122};
123
126{
127public:
129
131 {
132 return btVector3(0, 0, 1);
133 }
134
135 //debugging
136 virtual const char* getName() const
137 {
138 return "ConeZ";
139 }
140};
141
144{
146
148
149 char m_padding[4];
150};
151
153{
154 return sizeof(btConeShapeData);
155}
156
159{
161
162 btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData, serializer);
163
164 shapeData->m_upIndex = m_coneIndices[1];
165
166 // Fill padding with zeros to appease msan.
167 shapeData->m_padding[0] = 0;
168 shapeData->m_padding[1] = 0;
169 shapeData->m_padding[2] = 0;
170 shapeData->m_padding[3] = 0;
171
172 return "btConeShapeData";
173}
174
175#endif //BT_CONE_MINKOWSKI_H
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:27
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:99
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
btConeShape implements a Cone shape, around the X axis
virtual const char * getName() const
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
btConeShapeZ implements a Cone shape, around the Z axis
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
virtual const char * getName() const
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
Definition btConeShape.h:26
btScalar getRadius() const
Definition btConeShape.h:42
void setRadius(const btScalar radius)
Definition btConeShape.h:45
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
Definition btConeShape.h:93
btScalar m_height
Definition btConeShape.h:29
btScalar m_radius
Definition btConeShape.h:28
BT_DECLARE_ALIGNED_ALLOCATOR()
btScalar m_sinAngle
Definition btConeShape.h:27
void setHeight(const btScalar height)
Definition btConeShape.h:49
int getConeUpIndex() const
Definition btConeShape.h:88
virtual int calculateSerializeBufferSize() const
virtual const char * getName() const
Definition btConeShape.h:80
int m_coneIndices[3]
Definition btConeShape.h:30
btScalar getHeight() const
Definition btConeShape.h:43
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
Definition btConeShape.h:54
The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:30
void setIdentity()
Set this transformation to the identity.
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btConvexInternalShapeData m_convexInternalShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64