Add area to moved list when changing monitorable,
and only remove area from query when deleting pair if it was monitorable.
This commit is contained in:
parent
c6d2768a19
commit
1d1ceca6b4
6 changed files with 18 additions and 8 deletions
|
@ -213,6 +213,7 @@ void GodotArea2D::set_monitorable(bool p_monitorable) {
|
|||
|
||||
monitorable = p_monitorable;
|
||||
_set_static(!monitorable);
|
||||
_shapes_changed();
|
||||
}
|
||||
|
||||
void GodotArea2D::call_queries() {
|
||||
|
|
|
@ -128,7 +128,7 @@ bool GodotArea2Pair2D::setup(real_t p_step) {
|
|||
|
||||
process_collision_a = false;
|
||||
if (result_a != colliding_a) {
|
||||
if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) {
|
||||
if (area_a->has_area_monitor_callback() && area_b_monitorable) {
|
||||
process_collision_a = true;
|
||||
process_collision = true;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ bool GodotArea2Pair2D::setup(real_t p_step) {
|
|||
|
||||
process_collision_b = false;
|
||||
if (result_b != colliding_b) {
|
||||
if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) {
|
||||
if (area_b->has_area_monitor_callback() && area_a_monitorable) {
|
||||
process_collision_b = true;
|
||||
process_collision = true;
|
||||
}
|
||||
|
@ -176,19 +176,21 @@ GodotArea2Pair2D::GodotArea2Pair2D(GodotArea2D *p_area_a, int p_shape_a, GodotAr
|
|||
area_b = p_area_b;
|
||||
shape_a = p_shape_a;
|
||||
shape_b = p_shape_b;
|
||||
area_a_monitorable = area_a->is_monitorable();
|
||||
area_b_monitorable = area_b->is_monitorable();
|
||||
area_a->add_constraint(this);
|
||||
area_b->add_constraint(this);
|
||||
}
|
||||
|
||||
GodotArea2Pair2D::~GodotArea2Pair2D() {
|
||||
if (colliding_a) {
|
||||
if (area_a->has_area_monitor_callback()) {
|
||||
if (area_a->has_area_monitor_callback() && area_b_monitorable) {
|
||||
area_a->remove_area_from_query(area_b, shape_b, shape_a);
|
||||
}
|
||||
}
|
||||
|
||||
if (colliding_b) {
|
||||
if (area_b->has_area_monitor_callback()) {
|
||||
if (area_b->has_area_monitor_callback() && area_a_monitorable) {
|
||||
area_b->remove_area_from_query(area_a, shape_a, shape_b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@ class GodotArea2Pair2D : public GodotConstraint2D {
|
|||
bool colliding_b = false;
|
||||
bool process_collision_a = false;
|
||||
bool process_collision_b = false;
|
||||
bool area_a_monitorable;
|
||||
bool area_b_monitorable;
|
||||
|
||||
public:
|
||||
virtual bool setup(real_t p_step) override;
|
||||
|
|
|
@ -242,6 +242,7 @@ void GodotArea3D::set_monitorable(bool p_monitorable) {
|
|||
|
||||
monitorable = p_monitorable;
|
||||
_set_static(!monitorable);
|
||||
_shapes_changed();
|
||||
}
|
||||
|
||||
void GodotArea3D::call_queries() {
|
||||
|
|
|
@ -129,7 +129,7 @@ bool GodotArea2Pair3D::setup(real_t p_step) {
|
|||
|
||||
process_collision_a = false;
|
||||
if (result_a != colliding_a) {
|
||||
if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) {
|
||||
if (area_a->has_area_monitor_callback() && area_b_monitorable) {
|
||||
process_collision_a = true;
|
||||
process_collision = true;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ bool GodotArea2Pair3D::setup(real_t p_step) {
|
|||
|
||||
process_collision_b = false;
|
||||
if (result_b != colliding_b) {
|
||||
if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) {
|
||||
if (area_b->has_area_monitor_callback() && area_a_monitorable) {
|
||||
process_collision_b = true;
|
||||
process_collision = true;
|
||||
}
|
||||
|
@ -177,19 +177,21 @@ GodotArea2Pair3D::GodotArea2Pair3D(GodotArea3D *p_area_a, int p_shape_a, GodotAr
|
|||
area_b = p_area_b;
|
||||
shape_a = p_shape_a;
|
||||
shape_b = p_shape_b;
|
||||
area_a_monitorable = area_a->is_monitorable();
|
||||
area_b_monitorable = area_b->is_monitorable();
|
||||
area_a->add_constraint(this);
|
||||
area_b->add_constraint(this);
|
||||
}
|
||||
|
||||
GodotArea2Pair3D::~GodotArea2Pair3D() {
|
||||
if (colliding_a) {
|
||||
if (area_a->has_area_monitor_callback()) {
|
||||
if (area_a->has_area_monitor_callback() && area_b_monitorable) {
|
||||
area_a->remove_area_from_query(area_b, shape_b, shape_a);
|
||||
}
|
||||
}
|
||||
|
||||
if (colliding_b) {
|
||||
if (area_b->has_area_monitor_callback()) {
|
||||
if (area_b->has_area_monitor_callback() && area_a_monitorable) {
|
||||
area_b->remove_area_from_query(area_a, shape_a, shape_b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ class GodotArea2Pair3D : public GodotConstraint3D {
|
|||
bool colliding_b = false;
|
||||
bool process_collision_a = false;
|
||||
bool process_collision_b = false;
|
||||
bool area_a_monitorable;
|
||||
bool area_b_monitorable;
|
||||
|
||||
public:
|
||||
virtual bool setup(real_t p_step) override;
|
||||
|
|
Loading…
Reference in a new issue