From cd126aae8f5d172e91df96c0dfd8bfc6f121f0c2 Mon Sep 17 00:00:00 2001 From: "john.mccutchan" Date: Mon, 9 Feb 2009 16:28:44 +0000 Subject: [PATCH] Height field terrain shape fixes from tomva1@yahoo.com --- .../btHeightfieldTerrainShape.cpp | 20 ++++++++++--------- .../btHeightfieldTerrainShape.h | 13 +++++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp index cc5a04e82..875d58ef8 100644 --- a/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp +++ b/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp @@ -144,7 +144,12 @@ void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin, aabbMax = center + extent; } -btScalar btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const + +/// This returns the "raw" (user's initial) height, not the actual height. +/// The actual height needs to be adjusted to be relative to the center +/// of the heightfield's AABB. +btScalar +btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const { btScalar val = 0.f; switch (m_heightDataType) @@ -181,24 +186,22 @@ btScalar btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const - +/// this returns the vertex in bullet-local coordinates void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const { - btAssert(x>=0); btAssert(y>=0); btAssert(x