From 10544f1cf777324efc676565ecc698f8ba9f06e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 28 Jul 2020 11:29:29 +0200 Subject: [PATCH] Revert "Move Bullet physics query flush from Bullet space pre-tick callback to" This reverts commit e7d8464f87881af455d49e505d9a5bd9b3b3bf43. Fixes #40508 regression. This will be re-applied and the regression fixed for a future 3.2.x release. --- modules/bullet/bullet_physics_server.cpp | 6 ------ modules/bullet/space_bullet.cpp | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index c211888611b..6662e130c8d 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -1572,12 +1572,6 @@ void BulletPhysicsServer::sync() { } void BulletPhysicsServer::flush_queries() { - if (!active) - return; - - for (int i = 0; i < active_spaces_count; ++i) { - active_spaces[i]->flush_queries(); - } } void BulletPhysicsServer::finish() { diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index f5352c47d54..ec9db926f0b 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -561,6 +561,10 @@ void SpaceBullet::remove_all_collision_objects() { } } +void onBulletPreTickCallback(btDynamicsWorld *p_dynamicsWorld, btScalar timeStep) { + static_cast(p_dynamicsWorld->getWorldUserInfo())->flush_queries(); +} + void onBulletTickCallback(btDynamicsWorld *p_dynamicsWorld, btScalar timeStep) { const btCollisionObjectArray &colObjArray = p_dynamicsWorld->getCollisionObjectArray(); @@ -632,6 +636,7 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) { dynamicsWorld->setWorldUserInfo(this); + dynamicsWorld->setInternalTickCallback(onBulletPreTickCallback, this, true); dynamicsWorld->setInternalTickCallback(onBulletTickCallback, this, false); dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(ghostPairCallback); // Setup ghost check dynamicsWorld->getPairCache()->setOverlapFilterCallback(godotFilterCallback);