From 16fc7a300fe88e7fb1250c0f4ab98bb2ec58d9c3 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Fri, 22 Jan 2021 13:51:23 +0000 Subject: [PATCH] Reduce 2D default safe margin to 0.001 --- doc/classes/KinematicBody2D.xml | 2 +- doc/classes/PhysicsServer2D.xml | 2 +- doc/classes/RigidBody2D.xml | 2 +- scene/2d/physics_body_2d.cpp | 4 ++-- scene/2d/physics_body_2d.h | 2 +- servers/physics_2d/space_2d_sw.cpp | 2 +- servers/physics_server_2d.cpp | 2 +- servers/physics_server_2d.h | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/classes/KinematicBody2D.xml b/doc/classes/KinematicBody2D.xml index 476b64a336f9..2e41368c879f 100644 --- a/doc/classes/KinematicBody2D.xml +++ b/doc/classes/KinematicBody2D.xml @@ -161,7 +161,7 @@ - + If the body is at least this close to another body, this body will consider them to be colliding. diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml index 6a1508b0e376..cf11d687e1f8 100644 --- a/doc/classes/PhysicsServer2D.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -818,7 +818,7 @@ - + diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 6b27c77f26af..16b30c828309 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -107,7 +107,7 @@ - + diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index ee625fb6f98e..da561907befd 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -794,7 +794,7 @@ void RigidBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidBody2D::set_can_sleep); ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidBody2D::is_able_to_sleep); - ClassDB::bind_method(D_METHOD("test_motion", "motion", "infinite_inertia", "margin", "result"), &RigidBody2D::_test_motion, DEFVAL(true), DEFVAL(0.08), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("test_motion", "motion", "infinite_inertia", "margin", "result"), &RigidBody2D::_test_motion, DEFVAL(true), DEFVAL(0.001), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("_direct_state_changed"), &RigidBody2D::_direct_state_changed); @@ -1247,7 +1247,7 @@ void KinematicBody2D::_bind_methods() { KinematicBody2D::KinematicBody2D() : PhysicsBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) { - margin = 0.08; + margin = 0.001; on_floor = false; on_ceiling = false; diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index b2a4aed01957..c2b856ea6778 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -176,7 +176,7 @@ class RigidBody2D : public PhysicsBody2D { void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape); void _direct_state_changed(Object *p_state); - bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, real_t p_margin = 0.08, const Ref &p_result = Ref()); + bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, real_t p_margin = 0.001, const Ref &p_result = Ref()); protected: void _notification(int p_what); diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 05136e2501c4..493174c2b70c 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -1324,7 +1324,7 @@ Space2DSW::Space2DSW() { contact_recycle_radius = 1.0; contact_max_separation = 1.5; contact_max_allowed_penetration = 0.3; - test_motion_min_contact_depth = 0.005; + test_motion_min_contact_depth = 0.0001; constraint_bias = 0.2; body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_linear", 2.0); diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp index 7c36229e9fde..2e8b83671f6d 100644 --- a/servers/physics_server_2d.cpp +++ b/servers/physics_server_2d.cpp @@ -649,7 +649,7 @@ void PhysicsServer2D::_bind_methods() { ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer2D::body_set_force_integration_callback, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(0.001), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer2D::body_get_direct_state); diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 710eecfdec0e..eaef7d0c98c0 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -230,7 +230,7 @@ class PhysicsServer2D : public Object { static PhysicsServer2D *singleton; - virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, const Ref &p_result = Ref()); + virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, const Ref &p_result = Ref()); protected: static void _bind_methods();