From 415e47780ca2d129df5598fa517148b9556a29a7 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Wed, 21 Sep 2022 14:54:57 +0800 Subject: [PATCH] Completed Transform System --- .../Math/Transform/SHTransformComponent.cpp | 38 +++++++++++++++++++ .../src/Math/Transform/SHTransformComponent.h | 17 +++++---- .../src/Math/Transform/SHTransformSystem.cpp | 4 +- .../src/Math/Transform/SHTransformSystem.h | 4 ++ 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/SHADE_Engine/src/Math/Transform/SHTransformComponent.cpp b/SHADE_Engine/src/Math/Transform/SHTransformComponent.cpp index af56b67a..cdc5105f 100644 --- a/SHADE_Engine/src/Math/Transform/SHTransformComponent.cpp +++ b/SHADE_Engine/src/Math/Transform/SHTransformComponent.cpp @@ -21,8 +21,46 @@ namespace SHADE SHTransformComponent::SHTransformComponent() noexcept : SHComponent {} + , dirty { true } {} + SHTransformComponent::SHTransformComponent(const SHTransformComponent& rhs) noexcept + : SHComponent {} + , dirty { true } + , local { rhs.local } + , world { rhs.world } + {} + + SHTransformComponent::SHTransformComponent(SHTransformComponent&& rhs) noexcept + : SHComponent {} + , dirty { true } + , local { std::move(rhs.local) } + , world { std::move(rhs.world) } + {} + + /*-----------------------------------------------------------------------------------*/ + /* Operator Overload Definitions */ + /*-----------------------------------------------------------------------------------*/ + + SHTransformComponent& SHTransformComponent::operator=(const SHTransformComponent& rhs) noexcept + { + dirty = true; + local = rhs.local; + world = rhs.world; + + return *this; + } + + SHTransformComponent& SHTransformComponent::operator=(SHTransformComponent&& rhs) noexcept + { + dirty = true; + local = std::move(rhs.local); + world = std::move(rhs.world); + + return *this; + } + + /*-----------------------------------------------------------------------------------*/ /* Getter Function Definitions */ /*-----------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Math/Transform/SHTransformComponent.h b/SHADE_Engine/src/Math/Transform/SHTransformComponent.h index c3fa8a01..7f7dd473 100644 --- a/SHADE_Engine/src/Math/Transform/SHTransformComponent.h +++ b/SHADE_Engine/src/Math/Transform/SHTransformComponent.h @@ -37,15 +37,18 @@ namespace SHADE /* Constructors & Destructor */ /*---------------------------------------------------------------------------------*/ - ~SHTransformComponent () override = default; + ~SHTransformComponent () override = default; - SHTransformComponent () noexcept; + SHTransformComponent () noexcept; + SHTransformComponent (const SHTransformComponent& rhs) noexcept; + SHTransformComponent (SHTransformComponent&& rhs) noexcept; - // TODO(Diren): Do I implement these in a specific manner or delete? - SHTransformComponent (const SHTransformComponent&) = delete; - SHTransformComponent (SHTransformComponent&&) = delete; - SHTransformComponent& operator=(const SHTransformComponent&) = delete; - SHTransformComponent& operator=(SHTransformComponent&&) = delete; + /*---------------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*---------------------------------------------------------------------------------*/ + + SHTransformComponent& operator=(const SHTransformComponent& rhs) noexcept; + SHTransformComponent& operator=(SHTransformComponent&& rhs) noexcept; /*---------------------------------------------------------------------------------*/ /* Getter Functions */ diff --git a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp index b9701020..6a1daff2 100644 --- a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp +++ b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp @@ -37,8 +37,6 @@ namespace SHADE // Get the current scene graph to traverse and update auto& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); UpdateEntity(sceneGraph.GetRoot()); - - // Clear all dirty flags } /*-----------------------------------------------------------------------------------*/ @@ -62,6 +60,8 @@ namespace SHADE UpdateTransform(*childTransform, NODE_TRANSFORM); UpdateEntity(child); + + childTransform->dirty = false; } } diff --git a/SHADE_Engine/src/Math/Transform/SHTransformSystem.h b/SHADE_Engine/src/Math/Transform/SHTransformSystem.h index 516bd209..5eebd292 100644 --- a/SHADE_Engine/src/Math/Transform/SHTransformSystem.h +++ b/SHADE_Engine/src/Math/Transform/SHTransformSystem.h @@ -35,6 +35,10 @@ namespace SHADE SHTransformSystem (const SHTransformSystem&) = delete; SHTransformSystem (SHTransformSystem&&) = delete; + /*---------------------------------------------------------------------------------*/ + /* Operator Overloads */ + /*---------------------------------------------------------------------------------*/ + SHTransformSystem& operator= (const SHTransformSystem&) = delete; SHTransformSystem& operator= (SHTransformSystem&&) = delete;