From ac3d52d81b8eec06f4b60aa1545b7e1044fa89a2 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Tue, 22 Dec 2009 21:19:41 +0000 Subject: [PATCH] bugfix in aabb expansion, causing the convexSweepTest to fail in certain cases (when the AABB is not symmetric around the origin) Thanks to fishboy82 for the report and fix: See http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4484 http://code.google.com/p/bullet/issues/detail?id=322 --- src/BulletCollision/BroadphaseCollision/btDbvt.h | 4 ++-- .../BroadphaseCollision/btQuantizedBvh.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BulletCollision/BroadphaseCollision/btDbvt.h b/src/BulletCollision/BroadphaseCollision/btDbvt.h index d733fedf2..061b5030f 100644 --- a/src/BulletCollision/BroadphaseCollision/btDbvt.h +++ b/src/BulletCollision/BroadphaseCollision/btDbvt.h @@ -961,8 +961,8 @@ inline void btDbvt::rayTestInternal( const btDbvtNode* root, do { const btDbvtNode* node=stack[--depth]; - bounds[0] = node->volume.Mins()+aabbMin; - bounds[1] = node->volume.Maxs()+aabbMax; + bounds[0] = node->volume.Mins()-aabbMax; + bounds[1] = node->volume.Maxs()-aabbMin; btScalar tmin=1.f,lambda_min=0.f; unsigned int result1=false; result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); diff --git a/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp b/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp index edd890ebb..9a35242fb 100644 --- a/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp +++ b/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp @@ -493,8 +493,8 @@ void btQuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall bounds[0] = rootNode->m_aabbMinOrg; bounds[1] = rootNode->m_aabbMaxOrg; /* Add box cast extents */ - bounds[0] += aabbMin; - bounds[1] += aabbMax; + bounds[0] -= aabbMax; + bounds[1] -= aabbMin; aabbOverlap = TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg); //perhaps profile if it is worth doing the aabbOverlap test first @@ -617,8 +617,8 @@ void btQuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* bounds[0] = unQuantize(rootNode->m_quantizedAabbMin); bounds[1] = unQuantize(rootNode->m_quantizedAabbMax); /* Add box cast extents */ - bounds[0] += aabbMin; - bounds[1] += aabbMax; + bounds[0] -= aabbMax; + bounds[1] -= aabbMin; btVector3 normal; #if 0 bool ra2 = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);