From 9c8238ba72e3ff9b0d5e6c0e00d70b36c7be2c76 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Wed, 11 May 2022 15:36:50 +0200 Subject: [PATCH] Add Warning to NavigationMesh bake when source geometry is suspiciously big Adds Warning when users try to bake a NavigationMesh with suspiciously big source geometry and small cellsizes as this baking process will likely fail or result in a NavigationMesh that will create serious pathfinding performance issues. (cherry picked from commit 79511af7c94b447409d10194239069facef9c4a0) --- modules/navigation/navigation_mesh_generator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 9cc737cad..6781e5640 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -355,6 +355,14 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( #endif rcCalcGridSize(cfg.bmin, cfg.bmax, cfg.cs, &cfg.width, &cfg.height); + // ~30000000 seems to be around sweetspot where Editor baking breaks + if ((cfg.width * cfg.height) > 30000000) { + WARN_PRINT("NavigationMesh baking process will likely fail." + "\nSource geometry is suspiciously big for the current Cell Size and Cell Height in the NavMesh Resource bake settings." + "\nIf baking does not fail, the resulting NavigationMesh will create serious pathfinding performance issues." + "\nIt is advised to increase Cell Size and/or Cell Height in the NavMesh Resource bake settings or reduce the size / scale of the source geometry."); + } + #ifdef TOOLS_ENABLED if (ep) ep->step(TTR("Creating heightfield..."), 3);