summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-06-18 14:08:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-06-18 14:08:58 +0200
commit29654bdc4ff752d1206a87dcc172faa6a85655f8 (patch)
treedca863032c17ca5badc21e7c5584e0f8e31649fa /servers
parent6c399a434dc8027c07242d96fbef1e4e49ac5daf (diff)
parentef9b82a0760a769459f3e3402515e56f269844d4 (diff)
downloadredot-engine-29654bdc4ff752d1206a87dcc172faa6a85655f8.tar.gz
Merge pull request #93286 from rune-scape/fix-rare-physics-crash
GodotPhysics: Fix crash on null space
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/godot_body_2d.cpp4
-rw-r--r--servers/physics_3d/godot_body_3d.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp
index 01996dc43c..c401e6eee7 100644
--- a/servers/physics_2d/godot_body_2d.cpp
+++ b/servers/physics_2d/godot_body_2d.cpp
@@ -616,6 +616,8 @@ void GodotBody2D::integrate_velocities(real_t p_step) {
return;
}
+ ERR_FAIL_NULL(get_space());
+
if (fi_callback_data || body_state_callback.is_valid()) {
get_space()->body_add_to_state_query_list(&direct_state_query_list);
}
@@ -705,6 +707,8 @@ bool GodotBody2D::sleep_test(real_t p_step) {
return false;
}
+ ERR_FAIL_NULL_V(get_space(), true);
+
if (Math::abs(angular_velocity) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) {
still_time += p_step;
diff --git a/servers/physics_3d/godot_body_3d.cpp b/servers/physics_3d/godot_body_3d.cpp
index 407957b904..669c4b985b 100644
--- a/servers/physics_3d/godot_body_3d.cpp
+++ b/servers/physics_3d/godot_body_3d.cpp
@@ -675,6 +675,8 @@ void GodotBody3D::integrate_velocities(real_t p_step) {
return;
}
+ ERR_FAIL_NULL(get_space());
+
if (fi_callback_data || body_state_callback.is_valid()) {
get_space()->body_add_to_state_query_list(&direct_state_query_list);
}
@@ -784,6 +786,8 @@ bool GodotBody3D::sleep_test(real_t p_step) {
return false;
}
+ ERR_FAIL_NULL_V(get_space(), true);
+
if (Math::abs(angular_velocity.length()) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) {
still_time += p_step;