Bullet Collision Detection & Physics Library: btHeightfieldTerrainShape.h Source File

Bullet Collision Detection & Physics Library

btHeightfieldTerrainShape.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4
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:
10
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.
14 */
15
16 #ifndef BT_HEIGHTFIELD_TERRAIN_SHAPE_H
17 #define BT_HEIGHTFIELD_TERRAIN_SHAPE_H
18
19 #include "btConcaveShape.h"
20
22
71 ATTRIBUTE_ALIGNED16(class) btHeightfieldTerrainShape : public btConcaveShape
72 {
73 protected:
74 btVector3 m_localAabbMin;
75 btVector3 m_localAabbMax;
76 btVector3 m_localOrigin;
77
79 int m_heightStickWidth;
80 int m_heightStickLength;
81 btScalar m_minHeight;
82 btScalar m_maxHeight;
83 btScalar m_width;
84 btScalar m_length;
85 btScalar m_heightScale;
86 union
87 {
88 const unsigned char* m_heightfieldDataUnsignedChar;
89 const short* m_heightfieldDataShort;
90 const btScalar* m_heightfieldDataFloat;
91 const void* m_heightfieldDataUnknown;
92 };
93
94 PHY_ScalarType m_heightDataType;
95 bool m_flipQuadEdges;
96 bool m_useDiamondSubdivision;
97 bool m_useZigzagSubdivision;
98
99 int m_upAxis;
100
101 btVector3 m_localScaling;
102
103 virtual btScalar getRawHeightFieldValue(int x,int y) const;
104 void quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
105 void getVertex(int x,int y,btVector3& vertex) const;
106
107
108
110
114 void initialize(int heightStickWidth, int heightStickLength,
115 const void* heightfieldData, btScalar heightScale,
116 btScalar minHeight, btScalar maxHeight, int upAxis,
117 PHY_ScalarType heightDataType, bool flipQuadEdges);
118
119 public:
120
121 BT_DECLARE_ALIGNED_ALLOCATOR();
122
124
129 btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,
130 const void* heightfieldData, btScalar heightScale,
131 btScalar minHeight, btScalar maxHeight,
132 int upAxis, PHY_ScalarType heightDataType,
133 bool flipQuadEdges);
134
136
142 btHeightfieldTerrainShape(int heightStickWidth,int heightStickLength,const void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
143
144 virtual ~btHeightfieldTerrainShape();
145
146
147 void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;}
148
150 void setUseZigzagSubdivision(bool useZigzagSubdivision=true) { m_useZigzagSubdivision = useZigzagSubdivision;}
151
152 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
153
154 virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
155
156 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
157
158 virtual void setLocalScaling(const btVector3& scaling);
159
160 virtual const btVector3& getLocalScaling() const;
161
162 //debugging
163 virtual const char* getName()const {return "HEIGHTFIELD";}
164
165 };
166
167 #endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H
btHeightfieldTerrainShape::m_flipQuadEdges
bool m_flipQuadEdges
Definition: btHeightfieldTerrainShape.h:95
btHeightfieldTerrainShape::m_localAabbMax
btVector3 m_localAabbMax
Definition: btHeightfieldTerrainShape.h:75
btHeightfieldTerrainShape::m_maxHeight
btScalar m_maxHeight
Definition: btHeightfieldTerrainShape.h:82
btHeightfieldTerrainShape::m_heightStickLength
int m_heightStickLength
Definition: btHeightfieldTerrainShape.h:80
btHeightfieldTerrainShape::m_useDiamondSubdivision
bool m_useDiamondSubdivision
Definition: btHeightfieldTerrainShape.h:96
btHeightfieldTerrainShape::m_length
btScalar m_length
Definition: btHeightfieldTerrainShape.h:84
btHeightfieldTerrainShape
btHeightfieldTerrainShape simulates a 2D heightfield terrain
Definition: btHeightfieldTerrainShape.h:71
btHeightfieldTerrainShape::m_heightfieldDataFloat
const btScalar * m_heightfieldDataFloat
Definition: btHeightfieldTerrainShape.h:90
btHeightfieldTerrainShape::m_heightDataType
PHY_ScalarType m_heightDataType
Definition: btHeightfieldTerrainShape.h:94
btHeightfieldTerrainShape::setUseZigzagSubdivision
void setUseZigzagSubdivision(bool useZigzagSubdivision=true)
could help compatibility with Ogre heightfields. See https://code.google.com/p/bullet/issues/detail?id=625
Definition: btHeightfieldTerrainShape.h:150
btHeightfieldTerrainShape::m_localScaling
btVector3 m_localScaling
Definition: btHeightfieldTerrainShape.h:101
btHeightfieldTerrainShape::m_useZigzagSubdivision
bool m_useZigzagSubdivision
Definition: btHeightfieldTerrainShape.h:97
btConcaveShape.h
btHeightfieldTerrainShape::m_heightfieldDataUnsignedChar
const unsigned char * m_heightfieldDataUnsignedChar
Definition: btHeightfieldTerrainShape.h:88
btHeightfieldTerrainShape::m_minHeight
btScalar m_minHeight
Definition: btHeightfieldTerrainShape.h:81
btHeightfieldTerrainShape::m_heightScale
btScalar m_heightScale
Definition: btHeightfieldTerrainShape.h:85
btHeightfieldTerrainShape::setUseDiamondSubdivision
void setUseDiamondSubdivision(bool useDiamondSubdivision=true)
Definition: btHeightfieldTerrainShape.h:147
btTriangleCallback
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
Definition: btTriangleCallback.h:24
btHeightfieldTerrainShape::m_localAabbMin
btVector3 m_localAabbMin
Definition: btHeightfieldTerrainShape.h:74
btHeightfieldTerrainShape::getName
virtual const char * getName() const
Definition: btHeightfieldTerrainShape.h:163
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:65
btHeightfieldTerrainShape::m_heightfieldDataShort
const short * m_heightfieldDataShort
Definition: btHeightfieldTerrainShape.h:89
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btHeightfieldTerrainShape::m_upAxis
int m_upAxis
Definition: btHeightfieldTerrainShape.h:99
btConcaveShape
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
Definition: btConcaveShape.h:36
BT_DECLARE_ALIGNED_ALLOCATOR
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:389
btHeightfieldTerrainShape::m_width
btScalar m_width
Definition: btHeightfieldTerrainShape.h:83
btHeightfieldTerrainShape::m_localOrigin
btVector3 m_localOrigin
Definition: btHeightfieldTerrainShape.h:76
btHeightfieldTerrainShape::m_heightfieldDataUnknown
const void * m_heightfieldDataUnknown
Definition: btHeightfieldTerrainShape.h:91
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:279
PHY_ScalarType
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
Definition: btConcaveShape.h:25
btHeightfieldTerrainShape::m_heightStickWidth
int m_heightStickWidth
terrain data
Definition: btHeightfieldTerrainShape.h:79