From 56e072ccc6f9768e34b071ce942c3466dc61ba21 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Sat, 17 Nov 2007 17:07:58 +0000 Subject: [PATCH] fixed memory leak in btMultiSapBroadphase, fixed hash function (typo, should use 2 proxies) Thanks to Stephen (shatcher) for reporting and fixes! http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1696 --- .../BroadphaseCollision/btMultiSapBroadphase.cpp | 2 +- .../BroadphaseCollision/btOverlappingPairCache.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp b/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp index a75689c99..2799b2248 100644 --- a/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp +++ b/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp @@ -80,7 +80,7 @@ btBroadphaseProxy* btMultiSapBroadphase::createProxy( const btVector3& aabbMin, simpleProxy->m_multiSapParentProxy = proxy; mem = btAlignedAlloc(sizeof(btChildProxy),16); - btChildProxy* childProxyRef = new btChildProxy(); + btChildProxy* childProxyRef = new(mem) btChildProxy(); childProxyRef->m_proxy = simpleProxy; childProxyRef->m_childBroadphase = m_simpleBroadphase; proxy->m_childProxies.push_back(childProxyRef); diff --git a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h index 8930dbaa9..c3a9339e0 100644 --- a/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h +++ b/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h @@ -177,7 +177,7 @@ private: SIMD_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2) { - int key = ((unsigned int)proxyId1) | (((unsigned int)proxyId1) <<16); + int key = ((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16); // Thomas Wang's hash key += ~(key << 15);