Over the last few weeks I have just been playing around with Bullet and OGRES. I have been trying to use the btHeightfieldTerrainShape to map over the heightmap rendered through OGRES.
After much fighting to force the Collision Vertices to render using the processAllTriangles() method, I discovered that the collision map was slightly off compared with the rendered equivalent.
I believe I have tracked the difference down to an integer divide in the getVertex() method of btHeightfieldShapeTerrain. By changing the setValue methods from:
Code: Select all
setValue(-m_width/2+x, height, -m_length/2+y)
Code: Select all
setValue(-m_width/2,0f+x, height, -m_length/2.0f+y)
This does have a knock on effect, because there can now be cases where the range of triangles assessed for collision does not include the correct one. To overcome this I have enhanced the quantisation mechanism to round further up or down by adding 0.5 in magnitude to the point values. i.e.
Code: Select all
int x' = int(x + 0.5*abs(x)/x)
So this seems to work for me, and matches the OGRES terrain well. Can this be raised as a bug ? Or am I using this in completely the wrong way ?
Thanks,
Spangle.