mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Added Recast&Detour implementation
- Implemented debug renderer of navigation meshes - Can now generate navigation meshes from .map files
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <src/Scene/Components/QuakeMap.h>
|
||||
#include "src/Scene/Systems/QuakeMapBuilder.h"
|
||||
#include <src/Core/FileSystem.h>
|
||||
#include <src/AI/NavManager.h>
|
||||
|
||||
|
||||
class QuakeMapPanel : ComponentPanel {
|
||||
@@ -74,6 +75,32 @@ public:
|
||||
|
||||
//ComponentTableReset(component.Class, "");
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
ImGui::Text("Build Navigation Mesh");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (ImGui::Button("Build Navigation"))
|
||||
{
|
||||
for (auto& mesh : component.m_Brushes)
|
||||
{
|
||||
if (mesh.HasComponent<ModelComponent>())\
|
||||
{
|
||||
TransformComponent& transformComponent = mesh.GetComponent<TransformComponent>();
|
||||
for (auto& mesh : mesh.GetComponent<ModelComponent>().ModelResource->GetMeshes())
|
||||
{
|
||||
Nuake::NavManager::Get().PushMesh(mesh, transformComponent.GetGlobalTransform());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Nuake::NavManager::Get().BuildNavMesh();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
}
|
||||
}
|
||||
EndComponentTable();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "src/Core/Input.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
void EditorLayer::OnAttach()
|
||||
{
|
||||
@@ -50,6 +52,28 @@ void EditorLayer::OnUpdate()
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
|
||||
if (m_EditorInterface->ShouldDrawNavMesh())
|
||||
{
|
||||
auto cam = Engine::GetCurrentScene()->m_EditorCamera;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf(glm::value_ptr(cam->GetPerspective()));
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf(glm::value_ptr(cam->GetTransform()));
|
||||
|
||||
|
||||
glDepthFunc(GL_LESS);
|
||||
RenderCommand::Disable(RendererEnum::DEPTH_TEST);
|
||||
Nuake::NavManager::Get().DrawNavMesh();
|
||||
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
|
||||
|
||||
Nuake::NavManager::Get().DrawNavMesh();
|
||||
glDepthFunc(GL_GREATER);
|
||||
Nuake::NavManager::Get().DrawNavMesh();
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
|
||||
if (m_EditorInterface->ShouldDrawCollision())
|
||||
{
|
||||
m_GizmoDrawer->DrawGizmos(currentScene, false);
|
||||
@@ -58,6 +82,8 @@ void EditorLayer::OnUpdate()
|
||||
m_GizmoDrawer->DrawGizmos(currentScene, true);
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
sceneFramebuffer->Unbind();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <src/Application/Layer.h>
|
||||
#include "Commands/CommandBuffer.h"
|
||||
#include "src/AI/NavMeshDebugDrawer.h"
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
@@ -25,4 +26,6 @@ private:
|
||||
CommandBuffer mCommandBuffer;
|
||||
Nuake::EditorInterface* m_EditorInterface;
|
||||
GizmoDrawer* m_GizmoDrawer;
|
||||
|
||||
Nuake::NavMeshDebugDrawer m_NavMeshDrawer;
|
||||
};
|
||||
@@ -2242,6 +2242,11 @@ namespace Nuake {
|
||||
PhysicsManager::Get().SetDrawDebug(m_DebugCollisions);
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Draw navigation meshes", NULL, m_DrawNavMesh))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Settings", NULL)) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Nuake
|
||||
bool m_DrawAxis = true;
|
||||
bool m_ShowImGuiDemo = false;
|
||||
bool m_DebugCollisions = true;
|
||||
bool m_DrawNavMesh = true;
|
||||
bool m_ShowOverlay = true;
|
||||
bool m_IsHoveringViewport = false;
|
||||
bool m_IsViewportFocused = false;
|
||||
@@ -76,6 +77,7 @@ namespace Nuake
|
||||
|
||||
bool ShouldDrawAxis() const { return m_DrawAxis; }
|
||||
bool ShouldDrawCollision() const { return m_DebugCollisions; }
|
||||
bool ShouldDrawNavMesh() const { return m_DrawNavMesh; }
|
||||
bool LoadProject(const std::string& projectPath);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user