btHeightFieldTerrainShape - Bug

rkeene
Posts: 3
Joined: Wed Oct 19, 2011 9:56 pm

btHeightFieldTerrainShape - Bug

Post by rkeene »

When I switched to BT_USE_DOUBLE_PRECISION in my build terrain collision broke.

My terrain height array is float, not double.

The flag PHY_FLOAT that you pass to new btHeightfieldTerrainShape(...) is misleading.

What it actually means is that the data type is btScalar.

So when I switched to BT_USE_DOUBLE_PRECISION it broke.
After some trial and error I tried...

Code: Select all

double * alts = new double[65 * 65];
for(int i=0; i<65 * 65; i++)
{
	alts[i] = m_altitudes[i];
}
btHeightfieldTerrainShape * groundShape = new btHeightfieldTerrainShape( 
	65,	65,
	alts,
	btScalar(1.0), // Height scale
	btScalar(TDLMINGROUNDLEVEL), btScalar(TDLMAXGROUNDLEVEL),
	1, // Up axis
	PHY_FLOAT,s
	false);
And now it works fine and my zombies collide with the terrain mesh.

m_altitudes is a float array.
So as you can see I have to flag for FLOAT but i'm using double.

(Yes there is a memory leak there but this is just hacked in for debugging.) (Later - fixed the leak)
Yuch.