Blender  V3.3
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"
21 
23 
74 {
75 public:
76  struct Range
77  {
78  btScalar min;
80  };
81 
82 protected:
86 
95  union {
96  const unsigned char* m_heightfieldDataUnsignedChar;
97  const short* m_heightfieldDataShort;
100  };
101 
107  int m_upAxis;
108 
110 
111  // Accelerator
116 
119 
121 
122  virtual btScalar getRawHeightFieldValue(int x, int y) const;
123  void quantizeWithClamp(int* out, const btVector3& point, int isMax) const;
124 
126 
130  void initialize(int heightStickWidth, int heightStickLength,
131  const void* heightfieldData, btScalar heightScale,
132  btScalar minHeight, btScalar maxHeight, int upAxis,
133  PHY_ScalarType heightDataType, bool flipQuadEdges);
134 
135 public:
137 
139 
144  btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength,
145  const void* heightfieldData, btScalar heightScale,
146  btScalar minHeight, btScalar maxHeight,
147  int upAxis, PHY_ScalarType heightDataType,
148  bool flipQuadEdges);
149 
151 
157  btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength, const void* heightfieldData, btScalar maxHeight, int upAxis, bool useFloatData, bool flipQuadEdges);
158 
159  virtual ~btHeightfieldTerrainShape();
160 
161  void setUseDiamondSubdivision(bool useDiamondSubdivision = true) { m_useDiamondSubdivision = useDiamondSubdivision; }
162 
164  void setUseZigzagSubdivision(bool useZigzagSubdivision = true) { m_useZigzagSubdivision = useZigzagSubdivision; }
165 
166  void setFlipTriangleWinding(bool flipTriangleWinding)
167  {
168  m_flipTriangleWinding = flipTriangleWinding;
169  }
170  virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const;
171 
172  virtual void processAllTriangles(btTriangleCallback * callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
173 
174  virtual void calculateLocalInertia(btScalar mass, btVector3 & inertia) const;
175 
176  virtual void setLocalScaling(const btVector3& scaling);
177 
178  virtual const btVector3& getLocalScaling() const;
179 
180  void getVertex(int x, int y, btVector3& vertex) const;
181 
182  void performRaycast(btTriangleCallback * callback, const btVector3& raySource, const btVector3& rayTarget) const;
183 
184  void buildAccelerator(int chunkSize = 16);
185  void clearAccelerator();
186 
187  int getUpAxis() const
188  {
189  return m_upAxis;
190  }
191  //debugging
192  virtual const char* getName() const { return "HEIGHTFIELD"; }
193 
194 
195  void setUserIndex2(int index)
196  {
197  m_userIndex2 = index;
198  }
199  int getUserIndex2() const
200  {
201  return m_userIndex2;
202  }
204  {
205  m_userValue3 = value;
206  }
208  {
209  return m_userValue3;
210  }
211  const struct btTriangleInfoMap* getTriangleInfoMap() const
212  {
213  return m_triangleInfoMap;
214  }
216  {
217  return m_triangleInfoMap;
218  }
220  {
222  }
223  const unsigned char* getHeightfieldRawData() const
224  {
226  }
227 };
228 
229 #endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
btConcaveShape()
PHY_ScalarType
void initialize(int heightStickWidth, int heightStickLength, const void *heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, PHY_ScalarType heightDataType, bool flipQuadEdges)
protected initialization
const void * m_heightfieldDataUnknown
btAlignedObjectArray< Range > m_vboundsGrid
PHY_ScalarType m_heightDataType
virtual void setLocalScaling(const btVector3 &scaling)
in case we receive negative scaling
Definition: btBox2dShape.h:120
BT_DECLARE_ALIGNED_ALLOCATOR()
const unsigned char * getHeightfieldRawData() const
const struct btTriangleInfoMap * getTriangleInfoMap() const
btVector3 m_localAabbMin
void getVertex(int x, int y, btVector3 &vertex) const
int m_heightStickWidth
terrain data
struct btTriangleInfoMap * m_triangleInfoMap
btVector3 m_localOrigin
virtual const char * getName() const
virtual btScalar getRawHeightFieldValue(int x, int y) const
void setTriangleInfoMap(btTriangleInfoMap *map)
btScalar m_heightScale
void quantizeWithClamp(int *out, const btVector3 &point, int isMax) const
given input vector, return quantized version
btScalar m_maxHeight
void setUseDiamondSubdivision(bool useDiamondSubdivision=true)
virtual ~btHeightfieldTerrainShape()
int m_vboundsGridWidth
void performRaycast(btTriangleCallback *callback, const btVector3 &raySource, const btVector3 &rayTarget) const
btScalar max
btScalar getUserValue3() const
void clearAccelerator()
btScalar m_userValue3
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
CollisionShape Interface.
Definition: btConeShape.h:54
int getUpAxis() const
bool m_useDiamondSubdivision
btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength, const void *heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, PHY_ScalarType heightDataType, bool flipQuadEdges)
preferred constructor
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
Definition: btEmptyShape.h:57
btScalar m_minHeight
void setUserIndex2(int index)
int m_vboundsGridLength
const unsigned char * m_heightfieldDataUnsignedChar
const short * m_heightfieldDataShort
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
bool m_useZigzagSubdivision
int m_heightStickLength
btScalar m_width
btScalar m_length
btVector3 m_localAabbMax
void setUseZigzagSubdivision(bool useZigzagSubdivision=true)
could help compatibility with Ogre heightfields. See https://code.google.com/p/bullet/issues/detail?...
int m_vboundsChunkSize
bool m_flipTriangleWinding
void setFlipTriangleWinding(bool flipTriangleWinding)
btVector3 m_localScaling
virtual const btVector3 & getLocalScaling() const
void setUserValue3(btScalar value)
void buildAccelerator(int chunkSize=16)
int getUserIndex2() const
const btScalar * m_heightfieldDataFloat
bool m_flipQuadEdges
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:285
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
DEGForeachIDComponentCallback callback
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
SocketIndexByIdentifierMap * map
#define min(a, b)
Definition: sort.c:35
The btTriangleInfoMap stores edge angle information for some triangles. You can compute this informat...