mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Added separte settings for gizmo, shape drawing, fixed sky, better UI
This commit is contained in:
@@ -53,10 +53,15 @@ void EditorLayer::OnUpdate()
|
||||
m_GizmoDrawer->DrawNavMesh(currentScene, true);
|
||||
}
|
||||
|
||||
if (m_EditorInterface->ShouldDrawCollision())
|
||||
if (m_EditorInterface->ShouldDrawGizmos())
|
||||
{
|
||||
m_GizmoDrawer->DrawGizmos(currentScene, false);
|
||||
}
|
||||
|
||||
if (m_EditorInterface->ShouldDrawShapes())
|
||||
{
|
||||
m_GizmoDrawer->DrawShapes(currentScene, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -219,31 +219,11 @@ void GizmoDrawer::DrawNavMesh(Ref<Scene> scene, bool occluded)
|
||||
}
|
||||
}
|
||||
|
||||
void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
|
||||
void GizmoDrawer::DrawShapes(Ref<Scene> scene, bool occluded)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
auto camView = scene->m_Registry.view<TransformComponent, CameraComponent>();
|
||||
|
||||
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
|
||||
|
||||
glLineWidth(3.0f);
|
||||
auto boxColliderView = scene->m_Registry.view<TransformComponent, BoxColliderComponent>();
|
||||
for (auto e : boxColliderView)
|
||||
{
|
||||
auto [transform, box] = scene->m_Registry.get<TransformComponent, BoxColliderComponent>(e);
|
||||
|
||||
const Quat& globalRotation = glm::normalize(transform.GetGlobalRotation());
|
||||
const Matrix4& rotationMatrix = glm::mat4_cast(globalRotation);
|
||||
|
||||
m_LineShader->Bind();
|
||||
m_LineShader->SetUniform("u_Opacity", 1.f);
|
||||
m_LineShader->SetUniform("u_View", glm::scale(glm::translate(scene->m_EditorCamera->GetTransform(), Vector3(transform.GetGlobalTransform()[3])) * rotationMatrix, box.Size));
|
||||
m_LineShader->SetUniform("u_Projection", scene->m_EditorCamera->GetPerspective());
|
||||
|
||||
m_BoxBuffer->Bind();
|
||||
Nuake::RenderCommand::DrawLines(0, 26);
|
||||
}
|
||||
|
||||
auto navMeshVolumeView = scene->m_Registry.view<TransformComponent, NavMeshVolumeComponent>();
|
||||
for (auto e : navMeshVolumeView)
|
||||
@@ -267,6 +247,23 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
|
||||
Nuake::RenderCommand::DrawLines(0, 26);
|
||||
}
|
||||
|
||||
auto boxColliderView = scene->m_Registry.view<TransformComponent, BoxColliderComponent>();
|
||||
for (auto e : boxColliderView)
|
||||
{
|
||||
auto [transform, box] = scene->m_Registry.get<TransformComponent, BoxColliderComponent>(e);
|
||||
|
||||
const Quat& globalRotation = glm::normalize(transform.GetGlobalRotation());
|
||||
const Matrix4& rotationMatrix = glm::mat4_cast(globalRotation);
|
||||
|
||||
m_LineShader->Bind();
|
||||
m_LineShader->SetUniform("u_Opacity", 1.f);
|
||||
m_LineShader->SetUniform("u_View", glm::scale(glm::translate(scene->m_EditorCamera->GetTransform(), Vector3(transform.GetGlobalTransform()[3])) * rotationMatrix, box.Size));
|
||||
m_LineShader->SetUniform("u_Projection", scene->m_EditorCamera->GetPerspective());
|
||||
|
||||
m_BoxBuffer->Bind();
|
||||
Nuake::RenderCommand::DrawLines(0, 26);
|
||||
}
|
||||
|
||||
auto sphereColliderView = scene->m_Registry.view<TransformComponent, SphereColliderComponent>();
|
||||
for (auto e : sphereColliderView)
|
||||
{
|
||||
@@ -462,6 +459,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
auto camView = scene->m_Registry.view<TransformComponent, CameraComponent>();
|
||||
for (auto e : camView)
|
||||
{
|
||||
auto [transform, camera] = scene->m_Registry.get<TransformComponent, CameraComponent>(e);
|
||||
@@ -480,6 +478,18 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
|
||||
Nuake::RenderCommand::DrawLines(0, 26);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
auto camView = scene->m_Registry.view<TransformComponent, CameraComponent>();
|
||||
|
||||
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
|
||||
|
||||
glLineWidth(3.0f);
|
||||
|
||||
auto flatShader = ShaderManager::GetShader("Resources/Shaders/flat.shader");
|
||||
flatShader->Bind();
|
||||
flatShader->SetUniform("u_View", scene->m_EditorCamera->GetTransform());
|
||||
@@ -526,6 +536,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene, bool occluded)
|
||||
}
|
||||
|
||||
// Lights
|
||||
auto lightView = scene->m_Registry.view<TransformComponent, LightComponent>();
|
||||
for (auto e : lightView)
|
||||
{
|
||||
auto [transform, light] = scene->m_Registry.get<TransformComponent, LightComponent>(e);
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
GizmoDrawer() = default;
|
||||
~GizmoDrawer() = default;
|
||||
|
||||
void DrawShapes(Ref<Scene> scene, bool occluded);
|
||||
void DrawGizmos(Ref<Scene> scene, bool occluded);
|
||||
void DrawAxis(Ref<Scene> scene, bool occluded);
|
||||
void DrawNavMesh(Ref<Scene> scene, bool occluded);
|
||||
|
||||
@@ -3019,7 +3019,7 @@ namespace Nuake {
|
||||
|
||||
corner = 2;
|
||||
|
||||
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid() && Selection.Entity.HasComponent<CameraComponent>() && !Engine::IsPlayMode())
|
||||
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid() && Selection.Entity.HasComponent<CameraComponent>() && !Engine::IsPlayMode() && m_DrawCamPreview)
|
||||
{
|
||||
window_flags |= ImGuiWindowFlags_NoMove;
|
||||
viewport = ImGui::GetWindowViewport();
|
||||
@@ -3252,7 +3252,7 @@ namespace Nuake {
|
||||
}
|
||||
if (ImGui::BeginMenu("View"))
|
||||
{
|
||||
if (ImGui::MenuItem("Draw grid", NULL, m_DrawGrid))
|
||||
if (ImGui::MenuItem("Draw Grid", NULL, m_DrawGrid))
|
||||
{
|
||||
m_DrawGrid = !m_DrawGrid;
|
||||
}
|
||||
@@ -3262,18 +3262,28 @@ namespace Nuake {
|
||||
m_DrawAxis = !m_DrawAxis;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Draw collisions", NULL, m_DebugCollisions))
|
||||
if (ImGui::MenuItem("Draw Shapes", NULL, m_DrawShapes))
|
||||
{
|
||||
m_DebugCollisions = !m_DebugCollisions;
|
||||
PhysicsManager::Get().SetDrawDebug(m_DebugCollisions);
|
||||
m_DrawShapes = !m_DrawShapes;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Draw navigation meshes", NULL, m_DrawNavMesh))
|
||||
if (ImGui::MenuItem("Draw Gizmos", NULL, m_DrawGizmos))
|
||||
{
|
||||
|
||||
m_DrawGizmos = !m_DrawGizmos;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("Settings", NULL)) {}
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("Draw Camera Preview", NULL, m_DrawCamPreview))
|
||||
{
|
||||
m_DrawCamPreview = !m_DrawCamPreview;
|
||||
}
|
||||
|
||||
#ifdef NK_DEBUG
|
||||
if (ImGui::MenuItem("Show ImGui", NULL, m_ShowImGuiDemo)) m_ShowImGuiDemo = !m_ShowImGuiDemo;
|
||||
#endif // NK_DEBUG
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Tool"))
|
||||
@@ -3369,9 +3379,11 @@ namespace Nuake {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (ImGui::BeginMenu("Debug"))
|
||||
{
|
||||
if (ImGui::MenuItem("Show ImGui demo", NULL, m_ShowImGuiDemo)) m_ShowImGuiDemo = !m_ShowImGuiDemo;
|
||||
|
||||
if (ImGui::MenuItem("Rebuild Shaders", NULL))
|
||||
{
|
||||
Nuake::Logger::Log("Rebuilding Shaders...");
|
||||
@@ -3384,7 +3396,6 @@ namespace Nuake {
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Quit")) ImGui::EndMenu();
|
||||
|
||||
|
||||
}
|
||||
@@ -3500,7 +3511,7 @@ namespace Nuake {
|
||||
auto window = Window::Get();
|
||||
window->SetDecorated(true);
|
||||
window->ShowTitleBar(false);
|
||||
window->SetSize({ 1100, 1000 });
|
||||
window->SetSize({ 1600, 900 });
|
||||
window->Center();
|
||||
frameCount = 0;
|
||||
return;
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace Nuake
|
||||
bool m_DrawGrid = false;
|
||||
bool m_DrawAxis = true;
|
||||
bool m_ShowImGuiDemo = false;
|
||||
bool m_DebugCollisions = true;
|
||||
bool m_DrawShapes = true;
|
||||
bool m_DrawGizmos = true;
|
||||
bool m_DrawCamPreview = false;
|
||||
bool m_DrawNavMesh = true;
|
||||
bool m_ShowOverlay = true;
|
||||
bool m_IsHoveringViewport = false;
|
||||
@@ -109,7 +111,8 @@ namespace Nuake
|
||||
|
||||
void OpenPrefabWindow(const std::string& prefabPath);
|
||||
bool ShouldDrawAxis() const { return m_DrawAxis; }
|
||||
bool ShouldDrawCollision() const { return m_DebugCollisions; }
|
||||
bool ShouldDrawShapes() const { return m_DrawShapes; }
|
||||
bool ShouldDrawGizmos() const { return m_DrawGizmos; }
|
||||
bool ShouldDrawNavMesh() const { return m_DrawNavMesh; }
|
||||
bool LoadProject(const std::string& projectPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user