Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] Reduce 2D default safe margin to 0.001 #45362

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/classes/KinematicBody2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</method>
</methods>
<members>
<member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin" default="0.08">
<member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin" default="0.001">
If the body is at least this close to another body, this body will consider them to be colliding.
</member>
<member name="motion/sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Physics2DServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@
</argument>
<argument index="3" name="infinite_inertia" type="bool">
</argument>
<argument index="4" name="margin" type="float" default="0.08">
<argument index="4" name="margin" type="float" default="0.001">
</argument>
<argument index="5" name="result" type="Physics2DTestMotionResult" default="null">
</argument>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/RigidBody2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
</argument>
<argument index="1" name="infinite_inertia" type="bool" default="true">
</argument>
<argument index="2" name="margin" type="float" default="0.08">
<argument index="2" name="margin" type="float" default="0.001">
</argument>
<argument index="3" name="result" type="Physics2DTestMotionResult" default="null">
</argument>
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/physics_body_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,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);
ClassDB::bind_method(D_METHOD("_body_enter_tree"), &RigidBody2D::_body_enter_tree);
Expand Down Expand Up @@ -1504,7 +1504,7 @@ void KinematicBody2D::_bind_methods() {
KinematicBody2D::KinematicBody2D() :
PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC) {

margin = 0.08;
margin = 0.001;

on_floor = false;
on_ceiling = false;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/physics_body_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.001, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());

protected:
void _notification(int p_what);
Expand Down
2 changes: 1 addition & 1 deletion servers/physics_2d/space_2d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,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);
Expand Down
2 changes: 1 addition & 1 deletion servers/physics_2d_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ void Physics2DServer::_bind_methods() {

ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &Physics2DServer::body_set_force_integration_callback, DEFVAL(Variant()));

ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &Physics2DServer::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &Physics2DServer::_body_test_motion, DEFVAL(0.001), DEFVAL(Variant()));

ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &Physics2DServer::body_get_direct_state);

Expand Down
2 changes: 1 addition & 1 deletion servers/physics_2d_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class Physics2DServer : public Object {

static Physics2DServer *singleton;

virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.001, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());

protected:
static void _bind_methods();
Expand Down