From 712be0b162237c21546119bf70fad3f191f0d4a7 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Mon, 17 Jul 2023 10:33:28 -0400 Subject: [PATCH 01/15] Fixed shadows --- Editor/Editor.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index db9a8176..3d15e8d1 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -28,6 +30,9 @@ #include "src/Windows/FileSystemUI.h" #include +#include + + const std::string WindowTitle = "Nuake Editor"; @@ -184,9 +189,19 @@ int main(int argc, char* argv[]) camera = currentScene->m_EditorCamera; } - if (currentScene && !Nuake::Engine::IsPlayMode() && editor.ShouldDrawAxis()) + if (currentScene && !Nuake::Engine::IsPlayMode()) { - gizmoDrawer.DrawGizmos(currentScene); + glEnable(GL_LINE_SMOOTH); + + if (editor.ShouldDrawAxis()) + { + //gizmoDrawer.DrawAxis(currentScene); + } + + if (editor.ShouldDrawCollision()) + { + gizmoDrawer.DrawGizmos(currentScene); + } } } sceneFramebuffer->Unbind(); From 7baec67bf4757f398f0d9062caebc535a895eeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9meryc?= Date: Mon, 17 Jul 2023 20:21:15 -0400 Subject: [PATCH 02/15] NK-113 - Open Wren Script File with Double Click --- Editor/src/ComponentsPanel/ScriptPanel.h | 12 +++++++++++- Nuake/src/Scene/Components/WrenScriptComponent.h | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Editor/src/ComponentsPanel/ScriptPanel.h b/Editor/src/ComponentsPanel/ScriptPanel.h index cad0f9d5..00f4988e 100644 --- a/Editor/src/ComponentsPanel/ScriptPanel.h +++ b/Editor/src/ComponentsPanel/ScriptPanel.h @@ -27,7 +27,7 @@ public: if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Script")) { char* file = (char*)payload->Data; - + std::string fullPath = std::string(file, 512); path = Nuake::FileSystem::AbsoluteToRelative(std::move(fullPath)); @@ -37,6 +37,16 @@ public: } component.Script = path; + + // Double click on file + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) + { + if(!component.Script.empty()) + { + Nuake::OS::OpenIn(component.mWrenScript->GetFile()->GetAbsolutePath()); + } + } + ImGui::TableNextColumn(); ComponentTableReset(component.Script, ""); diff --git a/Nuake/src/Scene/Components/WrenScriptComponent.h b/Nuake/src/Scene/Components/WrenScriptComponent.h index d5f069e2..57bbf47c 100644 --- a/Nuake/src/Scene/Components/WrenScriptComponent.h +++ b/Nuake/src/Scene/Components/WrenScriptComponent.h @@ -39,7 +39,10 @@ namespace Nuake if (j.contains("Script")) { Script = j["Script"]; - LoadScript(Script); + if(!Script.empty()) + { + LoadScript(Script); + } } if (j.contains("mModule")) From 5b8dbf8d9480a7001b1a4a9b27bf62153a74bf90 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Tue, 18 Jul 2023 03:28:06 +0000 Subject: [PATCH 03/15] Removed tabs --- Editor/src/ComponentsPanel/ScriptPanel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/src/ComponentsPanel/ScriptPanel.h b/Editor/src/ComponentsPanel/ScriptPanel.h index 00f4988e..2a51065d 100644 --- a/Editor/src/ComponentsPanel/ScriptPanel.h +++ b/Editor/src/ComponentsPanel/ScriptPanel.h @@ -27,7 +27,7 @@ public: if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Script")) { char* file = (char*)payload->Data; - + std::string fullPath = std::string(file, 512); path = Nuake::FileSystem::AbsoluteToRelative(std::move(fullPath)); From dc15f61a66d2bb93142840fc7b4a5f3589c1f677 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Tue, 18 Jul 2023 10:35:15 -0400 Subject: [PATCH 04/15] Update SceneModule.h --- Nuake/src/Scripting/Modules/SceneModule.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Nuake/src/Scripting/Modules/SceneModule.h b/Nuake/src/Scripting/Modules/SceneModule.h index bd2c2e4e..96976c34 100644 --- a/Nuake/src/Scripting/Modules/SceneModule.h +++ b/Nuake/src/Scripting/Modules/SceneModule.h @@ -107,7 +107,6 @@ namespace Nuake { prefabComponent.PrefabInstance = Prefab::New(prefabPath); wrenSetSlotDouble(vm, 0, newEntity.GetHandle()); - return; } static void EntityHasComponent(WrenVM* vm) From 4e4d203666c76b3272fcfb9ee97b0f6ca52b0418 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 19 Jul 2023 00:31:22 -0400 Subject: [PATCH 05/15] Renamed some glm::vec3 to Vector3 --- Editor/src/ComponentsPanel/BoxColliderPanel.h | 2 +- Nuake/src/Core/Maths.cpp | 33 +++++-------------- Nuake/src/Core/Physics/CharacterController.h | 4 +-- Nuake/src/Core/Physics/DynamicWorld.cpp | 10 +++--- Nuake/src/Core/Physics/DynamicWorld.h | 4 +-- Nuake/src/Core/Physics/PhysicsManager.cpp | 4 +-- Nuake/src/Core/Physics/PhysicsManager.h | 2 +- Nuake/src/Core/Physics/PhysicsShapes.cpp | 9 ++--- Nuake/src/Core/Physics/PhysicsShapes.h | 2 +- Nuake/src/Core/Physics/RaycastResult.h | 6 ++-- Nuake/src/Core/Physics/Rigibody.h | 2 +- Nuake/src/Core/Physics/Rigidbody.cpp | 4 +-- Nuake/src/Rendering/Camera.cpp | 6 ++-- Nuake/src/Rendering/Frustum.h | 2 +- Nuake/src/Rendering/Light.cpp | 6 ++-- Nuake/src/Rendering/PostFX/SSAO.cpp | 6 ++-- Nuake/src/Rendering/Renderer.cpp | 2 +- Nuake/src/Rendering/Renderer.h | 7 +--- Nuake/src/Rendering/SceneRenderer.cpp | 3 +- Nuake/src/Rendering/Textures/Material.cpp | 2 +- Nuake/src/Rendering/Textures/Material.h | 2 +- Nuake/src/Scene/Components/BoxCollider.h | 2 +- Nuake/src/Scene/Components/LightComponent.cpp | 2 +- Nuake/src/Scene/Components/LightComponent.h | 33 ++++++------------- 24 files changed, 59 insertions(+), 96 deletions(-) diff --git a/Editor/src/ComponentsPanel/BoxColliderPanel.h b/Editor/src/ComponentsPanel/BoxColliderPanel.h index 05ba27e5..1e3d56f5 100644 --- a/Editor/src/ComponentsPanel/BoxColliderPanel.h +++ b/Editor/src/ComponentsPanel/BoxColliderPanel.h @@ -28,7 +28,7 @@ public: component.Size.z = std::max(component.Size.z, 0.0001f); ImGui::TableNextColumn(); - ComponentTableReset(component.Size, glm::vec3(0.5f, 0.5f, 0.5f)); + ComponentTableReset(component.Size, Vector3(0.5f, 0.5f, 0.5f)); } ImGui::TableNextColumn(); { diff --git a/Nuake/src/Core/Maths.cpp b/Nuake/src/Core/Maths.cpp index 884f4339..0b66c7a8 100644 --- a/Nuake/src/Core/Maths.cpp +++ b/Nuake/src/Core/Maths.cpp @@ -37,29 +37,12 @@ Quat Nuake::CreateFromAxisAngle(Vector3 axis, float angle) Quat Nuake::QuatFromEuler(float x, float y, float z) { - glm::quat pitchQuat = glm::angleAxis(Rad(x), glm::vec3(1.0f, 0.0f, 0.0f)); - glm::quat yawQuat = glm::angleAxis(Rad(y), glm::vec3(0.0f, 1.0f, 0.0f)); - glm::quat rollQuat = glm::angleAxis(Rad(z), glm::vec3(0.0f, 0.0f, -1.0f)); - glm::quat orientation = yawQuat * pitchQuat * rollQuat; + Quat pitchQuat = glm::angleAxis(Rad(x), Vector3(1.0f, 0.0f, 0.0f)); + Quat yawQuat = glm::angleAxis(Rad(y), Vector3(0.0f, 1.0f, 0.0f)); + Quat rollQuat = glm::angleAxis(Rad(z), Vector3(0.0f, 0.0f, -1.0f)); + Quat orientation = yawQuat * pitchQuat * rollQuat; return glm::normalize(orientation); - - return Quat(Vector3(Rad(x), Rad(y), Rad(z))); - - Quat q; - - float cr = cos(x * 0.5); - float sr = sin(x * 0.5); - float cp = cos(y * 0.5); - float sp = sin(y * 0.5); - float cy = cos(z * 0.5); - float sy = sin(z * 0.5); - - q.w = cr * cp * cy + sr * sp * sy; - q.x = sr * cp * cy - cr * sp * sy; - q.y = cr * sp * cy + sr * cp * sy; - q.z = cr * cp * sy - sr * sp * cy; - return q; } Vector3 Nuake::QuatToDirection(const Quat& quat) @@ -72,9 +55,9 @@ void Nuake::Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale) pos = m[3]; for (int i = 0; i < 3; i++) scale[i] = glm::length(Vector3(m[i])); - const glm::mat3 rotMtx( - glm::vec3(m[0]) / scale[0], - glm::vec3(m[1]) / scale[1], - glm::vec3(m[2]) / scale[2]); + const Matrix3 rotMtx( + Vector3(m[0]) / scale[0], + Vector3(m[1]) / scale[1], + Vector3(m[2]) / scale[2]); rot = glm::quat_cast(rotMtx); } \ No newline at end of file diff --git a/Nuake/src/Core/Physics/CharacterController.h b/Nuake/src/Core/Physics/CharacterController.h index 9e20bb6b..791ee773 100644 --- a/Nuake/src/Core/Physics/CharacterController.h +++ b/Nuake/src/Core/Physics/CharacterController.h @@ -29,8 +29,8 @@ namespace Nuake float m_bottomYOffset; float m_bottomRoundedRegionYOffset; - glm::vec3 m_manualVelocity; - std::vector m_surfaceHitNormals; + Vector3 m_manualVelocity; + std::vector m_surfaceHitNormals; CharacterController(const Ref& shape, float friction, float maxSlopeAngle); diff --git a/Nuake/src/Core/Physics/DynamicWorld.cpp b/Nuake/src/Core/Physics/DynamicWorld.cpp index 1d674c8a..0ffbcf16 100644 --- a/Nuake/src/Core/Physics/DynamicWorld.cpp +++ b/Nuake/src/Core/Physics/DynamicWorld.cpp @@ -241,7 +241,7 @@ namespace Nuake } - void DynamicWorld::SetGravity(glm::vec3 g) + void DynamicWorld::SetGravity(const Vector3& gravity) { } @@ -323,16 +323,16 @@ namespace Nuake return false; } - RaycastResult DynamicWorld::Raycast(glm::vec3 from, glm::vec3 to) + RaycastResult DynamicWorld::Raycast(const Vector3& from, const Vector3& to) { - Vector3 localNorm = glm::vec3(0,0,0); + Vector3 localNorm = Vector3(0,0,0); //Logger::Log("normal: x:" + std::to_string(localNorm.x) + " y:" + std::to_string(localNorm.y )+ "z: " + std::to_string(localNorm.z)); // Map bullet result to dto. RaycastResult result{ - glm::vec3(0,0,0), - glm::vec3(0,0,0), + Vector3(0,0,0), + Vector3(0,0,0), localNorm }; diff --git a/Nuake/src/Core/Physics/DynamicWorld.h b/Nuake/src/Core/Physics/DynamicWorld.h index cfa25a48..0bc45ecd 100644 --- a/Nuake/src/Core/Physics/DynamicWorld.h +++ b/Nuake/src/Core/Physics/DynamicWorld.h @@ -52,7 +52,7 @@ namespace Nuake void DrawDebug(); - void SetGravity(glm::vec3 g); + void SetGravity(const Vector3& g); void AddRigidbody(Ref rb); void AddGhostbody(Ref gb); @@ -62,7 +62,7 @@ namespace Nuake void MoveAndSlideCharacterController(const Entity& entity, const Vector3 velocity); - RaycastResult Raycast(glm::vec3 from, glm::vec3 to); + RaycastResult Raycast(const Vector3& from, const Vector3& to); void StepSimulation(Timestep ts); void Clear(); diff --git a/Nuake/src/Core/Physics/PhysicsManager.cpp b/Nuake/src/Core/Physics/PhysicsManager.cpp index 7d5ebaf1..26aa6bac 100644 --- a/Nuake/src/Core/Physics/PhysicsManager.cpp +++ b/Nuake/src/Core/Physics/PhysicsManager.cpp @@ -37,7 +37,7 @@ namespace Nuake m_World->Clear(); } - RaycastResult PhysicsManager::Raycast(glm::vec3 from, glm::vec3 to) + RaycastResult PhysicsManager::Raycast(const Vector3& from, const Vector3& to) { return m_World->Raycast(from, to); } @@ -58,7 +58,7 @@ namespace Nuake JPH::RegisterTypes(); m_World = new Physics::DynamicWorld(); - m_World->SetGravity(glm::vec3(0, -3, 0)); + m_World->SetGravity(Vector3(0, -3, 0)); m_IsRunning = false; } diff --git a/Nuake/src/Core/Physics/PhysicsManager.h b/Nuake/src/Core/Physics/PhysicsManager.h index 4a854340..3934a07c 100644 --- a/Nuake/src/Core/Physics/PhysicsManager.h +++ b/Nuake/src/Core/Physics/PhysicsManager.h @@ -45,7 +45,7 @@ namespace Nuake void Reset(); - RaycastResult Raycast(glm::vec3 from, glm::vec3 to); + RaycastResult Raycast(const Vector3& from, const Vector3& to); void RegisterBody(Ref rb); void RegisterGhostBody(Ref rb); diff --git a/Nuake/src/Core/Physics/PhysicsShapes.cpp b/Nuake/src/Core/Physics/PhysicsShapes.cpp index 5009e910..00ce6da5 100644 --- a/Nuake/src/Core/Physics/PhysicsShapes.cpp +++ b/Nuake/src/Core/Physics/PhysicsShapes.cpp @@ -1,5 +1,4 @@ #include "PhysicsShapes.h" -#include "src/Rendering/Vertex.h" namespace Nuake { @@ -7,12 +6,11 @@ namespace Nuake { Box::Box() { - Size = glm::vec3(1); + Size = Vector3(1); m_Type = BOX; } - // Sphere - Box::Box(glm::vec3 size) + Box::Box(Vector3 size) { Size = size; m_Type = BOX; @@ -20,11 +18,10 @@ namespace Nuake Box::Box(float x, float y, float z) { - Size = glm::vec3(x, y, z); + Size = Vector3(x, y, z); m_Type = BOX; } - // Sphere Sphere::Sphere(float radius) { Radius = radius; diff --git a/Nuake/src/Core/Physics/PhysicsShapes.h b/Nuake/src/Core/Physics/PhysicsShapes.h index 49e3b167..859768dc 100644 --- a/Nuake/src/Core/Physics/PhysicsShapes.h +++ b/Nuake/src/Core/Physics/PhysicsShapes.h @@ -26,7 +26,7 @@ namespace Nuake Vector3 Size; public: Box(); - Box(glm::vec3 size); + Box(Vector3 size); Box(float x, float y, float z); Vector3 GetSize() const { return Size; } diff --git a/Nuake/src/Core/Physics/RaycastResult.h b/Nuake/src/Core/Physics/RaycastResult.h index 2da51a59..be12f90c 100644 --- a/Nuake/src/Core/Physics/RaycastResult.h +++ b/Nuake/src/Core/Physics/RaycastResult.h @@ -13,8 +13,8 @@ namespace Nuake // result object from raycast. struct RaycastResult { - glm::vec3 WorldPoint; - glm::vec3 LocalPoint; - glm::vec3 Normal; + Vector3 WorldPoint; + Vector3 LocalPoint; + Vector3 Normal; }; } diff --git a/Nuake/src/Core/Physics/Rigibody.h b/Nuake/src/Core/Physics/Rigibody.h index 14b99b76..c579400a 100644 --- a/Nuake/src/Core/Physics/Rigibody.h +++ b/Nuake/src/Core/Physics/Rigibody.h @@ -26,7 +26,7 @@ namespace Nuake RigidBody(); RigidBody(Vector3 position, Entity handle); - RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, glm::vec3 initialVel = glm::vec3(0, 0, 0)); + RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, Vector3 initialVel = Vector3(0, 0, 0)); void UpdateTransform(); diff --git a/Nuake/src/Core/Physics/Rigidbody.cpp b/Nuake/src/Core/Physics/Rigidbody.cpp index aaa93938..0a4da02e 100644 --- a/Nuake/src/Core/Physics/Rigidbody.cpp +++ b/Nuake/src/Core/Physics/Rigidbody.cpp @@ -13,12 +13,12 @@ namespace Nuake } - RigidBody::RigidBody(glm::vec3 position, Entity handle) : _position(position) + RigidBody::RigidBody(Vector3 position, Entity handle) : _position(position) { } - RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, glm::vec3 initialVel) : + RigidBody::RigidBody(float mass, Vector3 position, Quat rotation, Matrix4 transform, Ref shape, Entity entity, Vector3 initialVel) : _position(position), _collisionShape(shape), _mass(mass), diff --git a/Nuake/src/Rendering/Camera.cpp b/Nuake/src/Rendering/Camera.cpp index f44b340c..7b60d972 100644 --- a/Nuake/src/Rendering/Camera.cpp +++ b/Nuake/src/Rendering/Camera.cpp @@ -10,7 +10,7 @@ namespace Nuake { - Camera::Camera(CAMERA_TYPE type, glm::vec3 position) + Camera::Camera(CAMERA_TYPE type, Vector3 position) { m_Type = PERSPECTIVE; Translation = position; @@ -25,7 +25,7 @@ namespace Nuake Camera::Camera() { m_Type = PERSPECTIVE; - Translation = glm::vec3(0, 0, 0); + Translation = Vector3(0, 0, 0); Direction = Vector3(0, 0, 1); Right = glm::normalize(glm::cross(Vector3(0, 1, 0), Direction)); Up = glm::cross(Direction, Right); @@ -83,7 +83,7 @@ namespace Nuake Matrix4 Camera::GetTransformRotation() { - return lookAt(glm::vec3(), Direction, Up); + return lookAt(Vector3(), Direction, Up); } bool Camera::BoxFrustumCheck(const AABB& aabb) diff --git a/Nuake/src/Rendering/Frustum.h b/Nuake/src/Rendering/Frustum.h index 01febbb9..22479bce 100644 --- a/Nuake/src/Rendering/Frustum.h +++ b/Nuake/src/Rendering/Frustum.h @@ -124,7 +124,7 @@ namespace Nuake { template inline Vector3 Frustum::intersection(const Vector3* crosses) const { - float D = glm::dot(glm::vec3(m_planes[a]), crosses[ij2k::k]); + float D = glm::dot(Vector3(m_planes[a]), crosses[ij2k::k]); Vector3 res = glm::mat3(crosses[ij2k::k], -crosses[ij2k::k], crosses[ij2k::k]) * Vector3(m_planes[a].w, m_planes[b].w, m_planes[c].w); return res * (-1.0f / D); diff --git a/Nuake/src/Rendering/Light.cpp b/Nuake/src/Rendering/Light.cpp index 84643404..b2091acc 100644 --- a/Nuake/src/Rendering/Light.cpp +++ b/Nuake/src/Rendering/Light.cpp @@ -87,17 +87,17 @@ namespace Nuake float radius = 0.0f; for (int i = 0; i < 8; i++) { - float distance = glm::length(glm::vec3(frustumCorners[i]) - frustumCenter); + float distance = glm::length(Vector3(frustumCorners[i]) - frustumCenter); radius = glm::max(radius, distance); } radius = std::ceil(radius * 16.0f) / 16.0f; - Vector3 maxExtents = glm::vec3(radius); + Vector3 maxExtents = Vector3(radius); Vector3 minExtents = -maxExtents; // Calculate the view and projection matrix Vector3 lightDir = -this->Direction; - Matrix4 lightViewMatrix = glm::lookAt(frustumCenter - lightDir * -minExtents.z, frustumCenter, glm::vec3(0.0f, 0.0f, 1.0f)); + Matrix4 lightViewMatrix = glm::lookAt(frustumCenter - lightDir * -minExtents.z, frustumCenter, Vector3(0.0f, 0.0f, 1.0f)); Matrix4 lightProjectionMatrix = glm::ortho(minExtents.x, maxExtents.x, minExtents.y, maxExtents.y, 0.0f + mCascadeNearPlaneOffset, maxExtents.z - minExtents.z + mCascadeFarPlaneOffset); // Offset to texel space to avoid shimmering ->(https://stackoverflow.com/questions/33499053/cascaded-shadow-map-shimmering) diff --git a/Nuake/src/Rendering/PostFX/SSAO.cpp b/Nuake/src/Rendering/PostFX/SSAO.cpp index 16624513..02a75aaf 100644 --- a/Nuake/src/Rendering/PostFX/SSAO.cpp +++ b/Nuake/src/Rendering/PostFX/SSAO.cpp @@ -44,10 +44,10 @@ namespace Nuake { std::uniform_real_distribution randomFloats(0.0, 1.0); // random floats between [0.0, 1.0] std::default_random_engine generator; - std::vector ssaoKernel; + std::vector ssaoKernel; for (unsigned int i = 0; i < 64; ++i) { - glm::vec3 sample( + Vector3 sample( randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) @@ -70,7 +70,7 @@ namespace Nuake for (unsigned int i = 0; i < 16; i++) { - glm::vec3 noise( + Vector3 noise( randomFloats(generator) * 2.0 - 1.0, randomFloats(generator) * 2.0 - 1.0, 0.0f); diff --git a/Nuake/src/Rendering/Renderer.cpp b/Nuake/src/Rendering/Renderer.cpp index bcd2d449..25f86f4f 100644 --- a/Nuake/src/Rendering/Renderer.cpp +++ b/Nuake/src/Rendering/Renderer.cpp @@ -209,7 +209,7 @@ namespace Nuake RenderCommand::DrawLines(0, 2); } - void Renderer::DrawDebugLine(glm::vec3 start, glm::vec3 end, glm::vec4 color) + void Renderer::DrawDebugLine(Vector3 start, Vector3 end, Vector3 color) { //m_DebugShader->Bind(); //m_DebugShader->SetUniform4f("u_Color", color.r, color.g, color.b, color.a); diff --git a/Nuake/src/Rendering/Renderer.h b/Nuake/src/Rendering/Renderer.h index 0b5de6ae..847e3b86 100644 --- a/Nuake/src/Rendering/Renderer.h +++ b/Nuake/src/Rendering/Renderer.h @@ -16,10 +16,6 @@ namespace Nuake }; const int MAX_LIGHT = 64; - //struct LightDataArray - //{ - // LightData Lights[MAX_LIGHT]; - //}; struct LightData { @@ -59,7 +55,6 @@ namespace Nuake static void Init(); static void LoadShaders(); - static void BeginScene(); static void SubmitMesh(Ref mesh, Matrix4 transform, const int32_t entityId = -1); static void SubmitCube(Matrix4 transform); static void Flush(Shader* shader, bool depthOnly = false); @@ -75,7 +70,7 @@ namespace Nuake // Debug static void DrawLine(Vector3 start, Vector3 end, Color color, Matrix4 transform = Matrix4()); - static void DrawDebugLine(glm::vec3 start, glm::vec3 end, glm::vec4 color); + static void DrawDebugLine(Vector3 start, Vector3 end, Vector3 color); static void DrawCube(TransformComponent transform, glm::vec4 color); static void DrawSphere(TransformComponent transform, glm::vec4 color); static void DrawQuad(Matrix4 transform = Matrix4()); diff --git a/Nuake/src/Rendering/SceneRenderer.cpp b/Nuake/src/Rendering/SceneRenderer.cpp index 6bd30a64..7d4b2512 100644 --- a/Nuake/src/Rendering/SceneRenderer.cpp +++ b/Nuake/src/Rendering/SceneRenderer.cpp @@ -4,7 +4,8 @@ #include #include -namespace Nuake { +namespace Nuake +{ void SceneRenderer::Init() { const auto defaultResolution = Vector2(1920, 1080); diff --git a/Nuake/src/Rendering/Textures/Material.cpp b/Nuake/src/Rendering/Textures/Material.cpp index f68785cd..65c14827 100644 --- a/Nuake/src/Rendering/Textures/Material.cpp +++ b/Nuake/src/Rendering/Textures/Material.cpp @@ -56,7 +56,7 @@ namespace Nuake InitDefaultTextures(); } - Material::Material(const glm::vec3 albedoColor) + Material::Material(const Vector3 albedoColor) { InitDefaultTextures(); InitUniformBuffer(); diff --git a/Nuake/src/Rendering/Textures/Material.h b/Nuake/src/Rendering/Textures/Material.h index 9dd2e269..2d9986fc 100644 --- a/Nuake/src/Rendering/Textures/Material.h +++ b/Nuake/src/Rendering/Textures/Material.h @@ -73,7 +73,7 @@ namespace Nuake Material(); Material(const std::string albedo); Material(Ref texture) { m_Albedo = texture; } - Material(const glm::vec3 albedoColor); + Material(const Vector3 albedoColor); ~Material(); void InitDefaultTextures(); diff --git a/Nuake/src/Scene/Components/BoxCollider.h b/Nuake/src/Scene/Components/BoxCollider.h index 125452b3..4cc88f8e 100644 --- a/Nuake/src/Scene/Components/BoxCollider.h +++ b/Nuake/src/Scene/Components/BoxCollider.h @@ -7,7 +7,7 @@ namespace Nuake { { public: Ref Box; - glm::vec3 Size = glm::vec3(0.5f, 0.5f, 0.5f); + Vector3 Size = Vector3(0.5f, 0.5f, 0.5f); bool IsTrigger = false; json Serialize(); diff --git a/Nuake/src/Scene/Components/LightComponent.cpp b/Nuake/src/Scene/Components/LightComponent.cpp index 9cd8a776..bbc00d16 100644 --- a/Nuake/src/Scene/Components/LightComponent.cpp +++ b/Nuake/src/Scene/Components/LightComponent.cpp @@ -50,7 +50,7 @@ namespace Nuake { } } - glm::mat4 LightComponent::GetProjection() + Matrix4 LightComponent::GetProjection() { return glm::ortho(-25.0f, 25.0f, -25.0f, 25.0f, -25.0f, 25.0f); } diff --git a/Nuake/src/Scene/Components/LightComponent.h b/Nuake/src/Scene/Components/LightComponent.h index 32c4a110..321fb07e 100644 --- a/Nuake/src/Scene/Components/LightComponent.h +++ b/Nuake/src/Scene/Components/LightComponent.h @@ -21,41 +21,28 @@ namespace Nuake { public: LightType Type = Point; - glm::vec3 Direction = glm::vec3(0, -1, 0); - glm::vec3 Color; + Vector3 Direction; + Vector3 Color; + bool IsVolumetric = false; float Strength; - bool SyncDirectionWithSky = false; - Ref m_Framebuffer; + bool SyncDirectionWithSky = false; bool CastShadows = false; Ref m_Framebuffers[CSM_AMOUNT]; - glm::mat4 mViewProjections[CSM_AMOUNT]; + Matrix4 mViewProjections[CSM_AMOUNT]; float mCascadeSplitDepth[CSM_AMOUNT]; + float mCascadeSplits[CSM_AMOUNT]; + public: LightComponent(); + ~LightComponent() = default; void SetCastShadows(bool toggle); - glm::mat4 GetProjection(); - - glm::mat4 GetLightTransform(); - void SetDirection(glm::vec3 dir); - glm::vec3 GetDirection(); - - void BeginDrawShadow(); - - void EndDrawShadow(); - void DrawShadow(); - - void Draw(TransformComponent transformComponent, Ref cam); - void DrawDeferred(TransformComponent transformComponent, Camera* cam); - void DrawEditor(); - - void SetType(LightType type); - - float mCascadeSplits[CSM_AMOUNT]; + Matrix4 GetProjection(); + Vector3 GetDirection(); void CalculateViewProjection(glm::mat4& view, const glm::mat4& projection) { From c3f740883d9d4ee2ed952c8a6283ad493b76f5cc Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 19 Jul 2023 00:31:39 -0400 Subject: [PATCH 06/15] Removed unused code --- Nuake/src/Core/Input.cpp | 1 - .../src/Core/Physics/CharacterController.cpp | 32 ------ Nuake/src/Core/Physics/CharacterController.h | 5 - Nuake/src/Scene/Components/LightComponent.cpp | 108 ++---------------- 4 files changed, 9 insertions(+), 137 deletions(-) diff --git a/Nuake/src/Core/Input.cpp b/Nuake/src/Core/Input.cpp index b5cd1db5..47e8e115 100644 --- a/Nuake/src/Core/Input.cpp +++ b/Nuake/src/Core/Input.cpp @@ -121,7 +121,6 @@ namespace Nuake { auto window = Window::Get()->GetHandle(); auto state = glfwGetMouseButton(window, button); - return state == GLFW_RELEASE && m_MouseButtons[button] == true; } diff --git a/Nuake/src/Core/Physics/CharacterController.cpp b/Nuake/src/Core/Physics/CharacterController.cpp index 93c8518c..ddcd671c 100644 --- a/Nuake/src/Core/Physics/CharacterController.cpp +++ b/Nuake/src/Core/Physics/CharacterController.cpp @@ -29,38 +29,6 @@ namespace Nuake { PhysicsManager::Get().GetWorld()->MoveAndSlideCharacterController(Owner, velocity); } - - void CharacterController::ParseGhostContacts() - { - - } - - void CharacterController::UpdatePosition() - { - - - } - - void CharacterController::UpdateVelocity() - { - // Decelerate - //m_manualVelocity -= m_manualVelocity * m_deceleration * m_pPhysicsWorld->GetScene()->m_frameTimer.GetTimeMultiplier(); - - if (m_hittingWall) - { - for (size_t i = 0, size = m_surfaceHitNormals.size(); i < size; i++) - { - // Cancel velocity across normal - glm::vec3 velInNormalDir(glm::reflect(m_manualVelocity, m_surfaceHitNormals[i])); - - // Apply correction - m_manualVelocity -= velInNormalDir * 1.05f; - } - - // Do not adjust rigid body velocity manually (so bodies can still be pushed by character) - return; - } - } } } diff --git a/Nuake/src/Core/Physics/CharacterController.h b/Nuake/src/Core/Physics/CharacterController.h index 791ee773..b4bf99ab 100644 --- a/Nuake/src/Core/Physics/CharacterController.h +++ b/Nuake/src/Core/Physics/CharacterController.h @@ -42,11 +42,6 @@ namespace Nuake { return IsOnGround; } - - private: - void ParseGhostContacts(); - void UpdatePosition(); - void UpdateVelocity(); }; } } diff --git a/Nuake/src/Scene/Components/LightComponent.cpp b/Nuake/src/Scene/Components/LightComponent.cpp index bbc00d16..42b69d47 100644 --- a/Nuake/src/Scene/Components/LightComponent.cpp +++ b/Nuake/src/Scene/Components/LightComponent.cpp @@ -7,25 +7,13 @@ #include "src/Core/Core.h" #include -namespace Nuake { - LightComponent::LightComponent() +namespace Nuake +{ + LightComponent::LightComponent() : + Color(1, 1, 1), + Strength(10.0f), + Direction(0, 1, 0) { - Color = glm::vec3(1, 1, 1); - Strength = 10.0f; - Direction = glm::vec3(0, -1, 0); - - - //m_Framebuffers = std::vector>(); - //mViewProjections = std::vector(); - //mCascadeSplitDepth = std::vector(); - //mCascadeSplits = std::vector(); - // Framebuffer used for shadow mapping. - - //for (int i = 0; i < 4; i++) - //{ - // m_Framebuffers[i] = CreateRef(false, glm::vec2(4096, 4096)); - // m_Framebuffers[i]->SetTexture(CreateRef(glm::vec2(4096, 4096), GL_DEPTH_COMPONENT), GL_DEPTH_ATTACHMENT); - //} } void LightComponent::SetCastShadows(bool toggle) @@ -42,7 +30,8 @@ namespace Nuake { } } - else { + else + { for (int i = 0; i < CSM_AMOUNT; i++) { m_Framebuffers[i] = nullptr; @@ -55,87 +44,8 @@ namespace Nuake { return glm::ortho(-25.0f, 25.0f, -25.0f, 25.0f, -25.0f, 25.0f); } - void LightComponent::SetDirection(glm::vec3 dir) + Vector3 LightComponent::GetDirection() { - - } - - glm::vec3 LightComponent::GetDirection() - { - //glm::mat4 start = glm::mat4(1.0f); - //glm::vec3 defaultDirection(0, 0, 1); // forward - // - //start = glm::rotate(start, glm::radians(Direction.x), glm::vec3(1, 0, 0)); - //start = glm::rotate(start, glm::radians(Direction.y), glm::vec3(0, 1, 0)); - //start = glm::rotate(start, glm::radians(Direction.z), glm::vec3(0, 0, 1)); - - //return glm::vec3(start * glm::vec4(defaultDirection, 1.0f)); return glm::normalize(Direction); } - - - void LightComponent::BeginDrawShadow() - { - Renderer::m_ShadowmapShader->Bind(); - //m_Framebuffer->Bind(); - - // Render scene... - - } - - void LightComponent::EndDrawShadow() - { - //m_Framebuffer->Unbind(); - } - - void LightComponent::DrawShadow() - { - if (Type != Directional) - return; - - Renderer::m_ShadowmapShader->Bind(); - } - - void LightComponent::DrawEditor() { - ImGui::TextColored(ImGui::GetStyleColorVec4(1), "Light properties"); - ImGui::ColorEdit3("Light Color", &Color.r); - ImGui::SliderFloat("Strength", &Strength, 0.0f, 50.0f); - bool before = CastShadows; - ImGui::Checkbox("Cast shadows", &CastShadows); - - if (CastShadows && before == false) - SetCastShadows(true); - - const char* types[] = { "Directional", "Point", "Spot" }; - static const char* current_item = types[Type]; - - if (ImGui::BeginCombo("Type", current_item)) // The second parameter is the label previewed before opening the combo. - { - for (int n = 0; n < IM_ARRAYSIZE(types); n++) - { - bool is_selected = (current_item == types[n]); // You can store your selection however you want, outside or inside your objects - if (ImGui::Selectable(types[n], is_selected)) { - current_item = types[n]; - Type = (LightType)n; - } - if (is_selected) - ImGui::SetItemDefaultFocus(); // You may set the initial focus when opening the combo (scrolling + for keyboard navigation support) - } - ImGui::EndCombo(); - } - - if (Type == Directional) { - ImGui::Checkbox("Sync with sky", &SyncDirectionWithSky); - ImGui::Checkbox("Volumetric?", &IsVolumetric); - ImGuiHelper::DrawVec3("Direction", &Direction); - } - - //if (Type == 1) { - // ImGui::SliderFloat("Attenuation", &Attenuation, 0.0f, 1.0f); - // ImGui::SliderFloat("Linear attenuation", &LinearAttenuation, 0.0f, 1.0f); - // ImGui::SliderFloat("Quadratic attenuation", &QuadraticAttenuation, 0.0f, 1.0f); - //} - - //Direction = glm::normalize(Direction); - } } From ecf26ef9ed05722e0ade7d3629572de00e15aa73 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 19 Jul 2023 11:25:51 -0400 Subject: [PATCH 07/15] Fix viewport selection happening if clicked outside of viewport and dragged in --- Editor/src/Windows/EditorInterface.cpp | 12 ++++++++++-- Editor/src/Windows/EditorInterface.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 1731eddf..e174f19b 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -79,6 +79,7 @@ namespace Nuake { { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); std::string name = ICON_FA_GAMEPAD + std::string(" Scene"); + if (ImGui::Begin(name.c_str())) { ImGui::PopStyleVar(); @@ -242,8 +243,11 @@ namespace Nuake { } } - if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_1) && !ImGuizmo::IsUsing()) + m_IsViewportFocused = ImGui::IsWindowFocused(); + if (m_IsHoveringViewport && Input::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_2) && !ImGuizmo::IsUsing()) { + ImGui::FocusWindow(ImGui::GetCurrentWindow()); + const auto windowPosNuake = Vector2(windowPos.x, windowPos.y); auto& gbuffer = Engine::GetCurrentScene()->mSceneRenderer->GetGBuffer(); auto pixelPos = Input::GetMousePosition() - windowPosNuake; @@ -1513,7 +1517,11 @@ namespace Nuake { } auto& editorCam = Engine::GetCurrentScene()->m_EditorCamera; - editorCam->Update(ts, m_IsHoveringViewport); + + if (m_IsViewportFocused) + { + editorCam->Update(ts, m_IsHoveringViewport); + } const bool entityIsSelected = Selection.Type == EditorSelectionType::Entity && Selection.Entity.IsValid(); if (entityIsSelected && Input::IsKeyPressed(GLFW_KEY_F)) diff --git a/Editor/src/Windows/EditorInterface.h b/Editor/src/Windows/EditorInterface.h index 57f5ac94..740b3a1b 100644 --- a/Editor/src/Windows/EditorInterface.h +++ b/Editor/src/Windows/EditorInterface.h @@ -26,6 +26,8 @@ namespace Nuake bool m_DebugCollisions = true; bool m_ShowOverlay = true; bool m_IsHoveringViewport = false; + bool m_IsViewportFocused = false; + Vector2 m_ViewportPos = {0, 0}; Vector2 m_ViewportSize = {}; From 1ab7c53a9a2d352b3d3d684e37e6a596c98eb543 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 19 Jul 2023 11:27:00 -0400 Subject: [PATCH 08/15] Fixed editor camera not updating --- Nuake/src/Scene/EditorCamera.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Nuake/src/Scene/EditorCamera.cpp b/Nuake/src/Scene/EditorCamera.cpp index 9d80a962..79d0c177 100644 --- a/Nuake/src/Scene/EditorCamera.cpp +++ b/Nuake/src/Scene/EditorCamera.cpp @@ -164,6 +164,8 @@ namespace Nuake mouseLastX = x; mouseLastY = y; controlled = true; + + SetDirection(glm::normalize(Direction)); } else if (Input::YScroll != 0) { @@ -171,6 +173,7 @@ namespace Nuake Input::YScroll = 0.0f; } + SetDirection(glm::normalize(Direction)); mouseLastX = x; mouseLastY = y; } @@ -192,7 +195,8 @@ namespace Nuake Direction.y = sin(glm::radians(Pitch)); Direction.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch)); Direction = glm::normalize(Direction); - Right = glm::normalize(glm::cross(Up, Direction)); + SetDirection(Direction); + } void EditorCamera::SetYaw(float yaw) From f40b760a01d942ec783b1e7cf633940377842c55 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 19 Jul 2023 11:31:08 -0400 Subject: [PATCH 09/15] Fix build --- Editor/src/ComponentsPanel/BoxColliderPanel.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Editor/src/ComponentsPanel/BoxColliderPanel.h b/Editor/src/ComponentsPanel/BoxColliderPanel.h index 1e3d56f5..c210f651 100644 --- a/Editor/src/ComponentsPanel/BoxColliderPanel.h +++ b/Editor/src/ComponentsPanel/BoxColliderPanel.h @@ -1,10 +1,13 @@ #pragma once #include "ComponentPanel.h" -#include + #include +#include +#include #include -class BoxColliderPanel : ComponentPanel { +class BoxColliderPanel : ComponentPanel +{ public: BoxColliderPanel() {} @@ -28,7 +31,7 @@ public: component.Size.z = std::max(component.Size.z, 0.0001f); ImGui::TableNextColumn(); - ComponentTableReset(component.Size, Vector3(0.5f, 0.5f, 0.5f)); + ComponentTableReset(component.Size, Nuake::Vector3(0.5f, 0.5f, 0.5f)); } ImGui::TableNextColumn(); { From f186c3780ecf02e5373d1a1f1bf672db3678653d Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 20 Jul 2023 20:38:16 -0400 Subject: [PATCH 10/15] Fixed Crash when pressing stop when not in play mode --- Editor/src/Windows/EditorInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index e174f19b..81af2da4 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -103,7 +103,7 @@ namespace Nuake { ImGui::SameLine(); - if (ImGui::Button(ICON_FA_STOP, ImVec2(30, 30)) || Input::IsKeyPressed(GLFW_KEY_F8)) + if ((ImGui::Button(ICON_FA_STOP, ImVec2(30, 30)) || Input::IsKeyPressed(GLFW_KEY_F8)) && Engine::IsPlayMode()) { Engine::ExitPlayMode(); From 40f61f4775481140a731cc9e08d6a5ca3d6f44d7 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 20 Jul 2023 22:03:04 -0400 Subject: [PATCH 11/15] Fix scene scripting api mismatch signatures --- Editor/resources/Scripts/Scene.wren | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/resources/Scripts/Scene.wren b/Editor/resources/Scripts/Scene.wren index 1464c3c3..a5f0eb65 100644 --- a/Editor/resources/Scripts/Scene.wren +++ b/Editor/resources/Scripts/Scene.wren @@ -4,7 +4,7 @@ import "Nuake:Math" for Vector3 class Scene { foreign static GetEntityID(name) - foreign static AddEntity(name) + foreign static CreateEntity(name) foreign static AddPrefab(prefabPath) static GetEntity(name) { From ed8998301abdb2de9ae35e000a4e39d25d706552 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 20 Jul 2023 22:17:54 -0400 Subject: [PATCH 12/15] Removed hide bar button --- Nuake/src/Window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 29b92506..2a3f2e5b 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -236,6 +236,7 @@ namespace Nuake ImGui::StyleColorsDark(); ImGuiStyle& s = ImGui::GetStyle(); + s.WindowMenuButtonPosition = ImGuiDir_None; s.FrameRounding = 2.0f; s.GrabRounding = 2.0f; s.CellPadding = ImVec2(8, 8); From 14ff25809407ca748abc17c1512fab2d790abf58 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 21 Jul 2023 00:11:49 -0400 Subject: [PATCH 13/15] Updated style for file browser --- Editor/src/Windows/FileSystemUI.cpp | 78 +++++++++++++++++++++++++---- Nuake/src/Window.cpp | 7 ++- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 1a07bf03..7a43c250 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -61,16 +61,16 @@ namespace Nuake void FileSystemUI::EditorInterfaceDrawFiletree(Ref dir) { - ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; + ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_FramePadding; //if (is_selected) - std::string icon = ICON_FA_FOLDER; if (m_CurrentDirectory == dir) base_flags |= ImGuiTreeNodeFlags_Selected; if (dir->Directories.size() <= 0) - base_flags = ImGuiTreeNodeFlags_Leaf; + base_flags |= ImGuiTreeNodeFlags_Leaf; - bool open = ImGui::TreeNodeEx(dir->name.c_str(), base_flags); + std::string icon = ICON_FA_FOLDER; + bool open = ImGui::TreeNodeEx((icon + " " + dir->name.c_str()).c_str(), base_flags); if (ImGui::IsItemClicked()) m_CurrentDirectory = dir; @@ -324,16 +324,19 @@ namespace Nuake ImVec2 avail = ImGui::GetContentRegionAvail(); Splitter(true, 4.0f, &sz1, &sz2, 100, 8, avail.y); - if (ImGui::BeginChild("Tree browser", ImVec2(sz1, avail.y))) + ImVec4* colors = ImGui::GetStyle().Colors; + ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]); + ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 8); + if (ImGui::BeginChild("Tree browser", ImVec2(sz1, avail.y), true)) { - ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_DefaultOpen; + ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_FramePadding; bool is_selected = m_CurrentDirectory == FileSystem::RootDirectory; if (is_selected) base_flags |= ImGuiTreeNodeFlags_Selected; std::string icon = ICON_FA_FOLDER; - bool open = ImGui::TreeNodeEx((icon + " " + "Project files").c_str(), base_flags); + bool open = ImGui::TreeNodeEx((icon + " Project files").c_str(), base_flags); if (ImGui::IsItemClicked()) { m_CurrentDirectory = FileSystem::RootDirectory; @@ -348,6 +351,8 @@ namespace Nuake } } + ImGui::PopStyleVar(); + ImGui::PopStyleColor(); ImGui::EndChild(); ImGui::SameLine(); @@ -368,31 +373,82 @@ namespace Nuake if (ImGui::BeginChild("Wrapper", avail)) { avail.y = 30; - if (ImGui::BeginChild("Path", avail)) + if (ImGui::BeginChild("Path", avail, true)) { - if (ImGui::Button("Refresh")) + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + + const auto buttonSize = ImVec2(24, 24); + std::string refreshIcon = ICON_FA_SYNC_ALT; + if (ImGui::Button((refreshIcon).c_str(), buttonSize)) { RefreshFileBrowser(); } ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_ANGLE_LEFT)).c_str(), buttonSize)) + { + if (m_CurrentDirectory != FileSystem::RootDirectory) + { + m_CurrentDirectory = m_CurrentDirectory->Parent; + } + } + + ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_ANGLE_RIGHT)).c_str(), buttonSize)) + { + + } + + ImGui::SameLine(); + + ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); + ImGui::BeginChild("pathBrowser", ImVec2(ImGui::GetContentRegionAvailWidth(), 24)); for (int i = paths.size() - 1; i > 0; i--) { if (i != paths.size()) ImGui::SameLine(); - if (ImGui::Button(paths[i]->name.c_str())) + std::string pathLabel; + if (i == paths.size() - 1) + { + pathLabel = "Project files"; + } + else + { + pathLabel = paths[i]->name; + } + + if (ImGui::Button(pathLabel.c_str())) + { m_CurrentDirectory = paths[i]; + } ImGui::SameLine(); ImGui::Text("/"); } + + ImGui::EndChild(); + ImGui::PopStyleVar(); + ImGui::PopStyleVar(); + ImGui::PopStyleColor(); + ImGui::PopStyleColor(); } + ImGui::EndChild(); + ImDrawList* drawList = ImGui::GetWindowDrawList(); + ImGui::GetWindowDrawList()->AddLine(ImVec2(ImGui::GetCursorPosX(), ImGui::GetCursorPosY()), ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetCursorPosY()), IM_COL32(255, 0, 0, 255), 1.0f); + + ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0)); avail = ImGui::GetContentRegionAvail(); - if (ImGui::BeginChild("Content", avail)) + bool child = ImGui::BeginChild("Content", avail); + ImGui::PopStyleVar(); + if (child) { int width = avail.x; ImVec2 buttonSize = ImVec2(80, 80); diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 2a3f2e5b..62ce9665 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -240,8 +240,10 @@ namespace Nuake s.FrameRounding = 2.0f; s.GrabRounding = 2.0f; s.CellPadding = ImVec2(8, 8); - s.WindowPadding = ImVec2(8, 8); + s.WindowPadding = ImVec2(2, 2); s.ScrollbarRounding = 9.0f; + s.ScrollbarSize = 15.0f; + s.GrabMinSize = 32.0f; s.TabRounding = 0; s.WindowRounding = 0; s.ChildRounding = 0; @@ -252,6 +254,7 @@ namespace Nuake s.ItemInnerSpacing = ImVec2(4, 4); s.TabRounding = 4.0f; s.WindowBorderSize = 0.0f; + s.IndentSpacing = 12.0f; s.ChildBorderSize = 0.0f; ImVec4* colors = ImGui::GetStyle().Colors; @@ -269,7 +272,7 @@ namespace Nuake colors[ImGuiCol_TitleBgActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.00f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 1.00f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); From c748b9a21836da67fdc2086a02849c939609054a Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 21 Jul 2023 00:18:01 -0400 Subject: [PATCH 14/15] Using font manager for folder icons --- Editor/src/Windows/FileSystemUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 7a43c250..eb059fc1 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -86,7 +86,7 @@ namespace Nuake void FileSystemUI::DrawDirectory(Ref directory) { - ImGui::PushFont(EditorInterface::bigIconFont); + ImGui::PushFont(FontManager::GetFont(Icons)); const char* icon = ICON_FA_FOLDER; const std::string id = ICON_FA_FOLDER + std::string("##") + directory->name; if (ImGui::Button(id.c_str(), ImVec2(100, 100))) From 46a531fd7d6a29bbae32c8f8a4f5108d67b73c1b Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 21 Jul 2023 15:31:52 -0400 Subject: [PATCH 15/15] Better filesystem ui --- Editor/src/Windows/FileSystemUI.cpp | 33 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index eb059fc1..d75531c3 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -44,8 +44,6 @@ const std::string TEMPLATE_SCRIPT_SECOND = R"( is ScriptableEntity { namespace Nuake { - - // TODO: add filetree in same panel void FileSystemUI::Draw() { @@ -336,11 +334,13 @@ namespace Nuake base_flags |= ImGuiTreeNodeFlags_Selected; std::string icon = ICON_FA_FOLDER; - bool open = ImGui::TreeNodeEx((icon + " Project files").c_str(), base_flags); + ImGui::PushFont(FontManager::GetFont(Bold)); + bool open = ImGui::TreeNodeEx("PROJECT", base_flags); if (ImGui::IsItemClicked()) { m_CurrentDirectory = FileSystem::RootDirectory; } + ImGui::PopFont(); if (open) { @@ -377,7 +377,7 @@ namespace Nuake { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - const auto buttonSize = ImVec2(24, 24); + const auto buttonSize = ImVec2(26, 26); std::string refreshIcon = ICON_FA_SYNC_ALT; if (ImGui::Button((refreshIcon).c_str(), buttonSize)) { @@ -386,6 +386,7 @@ namespace Nuake ImGui::SameLine(); + const auto cursorStart = ImGui::GetCursorPosX(); if (ImGui::Button((std::string(ICON_FA_ANGLE_LEFT)).c_str(), buttonSize)) { if (m_CurrentDirectory != FileSystem::RootDirectory) @@ -396,17 +397,20 @@ namespace Nuake ImGui::SameLine(); + const auto cursorEnd = ImGui::GetCursorPosX(); + const auto buttonWidth = cursorEnd - cursorStart; if (ImGui::Button((std::string(ICON_FA_ANGLE_RIGHT)).c_str(), buttonSize)) { - + // TODO } + const uint32_t numButtonAfterPathBrowser = 2; ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_ChildBg, colors[ImGuiCol_TitleBgCollapsed]); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); - ImGui::BeginChild("pathBrowser", ImVec2(ImGui::GetContentRegionAvailWidth(), 24)); + ImGui::BeginChild("pathBrowser", ImVec2(ImGui::GetContentRegionAvailWidth() - (numButtonAfterPathBrowser * buttonWidth) - 4.0, 24)); for (int i = paths.size() - 1; i > 0; i--) { if (i != paths.size()) @@ -435,7 +439,22 @@ namespace Nuake ImGui::PopStyleVar(); ImGui::PopStyleVar(); ImGui::PopStyleColor(); - ImGui::PopStyleColor(); + + ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_FOLDER_OPEN)).c_str(), buttonSize)) + { + OS::ShowInFileExplorer(m_CurrentDirectory->fullPath); + } + + ImGui::SameLine(); + + if (ImGui::Button((std::string(ICON_FA_ELLIPSIS_V)).c_str(), buttonSize)) + { + // TODO + } + + ImGui::PopStyleColor(); // Button color } ImGui::EndChild();