diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-02-16 11:06:17 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-02-16 11:06:44 -0300 |
commit | f439b786ea4b317c7e30a978e1b61a9578f1f483 (patch) | |
tree | 24f05407048022ef3ad7d56d2335940cf7b9593b | |
parent | 9ae86e90f9dcf6ad8bf706d0e858c45eb3a25eed (diff) |
Allow kinematic bodies without shapes to still move, fixes #24775
-rw-r--r-- | servers/physics/space_sw.cpp | 5 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 4 | ||||
-rw-r--r-- | servers/physics_2d_server.h | 6 | ||||
-rw-r--r-- | servers/physics_server.h | 5 |
4 files changed, 20 insertions, 0 deletions
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 1087cd2483..d1e1d1f8a2 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -717,6 +717,11 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve } if (!shapes_found) { + if (r_result) { + *r_result = PhysicsServer::MotionResult(); + r_result->motion = p_motion; + } + return false; } diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 4ea87efc52..bf7adb62a4 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -704,6 +704,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } if (!shapes_found) { + if (r_result) { + *r_result = Physics2DServer::MotionResult(); + r_result->motion = p_motion; + } return false; } diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index df7fe46f76..dbf50425ff 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -504,6 +504,12 @@ public: RID collider; int collider_shape; Variant collider_metadata; + + MotionResult() { + collision_local_shape = 0; + collider_shape = 0; + collider_id = 0; + } }; 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, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true) = 0; diff --git a/servers/physics_server.h b/servers/physics_server.h index 4ba096a994..f2d4c941bf 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -492,6 +492,11 @@ public: RID collider; int collider_shape; Variant collider_metadata; + MotionResult() { + collision_local_shape = 0; + collider_id = 0; + collider_shape = 0; + } }; virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true) = 0; |