summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-06-21 16:49:49 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-06-21 16:49:49 +0200
commit2bb4d5dee1a25256dce65aa59380c5a79ac02b41 (patch)
tree06e3106e3c132378b7106ff8acf28d285a9e307d
parent0e4b06a8300e096939ef2f4937d4821cfb1a5b7c (diff)
parentd98a2b1a8b18ebc1b4c0c2931d6087833d25b61e (diff)
downloadredot-engine-2bb4d5dee1a25256dce65aa59380c5a79ac02b41.tar.gz
Merge pull request #93423 from smix8/ref_that
Fix potential crash due to invalid navigation mesh ref
-rw-r--r--modules/navigation/nav_region.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/navigation/nav_region.cpp b/modules/navigation/nav_region.cpp
index fc1db391ae..c91071a3ab 100644
--- a/modules/navigation/nav_region.cpp
+++ b/modules/navigation/nav_region.cpp
@@ -84,11 +84,11 @@ void NavRegion::set_transform(Transform3D p_transform) {
void NavRegion::set_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh) {
#ifdef DEBUG_ENABLED
- if (map && !Math::is_equal_approx(double(map->get_cell_size()), double(p_navigation_mesh->get_cell_size()))) {
+ if (map && p_navigation_mesh.is_valid() && !Math::is_equal_approx(double(map->get_cell_size()), double(p_navigation_mesh->get_cell_size()))) {
ERR_PRINT_ONCE(vformat("Attempted to update a navigation region with a navigation mesh that uses a `cell_size` of %s while assigned to a navigation map set to a `cell_size` of %s. The cell size for navigation maps can be changed by using the NavigationServer map_set_cell_size() function. The cell size for default navigation maps can also be changed in the ProjectSettings.", double(p_navigation_mesh->get_cell_size()), double(map->get_cell_size())));
}
- if (map && !Math::is_equal_approx(double(map->get_cell_height()), double(p_navigation_mesh->get_cell_height()))) {
+ if (map && p_navigation_mesh.is_valid() && !Math::is_equal_approx(double(map->get_cell_height()), double(p_navigation_mesh->get_cell_height()))) {
ERR_PRINT_ONCE(vformat("Attempted to update a navigation region with a navigation mesh that uses a `cell_height` of %s while assigned to a navigation map set to a `cell_height` of %s. The cell height for navigation maps can be changed by using the NavigationServer map_set_cell_height() function. The cell height for default navigation maps can also be changed in the ProjectSettings.", double(p_navigation_mesh->get_cell_height()), double(map->get_cell_height())));
}
#endif // DEBUG_ENABLED