24 int heightStickWidth,
int heightStickLength,
const void* heightfieldData,
29 initialize(heightStickWidth, heightStickLength, heightfieldData,
30 heightScale, minHeight, maxHeight, upAxis, hdt,
45 btScalar heightScale = maxHeight / 65535;
47 initialize(heightStickWidth, heightStickLength, heightfieldData,
48 heightScale, minHeight, maxHeight, upAxis, hdt,
56 int heightStickWidth,
int heightStickLength,
const void* heightfieldData,
62 btAssert(heightStickWidth > 1 &&
"bad width");
63 btAssert(heightStickLength > 1 &&
"bad length");
64 btAssert(heightfieldData &&
"null heightfield data");
66 btAssert(minHeight <= maxHeight &&
"bad min/max height");
67 btAssert(upAxis >= 0 && upAxis < 3 &&
68 "bad upAxis--should be in range [0,2]");
70 "Bad height data type enum");
74 m_heightStickWidth = heightStickWidth;
75 m_heightStickLength = heightStickLength;
76 m_minHeight = minHeight;
77 m_maxHeight = maxHeight;
78 m_width = (
btScalar) (heightStickWidth - 1);
79 m_length = (
btScalar) (heightStickLength - 1);
80 m_heightScale = heightScale;
81 m_heightfieldDataUnknown = heightfieldData;
82 m_heightDataType = hdt;
83 m_flipQuadEdges = flipQuadEdges;
84 m_useDiamondSubdivision =
false;
85 m_useZigzagSubdivision =
false;
94 m_localAabbMin.setValue(m_minHeight, 0, 0);
95 m_localAabbMax.setValue(m_maxHeight, m_width, m_length);
100 m_localAabbMin.setValue(0, m_minHeight, 0);
101 m_localAabbMax.setValue(m_width, m_maxHeight, m_length);
106 m_localAabbMin.setValue(0, 0, m_minHeight);
107 m_localAabbMax.setValue(m_width, m_length, m_maxHeight);
118 m_localOrigin =
btScalar(0.5) * (m_localAabbMin + m_localAabbMax);
139 btVector3 extent = halfExtents.
dot3(abs_b[0], abs_b[1], abs_b[2]);
142 aabbMin = center - extent;
143 aabbMax = center + extent;
246 return (
int) (x - 0.5);
248 return (
int) (x + 0.5);
294 int quantizedAabbMin[3];
295 int quantizedAabbMax[3];
301 for (
int i = 0; i < 3; ++i) {
302 quantizedAabbMin[i]--;
303 quantizedAabbMax[i]++;
315 if (quantizedAabbMin[1]>startX)
316 startX = quantizedAabbMin[1];
317 if (quantizedAabbMax[1]<endX)
318 endX = quantizedAabbMax[1];
319 if (quantizedAabbMin[2]>startJ)
320 startJ = quantizedAabbMin[2];
321 if (quantizedAabbMax[2]<endJ)
322 endJ = quantizedAabbMax[2];
327 if (quantizedAabbMin[0]>startX)
328 startX = quantizedAabbMin[0];
329 if (quantizedAabbMax[0]<endX)
330 endX = quantizedAabbMax[0];
331 if (quantizedAabbMin[2]>startJ)
332 startJ = quantizedAabbMin[2];
333 if (quantizedAabbMax[2]<endJ)
334 endJ = quantizedAabbMax[2];
339 if (quantizedAabbMin[0]>startX)
340 startX = quantizedAabbMin[0];
341 if (quantizedAabbMax[0]<endX)
342 endX = quantizedAabbMax[0];
343 if (quantizedAabbMin[1]>startJ)
344 startJ = quantizedAabbMin[1];
345 if (quantizedAabbMax[1]<endJ)
346 endJ = quantizedAabbMax[1];
359 for(
int j=startJ; j<endJ; j++)
361 for(
int x=startX; x<endX; x++)
363 btVector3 vertices[3];
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
virtual void setLocalScaling(const btVector3 &scaling)
bool m_useDiamondSubdivision
const btScalar * m_heightfieldDataFloat
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)=0
virtual ~btHeightfieldTerrainShape()
PHY_ScalarType m_heightDataType
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
process all triangles within the provided axis-aligned bounding box
bool m_useZigzagSubdivision
void quantizeWithClamp(int *out, const btVector3 &point, int isMax) const
given input vector, return quantized version
const btScalar & getZ() const
Return the z value.
const unsigned char * m_heightfieldDataUnsignedChar
void initialize(int heightStickWidth, int heightStickLength, const void *heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, PHY_ScalarType heightDataType, bool flipQuadEdges)
protected initialization
virtual btScalar getRawHeightFieldValue(int x, int y) const
This returns the "raw" (user's initial) height, not the actual height.
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
btHeightfieldTerrainShape(int heightStickWidth, int heightStickLength, const void *heightfieldData, btScalar heightScale, btScalar minHeight, btScalar maxHeight, int upAxis, PHY_ScalarType heightDataType, bool flipQuadEdges)
preferred constructor
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
void getVertex(int x, int y, btVector3 &vertex) const
this returns the vertex in bullet-local coordinates
const btScalar & getY() const
Return the y value.
const btScalar & getX() const
Return the x value.
static int getQuantized(btScalar x)
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...
btVector3 can be used to represent 3D points and vectors.
const short * m_heightfieldDataShort
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
virtual const btVector3 & getLocalScaling() const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
virtual btScalar getMargin() const
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
int m_heightStickWidth
terrain data