From 239d88985f81bfda26a36fb9cfb845cf61eecaf0 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Tue, 16 Oct 2007 21:57:05 +0000 Subject: [PATCH] fix for heightfield, thanks SMJ/Spangle and Jay Lee for testing. http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1482 --- .../CollisionShapes/btHeightfieldTerrainShape.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp index 6268b4aba..e48757775 100644 --- a/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp +++ b/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp @@ -190,11 +190,11 @@ void btHeightfieldTerrainShape::quantizeWithClamp(int* out, const btVector3& poi btVector3 v = (clampedPoint );// * m_quantization; - out[0] = (int)(v.getX()); - out[1] = (int)(v.getY()); - out[2] = (int)(v.getZ()); - //correct for - + // SMJ - Add 0.5 in the correct direction before doing the int conversion. + 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) ); + }