From 2262b103c2eadd048ed1563f5918cee55476ee12 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Wed, 9 Aug 2023 00:31:41 -0400 Subject: [PATCH] Code cleanup --- Nuake/src/Scene/Components/LightComponent.cpp | 1 - Nuake/src/Scene/Components/LightComponent.h | 2 +- Nuake/src/Scene/Entities/Entity.h | 13 +++++++++---- Nuake/src/Scripting/Modules/SceneModule.h | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Nuake/src/Scene/Components/LightComponent.cpp b/Nuake/src/Scene/Components/LightComponent.cpp index 42b69d47..939240ca 100644 --- a/Nuake/src/Scene/Components/LightComponent.cpp +++ b/Nuake/src/Scene/Components/LightComponent.cpp @@ -27,7 +27,6 @@ namespace Nuake auto texture = CreateRef(glm::vec2(4096, 4096), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT); texture->SetParameter(GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); m_Framebuffers[i]->SetTexture(texture, GL_DEPTH_ATTACHMENT); - } } else diff --git a/Nuake/src/Scene/Components/LightComponent.h b/Nuake/src/Scene/Components/LightComponent.h index d1f88b32..63aacde2 100644 --- a/Nuake/src/Scene/Components/LightComponent.h +++ b/Nuake/src/Scene/Components/LightComponent.h @@ -71,7 +71,7 @@ namespace Nuake mCascadeSplits[i] = (d - nearClip) / clipRange; } - //mCascadeSplits[0] = 0.2f; + mCascadeSplits[0] = 0.01f; //mCascadeSplits[1] = 0.45f; //mCascadeSplits[2] = 1.0f; diff --git a/Nuake/src/Scene/Entities/Entity.h b/Nuake/src/Scene/Entities/Entity.h index 305034a4..f51a0837 100644 --- a/Nuake/src/Scene/Entities/Entity.h +++ b/Nuake/src/Scene/Entities/Entity.h @@ -21,16 +21,19 @@ namespace Nuake int GetID() { return GetComponent().ID; } template - bool HasComponent() { + bool HasComponent() const + { return m_Scene->m_Registry.all_of(m_EntityHandle); } - bool IsValid() { + bool IsValid() const + { return m_Scene->m_Registry.valid((entt::entity)GetHandle()); } template - T& AddComponent() { + T& AddComponent() + { T& component = m_Scene->m_Registry.emplace_or_replace (m_EntityHandle); return component; } @@ -66,9 +69,11 @@ namespace Nuake json Serialize() override; bool Deserialize(const json& str); - Scene* GetScene() { + Scene* GetScene() const + { return m_Scene; } + private: entt::entity m_EntityHandle; Scene* m_Scene; diff --git a/Nuake/src/Scripting/Modules/SceneModule.h b/Nuake/src/Scripting/Modules/SceneModule.h index 0a2ffc7d..c2f6708f 100644 --- a/Nuake/src/Scripting/Modules/SceneModule.h +++ b/Nuake/src/Scripting/Modules/SceneModule.h @@ -372,6 +372,7 @@ namespace Nuake double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get()); auto& transform = ent.GetComponent(); + // set the slots double x = wrenGetSlotDouble(vm, 2); double y = wrenGetSlotDouble(vm, 3); @@ -431,7 +432,8 @@ namespace Nuake } } - static void BrushGetTargetsCount(WrenVM* vm) { + static void BrushGetTargetsCount(WrenVM* vm) + { double handle = wrenGetSlotDouble(vm, 1); Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());