From 11aeaaa2cf175772f2db18c3ddbf9dca6c2e61d8 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Wed, 6 Oct 2021 16:06:03 -0700 Subject: [PATCH] Make body_test_motion thread safe for multi-threaded physics Needs proper synchro with the command buffer for thread safety, in case physics is not running on the main thread. --- servers/physics_2d/physics_2d_server_wrap_mt.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index a4ee5ef4311..dce042d9b42 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -251,15 +251,8 @@ public: FUNC2(body_set_pickable, RID, bool); - 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, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true, const Set &p_exclude = Set()) { - ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false); - return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes, p_exclude); - } - - int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.08) { - ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false); - return physics_2d_server->body_test_ray_separation(p_body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin); - } + FUNC8R(bool, body_test_motion, RID, const Transform2D &, const Vector2 &, bool, real_t, MotionResult *, bool, const Set &); + FUNC7R(int, body_test_ray_separation, RID, const Transform2D &, bool, Vector2 &, SeparationResult *, int, float); // this function only works on physics process, errors and returns null otherwise Physics2DDirectBodyState *body_get_direct_state(RID p_body) {