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 
73 {
74 protected:
78 
87  union {
88  const unsigned char* m_heightfieldDataUnsignedChar;
89  const short* m_heightfieldDataShort;
92  };
93 
98 
99  int m_upAxis;
100 
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 
108 
112  void initialize(int heightStickWidth, int heightStickLength,
113  const void* heightfieldData, btScalar heightScale,
114  btScalar minHeight, btScalar maxHeight, int upAxis,
115  PHY_ScalarType heightDataType, bool flipQuadEdges);
116 
117 public:
119 
121 
126  btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength,
127  const void* heightfieldData, btScalar heightScale,
128  btScalar minHeight, btScalar maxHeight,
129  int upAxis, PHY_ScalarType heightDataType,
130  bool flipQuadEdges);
131 
133 
139  btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength, const void* heightfieldData, btScalar maxHeight, int upAxis, bool useFloatData, bool flipQuadEdges);
140 
141  virtual ~btHeightfieldTerrainShape();
142 
143  void setUseDiamondSubdivision(bool useDiamondSubdivision = true) { m_useDiamondSubdivision = useDiamondSubdivision; }
144 
146  void setUseZigzagSubdivision(bool useZigzagSubdivision = true) { m_useZigzagSubdivision = useZigzagSubdivision; }
147 
148  virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const;
149 
150  virtual void processAllTriangles(btTriangleCallback * callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
151 
152  virtual void calculateLocalInertia(btScalar mass, btVector3 & inertia) const;
153 
154  virtual void setLocalScaling(const btVector3& scaling);
155 
156  virtual const btVector3& getLocalScaling() const;
157 
158  //debugging
159  virtual const char* getName() const { return "HEIGHTFIELD"; }
160 };
161 
162 #endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H
btHeightfieldTerrainShape simulates a 2D heightfield terrain
void setUseZigzagSubdivision(bool useZigzagSubdivision=true)
could help compatibility with Ogre heightfields. See https://code.google.com/p/bullet/issues/detail?id=625
const unsigned char * m_heightfieldDataUnsignedChar
void setUseDiamondSubdivision(bool useDiamondSubdivision=true)
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
virtual const char * getName() const
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:84
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:405
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.