Add option to hide navmesh in editor debug view

This commit is contained in:
Wojtek Figat
2021-01-13 15:21:50 +01:00
parent d1a282e228
commit af692605ab
2 changed files with 35 additions and 0 deletions

View File

@@ -34,6 +34,15 @@ public:
/// </summary>
AssetReference<RawDataAsset> DataAsset;
#if USE_EDITOR
/// <summary>
/// If checked, the navmesh will be drawn in debug view when showing navigation data.
/// </summary>
API_FIELD(Attributes="EditorOrder(-10), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true;
#endif
/// <summary>
/// The navigation mesh properties.
/// </summary>

View File

@@ -8,7 +8,12 @@
#include "Engine/Content/Content.h"
#include "Engine/Content/JsonAsset.h"
#include "Engine/Threading/Threading.h"
#if USE_EDITOR
#include "Engine/Level/Level.h"
#include "Engine/Level/Scene/Scene.h"
#endif
#include "NavMesh.h"
#include "Engine/Engine/EngineService.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Serialization/Serialization.h"
@@ -263,6 +268,27 @@ void Navigation::DrawNavMesh()
{
for (auto navMesh : NavMeshes)
{
#if USE_EDITOR
// Skip drawing if any of the navmeshes on scene has disabled ShowDebugDraw option
bool skip = false;
for (auto scene : Level::Scenes)
{
for (auto e : scene->NavigationMeshes)
{
if (e->Properties == navMesh->Properties)
{
if (!e->ShowDebugDraw)
{
skip = true;
}
break;
}
}
}
if (skip)
continue;
#endif
navMesh->DebugDraw();
}
}