Hack as a hot fix for Bullet's collision margin issue
(cherry picked from commit b3210c5cd6
)
This commit is contained in:
parent
5296ab8cd6
commit
6029200662
3 changed files with 10 additions and 1 deletions
|
@ -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);
|
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 Bullet’s 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.
|
// 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.
|
// 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) {
|
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
|
||||||
motion_cache.instance();
|
motion_cache.instance();
|
||||||
|
|
|
@ -810,6 +810,7 @@ PhysicsServer::~PhysicsServer() {
|
||||||
|
|
||||||
Vector<PhysicsServerManager::ClassInfo> PhysicsServerManager::physics_servers;
|
Vector<PhysicsServerManager::ClassInfo> PhysicsServerManager::physics_servers;
|
||||||
int PhysicsServerManager::default_server_id = -1;
|
int PhysicsServerManager::default_server_id = -1;
|
||||||
|
int PhysicsServerManager::current_server_id = -1;
|
||||||
int PhysicsServerManager::default_server_priority = -1;
|
int PhysicsServerManager::default_server_priority = -1;
|
||||||
const String PhysicsServerManager::setting_property_name(PNAME("physics/3d/physics_engine"));
|
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() {
|
PhysicsServer *PhysicsServerManager::new_default_server() {
|
||||||
ERR_FAIL_COND_V(default_server_id == -1, nullptr);
|
ERR_FAIL_COND_V(default_server_id == -1, nullptr);
|
||||||
|
current_server_id = default_server_id;
|
||||||
return physics_servers[default_server_id].create_callback();
|
return physics_servers[default_server_id].create_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,6 +867,7 @@ PhysicsServer *PhysicsServerManager::new_server(const String &p_name) {
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
current_server_id = id;
|
||||||
return physics_servers[id].create_callback();
|
return physics_servers[id].create_callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,6 +807,7 @@ class PhysicsServerManager {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const String setting_property_name;
|
static const String setting_property_name;
|
||||||
|
static int current_server_id;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void on_servers_changed();
|
static void on_servers_changed();
|
||||||
|
|
Loading…
Reference in a new issue