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
24
25{
26
31 btVector3 coneLocalSupport(const btVector3& v) const;
32
33
34public:
36
37 btConeShape (btScalar radius,btScalar height);
38
39 virtual btVector3 localGetSupportingVertex(const btVector3& vec) const;
41 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
42
43 btScalar getRadius() const { return m_radius;}
44 btScalar getHeight() const { return m_height;}
45
46 void setRadius(const btScalar radius)
47 {
48 m_radius = radius;
49 }
50 void setHeight(const btScalar height)
51 {
52 m_height = height;
53 }
54
55
56 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const
57 {
58 btTransform identity;
59 identity.setIdentity();
60 btVector3 aabbMin,aabbMax;
61 getAabb(identity,aabbMin,aabbMax);
62
63 btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
64
65 btScalar margin = getMargin();
66
67 btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
68 btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
69 btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
70 const btScalar x2 = lx*lx;
71 const btScalar y2 = ly*ly;
72 const btScalar z2 = lz*lz;
73 const btScalar scaledmass = mass * btScalar(0.08333333);
74
75 inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
76
77// inertia.x() = scaledmass * (y2+z2);
78// inertia.y() = scaledmass * (x2+z2);
79// inertia.z() = scaledmass * (x2+y2);
80 }
81
82
83 virtual const char* getName()const
84 {
85 return "Cone";
86 }
87
89 void setConeUpIndex(int upIndex);
90
91 int getConeUpIndex() const
92 {
93 return m_coneIndices[1];
94 }
95
97 {
98 return btVector3 (0,1,0);
99 }
100
101 virtual void setLocalScaling(const btVector3& scaling);
102
103
104 virtual int calculateSerializeBufferSize() const;
105
107 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
108
109
110};
111
114{
115 public:
116 btConeShapeX(btScalar radius,btScalar height);
117
119 {
120 return btVector3 (1,0,0);
121 }
122
123 //debugging
124 virtual const char* getName()const
125 {
126 return "ConeX";
127 }
128
129
130};
131
134{
135public:
136 btConeShapeZ(btScalar radius,btScalar height);
137
139 {
140 return btVector3 (0,0,1);
141 }
142
143 //debugging
144 virtual const char* getName()const
145 {
146 return "ConeZ";
147 }
148
149
150};
151
161
166
168SIMD_FORCE_INLINE const char* btConeShape::serialize(void* dataBuffer, btSerializer* serializer) const
169{
170 btConeShapeData* shapeData = (btConeShapeData*) dataBuffer;
171
173
174 shapeData->m_upIndex = m_coneIndices[1];
175
176 // Fill padding with zeros to appease msan.
177 shapeData->m_padding[0] = 0;
178 shapeData->m_padding[1] = 0;
179 shapeData->m_padding[2] = 0;
180 shapeData->m_padding[3] = 0;
181
182 return "btConeShapeData";
183}
184
185#endif //BT_CONE_MINKOWSKI_H
186
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:292
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:82
#define SIMD_FORCE_INLINE
Definition btScalar.h:81
virtual const char * getName() const
btConeShapeX(btScalar radius, btScalar height)
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
btConeShapeZ(btScalar radius, btScalar height)
virtual const char * getName() const
btScalar getRadius() const
Definition btConeShape.h:43
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3 &vec) const
btConeShape(btScalar radius, btScalar height)
void setRadius(const btScalar radius)
Definition btConeShape.h:46
virtual btVector3 getAnisotropicRollingFrictionDirection() const
the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction See...
Definition btConeShape.h:96
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:50
int getConeUpIndex() const
Definition btConeShape.h:91
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual int calculateSerializeBufferSize() const
virtual const char * getName() const
Definition btConeShape.h:83
int m_coneIndices[3]
Definition btConeShape.h:30
btScalar getHeight() const
Definition btConeShape.h:44
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
btVector3 coneLocalSupport(const btVector3 &v) const
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
Definition btConeShape.h:56
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
virtual btScalar getMargin() const
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:34
void setIdentity()
Set this transformation to the identity.
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:84
const btScalar & z() const
Return the z value.
Definition btVector3.h:591
const btScalar & x() const
Return the x value.
Definition btVector3.h:587
const btScalar & y() const
Return the y value.
Definition btVector3.h:589
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