From 254435fba48b7ddee11cc302ef6c9d883037b36c Mon Sep 17 00:00:00 2001 From: Ole Bueker Date: Sun, 9 Jul 2023 18:47:52 +0200 Subject: [PATCH] Finishing some small ToDos --- OloEditor/src/EditorLayer.cpp | 21 +++++++++++++- OloEditor/src/Panels/ContentBrowserPanel.cpp | 28 ++++++++++++++++++- .../src/OloEngine/Renderer/Framebuffer.h | 1 + .../src/OloEngine/Renderer/Renderer2D.cpp | 4 --- OloEngine/src/OloEngine/Renderer/Renderer2D.h | 2 -- OloEngine/src/OloEngine/Scene/Scene.cpp | 6 +--- .../src/OloEngine/Scripting/C#/ScriptGlue.cpp | 8 ++---- .../src/Platform/OpenGL/OpenGLFramebuffer.h | 2 +- .../src/Platform/OpenGL/OpenGLShader.cpp | 9 +++++- 9 files changed, 60 insertions(+), 21 deletions(-) diff --git a/OloEditor/src/EditorLayer.cpp b/OloEditor/src/EditorLayer.cpp index db8038e4..8ba8d842 100644 --- a/OloEditor/src/EditorLayer.cpp +++ b/OloEditor/src/EditorLayer.cpp @@ -5,6 +5,7 @@ #include "OloEngine/Math/Math.h" #include "OloEngine/Renderer/Font.h" #include "OloEngine/Scripting/C#/ScriptEngine.h" +#include "OloEngine/Scene/SceneCamera.h" #include "OloEngine/Scene/SceneSerializer.h" #include "OloEngine/Utils/PlatformUtils.h" @@ -673,7 +674,25 @@ namespace OloEngine Renderer2D::DrawCircle(transform, glm::vec4(1, 1, 1, 1), 0.03f); } - // TODO(olbu): Add outline for camera? + if (selection.HasComponent()) + { + auto const& cc = selection.GetComponent(); + + if (cc.Camera.GetProjectionType() == SceneCamera::ProjectionType::Orthographic) + { + // For orthographic cameras, we can still use a rectangle as an indicator + glm::mat4 transform = glm::translate(glm::mat4(1.0f), tc.Translation) + * glm::toMat4(glm::quat(tc.Rotation)) + * glm::scale(glm::mat4(1.0f), glm::vec3(cc.Camera.GetOrthographicSize(), cc.Camera.GetOrthographicSize(), 1.0f) + glm::vec3(0.03f)); + Renderer2D::DrawRect(transform, glm::vec4(1, 1, 1, 1)); + } + else if (cc.Camera.GetProjectionType() == SceneCamera::ProjectionType::Perspective) + { + //auto position = glm::vec3(tc.Translation.x, tc.Translation.y, 0.0f); + //auto size = glm::vec2(0.5f); // adjust as needed + // TODO(olbu): Draw the selected camera properly once the Renderer2D can draw triangles/points + } + } } } diff --git a/OloEditor/src/Panels/ContentBrowserPanel.cpp b/OloEditor/src/Panels/ContentBrowserPanel.cpp index bb8ae918..ab286ebb 100644 --- a/OloEditor/src/Panels/ContentBrowserPanel.cpp +++ b/OloEditor/src/Panels/ContentBrowserPanel.cpp @@ -71,7 +71,33 @@ namespace OloEngine ImGui::SliderFloat("Thumbnail Size", &thumbnailSize, 16, 512); ImGui::SliderFloat("Padding", &padding, 0, 32); - // TODO(olbu): status bar + // Get the total count of the files in the current directory. + int totalCount = 0; + for (auto& _ : std::filesystem::directory_iterator(m_CurrentDirectory)) + { + totalCount++; + } + + ImGui::Separator(); // Draw a line to separate the status bar from the rest of the content. + + // Change the background color for the status bar. + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.20f, 0.25f, 0.29f, 0.5f)); + + // Create a child window for the status bar. + ImGui::BeginChild("status_bar", ImVec2(0, ImGui::GetTextLineHeightWithSpacing() + 20), true, 0); + + // Change the text color for the status bar. + ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255)); + + // Add status bar information. + ImGui::Text("Total files: %d", totalCount); + ImGui::SameLine(); + ImGui::Text("Current path: %s", m_CurrentDirectory.string().c_str()); + + // Restore the colors we changed. + ImGui::PopStyleColor(2); + + ImGui::EndChild(); // End of child window. ImGui::End(); } diff --git a/OloEngine/src/OloEngine/Renderer/Framebuffer.h b/OloEngine/src/OloEngine/Renderer/Framebuffer.h index 7dff9705..bc889c82 100644 --- a/OloEngine/src/OloEngine/Renderer/Framebuffer.h +++ b/OloEngine/src/OloEngine/Renderer/Framebuffer.h @@ -65,6 +65,7 @@ namespace OloEngine virtual void ClearAttachment(u32 attachmentIndex, int value) = 0; [[nodiscard("Store this!")]] virtual u32 GetColorAttachmentRendererID(u32 index) const = 0; + [[nodiscard("Store this!")]] virtual u32 GetDepthAttachmentRendererID() const = 0; [[nodiscard("Store this!")]] virtual const FramebufferSpecification& GetSpecification() const = 0; diff --git a/OloEngine/src/OloEngine/Renderer/Renderer2D.cpp b/OloEngine/src/OloEngine/Renderer/Renderer2D.cpp index 65a064dd..eb748fac 100644 --- a/OloEngine/src/OloEngine/Renderer/Renderer2D.cpp +++ b/OloEngine/src/OloEngine/Renderer/Renderer2D.cpp @@ -340,11 +340,7 @@ namespace OloEngine const auto dataSize = static_cast(reinterpret_cast(s_Data.TextVertexBufferPtr) - reinterpret_cast(s_Data.TextVertexBufferBase)); VertexData data = { s_Data.TextVertexBufferBase, dataSize }; s_Data.TextVertexBuffer->SetData(data); - - // TODO(olbu): Find out wtf this buf is - //auto buf = s_Data.TextVertexBufferBase; s_Data.FontAtlasTexture->Bind(0); - s_Data.TextShader->Bind(); RenderCommand::DrawIndexed(s_Data.TextVertexArray, s_Data.TextIndexCount); ++s_Data.Stats.DrawCalls; diff --git a/OloEngine/src/OloEngine/Renderer/Renderer2D.h b/OloEngine/src/OloEngine/Renderer/Renderer2D.h index 1468ed81..18697964 100644 --- a/OloEngine/src/OloEngine/Renderer/Renderer2D.h +++ b/OloEngine/src/OloEngine/Renderer/Renderer2D.h @@ -26,7 +26,6 @@ namespace OloEngine static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& color); static void DrawQuad(const glm::vec2& position, const glm::vec2& size, const Ref& texture, f32 tilingFactor = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f)); static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const Ref& texture, f32 tilingFactor = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f)); - static void DrawQuad(const glm::mat4& transform, const glm::vec4& color, int entityID = -1); static void DrawQuad(const glm::mat4& transform, const Ref& texture, f32 tilingFactor = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f), int entityID = -1); @@ -42,7 +41,6 @@ namespace OloEngine static void DrawRect(const glm::vec3& position, const glm::vec2& size, const glm::vec4& color, int entityID = -1); static void DrawRect(const glm::mat4& transform, const glm::vec4& color, int entityID = -1); - static void DrawSprite(const glm::mat4& transform, SpriteRendererComponent const& src, int entityID); struct TextParams diff --git a/OloEngine/src/OloEngine/Scene/Scene.cpp b/OloEngine/src/OloEngine/Scene/Scene.cpp index 8ba19920..41a34395 100644 --- a/OloEngine/src/OloEngine/Scene/Scene.cpp +++ b/OloEngine/src/OloEngine/Scene/Scene.cpp @@ -362,10 +362,6 @@ namespace OloEngine RenderScene(camera); } - // TODO(olbu): Implement these as tests, rest from Renderer2D.cpp too - // Renderer2D::DrawLine(glm::vec3(0.0f), glm::vec3(5.0f), glm::vec4(1, 0, 1, 1)); - // Renderer2D::DrawRect(glm::vec3(0.0f), glm::vec2(5.0f), glm::vec4(1, 1, 1, 1)); - void Scene::OnViewportResize(const u32 width, const u32 height) { if ((m_ViewportWidth == width) && (m_ViewportHeight == height)) @@ -592,7 +588,7 @@ namespace OloEngine } template<> - void Scene::OnComponentAdded(Entity entity, TextComponent& component) + void Scene::OnComponentAdded(Entity, TextComponent&) { } diff --git a/OloEngine/src/OloEngine/Scripting/C#/ScriptGlue.cpp b/OloEngine/src/OloEngine/Scripting/C#/ScriptGlue.cpp index b0c69f82..71048b28 100644 --- a/OloEngine/src/OloEngine/Scripting/C#/ScriptGlue.cpp +++ b/OloEngine/src/OloEngine/Scripting/C#/ScriptGlue.cpp @@ -40,17 +40,13 @@ namespace OloEngine static void NativeLog_Vector(glm::vec3 const* parameter, glm::vec3* outResult) { - // TODO(olbu): Fix the logger, glm::vec3* is not valid type, need to provide a formatter specialization - //https://fmt.dev/latest/api.html#udt - //OLO_CORE_WARN("Value: {0}", *parameter); + OLO_CORE_WARN("Value: {0}", *parameter); *outResult = glm::normalize(*parameter); } [[nodiscard("Store this!")]] static f32 NativeLog_VectorDot(glm::vec3 const* parameter) { - // TODO(olbu): Fix the logger, glm::vec3* is not valid type, need to provide a formatter specialization - //https://fmt.dev/latest/api.html#udt - //OLO_CORE_WARN("Value: {0}", *parameter); + OLO_CORE_WARN("Value: {0}", *parameter); return glm::dot(*parameter, *parameter); } diff --git a/OloEngine/src/Platform/OpenGL/OpenGLFramebuffer.h b/OloEngine/src/Platform/OpenGL/OpenGLFramebuffer.h index e4a4871f..4da6f063 100644 --- a/OloEngine/src/Platform/OpenGL/OpenGLFramebuffer.h +++ b/OloEngine/src/Platform/OpenGL/OpenGLFramebuffer.h @@ -23,7 +23,7 @@ namespace OloEngine void ClearAttachment(u32 attachmentIndex, int value) override; [[nodiscard("Store this!")]] u32 GetColorAttachmentRendererID(const u32 index) const override { OLO_CORE_ASSERT(index < m_ColorAttachments.size()); return m_ColorAttachments[index]; } - // TODO(olbu): Add GetDepthAttachmentRendererID + [[nodiscard]] u32 GetDepthAttachmentRendererID() const override { return m_DepthAttachment; } [[nodiscard("Store this!")]] const FramebufferSpecification& GetSpecification() const override { return m_Specification; } private: u32 m_RendererID = 0; diff --git a/OloEngine/src/Platform/OpenGL/OpenGLShader.cpp b/OloEngine/src/Platform/OpenGL/OpenGLShader.cpp index 85e0aba1..71c2190f 100644 --- a/OloEngine/src/Platform/OpenGL/OpenGLShader.cpp +++ b/OloEngine/src/Platform/OpenGL/OpenGLShader.cpp @@ -68,10 +68,17 @@ namespace OloEngine [[nodiscard("Store this!")]] static const char* GetCacheDirectory() { - // TODO(olbu): make sure the assets directory is valid + const std::filesystem::path assetsDirectory = "assets"; + if (!std::filesystem::exists(assetsDirectory)) + { + OLO_CORE_ERROR("The assets directory does not exist."); + return nullptr; // Or return some default path. + } + return "assets/cache/shader/opengl"; } + static void CreateCacheDirectoryIfNeeded() { const std::filesystem::path cacheDirectory = GetCacheDirectory();