summaryrefslogtreecommitdiff
path: root/servers/physics_3d
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2021-11-20 06:57:34 +0000
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2021-11-20 06:57:34 +0000
commit1d1ceca6b4307f8e5eabe890a24759d429bbe346 (patch)
tree94fbc0d1a2d2961df9bbc5183d5d3e11f2723ddd /servers/physics_3d
parentc6d2768a192eedf9a7903e8fd7b3f6ffa771db11 (diff)
Add area to moved list when changing monitorable,
and only remove area from query when deleting pair if it was monitorable.
Diffstat (limited to 'servers/physics_3d')
-rw-r--r--servers/physics_3d/godot_area_3d.cpp1
-rw-r--r--servers/physics_3d/godot_area_pair_3d.cpp10
-rw-r--r--servers/physics_3d/godot_area_pair_3d.h2
3 files changed, 9 insertions, 4 deletions
diff --git a/servers/physics_3d/godot_area_3d.cpp b/servers/physics_3d/godot_area_3d.cpp
index 9cdad069fe..d4e14b8d85 100644
--- a/servers/physics_3d/godot_area_3d.cpp
+++ b/servers/physics_3d/godot_area_3d.cpp
@@ -242,6 +242,7 @@ void GodotArea3D::set_monitorable(bool p_monitorable) {
monitorable = p_monitorable;
_set_static(!monitorable);
+ _shapes_changed();
}
void GodotArea3D::call_queries() {
diff --git a/servers/physics_3d/godot_area_pair_3d.cpp b/servers/physics_3d/godot_area_pair_3d.cpp
index d3623178d5..58188565e3 100644
--- a/servers/physics_3d/godot_area_pair_3d.cpp
+++ b/servers/physics_3d/godot_area_pair_3d.cpp
@@ -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);
}
}
diff --git a/servers/physics_3d/godot_area_pair_3d.h b/servers/physics_3d/godot_area_pair_3d.h
index 16175e9fa8..4237e7722e 100644
--- a/servers/physics_3d/godot_area_pair_3d.h
+++ b/servers/physics_3d/godot_area_pair_3d.h
@@ -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;