Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Jolt: Remove forced area event queuing during body exit

Mikael Hermansson2a7d14671a8d
diff --git a/modules/jolt_physics/objects/jolt_area_3d.cpp b/modules/jolt_physics/objects/jolt_area_3d.cpp
index 297cb7a187f..1eb7c7dcf9a 100644
--- a/modules/jolt_physics/objects/jolt_area_3d.cpp
+++ b/modules/jolt_physics/objects/jolt_area_3d.cpp
@@ -611,52 +611,6 @@ bool JoltArea3D::shape_exited(const JPH::BodyID &p_body_id, const JPH::SubShapeI
return body_shape_exited(p_body_id, p_other_shape_id, p_self_shape_id) || area_shape_exited(p_body_id, p_other_shape_id, p_self_shape_id);
}
-void JoltArea3D::body_exited(const JPH::BodyID &p_body_id, bool p_notify) {
- Overlap *overlap = bodies_by_id.getptr(p_body_id);
- if (unlikely(overlap == nullptr)) {
- return;
- }
-
- if (unlikely(overlap->shape_pairs.is_empty())) {
- return;
- }
-
- for (const KeyValue<ShapeIDPair, ShapeIndexPair> &E : overlap->shape_pairs) {
- if (!overlap->pending_added.erase(E.value)) {
- overlap->pending_removed.push_back(E.value);
- }
- }
-
- _events_changed();
-
- overlap->shape_pairs.clear();
-
- if (p_notify) {
- _notify_body_exited(p_body_id);
- }
-}
-
-void JoltArea3D::area_exited(const JPH::BodyID &p_body_id) {
- Overlap *overlap = areas_by_id.getptr(p_body_id);
- if (unlikely(overlap == nullptr)) {
- return;
- }
-
- if (unlikely(overlap->shape_pairs.is_empty())) {
- return;
- }
-
- for (const KeyValue<ShapeIDPair, ShapeIndexPair> &E : overlap->shape_pairs) {
- if (!overlap->pending_added.erase(E.value)) {
- overlap->pending_removed.push_back(E.value);
- }
- }
-
- _events_changed();
-
- overlap->shape_pairs.clear();
-}
-
void JoltArea3D::call_queries() {
_flush_events(bodies_by_id, body_monitor_callback);
_flush_events(areas_by_id, area_monitor_callback);
diff --git a/modules/jolt_physics/objects/jolt_area_3d.h b/modules/jolt_physics/objects/jolt_area_3d.h
index 4a6824e636c..7ffb5410647 100644
--- a/modules/jolt_physics/objects/jolt_area_3d.h
+++ b/modules/jolt_physics/objects/jolt_area_3d.h
@@ -241,8 +241,6 @@ public:
bool area_shape_exited(const JPH::BodyID &p_body_id, const JPH::SubShapeID &p_other_shape_id, const JPH::SubShapeID &p_self_shape_id);
bool shape_exited(const JPH::BodyID &p_body_id, const JPH::SubShapeID &p_other_shape_id, const JPH::SubShapeID &p_self_shape_id);
- void body_exited(const JPH::BodyID &p_body_id, bool p_notify = true);
- void area_exited(const JPH::BodyID &p_body_id);
void call_queries();
diff --git a/modules/jolt_physics/objects/jolt_body_3d.cpp b/modules/jolt_physics/objects/jolt_body_3d.cpp
index a018bcef488..4c3ab6f35de 100644
--- a/modules/jolt_physics/objects/jolt_body_3d.cpp
+++ b/modules/jolt_physics/objects/jolt_body_3d.cpp
@@ -389,17 +389,12 @@ void JoltBody3D::_destroy_joint_constraints() {
}
}
-void JoltBody3D::_exit_all_areas() {
+void JoltBody3D::_clear_areas() {
if (!in_space()) {
return;
}
- for (JoltArea3D *area : areas) {
- area->body_exited(jolt_body->GetID(), false);
- }
-
areas.clear();
-
_areas_changed();
}
@@ -435,7 +430,7 @@ void JoltBody3D::_space_changing() {
sleep_initially = is_sleeping();
_destroy_joint_constraints();
- _exit_all_areas();
+ _clear_areas();
_dequeue_call_queries();
}
diff --git a/modules/jolt_physics/objects/jolt_body_3d.h b/modules/jolt_physics/objects/jolt_body_3d.h
index ce5d8588a99..a9f833b08e2 100644
--- a/modules/jolt_physics/objects/jolt_body_3d.h
+++ b/modules/jolt_physics/objects/jolt_body_3d.h
@@ -135,7 +135,7 @@ private:
void _destroy_joint_constraints();
- void _exit_all_areas();
+ void _clear_areas();
void _mode_changed();
virtual void _shapes_committed() override;