Now only drawing navmesh if selected + properly serialized

This commit is contained in:
Antoine Pilote
2024-08-05 23:48:41 -04:00
parent 67b5a94613
commit ca1d17e058
8 changed files with 47 additions and 34 deletions

View File

@@ -22,6 +22,7 @@
#include <src/Scene/Components/ParticleEmitterComponent.h>
#include <src/Scene/Components/BoneComponent.h>
#include <src/Scene/Components/AudioEmitterComponent.h>
#include <DetourDebugDraw.h>
GizmoDrawer::GizmoDrawer(EditorInterface* editor)
@@ -175,6 +176,23 @@ void GizmoDrawer::DrawAxis(Ref<Scene> scene, bool occluded)
}
}
void GizmoDrawer::DrawNavMesh(Ref<Scene> scene, bool occluded)
{
auto cam = Engine::GetCurrentScene()->m_EditorCamera;
auto navVolumesView = scene->m_Registry.view<TransformComponent, NavMeshVolumeComponent>();
for (auto e : navVolumesView)
{
if (!IsEntityInSelection(Nuake::Entity{ (entt::entity)e, scene.get() }))
{
continue;
}
auto [transform, navmesh] = scene->m_Registry.get<TransformComponent, NavMeshVolumeComponent>(e);
duDebugDrawNavMesh(&m_DebugDrawer, *navmesh.NavMeshData->GetNavMesh(), DU_DRAWNAVMESH_OFFMESHCONS);
}
}
void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
{
using namespace Nuake;

View File

@@ -11,7 +11,7 @@
#include "Gizmos/CapsuleGizmo.h"
#include "Gizmos/CylinderGizmo.h"
#include "../Windows/EditorInterface.h"
#include "src/AI/NavMeshDebugDrawer.h"
using namespace Nuake;
@@ -20,7 +20,7 @@ class GizmoDrawer
private:
EditorInterface* m_Editor;
Shader* m_LineShader;
NavMeshDebugDrawer m_DebugDrawer;
std::map<std::string, Ref<Model>> m_Gizmos;
std::map<uint32_t, Scope<CapsuleGizmo>> m_CapsuleGizmo;
std::map<uint32_t, Scope<CylinderGizmo>> m_CylinderGizmo;
@@ -54,8 +54,8 @@ public:
~GizmoDrawer() = default;
void DrawGizmos(Ref<Scene> scene, bool occluded);
void DrawAxis(Ref<Scene> scene, bool occlude);
void DrawAxis(Ref<Scene> scene, bool occluded);
void DrawNavMesh(Ref<Scene> scene, bool occluded);
private:
void GenerateSphereGizmo();
bool IsEntityInSelection(Nuake::Entity entity);