Skip to content

Commit

Permalink
Make query checks less agressive, fixes #24694
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Mar 2, 2019
1 parent a42549b commit b84b015
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion scene/2d/area_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ void Area2D::set_monitorable(bool p_enable) {

if (locked || (is_inside_tree() && Physics2DServer::get_singleton()->is_flushing_queries())) {
ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitorable\",true/false)");
ERR_FAIL();
}
ERR_FAIL_COND(locked || Physics2DServer::get_singleton()->is_flushing_queries());

if (p_enable == monitorable)
return;
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ void Area::set_monitorable(bool p_enable) {

if (locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries())) {
ERR_EXPLAIN("Function blocked during in/out signal. Use set_deferred(\"monitorable\",true/false)");
ERR_FAIL();
}
ERR_FAIL_COND(locked || PhysicsServer::get_singleton()->is_flushing_queries());

if (p_enable == monitorable)
return;
Expand Down
18 changes: 8 additions & 10 deletions servers/physics/physics_server_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
21 changes: 8 additions & 13 deletions servers/physics_2d/physics_2d_server_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); \
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -734,21 +731,19 @@ 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);
}
void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {

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);
}
Expand Down

0 comments on commit b84b015

Please sign in to comment.