Merge pull request #64875 from fabriceci/ulgy-hack-bullet-margin

This commit is contained in:
Rémi Verschelde 2022-08-30 11:44:25 +02:00 committed by GitHub
commit bbaedffb93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -962,8 +962,13 @@ Ref<KinematicCollision> KinematicBody::_move(const Vector3 &p_motion, bool p_inf
bool collided = move_and_collide(p_motion, p_infinite_inertia, col, p_exclude_raycast_shapes, p_test_only);
// Ugly hack as a hot fix, 65b3200 fix an issue but cause a problem with Bullet that broke games using Bullet.
// The bug is something internal to Bullet, seems to be related to the Bullets margin. As not proper fix was found yet,
// this temporary solution solves the issue for games using Bullet.
bool is_bullet = PhysicsServerManager::current_server_id != 0;
// Don't report collision when the whole motion is done.
if (collided && col.collision_safe_fraction < 1) {
if (collided && (col.collision_safe_fraction < 1 || is_bullet)) {
// Create a new instance when the cached reference is invalid or still in use in script.
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
motion_cache.instance();

View File

@ -810,6 +810,7 @@ PhysicsServer::~PhysicsServer() {
Vector<PhysicsServerManager::ClassInfo> PhysicsServerManager::physics_servers;
int PhysicsServerManager::default_server_id = -1;
int PhysicsServerManager::current_server_id = -1;
int PhysicsServerManager::default_server_priority = -1;
const String PhysicsServerManager::setting_property_name(PNAME("physics/3d/physics_engine"));
@ -857,6 +858,7 @@ String PhysicsServerManager::get_server_name(int p_id) {
PhysicsServer *PhysicsServerManager::new_default_server() {
ERR_FAIL_COND_V(default_server_id == -1, nullptr);
current_server_id = default_server_id;
return physics_servers[default_server_id].create_callback();
}
@ -865,6 +867,7 @@ PhysicsServer *PhysicsServerManager::new_server(const String &p_name) {
if (id == -1) {
return nullptr;
} else {
current_server_id = id;
return physics_servers[id].create_callback();
}
}

View File

@ -807,6 +807,7 @@ class PhysicsServerManager {
public:
static const String setting_property_name;
static int current_server_id;
private:
static void on_servers_changed();