btHeightfieldTerrainShape::quantizeWithClamp(...)
Completely breaks my heightfield. Reverting this
Code: Select all
out[0] = (unsigned short)(((unsigned short)v.getX() & 0xffffffe) | isMax);
out[1] = (unsigned short)(((unsigned short)v.getY() & 0xffffffe) | isMax);
out[2] = (unsigned short)(((unsigned short)v.getZ() & 0xffffffe) | isMax);
fixes it.
Code: Select all
out[0] = (int)(v.getX() + v.getX() / btFabs(v.getX())* btScalar(0.5) );
out[1] = (int)(v.getY() + v.getY() / btFabs(v.getY())* btScalar(0.5) );
out[2] = (int)(v.getZ() + v.getZ() / btFabs(v.getZ())* btScalar(0.5) );
gcc 4.1.3 20070929 (both -O3 and -O1)
Note: I am using a heightfield of floats. The demos (which don't use floats) work.
Code: Select all
btScalar maxHeight = 1000.0f;
int upAxis = 1; // y
bool useFloats = true;
bool flipQuadEdges = true;
btHeightfieldTerrainShape* terrainShape =
new btHeightfieldTerrainShape(terrain.width(), terrain.height(),
terrain.heights(), maxHeight, upAxis,
useFloats, flipQuadEdges);