Corrected physics query max result checking

(cherry picked from commit 444b8471a3)
This commit is contained in:
Andrea Catania 2018-04-04 11:55:58 +02:00 committed by Hein-Pieter van Braam
parent 6989a7ac53
commit 5e09cf3e89
1 changed files with 10 additions and 3 deletions

View File

@ -63,6 +63,9 @@ bool GodotClosestRayResultCallback::needsCollision(btBroadphaseProxy *proxy0) co
} }
bool GodotAllConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { bool GodotAllConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
if (count >= m_resultMax)
return false;
const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask);
if (needs) { if (needs) {
btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject);
@ -70,6 +73,7 @@ bool GodotAllConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) con
if (m_exclude->has(gObj->get_self())) { if (m_exclude->has(gObj->get_self())) {
return false; return false;
} }
return true; return true;
} else { } else {
return false; return false;
@ -87,7 +91,7 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo
result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id); result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id);
++count; ++count;
return count < m_resultMax; return 1; // not used by bullet
} }
bool GodotKinClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { bool GodotKinClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
@ -176,6 +180,9 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
} }
bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
if (m_count >= m_resultMax)
return false;
const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask);
if (needs) { if (needs) {
btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject);
@ -201,7 +208,7 @@ btScalar GodotContactPairContactResultCallback::addSingleResult(btManifoldPoint
++m_count; ++m_count;
return m_count < m_resultMax; return 1; // Not used by bullet
} }
bool GodotRestInfoContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { bool GodotRestInfoContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
@ -247,7 +254,7 @@ btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp
m_collided = true; m_collided = true;
} }
return cp.getDistance(); return 1; // Not used by bullet
} }
void GodotDeepPenetrationContactResultCallback::addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorldOnB, btScalar depth) { void GodotDeepPenetrationContactResultCallback::addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorldOnB, btScalar depth) {