diff options
author | Juan Linietsky <juan@godotengine.org> | 2019-03-02 08:48:13 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2019-03-02 08:48:47 -0300 |
commit | b84b015225dffb373f409c929821da6961e6d485 (patch) | |
tree | bf6c149aacaf54b5e91060802a7a4c4d56047559 /servers | |
parent | a42549b8f703754a43bad2557357cb7046874118 (diff) |
Make query checks less agressive, fixes #24694
Diffstat (limited to 'servers')
-rw-r--r-- | servers/physics/physics_server_sw.cpp | 18 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 21 |
2 files changed, 16 insertions, 23 deletions
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 2975ae9453..36d18e8901 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -40,10 +40,10 @@ #include "joints/pin_joint_sw.h" #include "joints/slider_joint_sw.h" -#define FLUSH_QUERY_CHECK \ - if (flushing_queries) { \ - ERR_EXPLAIN("Can't change this state while flushing queries. Use call_deferred()/set_deferred() to change monitoring state instead"); \ - ERR_FAIL(); \ +#define FLUSH_QUERY_CHECK(m_object) \ + if (m_object->get_space() && flushing_queries) { \ + ERR_EXPLAIN("Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead"); \ + ERR_FAIL(); \ } RID PhysicsServerSW::shape_create(ShapeType p_shape) { @@ -358,11 +358,10 @@ void PhysicsServerSW::area_clear_shapes(RID p_area) { void PhysicsServerSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { - FLUSH_QUERY_CHECK - AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count()); + FLUSH_QUERY_CHECK(area); area->set_shape_as_disabled(p_shape_idx, p_disabled); } @@ -443,10 +442,9 @@ void PhysicsServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { void PhysicsServerSW::area_set_monitorable(RID p_area, bool p_monitorable) { - FLUSH_QUERY_CHECK - AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); + FLUSH_QUERY_CHECK(area); area->set_monitorable(p_monitorable); } @@ -592,11 +590,11 @@ RID PhysicsServerSW::body_get_shape(RID p_body, int p_shape_idx) const { void PhysicsServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { - FLUSH_QUERY_CHECK - BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); + FLUSH_QUERY_CHECK(body); + body->set_shape_as_disabled(p_shape_idx, p_disabled); } diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 4d1c56b843..283d20876d 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -36,8 +36,8 @@ #include "core/project_settings.h" #include "core/script_language.h" -#define FLUSH_QUERY_CHECK \ - if (flushing_queries) { \ +#define FLUSH_QUERY_CHECK(m_object) \ + if (m_object->get_space() && flushing_queries) { \ ERR_EXPLAIN("Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead"); \ ERR_FAIL(); \ } @@ -410,12 +410,11 @@ void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, co void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) { - FLUSH_QUERY_CHECK - Area2DSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); - ERR_FAIL_INDEX(p_shape, area->get_shape_count()); + FLUSH_QUERY_CHECK(area); + area->set_shape_as_disabled(p_shape, p_disabled); } @@ -550,10 +549,9 @@ void Physics2DServerSW::area_set_pickable(RID p_area, bool p_pickable) { void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) { - FLUSH_QUERY_CHECK - Area2DSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); + FLUSH_QUERY_CHECK(area); area->set_monitorable(p_monitorable); } @@ -630,10 +628,9 @@ RID Physics2DServerSW::body_get_space(RID p_body) const { void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) { - FLUSH_QUERY_CHECK - Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); + FLUSH_QUERY_CHECK(body); body->set_mode(p_mode); }; @@ -734,12 +731,10 @@ void Physics2DServerSW::body_clear_shapes(RID p_body) { void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { - FLUSH_QUERY_CHECK - Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); - ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); + FLUSH_QUERY_CHECK(body); body->set_shape_as_disabled(p_shape_idx, p_disabled); } @@ -747,8 +742,8 @@ void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); - ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); + FLUSH_QUERY_CHECK(body); body->set_shape_as_one_way_collision(p_shape_idx, p_enable, p_margin); } |