diff --git a/Engine/Launcher.exe b/Engine/Launcher.exe index 326ab3034..87caddc79 100644 --- a/Engine/Launcher.exe +++ b/Engine/Launcher.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78d636df16f940a3d3e891ef7449bf116d4619363b57f9796c0528d6db679000 -size 26982912 +oid sha256:996b325f385441f73dde5c8119d8a46bf56fbed851e7cc133c093edc0c177bc9 +size 26463744 diff --git a/Engine/Sandbox.exe b/Engine/Sandbox.exe index a257395f8..8603bb5bb 100644 --- a/Engine/Sandbox.exe +++ b/Engine/Sandbox.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e5484bb4d7bec0c0c1e53c86fc788a52f3de8b86615119034928b02e4ee00f1 -size 44156416 +oid sha256:838f216270a3f3f47efdf63e2e3bb9b0ea4169dea5c8806c882de39b8c31bb52 +size 42923008 diff --git a/Engine/Scripts/Volt-ScriptCore.dll b/Engine/Scripts/Volt-ScriptCore.dll index 50cbcf6af..01e88b5e7 100644 --- a/Engine/Scripts/Volt-ScriptCore.dll +++ b/Engine/Scripts/Volt-ScriptCore.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc1912fe7bc6503c3bfb4b847c5e885000d7016ebae92551a0bfd32f95892f8c -size 95744 +oid sha256:d15779355f2782df5362ba06daa0df3bcf3c6fc9c44e974beea81773219de866 +size 94720 diff --git a/Engine/Scripts/Volt-ScriptCore.pdb b/Engine/Scripts/Volt-ScriptCore.pdb index 2f340a7bf..68bbc066a 100644 --- a/Engine/Scripts/Volt-ScriptCore.pdb +++ b/Engine/Scripts/Volt-ScriptCore.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:366710b9d39f95c1a47d1621c27d7868794fb5d69ed5b1eda9879a0bf5e7d89d -size 37384 +oid sha256:68b110f72ca743bb02aa7edd6d3d84658c87d324ed0598ba460967ad9c012c31 +size 47760 diff --git a/Volt/Amp/premake5.lua b/Volt/Amp/premake5.lua index 3e4faea0e..fd61d2011 100644 --- a/Volt/Amp/premake5.lua +++ b/Volt/Amp/premake5.lua @@ -12,23 +12,11 @@ project "Amp" warnings "Extra" - flags - { - "FatalWarnings" - } - - disablewarnings - { - "4005", - "4201", - "4100" - } - - linkoptions - { - "/ignore:4006", - "/ignore:4099" - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() files { @@ -45,21 +33,13 @@ project "Amp" "%{IncludeDir.yaml}", "%{IncludeDir.spdlog}", "%{IncludeDir.ImGui}", - "%{IncludeDir.Optick}", "%{IncludeDir.fmod}", - "%{IncludeDir.glm}", "%{IncludeDir.wwise}" } defines { - "NOMINMAX", - "_HAS_STD_BYTE=0", - "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", "PX_PHYSX_STATIC_LIB", - - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED" } filter "files:vendor/**.cpp" diff --git a/Volt/GraphKey/premake5.lua b/Volt/GraphKey/premake5.lua index 7241256e9..cb666c98c 100644 --- a/Volt/GraphKey/premake5.lua +++ b/Volt/GraphKey/premake5.lua @@ -12,23 +12,11 @@ project "GraphKey" warnings "Extra" - flags - { - "FatalWarnings" - } - - disablewarnings - { - "4005", - "4201", - "4100" - } - - linkoptions - { - "/ignore:4006", - "/ignore:4099" - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() buildoptions { @@ -50,10 +38,8 @@ project "GraphKey" "../Nexus/src", "%{IncludeDir.yaml}", - "%{IncludeDir.Optick}", "%{IncludeDir.spdlog}", - "%{IncludeDir.glm}", "%{IncludeDir.fmod}", "%{IncludeDir.ImGui}", @@ -68,11 +54,7 @@ project "GraphKey" defines { - "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", "PX_PHYSX_STATIC_LIB", - - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED" } filter "files:vendor/**.cpp" diff --git a/Volt/GraphKey/src/GraphKey/Graph.cpp b/Volt/GraphKey/src/GraphKey/Graph.cpp index 1a849df9b..a4b67f8d7 100644 --- a/Volt/GraphKey/src/GraphKey/Graph.cpp +++ b/Volt/GraphKey/src/GraphKey/Graph.cpp @@ -93,7 +93,7 @@ namespace GraphKey } } - Graph::Graph(entt::entity entity) + Graph::Graph(Volt::EntityID entity) : myEntity(entity) { } @@ -303,7 +303,7 @@ namespace GraphKey { Ref newNode; - if (dstGraph->GetEntity() != entt::null) + if (dstGraph->GetEntity() != Volt::Entity::NullID()) { newNode = n->CreateCopy(dstGraph.get(), dstGraph->GetEntity()); } @@ -323,7 +323,7 @@ namespace GraphKey newLink.output = l.output; } - if (dstGraph->myEntity == entt::null) + if (dstGraph->myEntity == Volt::Entity::NullID()) { dstGraph->myEntity = srcGraph->myEntity; } diff --git a/Volt/GraphKey/src/GraphKey/Graph.h b/Volt/GraphKey/src/GraphKey/Graph.h index 9c85ac380..2f36dcdc1 100644 --- a/Volt/GraphKey/src/GraphKey/Graph.h +++ b/Volt/GraphKey/src/GraphKey/Graph.h @@ -33,7 +33,7 @@ namespace GraphKey { public: Graph(); - Graph(entt::entity entity); + Graph(Volt::EntityID entity); ~Graph() override = default; void OnEvent(Volt::Event& e); @@ -56,14 +56,14 @@ namespace GraphKey const bool IsAttributeLinked(const Volt::UUID id) const; - inline const entt::entity GetEntity() const { return myEntity; } + inline const Volt::EntityID GetEntity() const { return myEntity; } inline std::vector>& GetNodes() { return myNodes; } inline std::vector& GetLinks() { return myLinks; } inline std::vector& GetBlackboard() { return myParentBlackboard ? *myParentBlackboard : myBlackboard; } inline std::vector& GetEvents() { return myGraphEvents; } inline EventSystem& GetEventSystem() { return myEventSystem; } - inline void SetEntity(entt::entity id) { myEntity = id; } + inline void SetEntity(Volt::EntityID id) { myEntity = id; } inline void SetParentBlackboard(std::vector* blackboard) { myParentBlackboard = blackboard; } void AddEvent(const std::string& name, const Volt::UUID id = {}); @@ -105,7 +105,7 @@ namespace GraphKey std::vector myBlackboard; std::vector myGraphEvents; - entt::entity myEntity = entt::null; + Volt::EntityID myEntity = Volt::Entity::NullID(); std::vector> myNodes; std::vector myLinks; diff --git a/Volt/GraphKey/src/GraphKey/Node.cpp b/Volt/GraphKey/src/GraphKey/Node.cpp index a5966af0d..8a1fb7986 100644 --- a/Volt/GraphKey/src/GraphKey/Node.cpp +++ b/Volt/GraphKey/src/GraphKey/Node.cpp @@ -49,7 +49,7 @@ namespace GraphKey } } - Ref Node::CreateCopy(Graph* ownerGraph, entt::entity entity) + Ref Node::CreateCopy(Graph* ownerGraph, Volt::EntityID entity) { Ref newNode = Registry::Create(GetRegistryName()); diff --git a/Volt/GraphKey/src/GraphKey/Node.h b/Volt/GraphKey/src/GraphKey/Node.h index 6f95dcb04..c0168fcad 100644 --- a/Volt/GraphKey/src/GraphKey/Node.h +++ b/Volt/GraphKey/src/GraphKey/Node.h @@ -67,7 +67,7 @@ namespace GraphKey virtual void Serialize(YAML::Emitter&) {} virtual void Deserialize(const YAML::Node&) {} - virtual Ref CreateCopy(Graph* ownerGraph, entt::entity entity = entt::null); + virtual Ref CreateCopy(Graph* ownerGraph, Volt::EntityID entity = Volt::Entity::NullID()); virtual const std::string GetName() = 0; virtual const glm::vec4 GetColor() = 0; @@ -96,7 +96,7 @@ namespace GraphKey void SetOutputData(uint32_t index, const T& data); Volt::UUID id{}; - entt::entity nodeEntity = entt::null; + Volt::EntityID nodeEntity = Volt::Entity::NullID(); std::vector inputs; std::vector outputs; diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.cpp b/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.cpp index a5bb9d3b0..37603ddd7 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.cpp +++ b/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.cpp @@ -396,7 +396,7 @@ namespace GraphKey } } - Ref LayeredBlendPerBoneNode::CreateCopy(Graph* ownerGraph, entt::entity entityId) + Ref LayeredBlendPerBoneNode::CreateCopy(Graph* ownerGraph, Volt::EntityID entityId) { Ref copy = Node::CreateCopy(ownerGraph, entityId); Ref blendNode = std::reinterpret_pointer_cast(copy); diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.h b/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.h index 21a7fbabc..c73974b3c 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.h +++ b/Volt/GraphKey/src/GraphKey/Nodes/Animation/BlendNodes.h @@ -72,7 +72,7 @@ namespace GraphKey inline std::vector& GetBlendIncludeFilters() { return myIncludeFilters; } inline std::vector& GetBlendExcludeFilters() { return myExcludeFilters; } - Ref CreateCopy(Graph* ownerGraph, entt::entity entity = entt::null) override; + Ref CreateCopy(Graph* ownerGraph, Volt::EntityID entity = Volt::EntityID(0)) override; private: void TryApplyLayeredBlendPerBone(); diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Animation/SequenceNodes.cpp b/Volt/GraphKey/src/GraphKey/Nodes/Animation/SequenceNodes.cpp index b222eb046..8151b3927 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Animation/SequenceNodes.cpp +++ b/Volt/GraphKey/src/GraphKey/Nodes/Animation/SequenceNodes.cpp @@ -75,14 +75,14 @@ namespace GraphKey const uint32_t currentFrame = anim->GetFrameFromStartTime(animGraph->GetStartTime(), speed); const int32_t animationIndex = character->GetAnimationIndexFromHandle(animHandle); - if (myGraph->GetEntity() != entt::null && Volt::SceneManager::GetActiveScene().lock() && animationIndex != -1 && character->HasAnimationEvents((uint32_t)animationIndex)) + if (myGraph->GetEntity() != Volt::Entity::NullID() && Volt::SceneManager::GetActiveScene() && animationIndex != -1 && character->HasAnimationEvents((uint32_t)animationIndex)) { const auto& animEvents = character->GetAnimationEvents((uint32_t)animationIndex); for (const auto& event : animEvents) { if (event.frame == currentFrame && (int32_t)currentFrame != myLastFrame) { - Volt::Entity entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + Volt::Entity entity = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); if (!entity) { continue; diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.cpp b/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.cpp index 179e19acb..a397ebebc 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.cpp +++ b/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.cpp @@ -220,7 +220,7 @@ namespace GraphKey return "State Machine"; } - Ref StateMachineNode::CreateCopy(Graph* ownerGraph, entt::entity entity) + Ref StateMachineNode::CreateCopy(Graph* ownerGraph, Volt::EntityID entity) { Ref copy = Node::CreateCopy(ownerGraph, entity); Ref stateMachineNode = std::reinterpret_pointer_cast(copy); diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.h b/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.h index e43bf3f42..5b7227b70 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.h +++ b/Volt/GraphKey/src/GraphKey/Nodes/Animation/StateMachineNodes.h @@ -18,7 +18,7 @@ namespace GraphKey void Deserialize(const YAML::Node& node) override; const std::string GetName() override; - Ref CreateCopy(Graph* ownerGraph, entt::entity entity = entt::null) override; + Ref CreateCopy(Graph* ownerGraph, Volt::EntityID entity = Volt::Entity::NullID()) override; inline const glm::vec4 GetColor() override { return { 1.f }; } inline const Ref GetStateMachine() const { return myStateMachine; } diff --git a/Volt/GraphKey/src/GraphKey/Nodes/ComponentNodes.cpp b/Volt/GraphKey/src/GraphKey/Nodes/ComponentNodes.cpp index 7cc45c233..308aa82ae 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/ComponentNodes.cpp +++ b/Volt/GraphKey/src/GraphKey/Nodes/ComponentNodes.cpp @@ -8,7 +8,7 @@ namespace GraphKey { void LightNode::Initialize() { - inputs[1].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[1].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } void LightNode::SetProperties() @@ -28,7 +28,7 @@ namespace GraphKey void ChangeLightColorNode::Initialize() { - inputs[1].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[1].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } void ChangeLightColorNode::OnEvent(Volt::Event& e) diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Entity/BaseEntityNodes.cpp b/Volt/GraphKey/src/GraphKey/Nodes/Entity/BaseEntityNodes.cpp index 210d60923..db1c008e0 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Entity/BaseEntityNodes.cpp +++ b/Volt/GraphKey/src/GraphKey/Nodes/Entity/BaseEntityNodes.cpp @@ -26,7 +26,7 @@ namespace GraphKey void CreateEntityNode::CreateEntity() { auto activeScene = Volt::SceneManager::GetActiveScene(); - auto scenePtr = activeScene.lock(); + auto scenePtr = activeScene; if (scenePtr) { @@ -58,7 +58,7 @@ namespace GraphKey { if (!std::any_cast(outputs[0].data)) { - outputs[0].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + outputs[0].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } @@ -81,7 +81,7 @@ namespace GraphKey auto activeScene = Volt::SceneManager::GetActiveScene(); auto entity = GetInput(1); - auto scenePtr = activeScene.lock(); + auto scenePtr = activeScene; if (scenePtr && entity) { @@ -108,7 +108,7 @@ namespace GraphKey { if (!std::any_cast(inputs[0].data)) { - inputs[0].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[0].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } @@ -133,7 +133,7 @@ namespace GraphKey void SelfNode::Initialize() { - outputs[0].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + outputs[0].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } void SelfNode::GetEntity() diff --git a/Volt/GraphKey/src/GraphKey/Nodes/Entity/TransformNodes.cpp b/Volt/GraphKey/src/GraphKey/Nodes/Entity/TransformNodes.cpp index a0fc958f0..4ccd5c1df 100644 --- a/Volt/GraphKey/src/GraphKey/Nodes/Entity/TransformNodes.cpp +++ b/Volt/GraphKey/src/GraphKey/Nodes/Entity/TransformNodes.cpp @@ -24,7 +24,7 @@ namespace GraphKey { if (!std::any_cast(inputs[0].data)) { - inputs[0].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[0].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } @@ -76,7 +76,7 @@ namespace GraphKey { if (!std::any_cast(inputs[1].data)) { - inputs[1].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[1].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } @@ -112,7 +112,7 @@ namespace GraphKey { if (!std::any_cast(inputs[1].data)) { - inputs[1].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[1].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } @@ -146,7 +146,7 @@ namespace GraphKey { if (!std::any_cast(inputs[1].data)) { - inputs[1].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[1].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } @@ -180,7 +180,7 @@ namespace GraphKey { if (!std::any_cast(inputs[1].data)) { - inputs[1].data = Volt::Entity{ myGraph->GetEntity(), Volt::SceneManager::GetActiveScene() }; + inputs[1].data = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(myGraph->GetEntity()); } } diff --git a/Volt/Launcher/premake5.lua b/Volt/Launcher/premake5.lua index 600614907..164d94b24 100644 --- a/Volt/Launcher/premake5.lua +++ b/Volt/Launcher/premake5.lua @@ -13,22 +13,14 @@ project "Launcher" warnings "Extra" - flags - { - "FatalWarnings" - } - - disablewarnings - { - "4005", - "4201", - "4100" - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() linkoptions { - "/ignore:4006", - "/ignore:4099", "/ignore:4098", "/ignore:4217", "/WHOLEARCHIVE:Volt", @@ -39,9 +31,6 @@ project "Launcher" defines { "GLFW_INCLUDE_NONE", - - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED" } files @@ -69,7 +58,6 @@ project "Launcher" "%{IncludeDir.spdlog}", "%{IncludeDir.yaml}", "%{IncludeDir.ImGui}", - "%{IncludeDir.Optick}", "%{IncludeDir.imgui_notify}", "%{IncludeDir.ImGuizmo}", "%{IncludeDir.fmod}", @@ -85,7 +73,6 @@ project "Launcher" "%{IncludeDir.steam}", "%{IncludeDir.discord}", - "%{IncludeDir.glm}", "%{IncludeDir.entt}", "%{IncludeDir.ffmpeg}", diff --git a/Volt/Navigation/premake5.lua b/Volt/Navigation/premake5.lua index b9878a55b..261b9e4fd 100644 --- a/Volt/Navigation/premake5.lua +++ b/Volt/Navigation/premake5.lua @@ -12,23 +12,11 @@ project "Navigation" warnings "Extra" - flags - { - "FatalWarnings" - } - - disablewarnings - { - "4005", - "4201", - "4100" - } - - linkoptions - { - "/ignore:4006", - "/ignore:4099" - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() files { @@ -60,7 +48,6 @@ project "Navigation" "../Nexus/src", "%{IncludeDir.yaml}", - "%{IncludeDir.Optick}", "%{IncludeDir.spdlog}", "%{IncludeDir.PhysX}", @@ -89,16 +76,6 @@ project "Navigation" "%{IncludeDir.shaderc_utils}" } - defines - { - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED", - - "_USE_MATH_DEFINES", - "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", - "_CRT_SECURE_NO_WARNINGS" - } - filter "files:vendor/**.c" flags {"NoPCH"} warnings "off" diff --git a/Volt/Navigation/src/Navigation/Core/NavigationSystem.cpp b/Volt/Navigation/src/Navigation/Core/NavigationSystem.cpp index 3c1b0d5eb..6c588e769 100644 --- a/Volt/Navigation/src/Navigation/Core/NavigationSystem.cpp +++ b/Volt/Navigation/src/Navigation/Core/NavigationSystem.cpp @@ -48,7 +48,7 @@ namespace Volt for (auto [entityId, agentId] : agentMap) { - auto entity = Volt::Entity(entityId, myActiveScene); + auto entity = myActiveScene->GetEntityFromUUID(entityId); if (!entity || !entity.HasComponent()) { @@ -74,7 +74,7 @@ namespace Volt crowd->SetAgentPosition(entity, entity.GetPosition()); - if (!crowd->GetAgentMap().contains(id)) + if (!crowd->GetAgentMap().contains(entity.GetID())) { crowd->AddAgent(entity); crowd->UpdateAgentParams(entity); @@ -99,7 +99,7 @@ namespace Volt VT_PROFILE_SCOPE("Update agent positions"); for (auto [entityId, agentId] : agentMap) { - Volt::Entity entity(entityId, myActiveScene.get()); + Volt::Entity entity = myActiveScene->GetEntityFromUUID(entityId); if (entity.GetComponent().active) { SyncDetourPosition(entity, e.GetTimestep()); diff --git a/Volt/Navigation/src/Navigation/Core/NavigationSystem.h b/Volt/Navigation/src/Navigation/Core/NavigationSystem.h index b68300fce..abc02491e 100644 --- a/Volt/Navigation/src/Navigation/Core/NavigationSystem.h +++ b/Volt/Navigation/src/Navigation/Core/NavigationSystem.h @@ -38,7 +38,7 @@ namespace Volt void InitAgents(); void ClearAgents(); - std::unordered_map myEntityIdToTargetPosMap; + std::unordered_map myEntityIdToTargetPosMap; Ref myNavMesh = nullptr; Ref myActiveScene = nullptr; diff --git a/Volt/Navigation/src/Navigation/Crowd/DtCrowd.cpp b/Volt/Navigation/src/Navigation/Crowd/DtCrowd.cpp index 7db6c534e..b6598e8ae 100644 --- a/Volt/Navigation/src/Navigation/Crowd/DtCrowd.cpp +++ b/Volt/Navigation/src/Navigation/Crowd/DtCrowd.cpp @@ -81,7 +81,7 @@ namespace Volt return myCrowd->getAgent(myEntityToAgentMap.at(entity.GetID())); } - const dtCrowdAgent* DtCrowd::GetAgent(entt::entity entityId) + const dtCrowdAgent* DtCrowd::GetAgent(EntityID entityId) { if (!myCrowd || !myEntityToAgentMap.contains(entityId)) { diff --git a/Volt/Navigation/src/Navigation/Crowd/DtCrowd.h b/Volt/Navigation/src/Navigation/Crowd/DtCrowd.h index d4701348a..4fd9ced1c 100644 --- a/Volt/Navigation/src/Navigation/Crowd/DtCrowd.h +++ b/Volt/Navigation/src/Navigation/Crowd/DtCrowd.h @@ -18,8 +18,8 @@ namespace Volt DtCrowd(Ref navmesh); const dtCrowdAgent* GetAgent(Volt::Entity entity); - const dtCrowdAgent* GetAgent(entt::entity entityId); - const std::unordered_map& GetAgentMap() const { return myEntityToAgentMap; }; + const dtCrowdAgent* GetAgent(EntityID entityId); + const std::unordered_map& GetAgentMap() const { return myEntityToAgentMap; }; void SetAgentPosition(Volt::Entity entity, glm::vec3 position); void SetAgentTarget(Volt::Entity entity, glm::vec3 target); @@ -37,7 +37,7 @@ namespace Volt Ref& GetDTCrowd() { return myCrowd; }; private: - std::unordered_map myEntityToAgentMap; + std::unordered_map myEntityToAgentMap; uint32_t myMaxAgents = 100; float myMaxAgentRadius = 60.f; diff --git a/Volt/Nexus/premake5.lua b/Volt/Nexus/premake5.lua index 6d57ff462..35d00297c 100644 --- a/Volt/Nexus/premake5.lua +++ b/Volt/Nexus/premake5.lua @@ -12,23 +12,11 @@ project "Nexus" warnings "Extra" - flags - { - "FatalWarnings" - } - - disablewarnings - { - "4005", - "4201", - "4100" - } - - linkoptions - { - "/ignore:4006", - "/ignore:4099" - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() files { @@ -45,19 +33,13 @@ project "Nexus" "%{IncludeDir.yaml}", "%{IncludeDir.spdlog}", "%{IncludeDir.ImGui}", - "%{IncludeDir.Optick}", "%{IncludeDir.fmod}", - "%{IncludeDir.glm}", "%{IncludeDir.entt}", } defines { - "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", "PX_PHYSX_STATIC_LIB", - - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED" } filter "files:vendor/**.cpp" @@ -78,9 +60,6 @@ project "Nexus" { "_WINSOCKAPI_", "_WINSOCK_DEPRECATED_NO_WARNINGS", - - "NOMINMAX", - "_HAS_STD_BYTE=0" } links diff --git a/Volt/Sandbox/premake5.lua b/Volt/Sandbox/premake5.lua index 4f00c9ed9..1ab05a633 100644 --- a/Volt/Sandbox/premake5.lua +++ b/Volt/Sandbox/premake5.lua @@ -17,23 +17,19 @@ project "Sandbox" warnings "Extra" - flags - { - "FatalWarnings" - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() disablewarnings { - "4005", - "4201", - "4100", "4927" } linkoptions { - "/ignore:4006", - "/ignore:4099", "/ignore:4098", "/ignore:4217", "/WHOLEARCHIVE:Volt", @@ -48,15 +44,8 @@ project "Sandbox" defines { - "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", - "_CRT_SECURE_NO_WARNINGS", - "_WINSOCK_DEPRECATED_NO_WARNINGS", - "GLFW_INCLUDE_NONE", "CPPHTTPLIB_OPENSSL_SUPPORT", - - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED" } files @@ -86,7 +75,6 @@ project "Sandbox" "%{IncludeDir.yaml}", "%{IncludeDir.ImGui}", "%{IncludeDir.entt}", - "%{IncludeDir.Optick}", "%{IncludeDir.imgui_notify}", "%{IncludeDir.ImGuizmo}", "%{IncludeDir.fmod}", diff --git a/Volt/Sandbox/src/Sandbox/DebugRendering.cpp b/Volt/Sandbox/src/Sandbox/DebugRendering.cpp index 21217c2d6..08f65d110 100644 --- a/Volt/Sandbox/src/Sandbox/DebugRendering.cpp +++ b/Volt/Sandbox/src/Sandbox/DebugRendering.cpp @@ -30,7 +30,7 @@ void Sandbox::RenderSelection(Ref camera) for (const auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myRuntimeScene }; + Volt::Entity entity = myRuntimeScene->GetEntityFromUUID(id); if (!entity.HasComponent()) { @@ -102,7 +102,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) if (distance < maxDist) { float scale = glm::max(glm::min(distance / maxDist * 2.f, maxScale), minScale); - Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::EntityGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetUIntID()); + Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::EntityGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetID()); } }); } @@ -135,7 +135,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) if (distance < maxDist) { float scale = glm::min(distance / maxDist, maxScale); - Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetUIntID()); + Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetID()); } }); @@ -165,7 +165,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) if (distance < maxDist) { float scale = glm::min(distance / maxDist, maxScale); - Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetUIntID()); + Volt::DebugRenderer::DrawBillboard(EditorResources::GetEditorIcon(EditorIcon::LightGizmo), p, scale, glm::vec4{ 1.f, 1.f, 1.f, alpha }, entity.GetID()); } }); @@ -292,7 +292,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) auto cubeMesh = Volt::AssetManager::GetAsset("Engine/Meshes/Primitives/SM_Cube.vtmesh"); const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), collider.halfSize * 2.f * 0.01f); - Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetID()); }); myRuntimeScene->ForEachWithComponents([&](entt::entity id, const Volt::SphereColliderComponent& collider) @@ -302,7 +302,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) auto sphereMesh = Volt::AssetManager::GetAsset("Engine/Meshes/Primitives/SM_Sphere.vtmesh"); const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f }); - Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetID()); }); myRuntimeScene->ForEachWithComponents([&](entt::entity id, const Volt::CapsuleColliderComponent& collider) @@ -312,7 +312,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f, collider.height * 0.01f, collider.radius * 2.f * 0.01f }); auto capsuleMesh = Volt::AssetManager::GetAsset("Engine/Meshes/Primitives/SM_Capsule.vtmesh"); - Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetID()); }); myRuntimeScene->ForEachWithComponents([&](entt::entity id, const Volt::MeshColliderComponent& collider) @@ -328,7 +328,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) return; } - Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, entity.GetTransform(), entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, entity.GetTransform(), entity.GetID()); }); break; @@ -340,7 +340,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) for (const auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myRuntimeScene.get() }; + Volt::Entity entity = myRuntimeScene->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -348,7 +348,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) auto cubeMesh = Volt::AssetManager::GetAsset("Engine/Meshes/Primitives/SM_Cube.vtmesh"); const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), collider.halfSize * 2.f * 0.01f); - Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(cubeMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetID()); } if (entity.HasComponent()) @@ -357,7 +357,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) auto sphereMesh = Volt::AssetManager::GetAsset("Engine/Meshes/Primitives/SM_Sphere.vtmesh"); const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f }); - Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(sphereMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetID()); } if (entity.HasComponent()) @@ -367,7 +367,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) const glm::mat4 colliderTransform = glm::translate(glm::mat4(1.f), collider.offset) * glm::scale(glm::mat4(1.f), { collider.radius * 2.f * 0.01f, collider.height * 0.01f, collider.radius * 2.f * 0.01f }); auto capsuleMesh = Volt::AssetManager::GetAsset("Engine/Meshes/Primitives/SM_Capsule.vtmesh"); - Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(capsuleMesh, collisionMaterial, entity.GetTransform() * colliderTransform, entity.GetID()); } if (entity.HasComponent()) @@ -383,7 +383,7 @@ void Sandbox::RenderGizmos(Ref scene, Ref camera) return; } - Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, entity.GetTransform(), entity.GetUIntID()); + Volt::DebugRenderer::DrawMesh(debugMesh, collisionMaterial, entity.GetTransform(), entity.GetID()); } } diff --git a/Volt/Sandbox/src/Sandbox/EditorCommandStack.h b/Volt/Sandbox/src/Sandbox/EditorCommandStack.h index 063e6a685..b0712a70b 100644 --- a/Volt/Sandbox/src/Sandbox/EditorCommandStack.h +++ b/Volt/Sandbox/src/Sandbox/EditorCommandStack.h @@ -64,7 +64,7 @@ struct GizmoCommand : EditorCommand glm::vec3 previousScaleValue; Weak scene; - entt::entity id; + Volt::EntityID id; }; GizmoCommand(GizmoData aGizmoData) @@ -98,9 +98,9 @@ struct GizmoCommand : EditorCommand *myRotationAdress = myPreviousRotationValue; *myScaleAdress = myPreviousScaleValue; - if (!myScene.expired()) + if (myScene) { - myScene.lock()->InvalidateEntityTransform(myID); + myScene->InvalidateEntityTransform(myID); } } @@ -123,9 +123,9 @@ struct GizmoCommand : EditorCommand *myRotationAdress = myPreviousRotationValue; *myScaleAdress = myPreviousScaleValue; - if (!myScene.expired()) + if (myScene) { - myScene.lock()->InvalidateEntityTransform(myID); + myScene->InvalidateEntityTransform(myID); } } @@ -137,13 +137,13 @@ struct GizmoCommand : EditorCommand const glm::quat myPreviousRotationValue; const glm::vec3 myPreviousScaleValue; - entt::entity myID; + Volt::EntityID myID; Weak myScene; }; struct MultiGizmoCommand : EditorCommand { - MultiGizmoCommand(Weak scene, const std::vector>& entities) + MultiGizmoCommand(Weak scene, const std::vector>& entities) : myPreviousTransforms(entities), myScene(scene) { } @@ -152,23 +152,23 @@ struct MultiGizmoCommand : EditorCommand void Undo() override { - if (myScene.expired()) + if (!myScene) { return; } - auto scenePtr = myScene.lock(); - std::vector> currentTransforms; + auto scenePtr = myScene; + std::vector> currentTransforms; for (const auto& [id, oldComp] : myPreviousTransforms) { - Volt::Entity entity{ id, scenePtr.get() }; + Volt::Entity entity = scenePtr->GetEntityFromUUID(id); Volt::TransformComponent transformComponent = entity.GetComponent(); currentTransforms.emplace_back(id, transformComponent); entity.GetComponent() = oldComp; - scenePtr->InvalidateEntityTransform(id); + scenePtr->InvalidateEntityTransform(entity.GetID()); } Ref command = CreateRef(myScene, currentTransforms); @@ -177,23 +177,23 @@ struct MultiGizmoCommand : EditorCommand void Redo() override { - if (myScene.expired()) + if (!myScene) { return; } - auto scenePtr = myScene.lock(); - std::vector> currentTransforms; + auto scenePtr = myScene; + std::vector> currentTransforms; for (const auto& [id, oldComp] : myPreviousTransforms) { - Volt::Entity entity{ id, scenePtr.get() }; + Volt::Entity entity = scenePtr->GetEntityFromUUID(id); Volt::TransformComponent transformComponent = entity.GetComponent(); currentTransforms.emplace_back(id, transformComponent); entity.GetComponent() = oldComp; - scenePtr->InvalidateEntityTransform(id); + scenePtr->InvalidateEntityTransform(entity.GetID()); } Ref command = CreateRef(myScene, currentTransforms); @@ -201,7 +201,7 @@ struct MultiGizmoCommand : EditorCommand } private: - std::vector> myPreviousTransforms; + std::vector> myPreviousTransforms; Weak myScene; }; diff --git a/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.cpp b/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.cpp index 7dd671cbf..fc8b794f6 100644 --- a/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.cpp +++ b/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.cpp @@ -308,7 +308,7 @@ void ProjectUpgradeModal::ConvertScenesToV113() Ref scene = CreateRef(sceneName); std::vector sceneLayers; - std::map entityRemapping; + std::map entityRemapping; for (const auto& entry : std::filesystem::directory_iterator(sceneDir / "Layers")) { @@ -340,10 +340,10 @@ void ProjectUpgradeModal::ConvertPreV113Prefab(const std::filesystem::path& file } uint32_t version = 0; - entt::entity rootEntityId = entt::null; + Volt::EntityID rootEntityId = Volt::Entity::NullID(); Ref prefabScene = CreateRef(); - std::map entityRemapping; + std::map entityRemapping; streamReader.EnterScope("Prefab"); { @@ -351,7 +351,7 @@ void ProjectUpgradeModal::ConvertPreV113Prefab(const std::filesystem::path& file streamReader.ForEach("entities", [&]() { - entt::entity entityId = streamReader.ReadKey("id", (entt::entity)entt::null); + Volt::EntityID entityId = streamReader.ReadKey("id", Volt::Entity::NullID()); if (IsPreV113EntityNull(entityId)) { return; @@ -366,11 +366,11 @@ void ProjectUpgradeModal::ConvertPreV113Prefab(const std::filesystem::path& file ValidateSceneConversion(prefabScene); // In old prefabs, the root is the only entity with no parent - prefabScene->ForEachWithComponents([&](const entt::entity id, const Volt::RelationshipComponent& comp) + prefabScene->ForEachWithComponents([&](const entt::entity id, const Volt::RelationshipComponent& comp, const Volt::IDComponent& idComponent) { - if (comp.parent == entt::null) + if (comp.parent == Volt::Entity::NullID()) { - rootEntityId = id; + rootEntityId = idComponent.id; } }); @@ -382,7 +382,7 @@ void ProjectUpgradeModal::ConvertPreV113Prefab(const std::filesystem::path& file Volt::PrefabImporter::Get().Save(imposterMeta, newPrefab); } -void ProjectUpgradeModal::DeserializePreV113SceneLayer(Ref scene, Volt::SceneLayer& sceneLayer, const std::filesystem::path& layerPath, std::map& entityRemapping) +void ProjectUpgradeModal::DeserializePreV113SceneLayer(Ref scene, Volt::SceneLayer& sceneLayer, const std::filesystem::path& layerPath, std::map& entityRemapping) { Volt::YAMLStreamReader streamReader{}; @@ -406,22 +406,24 @@ void ProjectUpgradeModal::DeserializePreV113SceneLayer(Ref scene, V streamReader.ExitScope(); } -void ProjectUpgradeModal::DeserializePreV113Entity(Ref scene, Volt::YAMLStreamReader& streamReader, std::map& entityRemapping, bool isPrefabEntity) +void ProjectUpgradeModal::DeserializePreV113Entity(Ref scene, Volt::YAMLStreamReader& streamReader, std::map& entityRemapping, bool isPrefabEntity) { if (!isPrefabEntity) { streamReader.EnterScope("Entity"); } - entt::entity originalEntityId = streamReader.ReadKey("id", (entt::entity)entt::null); + Volt::EntityID originalEntityId = streamReader.ReadKey("id", Volt::Entity::NullID()); if (IsPreV113EntityNull(originalEntityId)) { return; } - Volt::Entity newEntity = scene->CreateEntity("", originalEntityId); - const entt::entity entityId = newEntity.GetID(); + Volt::Entity newEntity = scene->CreateEntityWithUUID(originalEntityId); + const Volt::EntityID entityId = newEntity.GetID(); + + const auto handle = scene->GetHandleFromUUID(entityId); if (entityId != originalEntityId) { @@ -451,11 +453,11 @@ void ProjectUpgradeModal::DeserializePreV113Entity(Ref scene, Volt: { case Volt::ValueType::Component: { - if (!Volt::ComponentRegistry::Helpers::HasComponentWithGUID(compGuid, scene->GetRegistry(), entityId)) + if (!Volt::ComponentRegistry::Helpers::HasComponentWithGUID(compGuid, scene->GetRegistry(), handle)) { - Volt::ComponentRegistry::Helpers::AddComponentWithGUID(compGuid, scene->GetRegistry(), entityId); + Volt::ComponentRegistry::Helpers::AddComponentWithGUID(compGuid, scene->GetRegistry(), handle); } - void* voidCompPtr = Volt::ComponentRegistry::Helpers::GetComponentWithGUID(compGuid, scene->GetRegistry(), entityId); + void* voidCompPtr = Volt::ComponentRegistry::Helpers::GetComponentWithGUID(compGuid, scene->GetRegistry(), handle); uint8_t* componentData = reinterpret_cast(voidCompPtr); const Volt::IComponentTypeDesc* componentDesc = reinterpret_cast(typeDesc); @@ -495,9 +497,9 @@ void ProjectUpgradeModal::DeserializePreV113Entity(Ref scene, Volt: } }); - if (scene->GetRegistry().any_of(entityId) && !isPrefabEntity) + if (scene->GetRegistry().any_of(handle) && !isPrefabEntity) { - auto& prefabComp = scene->GetRegistry().get(entityId); + auto& prefabComp = scene->GetRegistry().get(handle); Ref prefabAsset = Volt::AssetManager::GetAsset(prefabComp.prefabAsset); if (prefabAsset && prefabAsset->IsValid()) @@ -524,15 +526,15 @@ void ProjectUpgradeModal::DeserializePreV113Entity(Ref scene, Volt: } } - if (scene->GetRegistry().any_of(entityId)) + if (scene->GetRegistry().any_of(handle)) { DeserializePreV113MonoScripts(scene, entityId, streamReader); } // Make sure entity has relationship component - if (!scene->GetRegistry().any_of(entityId)) + if (!scene->GetRegistry().any_of(handle)) { - scene->GetRegistry().emplace(entityId); + scene->GetRegistry().emplace(handle); } if (!isPrefabEntity) @@ -587,9 +589,9 @@ void ProjectUpgradeModal::DeserializePreV113Component(uint8_t* componentData, co s_arrayDeserializers.at(vectorValueType)(streamReader, tempBytePtr, 0); } - if (arrayTypeDesc->GetElementTypeIndex() == std::type_index{ typeid(entt::entity) }) + if (arrayTypeDesc->GetElementTypeIndex() == std::type_index{ typeid(Volt::EntityID) }) { - ValidateEntityValidity(reinterpret_cast(tempDataStorage)); + ValidateEntityValidity(reinterpret_cast(tempDataStorage)); } arrayTypeDesc->PushBack(arrayPtr, tempDataStorage); @@ -614,18 +616,18 @@ void ProjectUpgradeModal::DeserializePreV113Component(uint8_t* componentData, co if (typeDeserializers.contains(memberType)) { typeDeserializers.at(memberType)(streamReader, componentData, componentMember->offset); - if (memberType == std::type_index{ typeid(entt::entity) }) + if (memberType == std::type_index{ typeid(Volt::EntityID) }) { - entt::entity* entDataPtr = reinterpret_cast(&componentData[componentMember->offset]); + Volt::EntityID* entDataPtr = reinterpret_cast(&componentData[componentMember->offset]); ValidateEntityValidity(entDataPtr); } } }); } -void ProjectUpgradeModal::DeserializePreV113MonoScripts(Ref scene, const entt::entity entityId, Volt::YAMLStreamReader& streamReader) +void ProjectUpgradeModal::DeserializePreV113MonoScripts(Ref scene, const Volt::EntityID entityId, Volt::YAMLStreamReader& streamReader) { - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); const auto& typeDeserializers = Volt::SceneImporter::GetTypeDeserializers(); streamReader.ForEach("MonoScripts", [&]() @@ -691,7 +693,7 @@ void ProjectUpgradeModal::DeserializePreV113MonoScripts(Ref scene, }); } -void ProjectUpgradeModal::HandleEntityRemapping(Ref scene, const std::map& entityRemapping) +void ProjectUpgradeModal::HandleEntityRemapping(Ref scene, const std::map& entityRemapping) { for (auto&& curr : scene->GetRegistry().storage()) { @@ -721,7 +723,7 @@ void ProjectUpgradeModal::HandleEntityRemapping(Ref scene, const st } const Volt::IArrayTypeDesc* memberArrayTypeDesc = reinterpret_cast(member.typeDesc); - if (memberArrayTypeDesc->GetElementTypeIndex() != std::type_index{ typeid(entt::entity) }) + if (memberArrayTypeDesc->GetElementTypeIndex() != std::type_index{ typeid(Volt::EntityID) }) { continue; } @@ -732,7 +734,7 @@ void ProjectUpgradeModal::HandleEntityRemapping(Ref scene, const st HandleEntityArrayRemapping(scene, entityRemapping, member, componentDataPtr); } } - else if (member.typeIndex == std::type_index{ typeid(entt::entity) }) + else if (member.typeIndex == std::type_index{ typeid(Volt::EntityID) }) { for (const auto& id : storage) { @@ -740,7 +742,7 @@ void ProjectUpgradeModal::HandleEntityRemapping(Ref scene, const st for (const auto& [originalEntityId, newEntityId] : entityRemapping) { - entt::entity& value = *reinterpret_cast(&componentDataPtr[member.offset]); + Volt::EntityID& value = *reinterpret_cast(&componentDataPtr[member.offset]); if (value == originalEntityId) { value = newEntityId; @@ -752,14 +754,14 @@ void ProjectUpgradeModal::HandleEntityRemapping(Ref scene, const st } } -void ProjectUpgradeModal::HandleEntityArrayRemapping(Ref scene, const std::map& entityRemapping, const Volt::ComponentMember& componentMember, uint8_t* componentData) +void ProjectUpgradeModal::HandleEntityArrayRemapping(Ref scene, const std::map& entityRemapping, const Volt::ComponentMember& componentMember, uint8_t* componentData) { const Volt::IArrayTypeDesc* memberArrayTypeDesc = reinterpret_cast(componentMember.typeDesc); void* arrayPtr = reinterpret_cast(&componentData[componentMember.offset]); for (size_t i = 0; i < memberArrayTypeDesc->Size(arrayPtr); i++) { - entt::entity* value = reinterpret_cast(memberArrayTypeDesc->At(arrayPtr, i)); + Volt::EntityID* value = reinterpret_cast(memberArrayTypeDesc->At(arrayPtr, i)); for (const auto& [originalEntityId, newEntityId] : entityRemapping) { if (*value == originalEntityId) @@ -805,7 +807,7 @@ void ProjectUpgradeModal::ValidateSceneConversion(Ref scene) } const Volt::IArrayTypeDesc* memberArrayTypeDesc = reinterpret_cast(member.typeDesc); - if (memberArrayTypeDesc->GetElementTypeIndex() != std::type_index{ typeid(entt::entity) }) + if (memberArrayTypeDesc->GetElementTypeIndex() != std::type_index{ typeid(Volt::EntityID) }) { continue; } @@ -816,16 +818,16 @@ void ProjectUpgradeModal::ValidateSceneConversion(Ref scene) ValidateSceneConversionArray(scene, member, componentDataPtr); } } - else if (member.typeIndex == std::type_index{ typeid(entt::entity) }) + else if (member.typeIndex == std::type_index{ typeid(Volt::EntityID) }) { for (const auto& id : storage) { uint8_t* componentDataPtr = reinterpret_cast(storage.get(id)); - entt::entity& value = *reinterpret_cast(&componentDataPtr[member.offset]); + Volt::EntityID& value = *reinterpret_cast(&componentDataPtr[member.offset]); - if (!scene->GetRegistry().valid(value)) + if (!scene->GetRegistry().valid(scene->GetHandleFromUUID(value))) { - value = entt::null; + value = Volt::Entity::NullID(); } } } @@ -842,11 +844,11 @@ void ProjectUpgradeModal::ValidateSceneConversionArray(Ref scene, c for (size_t i = 0; i < memberArrayTypeDesc->Size(arrayPtr); i++) { - entt::entity* value = reinterpret_cast(memberArrayTypeDesc->At(arrayPtr, i)); - if (!scene->GetRegistry().valid(*value)) + Volt::EntityID* value = reinterpret_cast(memberArrayTypeDesc->At(arrayPtr, i)); + if (!scene->GetRegistry().valid(scene->GetHandleFromUUID(*value))) { indicesToRemove.emplace_back(i); - *value = entt::null; + *value = Volt::Entity::NullID(); } } @@ -856,16 +858,16 @@ void ProjectUpgradeModal::ValidateSceneConversionArray(Ref scene, c } } -const bool ProjectUpgradeModal::IsPreV113EntityNull(entt::entity entityId) +const bool ProjectUpgradeModal::IsPreV113EntityNull(Volt::EntityID entityId) { - return entityId == entt::null || entityId == static_cast(0); + return entityId == Volt::Entity::NullID(); } -void ProjectUpgradeModal::ValidateEntityValidity(entt::entity* entityId) +void ProjectUpgradeModal::ValidateEntityValidity(Volt::EntityID* entityId) { - if (*entityId == (entt::entity)0) + if (*entityId == (Volt::EntityID)0) { - *entityId = entt::null; + *entityId = Volt::Entity::NullID(); } } diff --git a/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.h b/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.h index 6006bbeff..a67769985 100644 --- a/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.h +++ b/Volt/Sandbox/src/Sandbox/Modals/ProjectUpgradeModal.h @@ -2,8 +2,8 @@ #include "Sandbox/Modals/Modal.h" +#include #include -#include #include @@ -37,19 +37,19 @@ class ProjectUpgradeModal : public Modal void ConvertPreV113Prefab(const std::filesystem::path& filePath); - void DeserializePreV113SceneLayer(Ref scene, Volt::SceneLayer& sceneLayer, const std::filesystem::path& layerPath, std::map& entityRemapping); - void DeserializePreV113Entity(Ref scene, Volt::YAMLStreamReader& streamReader, std::map& entityRemapping, bool isPrefabEntity); + void DeserializePreV113SceneLayer(Ref scene, Volt::SceneLayer& sceneLayer, const std::filesystem::path& layerPath, std::map& entityRemapping); + void DeserializePreV113Entity(Ref scene, Volt::YAMLStreamReader& streamReader, std::map& entityRemapping, bool isPrefabEntity); void DeserializePreV113Component(uint8_t* componentData, const Volt::IComponentTypeDesc* componentDesc, Volt::YAMLStreamReader& streamReader); - void DeserializePreV113MonoScripts(Ref scene, const entt::entity entityId, Volt::YAMLStreamReader& streamReader); + void DeserializePreV113MonoScripts(Ref scene, const Volt::EntityID entityId, Volt::YAMLStreamReader& streamReader); - void HandleEntityRemapping(Ref scene, const std::map& entityRemapping); - void HandleEntityArrayRemapping(Ref scene, const std::map& entityRemapping, const Volt::ComponentMember& componentMember, uint8_t* componentData); + void HandleEntityRemapping(Ref scene, const std::map& entityRemapping); + void HandleEntityArrayRemapping(Ref scene, const std::map& entityRemapping, const Volt::ComponentMember& componentMember, uint8_t* componentData); void ValidateSceneConversion(Ref scene); void ValidateSceneConversionArray(Ref scene, const Volt::ComponentMember& componentMember, uint8_t* componentData); - const bool IsPreV113EntityNull(entt::entity entityId); - void ValidateEntityValidity(entt::entity* entityId); + const bool IsPreV113EntityNull(Volt::EntityID entityId); + void ValidateEntityValidity(Volt::EntityID* entityId); const Volt::ComponentMember* TryGetComponentMemberFromName(const std::string& memberName, const Volt::IComponentTypeDesc* componentDesc); std::pair DeserializeV0MetaFile(const std::filesystem::path& metaPath); diff --git a/Volt/Sandbox/src/Sandbox/NodeGraph/IONodeGraphEditor.h b/Volt/Sandbox/src/Sandbox/NodeGraph/IONodeGraphEditor.h index 7ba90cf91..a01721687 100644 --- a/Volt/Sandbox/src/Sandbox/NodeGraph/IONodeGraphEditor.h +++ b/Volt/Sandbox/src/Sandbox/NodeGraph/IONodeGraphEditor.h @@ -1249,12 +1249,12 @@ inline void IONodeGraphEditor::DrawPinContextMenu() { if (SelectionManager::IsAnySelected() && ImGui::MenuItem("Assign Selected Entity")) { - pin->data = Volt::Entity{ SelectionManager::GetSelectedEntities().at(0), myCurrentScene.get() }; + pin->data = myCurrentScene->GetEntityFromUUID(SelectionManager::GetSelectedEntities().at(0)); } if (ImGui::MenuItem("Assign Graph Entity")) { - pin->data = Volt::Entity{ myOpenGraph->GetEntity(), myCurrentScene.get() }; + pin->data = myCurrentScene->GetEntityFromUUID(myOpenGraph->GetEntity()); } } } diff --git a/Volt/Sandbox/src/Sandbox/Sandbox.cpp b/Volt/Sandbox/src/Sandbox/Sandbox.cpp index eada030d9..341f964fb 100644 --- a/Volt/Sandbox/src/Sandbox/Sandbox.cpp +++ b/Volt/Sandbox/src/Sandbox/Sandbox.cpp @@ -1047,7 +1047,7 @@ bool Sandbox::OnKeyPressedEvent(Volt::KeyPressedEvent& e) for (const auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity ent{ id, myRuntimeScene.get() }; + Volt::Entity ent = myRuntimeScene->GetEntityFromUUID(id); avgPos += ent.GetPosition(); } diff --git a/Volt/Sandbox/src/Sandbox/Utility/AssetBrowserUtilities.cpp b/Volt/Sandbox/src/Sandbox/Utility/AssetBrowserUtilities.cpp index 7f097d9e0..aea2e45a9 100644 --- a/Volt/Sandbox/src/Sandbox/Utility/AssetBrowserUtilities.cpp +++ b/Volt/Sandbox/src/Sandbox/Utility/AssetBrowserUtilities.cpp @@ -114,7 +114,7 @@ namespace AssetBrowser for (const auto& ent : scene->GetAllEntitiesWith()) { - meshEntities.emplace_back(Volt::Entity(ent, scene.get())); + meshEntities.emplace_back(ent); } meshesToExport = Volt::MeshExporterUtilities::GetMeshes(meshEntities); diff --git a/Volt/Sandbox/src/Sandbox/Utility/AssetPreview.cpp b/Volt/Sandbox/src/Sandbox/Utility/AssetPreview.cpp index 3d3926646..f025c026d 100644 --- a/Volt/Sandbox/src/Sandbox/Utility/AssetPreview.cpp +++ b/Volt/Sandbox/src/Sandbox/Utility/AssetPreview.cpp @@ -20,9 +20,8 @@ AssetPreview::AssetPreview(const std::filesystem::path& path) myScene = Volt::Scene::CreateDefaultScene("Asset Preview", false); - auto entId = myScene->GetAllEntitiesWith().front(); + auto skylightEnt = myScene->GetAllEntitiesWith().front(); - Volt::Entity skylightEnt{ entId, myScene.get() }; auto& skylightComp = skylightEnt.GetComponent(); skylightComp.environmentHandle = Volt::AssetManager::GetAsset("Editor/Textures/HDRIs/studio_small_08_4k.hdr")->handle; skylightComp.lod = 2.f; diff --git a/Volt/Sandbox/src/Sandbox/Utility/ComponentPropertyUtilities.cpp b/Volt/Sandbox/src/Sandbox/Utility/ComponentPropertyUtilities.cpp index f3d4f1528..afd1f0326 100644 --- a/Volt/Sandbox/src/Sandbox/Utility/ComponentPropertyUtilities.cpp +++ b/Volt/Sandbox/src/Sandbox/Utility/ComponentPropertyUtilities.cpp @@ -113,12 +113,12 @@ void ComponentPropertyUtility::DrawComponents(Weak scene, Volt::Ent s_initialized = true; } - auto scenePtr = scene.lock(); + auto scenePtr = scene; auto& registry = scenePtr->GetRegistry(); for (auto&& curr : registry.storage()) { - if (auto& storage = curr.second; storage.contains(entity.GetID())) + if (auto& storage = curr.second; storage.contains(entity)) { std::string_view typeName = storage.type().name(); const Volt::ICommonTypeDesc* typeDesc = Volt::ComponentRegistry::GetTypeDescFromName(typeName); @@ -158,11 +158,11 @@ void ComponentPropertyUtility::DrawComponents(Weak scene, Volt::Ent } } - DrawComponent(scene, entity, compTypeDesc, storage.get(entity.GetID()), 0, open, false); + DrawComponent(scene, entity, compTypeDesc, storage.get(entity), 0, open, false); if (removeComp) { - Volt::ComponentRegistry::Helpers::RemoveComponentWithGUID(compTypeDesc->GetGUID(), scene.lock()->GetRegistry(), entity.GetID()); + Volt::ComponentRegistry::Helpers::RemoveComponentWithGUID(compTypeDesc->GetGUID(), scene->GetRegistry(), entity); } break; @@ -282,9 +282,9 @@ void ComponentPropertyUtility::DrawComponentDefaultMember(Weak scen } // Special case for entities - if (member.typeIndex == std::type_index{ typeid(entt::entity) }) + if (member.typeIndex == std::type_index{ typeid(Volt::EntityID) }) { - if (UI::PropertyEntity(std::string(member.label), scene.lock(), *reinterpret_cast(&bytePtr[offset + member.offset]))) + if (UI::PropertyEntity(std::string(member.label), scene, *reinterpret_cast(&bytePtr[offset + member.offset]))) { AddLocalChangeToEntity(entity, member.ownerTypeDesc->GetGUID(), member.name); } @@ -334,9 +334,9 @@ void ComponentPropertyUtility::DrawComponentDefaultMemberArray(Weak } // Special case for entities - if (arrayMember.typeIndex == std::type_index{ typeid(entt::entity) }) + if (arrayMember.typeIndex == std::type_index{ typeid(Volt::EntityID) }) { - if (UI::PropertyEntity(label, scene.lock(), *reinterpret_cast(elementData))) + if (UI::PropertyEntity(label, scene, *reinterpret_cast(elementData))) { AddLocalChangeToEntity(entity, arrayMember.ownerTypeDesc->GetGUID(), arrayMember.name); } @@ -528,7 +528,7 @@ void ComponentPropertyUtility::DrawMonoScript(Weak scene, const Vol if (Sandbox::Get().GetSceneState() == SceneState::Edit) { - auto scenePtr = scene.lock(); + auto scenePtr = scene; scenePtr->ShutdownEngineScripts(); scenePtr->InitializeEngineScripts(); @@ -545,7 +545,7 @@ void ComponentPropertyUtility::DrawMonoMembers(Weak scene, const Vo return; } - if (scene.lock()->IsPlaying() && scriptInstance) + if (scene->IsPlaying() && scriptInstance) { for (const auto& [name, field] : scriptInstance->GetClass()->GetFields()) { @@ -573,7 +573,7 @@ void ComponentPropertyUtility::DrawMonoMembers(Weak scene, const Vo } else if (field.type.IsEntity()) { - entt::entity value = scriptInstance->GetField(name); + Volt::EntityID value = scriptInstance->GetField(name); if (UI::PropertyEntity(displayName, scene, value)) { scriptInstance->SetField(name, &value); @@ -637,7 +637,7 @@ void ComponentPropertyUtility::DrawMonoMembers(Weak scene, const Vo const auto& classFields = Volt::MonoScriptEngine::GetScriptClass(scriptEntry.name)->GetFields(); const auto& defaultFieldValueMap = Volt::MonoScriptEngine::GetDefaultScriptFieldMap(scriptEntry.name); - auto& entityFields = scene.lock()->GetScriptFieldCache().GetCache()[scriptEntry.id]; + auto& entityFields = scene->GetScriptFieldCache().GetCache()[scriptEntry.id]; for (const auto& [name, field] : classFields) { @@ -709,7 +709,7 @@ void ComponentPropertyUtility::DrawMonoMembers(Weak scene, const Vo } else if (field.type.IsEntity()) { - fieldChanged = UI::PropertyEntity(displayName, scene, *currentField->data.As()); + fieldChanged = UI::PropertyEntity(displayName, scene, *currentField->data.As()); } else if (field.type.IsAsset()) { diff --git a/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.cpp b/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.cpp index 2d84630c0..e0c60e7d3 100644 --- a/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.cpp +++ b/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.cpp @@ -6,7 +6,7 @@ void SelectionManager::Init() { - myEntities[mySelectionKey] = std::vector(); + myEntities[mySelectionKey] = std::vector(); } void SelectionManager::SetSelectionKey(const std::string& key) @@ -14,7 +14,7 @@ void SelectionManager::SetSelectionKey(const std::string& key) mySelectionKey = key; if (!myEntities.contains(mySelectionKey)) { - myEntities[mySelectionKey] = std::vector(); + myEntities[mySelectionKey] = std::vector(); } } @@ -23,7 +23,7 @@ void SelectionManager::ResetSelectionKey() mySelectionKey = ""; } -bool SelectionManager::Select(entt::entity entity) +bool SelectionManager::Select(Volt::EntityID entity) { if (myLocked) return false; @@ -36,7 +36,7 @@ bool SelectionManager::Select(entt::entity entity) return true; } -bool SelectionManager::Deselect(entt::entity entity) +bool SelectionManager::Deselect(Volt::EntityID entity) { if (myLocked) return false; @@ -64,7 +64,7 @@ bool SelectionManager::IsAnySelected() return !myEntities.at(mySelectionKey).empty(); } -bool SelectionManager::IsSelected(entt::entity entity) +bool SelectionManager::IsSelected(Volt::EntityID entity) { return std::find(myEntities.at(mySelectionKey).begin(), myEntities.at(mySelectionKey).end(), entity) != myEntities.at(mySelectionKey).end(); } @@ -75,16 +75,16 @@ void SelectionManager::Update(Ref scene) for (const auto& ent : GetSelectedEntities()) { - if (!scene->GetRegistry().valid(ent)) + if (!scene->IsEntityValid(ent)) { SelectionManager::Deselect(ent); } } } -bool SelectionManager::IsAnyParentSelected(entt::entity id, Ref scene) +bool SelectionManager::IsAnyParentSelected(Volt::EntityID id, Ref scene) { - Volt::Entity entity{ id, scene.get() }; + Volt::Entity entity = scene->GetEntityFromUUID(id); if (entity.GetParent()) { diff --git a/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.h b/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.h index 3836828eb..06cf527a1 100644 --- a/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.h +++ b/Volt/Sandbox/src/Sandbox/Utility/SelectionManager.h @@ -1,6 +1,7 @@ #pragma once -#include +#include + #include namespace Volt @@ -15,22 +16,22 @@ class SelectionManager static void SetSelectionKey(const std::string& key); static void ResetSelectionKey(); - static bool Select(entt::entity entity); - static bool Deselect(entt::entity entity); + static bool Select(Volt::EntityID entity); + static bool Deselect(Volt::EntityID entity); static void DeselectAll(); static bool IsAnySelected(); - static bool IsSelected(entt::entity entity); + static bool IsSelected(Volt::EntityID entity); static void Update(Ref scene); - static bool IsAnyParentSelected(entt::entity entity, Ref scene); + static bool IsAnyParentSelected(Volt::EntityID entity, Ref scene); inline static int32_t& GetFirstSelectedRow() { return myFirstSelectedRow; } inline static int32_t& GetLastSelectedRow() { return myLastSelectedRow; } inline static const size_t GetSelectedCount() { return myEntities["Default"].size(); } - inline static const std::vector& GetSelectedEntities() { return myEntities.at(mySelectionKey); } + inline static const std::vector& GetSelectedEntities() { return myEntities.at(mySelectionKey); } inline static void Lock() { myLocked = true; } inline static void Unlock() { myLocked = false; } @@ -43,5 +44,5 @@ class SelectionManager inline static int32_t myFirstSelectedRow = -1; inline static int32_t myLastSelectedRow = -1; - inline static std::unordered_map> myEntities; + inline static std::unordered_map> myEntities; }; diff --git a/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.cpp b/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.cpp index 8cf013103..e42abcb76 100644 --- a/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.cpp @@ -77,7 +77,7 @@ bool VertexPainterPanel::BrushUpdate() glm::vec3 intersectionPoint; for (auto wireId : SelectionManager::GetSelectedEntities()) { - Volt::Entity currentEntity(wireId, ex_scene.get()); + Volt::Entity currentEntity = ex_scene->GetEntityFromUUID(wireId); if (!currentEntity.HasComponent()) continue; auto meshComponent = currentEntity.GetComponent(); @@ -185,7 +185,7 @@ void VertexPainterPanel::PanelDraw() { for (const auto& _entId : SelectionManager::GetSelectedEntities()) { - auto ent = Volt::Entity(_entId, Volt::SceneManager::GetActiveScene().lock().get()); + auto ent = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(_entId); if (!AddPainted(ent)) continue; for (auto& vertex : ent.GetComponent().vertexColors) { @@ -216,7 +216,7 @@ void VertexPainterPanel::PanelDraw() // Remove painted component for (const auto& _entId : SelectionManager::GetSelectedEntities()) { - auto ent = Volt::Entity(_entId, Volt::SceneManager::GetActiveScene().lock().get()); + auto ent = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(_entId); if (!ent.HasComponent()) continue; ent.RemoveComponent(); } @@ -338,7 +338,7 @@ void VertexPainterPanel::PanelDraw() { for (auto entId : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity = Volt::Entity(entId, ex_scene.get()); + Volt::Entity entity = ex_scene->GetEntityFromUUID(entId); if (!entity.HasComponent()) continue; auto& meshComp = entity.GetComponent(); meshComp.material = m_materialSettings.singleMat; @@ -373,7 +373,7 @@ void VertexPainterPanel::BillboardDraw() { for (auto id : SelectionManager::GetSelectedEntities()) { - auto paintedEnt = Volt::Entity(id, ex_scene.get()); + auto paintedEnt = ex_scene->GetEntityFromUUID(id); if (paintedEnt.HasComponent()) { auto meshComp = paintedEnt.GetComponent(); @@ -540,7 +540,7 @@ void VertexPainterPanel::Paint(float color) if (m_settings.isSelecting) return; for (auto id : SelectionManager::GetSelectedEntities()) { - auto paintedEnt = Volt::Entity(id, ex_scene.get()); + auto paintedEnt = ex_scene->GetEntityFromUUID(id); if (!paintedEnt.HasComponent()) continue; auto meshComp = paintedEnt.GetComponent(); @@ -608,11 +608,11 @@ void VertexPainterPanel::SetView(bool in_viewVertexColors) { for (auto entId : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity = Volt::Entity(entId, ex_scene.get()); + Volt::Entity entity = ex_scene->GetEntityFromUUID(entId); if (!entity.HasComponent()) continue; auto& meshComp = entity.GetComponent(); - std::pair entry; + std::pair entry; entry.first = entId; entry.second = meshComp.material; m_originalMaterials.insert(entry); @@ -623,7 +623,7 @@ void VertexPainterPanel::SetView(bool in_viewVertexColors) } for (auto _pair : m_originalMaterials) { - Volt::Entity entity = Volt::Entity(_pair.first, ex_scene.get()); + Volt::Entity entity = ex_scene->GetEntityFromUUID(_pair.first); if (!entity.HasComponent()) continue; auto& meshComp = entity.GetComponent(); meshComp.material = _pair.second; diff --git a/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.h b/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.h index 7ced09694..5fe8d68cc 100644 --- a/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.h +++ b/Volt/Sandbox/src/Sandbox/VertexPainting/VertexPainterPanel.h @@ -3,6 +3,8 @@ #include "Sandbox/Window/EditorWindow.h" #include +#include + class VertexPainterPanel : public EditorWindow { public: @@ -78,6 +80,6 @@ class VertexPainterPanel : public EditorWindow Ref& ex_scene; Ref& ex_cameraController; - std::unordered_map m_originalMaterials; + std::unordered_map m_originalMaterials; }; diff --git a/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.cpp index fe9c6236b..7101c3b77 100644 --- a/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.cpp @@ -218,8 +218,8 @@ void AssetBrowserPanel::UpdateMainContent() if (void* ptr = UI::DragDropTarget("scene_entity_hierarchy")) { - entt::entity entity = *(entt::entity*)ptr; - if (entity != entt::null) + Volt::EntityID entity = *(Volt::EntityID*)ptr; + if (entity != Volt::Entity::NullID()) { CreatePrefabAndSetupEntities(entity); Reload(); @@ -1192,9 +1192,9 @@ AssetBrowser::DirectoryItem* AssetBrowserPanel::FindDirectoryWithPathRecursivly( return nullptr; } -void AssetBrowserPanel::CreatePrefabAndSetupEntities(entt::entity id) +void AssetBrowserPanel::CreatePrefabAndSetupEntities(Volt::EntityID id) { - Volt::Entity entity{ id, myEditorScene }; + Volt::Entity entity = myEditorScene->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -1214,9 +1214,9 @@ void AssetBrowserPanel::CreatePrefabAndSetupEntities(entt::entity id) Reload(); } -void AssetBrowserPanel::SetupEntityAsPrefab(entt::entity id, Volt::AssetHandle prefabId) +void AssetBrowserPanel::SetupEntityAsPrefab(Volt::EntityID id, Volt::AssetHandle prefabId) { - Volt::Entity entity{ id, myEditorScene }; + Volt::Entity entity = myEditorScene->GetEntityFromUUID(id); if (!entity.HasComponent()) { diff --git a/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.h b/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.h index 50a0fc08c..58361aa4b 100644 --- a/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.h +++ b/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/AssetBrowserPanel.h @@ -56,8 +56,8 @@ class AssetBrowserPanel : public EditorWindow AssetBrowser::DirectoryItem* FindDirectoryWithPath(const std::filesystem::path& path); AssetBrowser::DirectoryItem* FindDirectoryWithPathRecursivly(const std::vector> dirList, const std::filesystem::path& path); - void CreatePrefabAndSetupEntities(entt::entity entity); - void SetupEntityAsPrefab(entt::entity entity, Volt::AssetHandle prefabId); + void CreatePrefabAndSetupEntities(Volt::EntityID entity); + void SetupEntityAsPrefab(Volt::EntityID entity, Volt::AssetHandle prefabId); void RecursiveRemoveFolderContents(DirectoryData* aDir); void RecursiceRenameFolderContents(DirectoryData* aDir, const std::filesystem::path& newDir); diff --git a/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/PreviewRenderer.cpp b/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/PreviewRenderer.cpp index 34eefe3cf..2ba0a88a5 100644 --- a/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/PreviewRenderer.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/AssetBrowser/PreviewRenderer.cpp @@ -27,7 +27,7 @@ PreviewRenderer::PreviewRenderer() { auto skylightEntities = myPreviewScene->GetAllEntitiesWith(); - Volt::Entity ent{ skylightEntities.front(), myPreviewScene.get() }; + Volt::Entity ent = skylightEntities.front(); ent.GetComponent().environmentHandle = Volt::AssetManager::GetAssetHandleFromFilePath("Engine/Textures/HDRIs/defaultHDRI.hdr"); } @@ -53,12 +53,12 @@ PreviewRenderer::~PreviewRenderer() void PreviewRenderer::RenderPreview(Weak assetItem) { - if (assetItem.expired()) + if (!assetItem) { return; } - auto itemPtr = assetItem.lock(); + auto itemPtr = assetItem; const auto assetType = Volt::AssetManager::GetAssetTypeFromHandle(itemPtr->handle); const bool assetWasLoaded = Volt::AssetManager::Get().IsLoaded(itemPtr->handle); @@ -102,7 +102,7 @@ void PreviewRenderer::RenderPreview(Weak assetItem) bool PreviewRenderer::RenderMeshPreview(Weak assetItem) { - auto itemPtr = assetItem.lock(); + auto itemPtr = assetItem; Ref mesh = Volt::AssetManager::QueueAsset(itemPtr->handle); if (!mesh || !mesh->IsValid()) @@ -126,7 +126,7 @@ bool PreviewRenderer::RenderMeshPreview(Weak assetItem) bool PreviewRenderer::RenderMaterialPreview(Weak assetItem) { - auto itemPtr = assetItem.lock(); + auto itemPtr = assetItem; Ref material = Volt::AssetManager::QueueAsset(itemPtr->handle); if (!material || !material->IsValid()) diff --git a/Volt/Sandbox/src/Sandbox/Window/GraphKey/GraphKeyPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/GraphKey/GraphKeyPanel.cpp index 875e66d58..4bc1b4b19 100644 --- a/Volt/Sandbox/src/Sandbox/Window/GraphKey/GraphKeyPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/GraphKey/GraphKeyPanel.cpp @@ -24,7 +24,7 @@ bool GraphKeyPanel::SaveSettings(const std::string& data) } auto entityId = myOpenGraph->GetEntity(); - Volt::Entity entity = { entityId, myCurrentScene.get() }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(entityId); if (!entity) { @@ -50,7 +50,7 @@ size_t GraphKeyPanel::LoadSettings(std::string& data) } auto entityId = myOpenGraph->GetEntity(); - Volt::Entity entity = { entityId, myCurrentScene.get() }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(entityId); if (!entity) { diff --git a/Volt/Sandbox/src/Sandbox/Window/MaterialEditorPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/MaterialEditorPanel.cpp index a577e5af9..c23f81eeb 100644 --- a/Volt/Sandbox/src/Sandbox/Window/MaterialEditorPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/MaterialEditorPanel.cpp @@ -48,7 +48,7 @@ MaterialEditorPanel::MaterialEditorPanel(Ref& aScene) { auto skylightEntities = myPreviewScene->GetAllEntitiesWith(); - Volt::Entity ent{ skylightEntities.front(), myPreviewScene.get() }; + Volt::Entity ent = skylightEntities.front(); ent.GetComponent().environmentHandle = Volt::AssetManager::GetAssetHandleFromFilePath("Engine/Textures/HDRIs/defaultHDRI.hdr"); } } @@ -98,7 +98,7 @@ void MaterialEditorPanel::OnOpen() { auto skylightEntities = myPreviewScene->GetAllEntitiesWith(); - Volt::Entity ent{ skylightEntities.front(), myPreviewScene.get() }; + Volt::Entity ent = skylightEntities.front(); ent.GetComponent().environmentHandle = Volt::AssetManager::GetAssetHandleFromFilePath("Engine/Textures/HDRIs/defaultHDRI.hdr"); } } @@ -163,7 +163,7 @@ void MaterialEditorPanel::UpdateToolbar() if (SelectionManager::GetSelectedCount() > 0) { auto id = SelectionManager::GetSelectedEntities().front(); - Volt::Entity entity{ id, myEditorScene }; + Volt::Entity entity = myEditorScene->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -198,7 +198,7 @@ void MaterialEditorPanel::UpdateToolbar() if (SelectionManager::GetSelectedCount() > 0 && mySelectedMaterial) { auto id = SelectionManager::GetSelectedEntities().front(); - Volt::Entity entity{ id, myEditorScene }; + Volt::Entity entity = myEditorScene->GetEntityFromUUID(id); if (entity.HasComponent()) { diff --git a/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.cpp index 9f9961005..088cd910b 100644 --- a/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.cpp @@ -53,7 +53,7 @@ void NetContractPanel::DrawPanel() { DrawCalls(contract); ImGui::Separator(); - if (Volt::Entity(m_entityId, m_scene.get()).HasComponent()) + if (m_scene->GetEntityFromUUID(m_entityId).HasComponent()) { ImGui::TextColored(ImColor(0, 255, 0), "NetActorComponent"); } @@ -75,7 +75,7 @@ void NetContractPanel::DrawActions() { UI::Notify(NotificationType::Error, "NetContract save Failed", "Make sure file is writable"); } - else if (m_entityId != entt::null && m_handle != 0) + else if (m_entityId != Volt::Entity::NullID() && m_handle != 0) { UI::Notify(NotificationType::Success, "NetContract Saved ", ""); auto contract = Volt::NetContractContainer::GetContract(m_handle); @@ -93,11 +93,11 @@ void NetContractPanel::DrawActions() ImGui::SameLine(); if (ImGui::Button("Refresh")) { - if (m_entityId != entt::null && m_handle != 0) + if (m_entityId != Volt::Entity::NullID() && m_handle != 0) { Volt::NetContractContainer::Clear(); Volt::NetContractContainer::Load(); - m_scene->RemoveEntity(Volt::Entity(m_entityId, m_scene.get())); + m_scene->RemoveEntity(m_scene->GetEntityFromUUID(m_entityId)); m_entityId = Volt::AssetManager::GetAsset(m_handle)->Instantiate(m_scene).GetID(); } } @@ -107,9 +107,9 @@ void NetContractPanel::DrawActions() { if (EditorUtils::Property("Prefab:", m_handle, Volt::AssetType::Prefab)) { - if (m_entityId != entt::null) + if (m_entityId != Volt::Entity::NullID()) { - m_scene->RemoveEntity(Volt::Entity(m_entityId, m_scene.get())); + m_scene->RemoveEntity(m_scene->GetEntityFromUUID(m_entityId)); Volt::NetContractContainer::Clear(); Volt::NetContractContainer::Load(); } @@ -173,7 +173,7 @@ void NetContractPanel::DrawCalls(Ref in_contract) void NetContractPanel::DrawComponentRules(Ref in_contract) { - if (m_entityId == entt::null || m_handle == 0) return; + if (m_entityId == Volt::Entity::NullID() || m_handle == 0) return; //auto entity = Volt::Entity(m_entityId, m_scene.get()); //auto& registry = m_scene->GetRegistry(); @@ -201,14 +201,14 @@ void NetContractPanel::DrawComponentRules(Ref in_contract) void NetContractPanel::DrawChildRules(Ref in_contract) { - if (m_entityId == entt::null || m_handle == 0) return; + if (m_entityId == Volt::Entity::NullID() || m_handle == 0) return; DrawChild(in_contract, m_entityId); } -void NetContractPanel::DrawChild(Ref in_contract, entt::entity in_id) +void NetContractPanel::DrawChild(Ref in_contract, Volt::EntityID in_id) { - auto ent = Volt::Entity(in_id, m_scene.get()); + auto ent = m_scene->GetEntityFromUUID(in_id); if (ImGui::CollapsingHeader(ent.GetTag().c_str())) { DrawRuleSet(in_contract, in_id); @@ -251,13 +251,13 @@ bool NetContractPanel::BlockStandardComponents(const std::string &in_name) return false; } -void NetContractPanel::DrawRuleSet(Ref in_contract, entt::entity in_id) +void NetContractPanel::DrawRuleSet(Ref in_contract, Volt::EntityID in_id) { - auto entity = Volt::Entity(in_id, m_scene.get()); + auto entity = m_scene->GetEntityFromUUID(in_id); for (auto&& curr : entity.GetScene()->GetRegistry().storage()) { - if (auto& storage = curr.second; storage.contains(in_id)) + if (auto& storage = curr.second; storage.contains(entity)) { auto typeDesc = Volt::ComponentRegistry::GetTypeDescFromName(storage.type().name()); if (!typeDesc) diff --git a/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.h b/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.h index 9e4590330..ca2c66a64 100644 --- a/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.h +++ b/Volt/Sandbox/src/Sandbox/Window/Net/NetContractPanel.h @@ -20,13 +20,13 @@ class NetContractPanel : public EditorWindow void DrawCalls(Ref in_contract); void DrawComponentRules(Ref in_contract); void DrawChildRules(Ref in_contract); - void DrawChild(Ref in_contract, entt::entity in_id); + void DrawChild(Ref in_contract, Volt::EntityID in_id); void RuleEntry(const std::string& in_name, Volt::NetRule& in_rules, const std::string& in_id); - void DrawRuleSet(Ref in_contract, entt::entity in_id); + void DrawRuleSet(Ref in_contract, Volt::EntityID in_id); bool BlockStandardComponents(const std::string& in_name); std::unordered_set m_blocked; Volt::AssetHandle m_handle = Volt::AssetHandle(0); Ref m_scene; - entt::entity m_entityId; + Volt::EntityID m_entityId; }; diff --git a/Volt/Sandbox/src/Sandbox/Window/ParticleEmitterEditor.cpp b/Volt/Sandbox/src/Sandbox/Window/ParticleEmitterEditor.cpp index 41a463b1e..c61690623 100644 --- a/Volt/Sandbox/src/Sandbox/Window/ParticleEmitterEditor.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/ParticleEmitterEditor.cpp @@ -26,7 +26,7 @@ ParticleEmitterEditor::ParticleEmitterEditor() myReferenceModel = myPreviewScene->CreateEntity("Reference Entity"); myReferenceModel.AddComponent(); - myLightEntity = Volt::Entity(myPreviewScene->GetAllEntitiesWith()[0], myPreviewScene.get()); + myLightEntity = myPreviewScene->GetAllEntitiesWith()[0]; auto& tempComp = myLightEntity.GetComponent(); tempComp.castShadows = false; tempComp.softShadows = false; @@ -295,7 +295,7 @@ bool ParticleEmitterEditor::DrawEditorPanel() UI::Property("Camera speed", cameraSpeed); myCameraController->SetTranslationSpeed(cameraSpeed); - EditorUtils::Property("Skybox", Volt::Entity(myPreviewScene->GetAllEntitiesWith()[0], myPreviewScene.get()).GetComponent().environmentHandle, Volt::AssetType::Texture); + EditorUtils::Property("Skybox", myPreviewScene->GetAllEntitiesWith()[0].GetComponent().environmentHandle, Volt::AssetType::Texture); UI::EndProperties(); } } diff --git a/Volt/Sandbox/src/Sandbox/Window/PropertiesPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/PropertiesPanel.cpp index efa07104f..4d1c630e4 100644 --- a/Volt/Sandbox/src/Sandbox/Window/PropertiesPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/PropertiesPanel.cpp @@ -53,7 +53,7 @@ void PropertiesPanel::UpdateMainContent() } const bool singleSelected = !(SelectionManager::GetSelectedCount() > 1); - auto firstEntity = Volt::Entity{ SelectionManager::GetSelectedEntities().front(), myCurrentScene }; + auto firstEntity = myCurrentScene->GetEntityFromUUID(SelectionManager::GetSelectedEntities().front()); const auto& entities = SelectionManager::GetSelectedEntities(); if (singleSelected) @@ -78,7 +78,7 @@ void PropertiesPanel::UpdateMainContent() for (auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -105,7 +105,7 @@ void PropertiesPanel::UpdateMainContent() { for (auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -122,7 +122,7 @@ void PropertiesPanel::UpdateMainContent() if (UI::BeginProperties("Transform")) { auto& entityId = SelectionManager::GetSelectedEntities().front(); - Volt::Entity entity{ entityId, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -143,7 +143,7 @@ void PropertiesPanel::UpdateMainContent() for (auto& entId : entities) { - Volt::Entity ent{ entId, myCurrentScene.get() }; + Volt::Entity ent = myCurrentScene->GetEntityFromUUID(entId); ent.SetLocalPosition(transform.position); myCurrentScene->InvalidateEntityTransform(entId); } @@ -166,7 +166,7 @@ void PropertiesPanel::UpdateMainContent() for (auto& entId : entities) { - Volt::Entity ent{ entId, myCurrentScene.get() }; + Volt::Entity ent = myCurrentScene->GetEntityFromUUID(entId); ent.SetLocalRotation(transform.rotation); myCurrentScene->InvalidateEntityTransform(entId); } @@ -185,7 +185,7 @@ void PropertiesPanel::UpdateMainContent() for (auto& entId : entities) { - Volt::Entity ent{ entId, myCurrentScene.get() }; + Volt::Entity ent = myCurrentScene->GetEntityFromUUID(entId); ent.SetLocalScale(transform.scale); myCurrentScene->InvalidateEntityTransform(entId); } @@ -206,7 +206,7 @@ void PropertiesPanel::UpdateMainContent() if (singleSelected) { const auto id = SelectionManager::GetSelectedEntities().front(); - Volt::Entity entity{ id, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(id); ComponentPropertyUtility::DrawComponents(myCurrentScene, entity); ComponentPropertyUtility::DrawMonoScripts(myCurrentScene, entity); @@ -307,7 +307,7 @@ void PropertiesPanel::AddComponentPopup() const bool newMonoScript = compGuid == Volt::MonoScriptComponent::guid; - Volt::Entity frontEntity{ SelectionManager::GetSelectedEntities().front(), myCurrentScene }; + Volt::Entity frontEntity = myCurrentScene->GetEntityFromUUID(SelectionManager::GetSelectedEntities().front()); if (!frontEntity.HasComponent(componentTypeName) || newMonoScript) { UI::ShiftCursor(4.f, 0.f); @@ -316,14 +316,14 @@ void PropertiesPanel::AddComponentPopup() { for (auto& ent : SelectionManager::GetSelectedEntities()) { - if (!Volt::ComponentRegistry::Helpers::HasComponentWithGUID(compGuid, myCurrentScene->GetRegistry(), ent)) + if (!Volt::ComponentRegistry::Helpers::HasComponentWithGUID(compGuid, myCurrentScene->GetRegistry(), myCurrentScene->GetHandleFromUUID(ent))) { - Volt::ComponentRegistry::Helpers::AddComponentWithGUID(compGuid, myCurrentScene->GetRegistry(), ent); + Volt::ComponentRegistry::Helpers::AddComponentWithGUID(compGuid, myCurrentScene->GetRegistry(), myCurrentScene->GetHandleFromUUID(ent)); } if (newMonoScript) { - Volt::MonoScriptComponent& comp = myCurrentScene->GetRegistry().get(frontEntity.GetID()); + Volt::MonoScriptComponent& comp = myCurrentScene->GetRegistry().get(frontEntity); if (comp.scriptIds.size() < Volt::MonoScriptEngine::MAX_SCRIPTS_PER_ENTITY) { comp.scriptIds.emplace_back(Volt::UUID()); @@ -393,7 +393,7 @@ void PropertiesPanel::AddMonoScriptPopup() { for (auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(id); if (!entity.HasComponent()) { @@ -437,7 +437,7 @@ void PropertiesPanel::AddMonoScriptPopup() for (auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(id); if (!entity.HasComponent()) { @@ -505,7 +505,7 @@ void PropertiesPanel::AcceptMonoDragDrop() { for (auto& id : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ id, myCurrentScene }; + Volt::Entity entity = myCurrentScene->GetEntityFromUUID(id); if (!entity.HasComponent()) { diff --git a/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.cpp index d12a1b924..07a8b02b1 100644 --- a/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.cpp @@ -102,10 +102,10 @@ void SceneViewPanel::UpdateMainContent() RebuildEntityDrawList(); } - std::unordered_map> layerEntityLists; + std::unordered_map> layerEntityLists; for (const auto& entId : m_entityDrawList) { - Volt::Entity entity{ entId, m_scene }; + Volt::Entity entity = m_scene->GetEntityFromUUID(entId); if (!entity.HasComponent()) { @@ -269,9 +269,8 @@ void SceneViewPanel::UpdateMainContent() const auto newVal = !layer.visible; layer.visible = newVal; - for (const auto& entityId : m_scene->GetAllEntities()) + for (auto entity : m_scene->GetAllEntities()) { - Volt::Entity entity{ entityId, m_scene.get() }; if (entity.GetParent()) { continue; @@ -295,9 +294,8 @@ void SceneViewPanel::UpdateMainContent() const auto newVal = !layer.locked; layer.locked = newVal; - for (const auto& entityId : m_scene->GetAllEntities()) + for (auto entity : m_scene->GetAllEntities()) { - Volt::Entity entity{ entityId, m_scene.get() }; if (entity.GetParent()) { continue; @@ -319,7 +317,7 @@ void SceneViewPanel::UpdateMainContent() { for (const auto& id : layerEntityLists[layer.id]) { - Volt::Entity entity{ id, m_scene.get() }; + Volt::Entity entity = m_scene->GetEntityFromUUID(id); DrawEntity(entity, m_searchQuery); } @@ -458,9 +456,9 @@ void SceneViewPanel::HighlightEntity(Volt::Entity entity) m_scrollToEntity = entity.GetID(); } -void RecursiveUnpackPrefab(Ref scene, entt::entity id) +void RecursiveUnpackPrefab(Ref scene, Volt::EntityID id) { - Volt::Entity entity{ id, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -469,7 +467,7 @@ void RecursiveUnpackPrefab(Ref scene, entt::entity id) for (auto& childId : entity.GetComponent().children) { - Volt::Entity child{ childId, scene }; + Volt::Entity child = scene->GetEntityFromUUID(childId); if (child.HasComponent()) { @@ -497,7 +495,7 @@ bool SceneViewPanel::OnKeyPressedEvent(Volt::KeyPressedEvent& e) auto selection = SelectionManager::GetSelectedEntities(); for (const auto& selectedEntity : selection) { - Volt::Entity tempEnt = Volt::Entity(selectedEntity, m_scene.get()); + Volt::Entity tempEnt = m_scene->GetEntityFromUUID(selectedEntity); entitiesToRemove.push_back(tempEnt); SelectionManager::Deselect(tempEnt.GetID()); @@ -537,13 +535,13 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) std::string entityName = "Null"; Volt::Entity parent = Volt::Entity::Null(); - std::vector children; + std::vector children; if (entity.HasComponent()) { auto& relComp = entity.GetComponent(); - parent = Volt::Entity{ relComp.parent, m_scene }; + parent = m_scene->GetEntityFromUUID(relComp.parent); children = relComp.children; } @@ -701,9 +699,9 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) UI::RenderMatchingTextBackground(entityName, entityName, EditorTheme::MatchingTextBackground, offset); } - if (m_scrollToEntity != entt::null && m_scrollToEntity == entity.GetID()) + if (m_scrollToEntity != Volt::Entity::NullID() && m_scrollToEntity == entity.GetID()) { - m_scrollToEntity = entt::null; + m_scrollToEntity = Volt::Entity::NullID(); ImGui::SetScrollHereY(); } @@ -794,13 +792,13 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) { ImGui::TextUnformatted(entity.GetTag().c_str()); - const entt::entity entityId = entity.GetID(); - ImGui::SetDragDropPayload("scene_entity_hierarchy", &entityId, sizeof(entt::entity)); + const Volt::EntityID entityId = entity.GetID(); + ImGui::SetDragDropPayload("scene_entity_hierarchy", &entityId, sizeof(Volt::EntityID)); ImGui::EndDragDropSource(); } else { - std::vector selectedEntities = SelectionManager::GetSelectedEntities(); + std::vector selectedEntities = SelectionManager::GetSelectedEntities(); for (uint32_t i = 0; const auto & id : selectedEntities) { @@ -809,7 +807,7 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) break; } - Volt::Entity ent{ id, m_scene.get() }; + Volt::Entity ent = m_scene->GetEntityFromUUID(id); ImGui::TextUnformatted(ent.GetTag().c_str()); i++; } @@ -930,7 +928,7 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) auto selection = SelectionManager::GetSelectedEntities(); for (const auto& selectedEntity : selection) { - Volt::Entity tempEnt = Volt::Entity(selectedEntity, m_scene.get()); + Volt::Entity tempEnt = m_scene->GetEntityFromUUID(selectedEntity); entitiesToRemove.push_back(tempEnt); SelectionManager::Deselect(tempEnt.GetID()); @@ -984,7 +982,7 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) { for (const auto& e : SelectionManager::GetSelectedEntities()) { - recursiveSetVisible(Volt::Entity{ e, m_scene }, newVal, recursiveSetVisible); + recursiveSetVisible(m_scene->GetEntityFromUUID(e), newVal, recursiveSetVisible); } } } @@ -1004,7 +1002,7 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) { for (const auto& e : SelectionManager::GetSelectedEntities()) { - Volt::Entity tempEnt = { e, m_scene }; + Volt::Entity tempEnt = m_scene->GetEntityFromUUID(e); auto& eTransformComponent = tempEnt.GetComponent(); eTransformComponent.locked = newVal; @@ -1021,7 +1019,7 @@ void SceneViewPanel::DrawEntity(Volt::Entity entity, const std::string& filter) { for (const auto& child : children) { - DrawEntity(Volt::Entity{ child, m_scene }, filter); + DrawEntity(m_scene->GetEntityFromUUID(child), filter); } ImGui::TreePop(); @@ -1060,9 +1058,9 @@ void SceneViewPanel::UpdatePrefabsInScene(Ref prefab, Volt::Entity return; } - m_scene->ForEachWithComponents([&](const entt::entity id, const Volt::PrefabComponent& prefabComp) + m_scene->ForEachWithComponents([&](const entt::entity id, const Volt::PrefabComponent& prefabComp, const Volt::IDComponent& idComponent) { - if (id == srcEntity.GetID()) + if (idComponent.id == srcEntity.GetID()) { return; } @@ -1082,9 +1080,9 @@ void SceneViewPanel::UpdatePrefabsInScene(Ref prefab, Volt::Entity if (prefabAsset->IsReference(srcEntity)) { - m_scene->ForEachWithComponents([&](const entt::entity id, const Volt::PrefabComponent& prefabComp) + m_scene->ForEachWithComponents([&](const entt::entity id, const Volt::PrefabComponent& prefabComp, const Volt::IDComponent& idComponent) { - if (id == srcEntity.GetID()) + if (idComponent.id == srcEntity.GetID()) { return; } diff --git a/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.h b/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.h index ccf0fe536..afc94ae46 100644 --- a/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.h +++ b/Volt/Sandbox/src/Sandbox/Window/SceneViewPanel.h @@ -44,13 +44,13 @@ class SceneViewPanel : public EditorWindow std::string m_searchQuery; bool m_hasSearchQuery = false; - entt::entity m_scrollToEntity = entt::null; + Volt::EntityID m_scrollToEntity = Volt::Entity::NullID(); bool m_isRenamingLayer = false; uint32_t m_renamingLayer = 0; - std::vector m_entityDrawList; - std::unordered_map m_entityToImGuiID; + std::vector m_entityDrawList; + std::unordered_map m_entityToImGuiID; bool m_rebuildDrawList = false; Ref& m_scene; diff --git a/Volt/Sandbox/src/Sandbox/Window/Timeline.cpp b/Volt/Sandbox/src/Sandbox/Window/Timeline.cpp index b26515d90..70572bdc9 100644 --- a/Volt/Sandbox/src/Sandbox/Window/Timeline.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/Timeline.cpp @@ -172,8 +172,8 @@ void Timeline::HandleTimelineInfo() if (auto ptr = UI::DragDropTarget("scene_entity_hierarchy")) { - entt::entity entityId = *(entt::entity*)ptr; - AddClip(static_cast(entityId)); + Volt::EntityID entityId = *(Volt::EntityID*)ptr; + AddClip(entityId); } } @@ -256,7 +256,7 @@ bool Timeline::CameraQuickshotKeyframe(Volt::KeyPressedEvent& e) return false; } - if (mySelectedTrack->targetEntity == entt::null) + if (mySelectedTrack->targetEntity == Volt::Entity::NullID()) { UI::Notify(NotificationType::Error, "Timeline", "No entity in selected track!"); return false; @@ -288,7 +288,7 @@ void Timeline::AddKeyframe() return; } - if (mySelectedTrack->targetEntity == entt::null) + if (mySelectedTrack->targetEntity == Volt::Entity::NullID()) { UI::Notify(NotificationType::Error, "Timeline", "No entity in selected track!"); return; @@ -298,7 +298,7 @@ void Timeline::AddKeyframe() Volt::Keyframe newKeyframe; newKeyframe.frame = GetFrameFromPos(myMPoint3); - Volt::Entity targetEnt = Volt::Entity{ mySelectedTrack->targetEntity, myCurrentScene.get() }; + Volt::Entity targetEnt = myCurrentScene->GetEntityFromUUID(mySelectedTrack->targetEntity); newKeyframe.position = targetEnt.GetPosition(); newKeyframe.rotation = targetEnt.GetRotation(); @@ -312,7 +312,7 @@ void Timeline::AddKeyframe() SortTrack(*mySelectedTrack); } -void Timeline::AddClip(uint32_t entityId) +void Timeline::AddClip(Volt::EntityID entityId) { if (mySelectedTrack == nullptr) { @@ -320,7 +320,7 @@ void Timeline::AddClip(uint32_t entityId) return; } - Volt::Entity cameraEnt = Volt::Entity{ static_cast(entityId), myCurrentScene }; + Volt::Entity cameraEnt = myCurrentScene->GetEntityFromUUID(entityId); if (!cameraEnt.HasComponent()) { UI::Notify(NotificationType::Error, "Timeline", "Entity needs to be a Vision Camera"); @@ -499,7 +499,7 @@ void Timeline::DrawClipsOnTrack(int trackIndex) drawlist->AddRectFilledMultiColor(ImVec2(trackXStartPos, trackMinPos.y), ImVec2(trackXEndPos, trackMinPos.y + myIndividualTrackSize.y), IM_COL32(150, 150, 150, 255), IM_COL32(150, 150, 150, 255), IM_COL32(100, 100, 100, 255), IM_COL32(100, 100, 100, 255)); } - Volt::Entity camEnt = Volt::Entity{ currClip.activeCamera, myCurrentScene.get() }; + Volt::Entity camEnt = myCurrentScene->GetEntityFromUUID(currClip.activeCamera); std::string entName; if (camEnt) { diff --git a/Volt/Sandbox/src/Sandbox/Window/Timeline.h b/Volt/Sandbox/src/Sandbox/Window/Timeline.h index c2c787611..d9ced8d50 100644 --- a/Volt/Sandbox/src/Sandbox/Window/Timeline.h +++ b/Volt/Sandbox/src/Sandbox/Window/Timeline.h @@ -41,7 +41,7 @@ class Timeline : public EditorWindow bool CameraQuickshotKeyframe(Volt::KeyPressedEvent& e); void AddKeyframe(); - void AddClip(uint32_t entityId); + void AddClip(Volt::EntityID entityId); void PreviewTimeline(); diff --git a/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.cpp index cac8aea7a..ec190f92c 100644 --- a/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.cpp @@ -153,7 +153,7 @@ void ViewportPanel::UpdateMainContent() { for (auto ent : SelectionManager::GetSelectedEntities()) { - if (Sandbox::Get().CheckForUpdateNavMesh(Volt::Entity(ent, m_editorScene.get()))) + if (Sandbox::Get().CheckForUpdateNavMesh(m_editorScene->GetEntityFromUUID(ent))) { Sandbox::Get().BakeNavMesh(); break; @@ -605,7 +605,7 @@ bool ViewportPanel::OnKeyPressedEvent(Volt::KeyPressedEvent& e) auto selection = SelectionManager::GetSelectedEntities(); for (const auto& selectedEntity : selection) { - Volt::Entity tempEnt = Volt::Entity(selectedEntity, m_editorScene.get()); + Volt::Entity tempEnt = m_editorScene->GetEntityFromUUID(selectedEntity); entitiesToRemove.push_back(tempEnt); SelectionManager::Deselect(tempEnt.GetID()); @@ -852,7 +852,7 @@ void ViewportPanel::DuplicateSelection() continue; } - duplicated.emplace_back(Volt::Entity::Duplicate(Volt::Entity{ ent, m_editorScene })); + duplicated.emplace_back(Volt::Entity::Duplicate(m_editorScene->GetEntityFromUUID(ent))); } SelectionManager::DeselectAll(); @@ -883,7 +883,7 @@ void ViewportPanel::HandleSingleSelect() SelectionManager::DeselectAll(); } - Volt::Entity entity{ pixelData, m_editorScene }; + Volt::Entity entity = m_editorScene->GetEntityFromUUID(pixelData); if (entity.IsValid()) { @@ -938,9 +938,9 @@ void ViewportPanel::HandleMultiSelect() for (const auto& d : data) { - if (d != entt::null) + if (d != Volt::Entity::NullID()) { - SelectionManager::Select(static_cast(d)); + SelectionManager::Select(static_cast(d)); } } } @@ -949,7 +949,7 @@ void ViewportPanel::HandleMultiSelect() void ViewportPanel::HandleSingleGizmoInteraction(const glm::mat4& avgTransform) { auto firstEntityId = SelectionManager::GetSelectedEntities().front(); - Volt::Entity entity{ firstEntityId, m_editorScene }; + Volt::Entity entity = m_editorScene->GetEntityFromUUID(firstEntityId); if (!entity.HasComponent() || !entity.HasComponent()) { @@ -978,9 +978,9 @@ void ViewportPanel::HandleSingleGizmoInteraction(const glm::mat4& avgTransform) glm::mat4 averageTransform = avgTransform; - if (relationshipComp.parent != entt::null) + if (relationshipComp.parent != Volt::Entity::NullID()) { - Volt::Entity parent(relationshipComp.parent, m_editorScene.get()); + Volt::Entity parent = m_editorScene->GetEntityFromUUID(relationshipComp.parent); auto pTransform = parent.GetTransform(); averageTransform = glm::inverse(pTransform) * averageTransform; @@ -999,11 +999,11 @@ void ViewportPanel::HandleSingleGizmoInteraction(const glm::mat4& avgTransform) void ViewportPanel::HandleMultiGizmoInteraction(const glm::mat4& deltaTransform) { - std::vector> previousTransforms; + std::vector> previousTransforms; for (const auto& entId : SelectionManager::GetSelectedEntities()) { - Volt::Entity entity{ entId, m_editorScene }; + Volt::Entity entity = m_editorScene->GetEntityFromUUID(entId); if (SelectionManager::IsAnyParentSelected(entId, m_editorScene)) { @@ -1025,9 +1025,9 @@ void ViewportPanel::HandleMultiGizmoInteraction(const glm::mat4& deltaTransform) glm::mat4 entDeltaTransform = deltaTransform; - if (relationshipComp.parent != entt::null) + if (relationshipComp.parent != Volt::Entity::NullID()) { - Volt::Entity parent(relationshipComp.parent, m_editorScene.get()); + Volt::Entity parent = m_editorScene->GetEntityFromUUID(relationshipComp.parent); auto pTransform = parent.GetTransform(); entDeltaTransform = glm::inverse(pTransform) * entDeltaTransform; @@ -1189,7 +1189,7 @@ glm::mat4 ViewportPanel::CalculateAverageTransform() for (const auto& ent : SelectionManager::GetSelectedEntities()) { - const auto trs = m_editorScene->GetWorldTQS(Volt::Entity{ ent, m_editorScene.get() }); + const auto trs = m_editorScene->GetWorldTQS(m_editorScene->GetEntityFromUUID(ent)); avgTranslation += trs.position; avgRotation = trs.rotation; diff --git a/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.h b/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.h index a57c0086e..70257e0e3 100644 --- a/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.h +++ b/Volt/Sandbox/src/Sandbox/Window/ViewportPanel.h @@ -94,7 +94,7 @@ class ViewportPanel : public EditorWindow Volt::Entity m_createdEntity; - entt::entity m_entityToAddMesh = entt::null; + Volt::EntityID m_entityToAddMesh = Volt::Entity::NullID(); std::filesystem::path m_meshToImport; Volt::AssetHandle m_sceneToOpen = Volt::Asset::Null(); diff --git a/Volt/Sandbox/src/Sandbox/Window/VisonPanel.cpp b/Volt/Sandbox/src/Sandbox/Window/VisonPanel.cpp index b0cfbab52..96e53c40c 100644 --- a/Volt/Sandbox/src/Sandbox/Window/VisonPanel.cpp +++ b/Volt/Sandbox/src/Sandbox/Window/VisonPanel.cpp @@ -153,14 +153,14 @@ void VisionPanel::UpdateCameraProperties() { if (UI::PropertyEntity("Follow", myCurrentScene, visionCamComp.followId, "Camera follows this entity")) { - Volt::Entity followEnt = Volt::Entity({ visionCamComp.followId, myCurrentScene.get() }); + Volt::Entity followEnt = myCurrentScene->GetEntityFromUUID(visionCamComp.followId); visionCamComp.offset = myVisionCams[mySelectedCamera].GetPosition() - followEnt.GetPosition(); } UI::PropertyEntity("LookAt", myCurrentScene, visionCamComp.lookAtId, "Camera looks at this entity"); - if (visionCamComp.followId != entt::null) + if (visionCamComp.followId != Volt::Entity::NullID()) { ImGui::LabelText("##Locks", "Constraints"); @@ -372,7 +372,7 @@ Volt::Entity VisionPanel::CreateNewTrigger() const std::vector VisionPanel::GetAllCameraTriggers() { - std::vector triggerIDs = myCurrentScene->GetAllEntitiesWith(); + std::vector triggerIDs = myCurrentScene->GetAllEntitiesWith(); if (triggerIDs.empty()) { @@ -385,7 +385,7 @@ const std::vector VisionPanel::GetAllCameraTriggers() for (auto& id : triggerIDs) { - triggers.emplace_back(Volt::Entity{ id,myCurrentScene.get() }); + triggers.emplace_back(id); } return triggers; @@ -393,7 +393,7 @@ const std::vector VisionPanel::GetAllCameraTriggers() const std::vector VisionPanel::GetAllCameras() { - std::vector cameraIDs = myCurrentScene->GetAllEntitiesWith(); + std::vector cameraIDs = myCurrentScene->GetAllEntitiesWith(); if (cameraIDs.empty()) { @@ -406,7 +406,7 @@ const std::vector VisionPanel::GetAllCameras() for (auto& id : cameraIDs) { - vtCams.emplace_back(Volt::Entity{ id,myCurrentScene.get() }); + vtCams.emplace_back(id); } return vtCams; @@ -422,15 +422,15 @@ void VisionPanel::UpdateSelectedCamera() Volt::Entity selectedEnt = myVisionCams[mySelectedCamera]; auto& visionCamComp = selectedEnt.GetComponent(); - if (visionCamComp.followId != entt::null) + if (visionCamComp.followId != Volt::Entity::NullID()) { - Volt::Entity target = Volt::Entity{ visionCamComp.followId, myCurrentScene.get() }; + Volt::Entity target = myCurrentScene->GetEntityFromUUID(visionCamComp.followId); selectedEnt.SetPosition(target.GetPosition() + visionCamComp.offset); } - if (visionCamComp.lookAtId != entt::null) + if (visionCamComp.lookAtId != Volt::Entity::NullID()) { - Volt::Entity lookAtEnt = Volt::Entity{ visionCamComp.lookAtId, myCurrentScene.get() }; + Volt::Entity lookAtEnt = myCurrentScene->GetEntityFromUUID(visionCamComp.lookAtId); glm::vec3 lookAtPos = lookAtEnt.GetPosition(); selectedEnt.SetLocalRotation(glm::quatLookAtLH(glm::normalize(lookAtPos - selectedEnt.GetPosition()), { 0,1,0 })); diff --git a/Volt/Volt/premake5.lua b/Volt/Volt/premake5.lua index 895af3aae..02b0daec7 100644 --- a/Volt/Volt/premake5.lua +++ b/Volt/Volt/premake5.lua @@ -12,23 +12,11 @@ project "Volt" warnings "Extra" - flags - { - "FatalWarnings" - } - - disablewarnings - { - "4005", - "4201", - "4100" - } - - linkoptions - { - "/ignore:4006", - "/ignore:4099", - } + AddCommonFlags() + AddCommonWarnings() + AddCommonLinkOptions() + AddCommonIncludeDirs() + AddCommonDefines() buildoptions { @@ -64,7 +52,6 @@ project "Volt" "%{IncludeDir.spdlog}", "%{IncludeDir.yaml}", "%{IncludeDir.ImGui}", - "%{IncludeDir.Optick}", "%{IncludeDir.TinyGLTF}", "%{IncludeDir.tinyddsloader}", "%{IncludeDir.imgui_notify}", @@ -125,14 +112,7 @@ project "Volt" defines { - "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", - "_CRT_SECURE_NO_WARNINGS", - "PX_PHYSX_STATIC_LIB", - "OPTICK_ENABLE_GPU_VULKAN", - - "GLM_FORCE_DEPTH_ZERO_TO_ONE", - "GLM_FORCE_LEFT_HANDED" } filter "files:vendor/**.cpp" diff --git a/Volt/Volt/src/Volt/Animation/AnimationStateMachine.cpp b/Volt/Volt/src/Volt/Animation/AnimationStateMachine.cpp index d53471236..f0347218b 100644 --- a/Volt/Volt/src/Volt/Animation/AnimationStateMachine.cpp +++ b/Volt/Volt/src/Volt/Animation/AnimationStateMachine.cpp @@ -318,7 +318,7 @@ namespace Volt return (int32_t)diff; } - Ref AnimationStateMachine::CreateCopy(GraphKey::Graph* ownerGraph, entt::entity entity) const + Ref AnimationStateMachine::CreateCopy(GraphKey::Graph* ownerGraph, Volt::EntityID entity) const { Ref newStateMachine = CreateRef(myName, myCharacterHandle); newStateMachine->myStartState = myStartState; diff --git a/Volt/Volt/src/Volt/Animation/AnimationStateMachine.h b/Volt/Volt/src/Volt/Animation/AnimationStateMachine.h index ac70211db..9a48a73ee 100644 --- a/Volt/Volt/src/Volt/Animation/AnimationStateMachine.h +++ b/Volt/Volt/src/Volt/Animation/AnimationStateMachine.h @@ -79,7 +79,7 @@ namespace Volt AnimationState* GetStateFromPin(const UUID outputId) const; const int32_t GetStateIndexFromId(const UUID stateId) const; - Ref CreateCopy(GraphKey::Graph* ownerGraph, entt::entity entity = entt::null) const; + Ref CreateCopy(GraphKey::Graph* ownerGraph, Volt::EntityID entity = Volt::EntityID(0)) const; void OnEvent(Event& e); diff --git a/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.cpp b/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.cpp index eed12ef56..9fd7a3ceb 100644 --- a/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.cpp +++ b/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.cpp @@ -5,7 +5,7 @@ namespace Volt { - Ref AnimationGraphAsset::CreateCopy(entt::entity entity) + Ref AnimationGraphAsset::CreateCopy(EntityID entity) { Ref newGraph = CreateRef(myAnimatedCharacter); newGraph->SetEntity(entity); diff --git a/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.h b/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.h index 7f18dc40e..93d934336 100644 --- a/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.h +++ b/Volt/Volt/src/Volt/Asset/Animation/AnimationGraphAsset.h @@ -13,7 +13,7 @@ namespace Volt { } - inline AnimationGraphAsset(AssetHandle character, entt::entity entity) + inline AnimationGraphAsset(AssetHandle character, EntityID entity) : GraphKey::Graph(entity), myAnimatedCharacter(character) { } @@ -31,7 +31,7 @@ namespace Volt static AssetType GetStaticType() { return Volt::AssetType::AnimationGraph; } AssetType GetType() override { return GetStaticType(); }; - Ref CreateCopy(entt::entity entity = entt::null); + Ref CreateCopy(EntityID entity = Entity::NullID()); private: friend class AnimationGraphImporter; diff --git a/Volt/Volt/src/Volt/Asset/Importers/NetContractImporter.cpp b/Volt/Volt/src/Volt/Asset/Importers/NetContractImporter.cpp index 24582263a..f250a92cd 100644 --- a/Volt/Volt/src/Volt/Asset/Importers/NetContractImporter.cpp +++ b/Volt/Volt/src/Volt/Asset/Importers/NetContractImporter.cpp @@ -55,7 +55,7 @@ namespace Volt auto ruleNodeOuter = node["Rules"]; for (YAML::const_iterator it = ruleNodeOuter.begin(); it != ruleNodeOuter.end(); ++it) { - auto outerKey = it->first.as(); + auto outerKey = it->first.as(); std::unordered_map outerValue; auto ruleNodeInner = ruleNodeOuter[std::to_string(static_cast(outerKey)).c_str()]; @@ -70,7 +70,7 @@ namespace Volt outerValue.insert({ innerKey, innerValue }); } - std::pair> entry{ outerKey,outerValue }; + std::pair> entry{ outerKey,outerValue }; rAsset->rules.insert(entry); } } diff --git a/Volt/Volt/src/Volt/Asset/Importers/PrefabImporter.cpp b/Volt/Volt/src/Volt/Asset/Importers/PrefabImporter.cpp index a16f1531a..4844e7139 100644 --- a/Volt/Volt/src/Volt/Asset/Importers/PrefabImporter.cpp +++ b/Volt/Volt/src/Volt/Asset/Importers/PrefabImporter.cpp @@ -41,7 +41,7 @@ namespace Volt streamReader.EnterScope("Prefab"); { prefab->m_version = streamReader.ReadKey("version", uint32_t(0)); - prefab->m_rootEntityId = streamReader.ReadKey("rootEntityId", (entt::entity)entt::null); + prefab->m_rootEntityId = streamReader.ReadKey("rootEntityId", Entity::NullID()); streamReader.ForEach("Entities", [&]() { @@ -50,9 +50,9 @@ namespace Volt streamReader.ForEach("PrefabReferences", [&]() { - entt::entity entityId = streamReader.ReadKey("entity", (entt::entity)entt::null); + EntityID entityId = streamReader.ReadKey("entity", Entity::NullID()); AssetHandle prefabHandle = streamReader.ReadKey("prefabHandle", Asset::Null()); - entt::entity prefabEntityReference = streamReader.ReadKey("prefabEntityReference", (entt::entity)entt::null); + EntityID prefabEntityReference = streamReader.ReadKey("prefabEntityReference", Entity::NullID()); auto& prefabRefData = prefab->m_prefabReferencesMap[entityId]; prefabRefData.prefabAsset = prefabHandle; diff --git a/Volt/Volt/src/Volt/Asset/Importers/SceneImporter.cpp b/Volt/Volt/src/Volt/Asset/Importers/SceneImporter.cpp index 8078f2acc..34a83e890 100644 --- a/Volt/Volt/src/Volt/Asset/Importers/SceneImporter.cpp +++ b/Volt/Volt/src/Volt/Asset/Importers/SceneImporter.cpp @@ -21,6 +21,8 @@ namespace Volt template void RegisterSerializationFunction(std::unordered_map>& outTypes) { + VT_PROFILE_FUNCTION(); + outTypes[std::type_index{ typeid(T) }] = [](YAMLStreamWriter& streamWriter, const uint8_t* data, const size_t offset) { const T& var = *reinterpret_cast(&data[offset]); @@ -31,6 +33,8 @@ namespace Volt template void RegisterDeserializationFunction(std::unordered_map>& outTypes) { + VT_PROFILE_FUNCTION(); + outTypes[std::type_index{ typeid(T) }] = [](YAMLStreamReader& streamReader, uint8_t* data, const size_t offset) { *reinterpret_cast(&data[offset]) = streamReader.ReadKey("data", T()); @@ -69,7 +73,7 @@ namespace Volt RegisterSerializationFunction(s_typeSerializers); RegisterSerializationFunction(s_typeSerializers); - RegisterSerializationFunction(s_typeSerializers); + RegisterSerializationFunction(s_typeSerializers); RegisterSerializationFunction(s_typeSerializers); RegisterDeserializationFunction(s_typeDeserializers); @@ -102,7 +106,7 @@ namespace Volt RegisterDeserializationFunction(s_typeDeserializers); RegisterDeserializationFunction(s_typeDeserializers); - RegisterDeserializationFunction(s_typeDeserializers); + RegisterDeserializationFunction(s_typeDeserializers); RegisterDeserializationFunction(s_typeDeserializers); s_instance = this; @@ -115,6 +119,8 @@ namespace Volt bool SceneImporter::Load(const AssetMetadata& metadata, Ref& asset) const { + VT_PROFILE_FUNCTION(); + asset = CreateRef(); Ref scene = reinterpret_pointer_cast(asset); @@ -173,6 +179,8 @@ namespace Volt void SceneImporter::LoadSceneLayers(const AssetMetadata& metadata, const Ref& scene, const std::filesystem::path& sceneDirectory) const { + VT_PROFILE_FUNCTION(); + std::filesystem::path layersFolderPath = sceneDirectory / "Layers"; if (!std::filesystem::exists(layersFolderPath)) { @@ -193,6 +201,8 @@ namespace Volt for (const auto& layerPath : layerPaths) { + VT_PROFILE_SCOPE("Layer"); + auto& sceneLayer = sceneLayers.emplace_back(); YAMLStreamReader streamReader{}; @@ -247,9 +257,8 @@ namespace Volt streamWriter.BeginSequence("Entities"); { - for (const auto id : scene->GetAllEntities()) + for (const auto entity : scene->GetAllEntities()) { - Entity entity{ id, scene }; const uint32_t layerId = entity.GetComponent().layerId; if (layerId != layer.id) @@ -257,7 +266,7 @@ namespace Volt continue; } - SerializeEntity(id, metadata, scene, streamWriter); + SerializeEntity(entity, metadata, scene, streamWriter); } } streamWriter.EndSequence(); @@ -275,7 +284,9 @@ namespace Volt auto& registry = scene->GetRegistry(); - streamWriter.SetKey("id", id); + Entity entity{ id, scene }; + + streamWriter.SetKey("id", entity.GetID()); streamWriter.BeginSequence("components"); { for (auto&& curr : registry.storage()) @@ -497,19 +508,23 @@ namespace Volt void SceneImporter::DeserializeEntity(const Ref& scene, const AssetMetadata& metadata, YAMLStreamReader& streamReader) const { + VT_PROFILE_FUNCTION(); + streamReader.EnterScope("Entity"); - entt::entity entityId = streamReader.ReadKey("id", (entt::entity)entt::null); + EntityID entityId = streamReader.ReadKey("id", Entity::NullID()); - if (entityId == entt::null) + if (entityId == Entity::NullID()) { return; } - entityId = scene->GetRegistry().create(entityId); + auto entity = scene->CreateEntityWithUUID(entityId); streamReader.ForEach("components", [&]() { + VT_PROFILE_SCOPE("Component"); + VoltGUID compGuid = streamReader.ReadKey("guid", VoltGUID::Null()); if (compGuid == VoltGUID::Null()) { @@ -526,8 +541,12 @@ namespace Volt { case ValueType::Component: { - ComponentRegistry::Helpers::AddComponentWithGUID(compGuid, scene->GetRegistry(), entityId); - void* voidCompPtr = ComponentRegistry::Helpers::GetComponentWithGUID(compGuid, scene->GetRegistry(), entityId); + if (!ComponentRegistry::Helpers::HasComponentWithGUID(compGuid, scene->GetRegistry(), entity)) + { + ComponentRegistry::Helpers::AddComponentWithGUID(compGuid, scene->GetRegistry(), entity); + } + + void* voidCompPtr = ComponentRegistry::Helpers::GetComponentWithGUID(compGuid, scene->GetRegistry(), entity); uint8_t* componentData = reinterpret_cast(voidCompPtr); const IComponentTypeDesc* componentDesc = reinterpret_cast(typeDesc); @@ -538,19 +557,19 @@ namespace Volt }); - if (scene->GetRegistry().any_of(entityId)) + if (scene->GetRegistry().any_of(entity)) { - DeserializeMono(entityId, scene, streamReader); + DeserializeMono(entity, scene, streamReader); } - if (scene->GetRegistry().any_of(entityId)) + if (scene->GetRegistry().any_of(entity)) { std::filesystem::path vpPath = metadata.filePath.parent_path(); vpPath = ProjectManager::GetDirectory() / vpPath / "Layers" / ("ent_" + std::to_string((uint32_t)entityId) + ".entVp"); if (std::filesystem::exists(vpPath)) { - auto& vpComp = scene->GetRegistry().get(entityId); + auto& vpComp = scene->GetRegistry().get(entity); std::ifstream vpFile(vpPath, std::ios::in | std::ios::binary); if (!vpFile.is_open()) @@ -583,6 +602,8 @@ namespace Volt void SceneImporter::DeserializeClass(uint8_t* data, const size_t offset, const IComponentTypeDesc* compDesc, YAMLStreamReader& streamReader) const { + VT_PROFILE_FUNCTION(); + streamReader.ForEach("members", [&]() { const std::string memberName = streamReader.ReadKey("name", std::string("")); @@ -634,6 +655,8 @@ namespace Volt void SceneImporter::DeserializeArray(uint8_t* data, const size_t offset, const IArrayTypeDesc* arrayDesc, YAMLStreamReader& streamReader) const { + VT_PROFILE_FUNCTION(); + void* arrayPtr = &data[offset]; const bool isNonDefaultType = arrayDesc->GetElementTypeDesc() != nullptr; @@ -689,6 +712,8 @@ namespace Volt void SceneImporter::DeserializeMono(entt::entity id, const Ref& scene, YAMLStreamReader& streamReader) const { + VT_PROFILE_FUNCTION(); + Entity entity{ id, scene }; streamReader.ForEach("MonoScripts", [&]() diff --git a/Volt/Volt/src/Volt/Asset/Importers/TimelineImporter.cpp b/Volt/Volt/src/Volt/Asset/Importers/TimelineImporter.cpp index 11d0ea27b..551622f80 100644 --- a/Volt/Volt/src/Volt/Asset/Importers/TimelineImporter.cpp +++ b/Volt/Volt/src/Volt/Asset/Importers/TimelineImporter.cpp @@ -11,6 +11,8 @@ #include "Volt/Utility/SerializationMacros.h" #include "Volt/Utility/YAMLSerializationHelpers.h" +#include "Volt/Scene/Entity.h" + #include "Volt/Asset/AssetManager.h" namespace Volt @@ -52,7 +54,7 @@ namespace Volt if (newTrack.trackType == TrackType::T_Animation) { - VT_DESERIALIZE_PROPERTY(targetEntId, newTrack.targetEntity, track, static_cast(entt::null)); + VT_DESERIALIZE_PROPERTY(targetEntId, newTrack.targetEntity, track, Entity::NullID()); for (auto keyFrame : track["Keyframes"]) { @@ -73,7 +75,7 @@ namespace Volt { Volt::Clip newClip = Volt::Clip(); - VT_DESERIALIZE_PROPERTY(clipCamera, newClip.activeCamera, clip, static_cast(entt::null)); + VT_DESERIALIZE_PROPERTY(clipCamera, newClip.activeCamera, clip, Entity::NullID()); VT_DESERIALIZE_PROPERTY(startTime, newClip.startTime, clip, 0.f); VT_DESERIALIZE_PROPERTY(endTime, newClip.endTime, clip, 0.f); diff --git a/Volt/Volt/src/Volt/Asset/Prefab.cpp b/Volt/Volt/src/Volt/Asset/Prefab.cpp index c2b96944f..601efd903 100644 --- a/Volt/Volt/src/Volt/Asset/Prefab.cpp +++ b/Volt/Volt/src/Volt/Asset/Prefab.cpp @@ -30,10 +30,8 @@ namespace Volt return Entity::Null(); } - auto targetScenePtr = targetScene.lock(); - - Entity newEntity = Entity::Duplicate(Entity{ m_rootEntityId, m_prefabScene }, targetScenePtr); - if (targetScenePtr->IsPlaying()) + Entity newEntity = Entity::Duplicate(m_prefabScene->GetEntityFromUUID(m_rootEntityId), targetScene); + if (targetScene->IsPlaying()) { InitializeComponents(newEntity); } @@ -57,7 +55,7 @@ namespace Volt } } - targetScenePtr->InvalidateEntityTransform(newEntity.GetID()); + targetScene->InvalidateEntityTransform(newEntity.GetID()); return newEntity; } @@ -68,7 +66,7 @@ namespace Volt return false; } - const bool updateSucceded = UpdateEntityInPrefabInternal(srcEntity, srcEntity.GetComponent().sceneRootEntity, entt::null); + const bool updateSucceded = UpdateEntityInPrefabInternal(srcEntity, srcEntity.GetComponent().sceneRootEntity, Entity::NullID()); if (updateSucceded) { @@ -92,12 +90,12 @@ namespace Volt void Prefab::UpdateEntityInScene(Entity sceneEntity) { - UpdateEntityInSceneInternal(sceneEntity, entt::null); + UpdateEntityInSceneInternal(sceneEntity, Entity::NullID()); } - void Prefab::CopyPrefabEntity(Entity dstEntity, entt::entity srcPrefabEntityId, const EntityCopyFlags copyFlags) const + void Prefab::CopyPrefabEntity(Entity dstEntity, EntityID srcPrefabEntityId, const EntityCopyFlags copyFlags) const { - Entity prefabEntity{ srcPrefabEntityId, m_prefabScene }; + Entity prefabEntity = m_prefabScene->GetEntityFromUUID(srcPrefabEntityId); if (!prefabEntity) { return; @@ -120,16 +118,16 @@ namespace Volt return false; } - const entt::entity prefabEntityId = entity.GetComponent().prefabEntity; + const EntityID prefabEntityId = entity.GetComponent().prefabEntity; - Entity prefabEntity{ prefabEntityId, m_prefabScene }; + Entity prefabEntity = m_prefabScene->GetEntityFromUUID(prefabEntityId); const bool isValid = prefabEntity.IsValid(); return isValid; } - const bool Prefab::IsEntityValidInPrefab(entt::entity prefabEntityId) const + const bool Prefab::IsEntityValidInPrefab(EntityID prefabEntityId) const { - return m_prefabScene->GetRegistry().valid(prefabEntityId); + return m_prefabScene->IsEntityValid(prefabEntityId); } const bool Prefab::IsEntityRoot(Entity entity) const @@ -164,9 +162,14 @@ namespace Volt return m_prefabReferencesMap.at(entity.GetComponent().prefabEntity); } + const Entity Prefab::GetRootEntity() const + { + return m_prefabScene->GetEntityFromUUID(m_rootEntityId); + } + void Prefab::InitializeComponents(Entity entity) { - Entity prefabEntity{ entity.GetComponent().prefabEntity, m_prefabScene }; + Entity prefabEntity = m_prefabScene->GetEntityFromUUID(entity.GetComponent().prefabEntity); if (prefabEntity.HasComponent()) { @@ -238,8 +241,8 @@ namespace Volt m_rootEntityId = srcRootEntity.GetID(); AddEntityToPrefabRecursive(srcRootEntity, Entity::Null()); - Entity rootPrefabEntity{ m_rootEntityId, m_prefabScene }; - rootPrefabEntity.GetComponent().parent = entt::null; + Entity rootPrefabEntity = m_prefabScene->GetEntityFromUUID(m_rootEntityId); + rootPrefabEntity.GetComponent().parent = Entity::NullID(); rootPrefabEntity.SetPosition({ 0.f }); rootPrefabEntity.SetRotation(glm::identity()); @@ -247,8 +250,8 @@ namespace Volt void Prefab::AddEntityToPrefabRecursive(Entity srcEntity, Entity parentPrefabEntity) { - entt::entity newEntityId = srcEntity.GetID(); - auto newEntity = m_prefabScene->CreateEntity("", newEntityId); + EntityID newEntityId = srcEntity.GetID(); + auto newEntity = m_prefabScene->CreateEntityWithUUID(newEntityId); // If this entity already has a prefab component, it probably is another prefab. Add it as a reference if (srcEntity.HasComponent()) @@ -290,12 +293,12 @@ namespace Volt void Prefab::ValidatePrefabUpdate(Entity srcEntity) { - std::vector entitiesToRemove; + std::vector entitiesToRemove; std::vector srcHeirarchy = FlattenEntityHeirarchy(srcEntity); - Entity srcPrefabEntity{ srcEntity.GetComponent().prefabEntity, m_prefabScene }; + Entity srcPrefabEntity = m_prefabScene->GetEntityFromUUID(srcEntity.GetComponent().prefabEntity); - m_prefabScene->ForEachWithComponents([&](const entt::entity id, const PrefabComponent& prefabComp) + m_prefabScene->ForEachWithComponents([&](const entt::entity id, const PrefabComponent& prefabComp, const IDComponent& idComponent) { bool exists = false; @@ -306,7 +309,7 @@ namespace Volt for (const auto& srcEnt : srcHeirarchy) { - if (id == srcEnt.GetComponent().prefabEntity) + if (idComponent.id == srcEnt.GetComponent().prefabEntity) { exists = true; break; @@ -315,7 +318,7 @@ namespace Volt if (!exists) { - entitiesToRemove.emplace_back(id); + entitiesToRemove.emplace_back(idComponent.id); } }); @@ -327,17 +330,17 @@ namespace Volt m_prefabReferencesMap.erase(id); } - auto entity = Entity{ id, m_prefabScene }; + auto entity = m_prefabScene->GetEntityFromUUID(id); if (!entity) { continue; } - m_prefabScene->RemoveEntity(Entity{ id, m_prefabScene }); + m_prefabScene->RemoveEntity(entity); } } - const bool Prefab::UpdateEntityInPrefabInternal(Entity srcEntity, entt::entity sceneRootId, entt::entity forcedPrefabEntity) + const bool Prefab::UpdateEntityInPrefabInternal(Entity srcEntity, EntityID sceneRootId, EntityID forcedPrefabEntity) { bool shouldAddEntity = !srcEntity.HasComponent(); if (!shouldAddEntity) @@ -358,7 +361,7 @@ namespace Volt } // Make sure we are not updating from another prefab - if (srcEntity.GetComponent().prefabAsset != handle && forcedPrefabEntity == entt::null) + if (srcEntity.GetComponent().prefabAsset != handle && forcedPrefabEntity == Entity::NullID()) { shouldAddEntity = true; } @@ -370,7 +373,7 @@ namespace Volt if (srcEntity.HasParent() && srcEntity.GetParent().HasComponent()) { - prefabParent = { srcEntity.GetParent().GetComponent().prefabEntity, m_prefabScene }; + prefabParent = m_prefabScene->GetEntityFromUUID(srcEntity.GetParent().GetComponent().prefabEntity); } AddEntityToPrefabRecursive(srcEntity, prefabParent); @@ -383,8 +386,8 @@ namespace Volt return false; } - const entt::entity prefabEntityId = forcedPrefabEntity != entt::null ? forcedPrefabEntity : srcPrefabComp.prefabEntity; - Entity targetEntity{ prefabEntityId, m_prefabScene }; + const EntityID prefabEntityId = forcedPrefabEntity != Entity::NullID() ? forcedPrefabEntity : srcPrefabComp.prefabEntity; + Entity targetEntity = m_prefabScene->GetEntityFromUUID(prefabEntityId); if (!targetEntity) { VT_CORE_WARN("[Prefab]: Trying to update an invalid entity in prefab!"); @@ -403,13 +406,13 @@ namespace Volt for (const auto& srcChild : srcEntity.GetChildren()) { - UpdateEntityInPrefabInternal(srcChild, sceneRootId, entt::null); + UpdateEntityInPrefabInternal(srcChild, sceneRootId, Entity::NullID()); } return true; } - void Prefab::UpdateEntityInSceneInternal(Entity sceneEntity, entt::entity forcedPrefabEntity) + void Prefab::UpdateEntityInSceneInternal(Entity sceneEntity, EntityID forcedPrefabEntity) { if (!sceneEntity.HasComponent()) { @@ -417,7 +420,7 @@ namespace Volt } const auto& scenePrefabComp = sceneEntity.GetComponent(); - const entt::entity prefabEntityId = forcedPrefabEntity != entt::null ? forcedPrefabEntity : scenePrefabComp.prefabEntity; + const EntityID prefabEntityId = forcedPrefabEntity != Entity::NullID() ? forcedPrefabEntity : scenePrefabComp.prefabEntity; if (m_prefabReferencesMap.contains(prefabEntityId)) { @@ -427,7 +430,7 @@ namespace Volt return; } - Entity prefabEntity{ prefabEntityId, m_prefabScene }; + Entity prefabEntity = m_prefabScene->GetEntityFromUUID(prefabEntityId); if (!prefabEntity) { sceneEntity.GetScene()->RemoveEntity(sceneEntity); @@ -489,15 +492,13 @@ namespace Volt Entity Prefab::InstantiateEntity(Weak targetScene, Entity prefabEntity) { - auto targetScenePtr = targetScene.lock(); - - Entity newEntity = Entity::Duplicate(Entity{ prefabEntity.GetID(), m_prefabScene }, targetScenePtr); - if (targetScenePtr->IsPlaying()) + Entity newEntity = Entity::Duplicate(prefabEntity, targetScene); + if (targetScene->IsPlaying()) { InitializeComponents(newEntity); } - targetScenePtr->InvalidateEntityTransform(newEntity.GetID()); + targetScene->InvalidateEntityTransform(newEntity.GetID()); return newEntity; } @@ -520,7 +521,7 @@ namespace Volt return result; } - Prefab::Prefab(Ref prefabScene, entt::entity rootEntityId, uint32_t version) + Prefab::Prefab(Ref prefabScene, EntityID rootEntityId, uint32_t version) : m_prefabScene(prefabScene), m_rootEntityId(rootEntityId), m_version(version) { } diff --git a/Volt/Volt/src/Volt/Asset/Prefab.h b/Volt/Volt/src/Volt/Asset/Prefab.h index 8703d6161..93597b93e 100644 --- a/Volt/Volt/src/Volt/Asset/Prefab.h +++ b/Volt/Volt/src/Volt/Asset/Prefab.h @@ -4,8 +4,6 @@ #include "Volt/Scene/Entity.h" -#include - namespace Volt { class Scene; @@ -16,12 +14,12 @@ namespace Volt struct PrefabReferenceData { AssetHandle prefabAsset; - entt::entity prefabReferenceEntity; + EntityID prefabReferenceEntity; }; Prefab() = default; Prefab(Entity srcRootEntity); - Prefab(Ref prefabScene, entt::entity rootEntityId, uint32_t version); + Prefab(Ref prefabScene, EntityID rootEntityId, uint32_t version); ~Prefab() override = default; @@ -29,11 +27,11 @@ namespace Volt const bool UpdateEntityInPrefab(Entity srcEntity); void UpdateEntityInScene(Entity sceneEntity); - void CopyPrefabEntity(Entity dstEntity, entt::entity srcPrefabEntityId, const EntityCopyFlags copyFlags = EntityCopyFlags::SkipRelationships) const; + void CopyPrefabEntity(Entity dstEntity, EntityID srcPrefabEntityId, const EntityCopyFlags copyFlags = EntityCopyFlags::SkipRelationships) const; - [[nodiscard]] inline const bool IsPrefabValid() { return m_prefabScene != nullptr && m_rootEntityId != entt::null; } + [[nodiscard]] inline const bool IsPrefabValid() { return m_prefabScene != nullptr && m_rootEntityId != Entity::NullID(); } [[nodiscard]] const bool IsEntityValidInPrefab(Entity entity) const; - [[nodiscard]] const bool IsEntityValidInPrefab(entt::entity prefabEntityId) const; + [[nodiscard]] const bool IsEntityValidInPrefab(EntityID prefabEntityId) const; [[nodiscard]] const bool IsEntityRoot(Entity entity) const; [[nodiscard]] const bool IsReference(Entity entity) const; @@ -45,22 +43,24 @@ namespace Volt private: friend class PrefabImporter; + [[nodiscard]] const Entity GetRootEntity() const; + void InitializeComponents(Entity entity); void CreatePrefab(Entity srcRootEntity); void AddEntityToPrefabRecursive(Entity entity, Entity parentPrefabEntity); void ValidatePrefabUpdate(Entity srcEntity); - const bool UpdateEntityInPrefabInternal(Entity srcEntity, entt::entity rootSceneId, entt::entity forcedPrefabEntity); - void UpdateEntityInSceneInternal(Entity sceneEntity, entt::entity forcedPrefabEntity); + const bool UpdateEntityInPrefabInternal(Entity srcEntity, EntityID rootSceneId, EntityID forcedPrefabEntity); + void UpdateEntityInSceneInternal(Entity sceneEntity, EntityID forcedPrefabEntity); Entity InstantiateEntity(Weak targetScene, Entity prefabEntity); const std::vector FlattenEntityHeirarchy(Entity entity); Ref m_prefabScene; - std::unordered_map m_prefabReferencesMap; // Maps this prefabs entity to an entity in another prefab + std::unordered_map m_prefabReferencesMap; // Maps this prefabs entity to an entity in another prefab - entt::entity m_rootEntityId = entt::null; + EntityID m_rootEntityId = Entity::NullID(); uint32_t m_version = 0; }; } diff --git a/Volt/Volt/src/Volt/Asset/TimelinePreset.h b/Volt/Volt/src/Volt/Asset/TimelinePreset.h index 5ae0d06d5..a8a003885 100644 --- a/Volt/Volt/src/Volt/Asset/TimelinePreset.h +++ b/Volt/Volt/src/Volt/Asset/TimelinePreset.h @@ -1,7 +1,7 @@ #pragma once -#include "Volt/Asset/Asset.h" -#include +#include "Volt/Asset/Asset.h" +#include "Volt/Scene/EntityID.h" namespace Volt { @@ -45,7 +45,7 @@ namespace Volt float startTime = 0.f; float endTime = 0.f; - entt::entity activeCamera = entt::null; + EntityID activeCamera = EntityID(0); }; struct Track @@ -55,7 +55,7 @@ namespace Volt TrackType trackType = TrackType::T_Animation; - entt::entity targetEntity = entt::null; + EntityID targetEntity = EntityID(0); std::vector keyframes = std::vector(); std::vector clips = std::vector(); diff --git a/Volt/Volt/src/Volt/Components/AudioComponents.h b/Volt/Volt/src/Volt/Components/AudioComponents.h index b0a3ca2fb..2af1498e5 100644 --- a/Volt/Volt/src/Volt/Components/AudioComponents.h +++ b/Volt/Volt/src/Volt/Components/AudioComponents.h @@ -48,14 +48,12 @@ namespace Volt { void OnCreate(entt::entity entityID) { - m_id = entityID; - Amp::WwiseAudioManager::CreateAudioObject(static_cast(m_id), "SpawnedObj"); + Amp::WwiseAudioManager::CreateAudioObject(static_cast(entityID), "SpawnedObj"); } void OnStart(Volt::Entity entity) { - m_id = entity.GetID(); - Amp::WwiseAudioManager::CreateAudioObject(static_cast(m_id), entity.GetTag().c_str()); + Amp::WwiseAudioManager::CreateAudioObject(entity, entity.GetTag().c_str()); } bool PlayOneshotEvent(const char* aEventName, const glm::vec3& aPosition, const glm::vec3& aForward, const glm::vec3& aUp) diff --git a/Volt/Volt/src/Volt/Components/CoreComponents.h b/Volt/Volt/src/Volt/Components/CoreComponents.h index 98d2f4be5..892200f1f 100644 --- a/Volt/Volt/src/Volt/Components/CoreComponents.h +++ b/Volt/Volt/src/Volt/Components/CoreComponents.h @@ -44,6 +44,19 @@ namespace Volt REGISTER_COMPONENT(TagComponent); }; + struct IDComponent + { + EntityID id{}; + + static void ReflectType(TypeDesc& reflect) + { + reflect.SetGUID("{663E0E0B-43EC-4973-8A9B-FF8A0BA566AA}"_guid); + reflect.SetLabel("ID Component"); + reflect.SetHidden(); + reflect.AddMember(&IDComponent::id, "id", "ID", "", EntityID{}, ComponentMemberFlag::NoSerialize); + } + }; + struct TransformComponent { glm::vec3 position = { 0.f }; @@ -91,16 +104,16 @@ namespace Volt struct RelationshipComponent { - entt::entity parent = entt::null; - std::vector children; + EntityID parent = EntityID(0); + std::vector children; static void ReflectType(TypeDesc& reflect) { reflect.SetGUID("{4A5FEDD2-4D0B-4696-A9E6-DCDFFB25B32C}"_guid); reflect.SetLabel("Relationship Component"); reflect.SetHidden(); - reflect.AddMember(&RelationshipComponent::parent, "parent", "Parent", "", entt::null); - reflect.AddMember(&RelationshipComponent::children, "children", "Children", "", std::vector{}); + reflect.AddMember(&RelationshipComponent::parent, "parent", "Parent", "", EntityID(0)); + reflect.AddMember(&RelationshipComponent::children, "children", "Children", "", std::vector{}); } REGISTER_COMPONENT(RelationshipComponent); @@ -137,8 +150,8 @@ namespace Volt struct PrefabComponent { AssetHandle prefabAsset = Asset::Null(); - entt::entity prefabEntity = entt::null; - entt::entity sceneRootEntity = entt::null; + EntityID prefabEntity = EntityID(0); + EntityID sceneRootEntity = EntityID(0); uint32_t version = 0; std::vector componentLocalChanges; @@ -152,8 +165,8 @@ namespace Volt reflect.SetLabel("Prefab Component"); reflect.SetHidden(); reflect.AddMember(&PrefabComponent::prefabAsset, "prefabAsset", "Prefab Asset", "", Asset::Null(), AssetType::Prefab); - reflect.AddMember(&PrefabComponent::prefabEntity, "prefabEntity", "Prefab Entity", "", entt::null); - reflect.AddMember(&PrefabComponent::sceneRootEntity, "sceneRootEntity", "Scene Root Entity", "", entt::null); + reflect.AddMember(&PrefabComponent::prefabEntity, "prefabEntity", "Prefab Entity", "", EntityID(0)); + reflect.AddMember(&PrefabComponent::sceneRootEntity, "sceneRootEntity", "Scene Root Entity", "", EntityID(0)); reflect.AddMember(&PrefabComponent::version, "version", "Version", "", 0); reflect.AddMember(&PrefabComponent::componentLocalChanges, "componentLocalChanges", "Component Local Changes", "", std::vector{}); reflect.AddMember(&PrefabComponent::scriptLocalChanges, "scriptLocalChanges", "Script Local Changes", "", std::vector{}); diff --git a/Volt/Volt/src/Volt/Core/Base.h b/Volt/Volt/src/Volt/Core/Base.h index c9304d156..929fa54be 100644 --- a/Volt/Volt/src/Volt/Core/Base.h +++ b/Volt/Volt/src/Volt/Core/Base.h @@ -1,5 +1,7 @@ #pragma once +#include "Volt/Core/Weak.h" + #include #include #include @@ -97,7 +99,3 @@ constexpr Ref CreateRef(Args&& ... args) { return std::make_shared(std::forward(args)...); } - -template -using Weak = std::weak_ptr; - diff --git a/Volt/Volt/src/Volt/Core/Graphics/GraphicsDevice.cpp b/Volt/Volt/src/Volt/Core/Graphics/GraphicsDevice.cpp index 35f3e592a..561ea1142 100644 --- a/Volt/Volt/src/Volt/Core/Graphics/GraphicsDevice.cpp +++ b/Volt/Volt/src/Volt/Core/Graphics/GraphicsDevice.cpp @@ -171,11 +171,11 @@ namespace Volt } GraphicsDevice::GraphicsDevice(const GraphicsDeviceInfo& info) - : myQueueFamilies(info.physicalDevice.lock()->GetQueueFamilies()) + : myQueueFamilies(info.physicalDevice->GetQueueFamilies()) { myPhysicalDevice = info.physicalDevice; - auto physicalDevicePtr = info.physicalDevice.lock(); + auto physicalDevicePtr = info.physicalDevice; const auto& capabilities = physicalDevicePtr->GetCapabilities(); std::vector deviceQueueInfos{}; @@ -248,7 +248,7 @@ namespace Volt enabledExtensions.push_back(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME); #endif - if (myPhysicalDevice.lock()->GetCapabilities().supportsRayTracing) + if (myPhysicalDevice->GetCapabilities().supportsRayTracing) { EnableRayTracing(enabledExtensions); myRayTracingFeatures.rayTracingPipelineFeature.pNext = &tempFeatures; @@ -482,14 +482,14 @@ namespace Volt VkCommandBuffer GraphicsDevice::GetSingleUseCommandBuffer(bool beginCommandBuffer, QueueType queueType) { - if (myPhysicalDevice.expired()) + if (!myPhysicalDevice) { return nullptr; } std::scoped_lock lock{ myCommandBufferDataMutex }; - auto physDevicePtr = myPhysicalDevice.lock(); + auto physDevicePtr = myPhysicalDevice; const auto threadId = std::this_thread::get_id(); diff --git a/Volt/Volt/src/Volt/Core/Graphics/VulkanAllocator.cpp b/Volt/Volt/src/Volt/Core/Graphics/VulkanAllocator.cpp index 3a307adac..6a0e50d77 100644 --- a/Volt/Volt/src/Volt/Core/Graphics/VulkanAllocator.cpp +++ b/Volt/Volt/src/Volt/Core/Graphics/VulkanAllocator.cpp @@ -227,7 +227,7 @@ namespace Volt { s_allocatorData = new VulkanAllocatorData(); - auto physDevicePtr = graphicsDevice->GetPhysicalDevice().lock(); + auto physDevicePtr = graphicsDevice->GetPhysicalDevice(); VmaAllocatorCreateInfo info{}; info.vulkanApiVersion = VK_API_VERSION_1_3; diff --git a/Volt/Volt/src/Volt/Core/UUID.cpp b/Volt/Volt/src/Volt/Core/UUID.cpp index 532f6d27f..7d4067bc9 100644 --- a/Volt/Volt/src/Volt/Core/UUID.cpp +++ b/Volt/Volt/src/Volt/Core/UUID.cpp @@ -8,15 +8,17 @@ namespace Volt { static std::random_device s_RandomDevice; static std::mt19937_64 s_Engine(s_RandomDevice()); + static std::mt19937 s_Engine32(s_RandomDevice()); static std::uniform_int_distribution s_UniformDistribution; + static std::uniform_int_distribution s_UniformDistribution32; UUID::UUID() : myUUID(s_UniformDistribution(s_Engine)) { } - UUID::UUID(uint64_t uuid) - : myUUID(uuid) + UUID32::UUID32() + : myUUID(s_UniformDistribution32(s_Engine32)) { } -} \ No newline at end of file +} diff --git a/Volt/Volt/src/Volt/Core/UUID.h b/Volt/Volt/src/Volt/Core/UUID.h index d4fca611f..dd3c8658c 100644 --- a/Volt/Volt/src/Volt/Core/UUID.h +++ b/Volt/Volt/src/Volt/Core/UUID.h @@ -4,11 +4,14 @@ namespace Volt { + class UUID { public: UUID(); - UUID(uint64_t uuid); + constexpr UUID(uint64_t uuid) + : myUUID(uuid) + {} UUID(const UUID&) = default; ~UUID() = default; @@ -17,6 +20,22 @@ namespace Volt private: uint64_t myUUID; }; + + class UUID32 + { + public: + UUID32(); + constexpr UUID32(uint32_t uuid) + : myUUID(uuid) + {} + + UUID32(const UUID32&) = default; + ~UUID32() = default; + + operator uint32_t() const { return myUUID; } + private: + uint32_t myUUID; + }; } namespace std @@ -31,4 +50,13 @@ namespace std return (uint64_t)uuid; } }; -} \ No newline at end of file + + template<> + struct hash + { + std::size_t operator()(const Volt::UUID32& uuid) const + { + return (uint32_t)uuid; + } + }; +} diff --git a/Volt/Volt/src/Volt/Core/Weak.h b/Volt/Volt/src/Volt/Core/Weak.h new file mode 100644 index 000000000..00fd52b3d --- /dev/null +++ b/Volt/Volt/src/Volt/Core/Weak.h @@ -0,0 +1,175 @@ +#pragma once + +#include + +template +class Weak +{ +public: + Weak() = default; + Weak(std::shared_ptr sharedPtr); + Weak(std::weak_ptr weakPtr); + + template + Weak(std::weak_ptr weakPtr); + + template + Weak(std::shared_ptr sharedPtr); + + T* operator->(); + T& operator*(); + + T* operator->() const; + T& operator*() const; + + [[nodiscard]] T* Get(); + [[nodiscard]] const T* Get() const; + void Reset(); + + inline const size_t GetHash() const + { + return std::hash()(m_weakPtr.lock().get()); + } + + template + [[nodiscard]] Weak As(); + + Weak& operator=(const Weak& other); + + template + Weak& operator=(const Weak& other); + + bool operator==(const Weak& rhs) const; + + template + bool operator==(const Weak& rhs) const; + + inline operator bool() const { return !m_weakPtr.expired(); } + inline operator std::shared_ptr() const { return m_weakPtr.lock(); } + + [[nodiscard]] inline std::shared_ptr GetSharedPtr() const { return m_weakPtr.lock(); } + +private: + std::weak_ptr m_weakPtr; +}; + +template +inline Weak::Weak(std::shared_ptr sharedPtr) + : m_weakPtr(sharedPtr) +{ +} + +template +inline Weak::Weak(std::weak_ptr weakPtr) + : m_weakPtr(weakPtr) +{ +} + +template +template +inline Weak::Weak(std::shared_ptr sharedPtr) + : m_weakPtr(std::reinterpret_pointer_cast(sharedPtr)) +{ +} + +template +template +inline Weak Weak::As() +{ + Weak weak{}; + weak.m_weakPtr = std::reinterpret_pointer_cast(m_weakPtr.lock()); + + return weak; +} + +template +template +inline Weak::Weak(std::weak_ptr weakPtr) + : m_weakPtr(std::reinterpret_pointer_cast(weakPtr.lock())) +{ +} + +template +inline T* Weak::operator->() +{ + return m_weakPtr.lock().get(); +} + +template +inline T& Weak::operator*() +{ + return *m_weakPtr.lock(); +} + +template +inline T* Weak::operator->() const +{ + return m_weakPtr.lock().get(); +} + +template +inline T& Weak::operator*() const +{ + return *m_weakPtr.lock(); +} + +template +inline const T* Weak::Get() const +{ + return m_weakPtr.lock().get(); +} + +template +inline T* Weak::Get() +{ + return m_weakPtr.lock().get(); +} + +template +inline void Weak::Reset() +{ + m_weakPtr.reset(); +} + +template +inline Weak& Weak::operator=(const Weak& other) +{ + m_weakPtr = other.m_weakPtr; + return *this; +} + +template +inline bool Weak::operator==(const Weak& rhs) const +{ + return m_weakPtr.lock().get() == rhs.m_weakPtr.lock().get(); +} + +template +template +inline bool Weak::operator==(const Weak& rhs) const +{ + return Get() == rhs.Get(); +} + + +template +template +inline Weak& Weak::operator=(const Weak& other) +{ + m_weakPtr = std::reinterpret_pointer_cast(other.GetSharedPtr()); + return *this; +} + +namespace std +{ + template struct hash; + + template + struct hash> + { + std::size_t operator()(const Weak ptr) const + { + return std::hash()(ptr.Get()); + } + }; +} diff --git a/Volt/Volt/src/Volt/Net/Client/NetClient.cpp b/Volt/Volt/src/Volt/Net/Client/NetClient.cpp index 9df1c85cf..0e5883f41 100644 --- a/Volt/Volt/src/Volt/Net/Client/NetClient.cpp +++ b/Volt/Volt/src/Volt/Net/Client/NetClient.cpp @@ -54,7 +54,7 @@ namespace Volt { auto ptr = m_registry.Get(repId); auto repEntity = *reinterpret_pointer_cast(ptr); - auto entity = Entity(repEntity.GetEntityId(), SceneManager::GetActiveScene().lock().get()); + auto entity = SceneManager::GetActiveScene()->GetEntityFromUUID(repEntity.GetEntityId()); if (!entity.IsValid()) continue; if (repEntity.GetOwner() != m_id) continue; @@ -132,7 +132,7 @@ namespace Volt if (m_registry.Get(repId)->GetType() == Nexus::TYPE::eReplicatedType::ENTITY) { auto ent = reinterpret_cast(m_registry.Get(repId).get())->GetEntityId(); - Volt::SceneManager::GetActiveScene().lock()->RemoveEntity(Entity(ent, SceneManager::GetActiveScene().lock().get())); + Volt::SceneManager::GetActiveScene()->RemoveEntity(Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(ent)); } m_registry.Unregister(repId); } @@ -204,9 +204,8 @@ namespace Volt m_registry.Unregister(repId); auto scene = SceneManager::GetActiveScene(); - auto scenePtr = scene.lock(); - scenePtr->RemoveEntity(Entity(repEnt->GetEntityId(), scenePtr.get())); + scene->RemoveEntity(scene->GetEntityFromUUID(repEnt->GetEntityId())); // find Entity // find connected variables @@ -251,7 +250,7 @@ namespace Volt return; } - auto sceneEnt = Entity(netEnt->GetEntityId(), SceneManager::GetActiveScene().lock().get()); + auto sceneEnt = SceneManager::GetActiveScene()->GetEntityFromUUID(netEnt->GetEntityId()); if (!sceneEnt.IsValid()) { VT_CORE_ERROR("scene entity is null in client RPC call"); @@ -270,7 +269,7 @@ namespace Volt VT_CORE_ERROR("missing monoscriptComponent in client RPC call"); return; } - auto scriptsVector = Entity(sceneEnt.GetID(), SceneManager::GetActiveScene().lock().get()).GetComponent().scriptIds; + auto scriptsVector = sceneEnt.GetComponent().scriptIds; Ref scrInstance = nullptr; for (auto scrID : scriptsVector) { diff --git a/Volt/Volt/src/Volt/Net/NetHandler.cpp b/Volt/Volt/src/Volt/Net/NetHandler.cpp index 3bc1a0f46..a9dd750f5 100644 --- a/Volt/Volt/src/Volt/Net/NetHandler.cpp +++ b/Volt/Volt/src/Volt/Net/NetHandler.cpp @@ -129,12 +129,11 @@ namespace Volt if (in_event.GetEventType() == Volt::EventType::OnSceneLoaded) { m_backend->m_registry.Clear(); - for (auto entId : SceneManager::GetActiveScene().lock().get()->GetAllEntitiesWith()) + for (auto sceneEnt : SceneManager::GetActiveScene()->GetAllEntitiesWith()) { - auto sceneEnt = Entity(entId, SceneManager::GetActiveScene().lock().get()); auto netComp = sceneEnt.GetComponent(); auto prefabComp = sceneEnt.GetComponent(); - auto repEnt = Volt::RepEntity(entId, netComp.clientId, prefabComp.prefabAsset, true); + auto repEnt = Volt::RepEntity(sceneEnt.GetID(), netComp.clientId, prefabComp.prefabAsset, true); // #nexus_todo: fix components to be hosted by host m_backend->GetRegistry().Register((Nexus::TYPE::REP_ID)netComp.repId, repEnt); diff --git a/Volt/Volt/src/Volt/Net/Replicated/RepEntity.h b/Volt/Volt/src/Volt/Net/Replicated/RepEntity.h index 28f8a60ed..dd59c76f2 100644 --- a/Volt/Volt/src/Volt/Net/Replicated/RepEntity.h +++ b/Volt/Volt/src/Volt/Net/Replicated/RepEntity.h @@ -7,17 +7,17 @@ namespace Volt class RepEntity : public Nexus::Replicated { public: - RepEntity(entt::entity in_entityId, Nexus::TYPE::CLIENT_ID in_ownerId, Volt::AssetHandle in_handle, bool preplaced = false) + RepEntity(Volt::EntityID in_entityId, Nexus::TYPE::CLIENT_ID in_ownerId, Volt::AssetHandle in_handle, bool preplaced = false) : Replicated(Nexus::TYPE::eReplicatedType::ENTITY, in_ownerId), m_entityId(in_entityId), m_prefabHandle(in_handle), m_preplaced(preplaced) { } - const entt::entity GetEntityId() const { return m_entityId; } + const Volt::EntityID GetEntityId() const { return m_entityId; } const Volt::AssetHandle GetHandle() const { return m_prefabHandle; } const bool GetPreplaced() const { return m_preplaced; } private: const Volt::AssetHandle m_prefabHandle; - const entt::entity m_entityId; + const Volt::EntityID m_entityId; const bool m_preplaced = false; }; } diff --git a/Volt/Volt/src/Volt/Net/Replicated/RepVariable.h b/Volt/Volt/src/Volt/Net/Replicated/RepVariable.h index ddad26cf2..6afe6ec03 100644 --- a/Volt/Volt/src/Volt/Net/Replicated/RepVariable.h +++ b/Volt/Volt/src/Volt/Net/Replicated/RepVariable.h @@ -19,7 +19,7 @@ namespace Volt class RepVariable : public Nexus::Replicated { public: - RepVariable(const std::string& in_variableName, Nexus::TYPE::REP_ID in_repOwner, Nexus::TYPE::CLIENT_ID in_ownerId, Ref in_scriptInstance, MonoScriptField in_field, entt::entity in_entityId) + RepVariable(const std::string& in_variableName, Nexus::TYPE::REP_ID in_repOwner, Nexus::TYPE::CLIENT_ID in_ownerId, Ref in_scriptInstance, MonoScriptField in_field, Volt::EntityID in_entityId) : Replicated(Nexus::TYPE::eReplicatedType::VARIABLE, in_ownerId) , m_varName(in_variableName) , m_repOwner(in_repOwner) @@ -27,7 +27,7 @@ namespace Volt , m_field(in_field) , m_entityId(in_entityId) { - //auto monoClass = m_scriptInstance.lock()->GetClass(); + //auto monoClass = m_scriptInstance->GetClass(); //MonoScriptEngine::NetFieldSetup(monoClass.get(), m_field); } @@ -46,22 +46,22 @@ namespace Volt MonoScriptField m_field; const std::string m_varName; const Nexus::TYPE::REP_ID m_repOwner; - const entt::entity m_entityId; + const Volt::EntityID m_entityId; bool m_changed = false; }; inline bool RepVariable::SetValue(void* data) { // #nexus_todo: need to failsafe data type with typeid - if (m_scriptInstance.expired()) return false; - m_scriptInstance.lock()->SetField(m_varName, data); + if (!m_scriptInstance) return false; + m_scriptInstance->SetField(m_varName, data); m_changed = true; // call bound method if (m_field.netData.boundFunction == "") return true; - auto monoClass = m_scriptInstance.lock()->GetClass(); + auto monoClass = m_scriptInstance->GetClass(); std::string boundFunction = (monoClass->GetNamespace() + "." + monoClass->GetClassName() + "." + m_field.netData.boundFunction); - CallMonoMethod(Entity(m_entityId, SceneManager::GetActiveScene().lock().get()), boundFunction, std::vector()); + CallMonoMethod(SceneManager::GetActiveScene()->GetEntityFromUUID(m_entityId), boundFunction, std::vector()); return true; } @@ -69,8 +69,8 @@ namespace Volt template inline bool RepVariable::GetValue(T& data) { - if (m_scriptInstance.expired()) return false; - data = m_scriptInstance.lock()->GetField(m_varName); + if (!m_scriptInstance) return false; + data = m_scriptInstance->GetField(m_varName); return true; } } diff --git a/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.cpp b/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.cpp index e18bd6e0c..51e5f7011 100644 --- a/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.cpp +++ b/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.cpp @@ -18,9 +18,9 @@ namespace Volt { - void NetContractContainer::Execute(entt::entity in_id, eNetEvent in_method, const std::vector& in_data) + void NetContractContainer::Execute(Volt::EntityID in_id, eNetEvent in_method, const std::vector& in_data) { - auto entity = Entity(in_id, SceneManager::GetActiveScene().lock().get()); + auto entity = SceneManager::GetActiveScene()->GetEntityFromUUID(in_id); if (!entity.HasComponent()) { VT_CORE_ERROR("Entity is not prefab in NetContractContainer::Execute"); @@ -59,30 +59,30 @@ namespace Volt const Ref NetContractContainer::GetContract(Nexus::TYPE::REP_ID in_id) { - auto* backend = Volt::Application::Get().GetNetHandler().GetBackend().get(); + auto backend = Volt::Application::Get().GetNetHandler().GetBackend().get(); if (!backend) return m_contracts[AssetHandle(0)]; auto sceneId = backend->GetRegistry().GetAs(in_id); if (!sceneId) return m_contracts[AssetHandle(0)]; return GetContract(sceneId->GetHandle()); } - const Ref NetContractContainer::GetContract(entt::entity in_id) + const Ref NetContractContainer::GetContract(Volt::EntityID in_id) { - auto entity = Entity(in_id, SceneManager::GetActiveScene().lock().get()); + auto entity = SceneManager::GetActiveScene()->GetEntityFromUUID(in_id); if (!entity.HasComponent()) return m_contracts[AssetHandle(0)]; return GetContract(entity.GetComponent().prefabAsset); } - std::string NetContractContainer::GetMethod(entt::entity in_id, eNetEvent in_event) + std::string NetContractContainer::GetMethod(Volt::EntityID in_id, eNetEvent in_event) { - auto entity = Entity(in_id, SceneManager::GetActiveScene().lock().get()); + auto entity = SceneManager::GetActiveScene()->GetEntityFromUUID(in_id); if (!entity.HasComponent()) return ""; return GetMethod(entity.GetComponent().prefabAsset, in_event); } std::string NetContractContainer::GetMethod(Nexus::TYPE::REP_ID in_id, eNetEvent in_event) { - auto entity = Entity(static_cast(in_id), SceneManager::GetActiveScene()); + auto entity = SceneManager::GetActiveScene()->GetEntityFromUUID(static_cast(in_id)); if (!entity.HasComponent()) return ""; return GetMethod(entity.GetComponent().prefabAsset, in_event); } @@ -103,7 +103,7 @@ namespace Volt { return m_contracts.contains(in_handle); } - bool NetContractContainer::RuleExists(const AssetHandle& in_handle, const std::string& in_rule, entt::entity in_ent) + bool NetContractContainer::RuleExists(const AssetHandle& in_handle, const std::string& in_rule, Volt::EntityID in_ent) { if (!m_contracts.contains(in_handle)) return false; if (!m_contracts.at(in_handle)->rules.contains(in_ent)) return false; diff --git a/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.h b/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.h index 7c17d6eb1..43df25875 100644 --- a/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.h +++ b/Volt/Volt/src/Volt/Net/SceneInteraction/NetContract.h @@ -5,6 +5,7 @@ #include #include "Volt/Net/Event/NetEvent.h" +#include "Volt/Scene/EntityID.h" #include @@ -45,7 +46,7 @@ namespace Volt AssetHandle prefab = AssetHandle(0); std::unordered_map calls; - std::unordered_map> rules; + std::unordered_map> rules; static AssetType GetStaticType() { return AssetType::NetContract; } AssetType GetType() override { return GetStaticType(); } @@ -54,7 +55,7 @@ namespace Volt class NetContractContainer { public: - static void Execute(entt::entity in_id, eNetEvent in_method, const std::vector& in_data); + static void Execute(Volt::EntityID in_id, eNetEvent in_method, const std::vector& in_data); static void Execute(Nexus::TYPE::REP_ID in_id, eNetEvent in_method, const std::vector& in_data); static std::string GetMethod(const AssetHandle& in_handle, eNetEvent in_method); @@ -62,14 +63,14 @@ namespace Volt static Ref GetContract(const AssetHandle& in_handle); static const Ref GetContract(Nexus::TYPE::REP_ID in_id); - static const Ref GetContract(entt::entity in_id); + static const Ref GetContract(Volt::EntityID in_id); - static std::string GetMethod(entt::entity in_id, eNetEvent in_method); + static std::string GetMethod(Volt::EntityID in_id, eNetEvent in_method); static std::string GetMethod(Nexus::TYPE::REP_ID in_id, eNetEvent in_method); static void AddContract(const AssetHandle& in_handle); static bool ContractExists(const AssetHandle& in_handle); - static bool RuleExists(const AssetHandle& in_handle, const std::string& in_rule, entt::entity in_ent = entt::null); + static bool RuleExists(const AssetHandle& in_handle, const std::string& in_rule, Volt::EntityID = Volt::EntityID(0)); static void Load(); static void Clear(); diff --git a/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.cpp b/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.cpp index 1eeea0381..cd78f6294 100644 --- a/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.cpp +++ b/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.cpp @@ -91,7 +91,7 @@ bool ApplyComponentData(Ref in_data, Nexus::ReplicationRegisty& i auto netEnt = reinterpret_pointer_cast(in_registry.Get(in_data->repId)); if (!netEnt) { *out_error = Volt::eNetErrorCode::MISSING_NET_ENTITY; return false; } - auto sceneEnt = Volt::Entity(netEnt->GetEntityId(), Volt::SceneManager::GetActiveScene().lock().get()); + auto sceneEnt = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(netEnt->GetEntityId()); if (!sceneEnt.IsValid()) { *out_error = Volt::eNetErrorCode::MISSING_SCENE_ENTITY; return false; } if (sceneEnt.HasComponent()) @@ -310,9 +310,9 @@ Volt::RepVariableData::RepVariableData(const RepVariableData& in_data) #pragma endregion #pragma region Transform -Nexus::Packet SerializeTransformPacket(entt::entity in_entityId, Nexus::TYPE::REP_ID in_repId, int pos, int rot, int scale) +Nexus::Packet SerializeTransformPacket(Volt::EntityID in_entityId, Nexus::TYPE::REP_ID in_repId, int pos, int rot, int scale) { - Volt::Entity entity = Volt::Entity(in_entityId, Volt::SceneManager::GetActiveScene().lock().get()); + Volt::Entity entity = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(in_entityId); Volt::RepTransformComponentData entTransform; entTransform.repId = in_repId; entTransform.setPos = pos; @@ -451,10 +451,10 @@ Nexus::Packet& operator>(Nexus::Packet& packet, Volt::RepRPCData& rpcData) } #pragma endregion -void HandleScript(entt::entity in_id, const std::string& id, bool in_keep) +void HandleScript(Volt::EntityID in_id, const std::string& id, bool in_keep) { if (in_keep) return; - auto ent = Volt::Entity(in_id, Volt::SceneManager::GetActiveScene().lock().get()); + auto ent = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(in_id); auto& scriptComp = ent.GetComponent(); for (uint32_t i = 0; i < scriptComp.scriptIds.size(); ++i) @@ -469,21 +469,19 @@ void HandleScript(entt::entity in_id, const std::string& id, bool in_keep) } #pragma region Prefab -void HandleComponent(entt::entity in_id, const std::string& in_comp, bool in_keep) +void HandleComponent(Volt::EntityID in_id, const std::string& in_comp, bool in_keep) { if (in_keep) return; - auto scenePtr = Volt::SceneManager::GetActiveScene().lock(); - - auto ent = Volt::Entity(in_id, scenePtr.get()); + auto ent = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(in_id); //scenePtr->GetRegistry().RemoveComponent(Wire::ComponentRegistry::GetRegistryDataFromName(in_comp).guid, in_id); } -void RecursiveOwnerShipControll(entt::entity in_id, const Volt::RepPrefabData& data) +void RecursiveOwnerShipControll(Volt::EntityID in_id, const Volt::RepPrefabData& data) { //auto contract = Volt::NetContractContainer::GetContract(data.handle); - //auto scenePtr = Volt::SceneManager::GetActiveScene().lock(); + //auto scenePtr = Volt::SceneManager::GetActiveScene(); //auto ent = Volt::Entity(in_id, scenePtr.get()); //const auto prefabData = Volt::AssetManager::GetAsset(data.handle); @@ -530,9 +528,9 @@ void RecursiveOwnerShipControll(entt::entity in_id, const Volt::RepPrefabData& d } // #mmax: should be called on play :P -void RecursiveHandleMono(entt::entity entId, Nexus::TYPE::REP_ID owner, Nexus::TYPE::REP_ID& varId, Nexus::ReplicationRegisty* registry, bool manageInstances) +void RecursiveHandleMono(Volt::EntityID entId, Nexus::TYPE::REP_ID owner, Nexus::TYPE::REP_ID& varId, Nexus::ReplicationRegisty* registry, bool manageInstances) { - Volt::Entity entity = { entId, Volt::SceneManager::GetActiveScene() }; + Volt::Entity entity = Volt::SceneManager::GetActiveScene()->GetEntityFromUUID(entId); auto repEnt = registry->GetAs(owner); diff --git a/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.h b/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.h index 857c395fa..c63dbef4f 100644 --- a/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.h +++ b/Volt/Volt/src/Volt/Net/Serialization/NetSerialization.h @@ -135,7 +135,7 @@ bool ApplyComponentData(Ref in_data, Nexus::ReplicationRegisty& i #pragma region Transform Nexus::Packet& operator<(Nexus::Packet& packet, const Volt::RepTransformComponentData& transform); Nexus::Packet& operator>(Nexus::Packet& packet, Volt::RepTransformComponentData& transform); -Nexus::Packet SerializeTransformPacket(entt::entity in_entityId, Nexus::TYPE::REP_ID in_repId, int pos = 1, int rot = 1, int scale = 1); +Nexus::Packet SerializeTransformPacket(Volt::EntityID in_entityId, Nexus::TYPE::REP_ID in_repId, int pos = 1, int rot = 1, int scale = 1); Volt::RepTransformComponentData CreateTransformComponentData(Nexus::TYPE::REP_ID in_repId, const Volt::TransformComponent& component); #pragma endregion @@ -155,8 +155,8 @@ Nexus::Packet SerializeVariablePacket(Volt::RepVariable& variable, Nexus::TYPE:: #pragma region Prefab Nexus::Packet& operator<(Nexus::Packet& packet, const Volt::RepPrefabData& data); Nexus::Packet& operator>(Nexus::Packet& packet, Volt::RepPrefabData& data); -void RecursiveOwnerShipControll(entt::entity in_id, const Volt::RepPrefabData& data); -void RecursiveHandleMono(entt::entity entId, Nexus::TYPE::REP_ID owner, Nexus::TYPE::REP_ID& varId, Nexus::ReplicationRegisty* registry = nullptr, bool manageInstances = true); +void RecursiveOwnerShipControll(Volt::EntityID in_id, const Volt::RepPrefabData& data); +void RecursiveHandleMono(Volt::EntityID entId, Nexus::TYPE::REP_ID owner, Nexus::TYPE::REP_ID& varId, Nexus::ReplicationRegisty* registry = nullptr, bool manageInstances = true); bool ConstructPrefab(const Volt::RepPrefabData& data, Nexus::ReplicationRegisty& registry); Volt::RepPrefabData CreatePrefabData(Nexus::TYPE::REP_ID in_repId, Nexus::TYPE::CLIENT_ID in_ownerId, Volt::AssetHandle in_handle); #pragma endregion diff --git a/Volt/Volt/src/Volt/Net/Server/NetServer.cpp b/Volt/Volt/src/Volt/Net/Server/NetServer.cpp index c0dd62557..aa5ed694f 100644 --- a/Volt/Volt/src/Volt/Net/Server/NetServer.cpp +++ b/Volt/Volt/src/Volt/Net/Server/NetServer.cpp @@ -61,7 +61,7 @@ namespace Volt { auto ptr = m_registry.Get(repId); const auto& repEntity = *reinterpret_pointer_cast(ptr); - auto entity = Entity(repEntity.GetEntityId(), SceneManager::GetActiveScene().lock().get()); + auto entity = SceneManager::GetActiveScene()->GetEntityFromUUID(repEntity.GetEntityId()); if (!entity.IsValid()) continue; const auto& pawnComp = entity.GetComponent(); @@ -80,7 +80,7 @@ namespace Volt } if (m_reload) { - AssetHandle handle = SceneManager::GetActiveScene().lock()->handle; + AssetHandle handle = SceneManager::GetActiveScene()->handle; Nexus::Packet reloadPacket; reloadPacket.id = Nexus::ePacketID::RELOAD_CONFIRMED; reloadPacket << handle; @@ -112,7 +112,7 @@ namespace Volt void NetServer::Reload() { - AssetHandle handle = SceneManager::GetActiveScene().lock()->handle; + AssetHandle handle = SceneManager::GetActiveScene()->handle; Volt::OnSceneTransitionEvent loadEvent{ handle }; Volt::Application::Get().OnEvent(loadEvent); @@ -168,7 +168,7 @@ namespace Volt if (m_registry.Get(repId)->GetType() == Nexus::TYPE::eReplicatedType::ENTITY) { auto ent = reinterpret_cast(m_registry.Get(repId).get())->GetEntityId(); - Volt::SceneManager::GetActiveScene().lock()->RemoveEntity(Entity(ent, SceneManager::GetActiveScene().lock().get())); + Volt::SceneManager::GetActiveScene()->RemoveEntity(SceneManager::GetActiveScene()->GetEntityFromUUID(ent)); } m_registry.Unregister(repId); } @@ -200,7 +200,7 @@ namespace Volt { Nexus::Packet confirmedPacket; confirmedPacket.id = Nexus::ePacketID::RELOAD_CONFIRMED; - confirmedPacket << SceneManager::GetActiveScene().lock()->handle; + confirmedPacket << SceneManager::GetActiveScene()->handle; m_relay.Transmit(confirmedPacket, m_currentPacket.first); return; } @@ -245,9 +245,9 @@ namespace Volt m_registry.Unregister(repId); auto scene = SceneManager::GetActiveScene(); - auto scenePtr = scene.lock(); + auto scenePtr = scene; - scenePtr->RemoveEntity(Entity(repEnt->GetEntityId(), scenePtr.get())); + scenePtr->RemoveEntity(scenePtr->GetEntityFromUUID(repEnt->GetEntityId())); auto tPack = m_currentPacket.second; tPack.ownerID = 0; @@ -262,13 +262,13 @@ namespace Volt Nexus::TYPE::REP_ID registerEntityId = Nexus::RandRepID(); while (m_registry.IdExist(registerEntityId)) registerEntityId = Nexus::RandRepID(); - auto gameMode = SceneManager::GetActiveScene().lock()->GetAllEntitiesWith(); + auto gameMode = SceneManager::GetActiveScene()->GetAllEntitiesWith(); if (gameMode.size() != 1) { VT_CORE_CRITICAL("Something went wrong with GameModeComponent. Make sure there is only one in the scene"); return; } - auto gameModeEnt = Entity(gameMode[0], SceneManager::GetActiveScene().lock().get()); + auto gameModeEnt = gameMode[0]; auto gameModeComp = gameModeEnt.GetComponent(); //auto spawnPointEnt = Entity(gameModeEnt.spawnPoint, SceneManager::GetActiveScene().get()).GetComponent(); @@ -304,7 +304,7 @@ namespace Volt if (repEnt->GetHandle() == 0) continue; if (repEnt->GetPreplaced()) continue; - auto sceneEnt = Entity(repEnt->GetEntityId(), SceneManager::GetActiveScene().lock().get()); + auto sceneEnt = SceneManager::GetActiveScene()->GetEntityFromUUID(repEnt->GetEntityId()); Nexus::Packet syncPacket; syncPacket.id = Nexus::ePacketID::CREATE_ENTITY; syncPacket < CreateTransformComponentData(repId, sceneEnt.GetComponent()); @@ -386,13 +386,13 @@ namespace Volt void NetServer::CreateDebugEnemy() { - auto gameMode = SceneManager::GetActiveScene().lock()->GetAllEntitiesWith(); + auto gameMode = SceneManager::GetActiveScene()->GetAllEntitiesWith(); if (gameMode.size() != 1) { VT_CORE_CRITICAL("Something went wrong with GameModeComponent. Make sure there is only one in the scene"); return; } - auto handle = Entity(gameMode[0], SceneManager::GetActiveScene().lock().get()).GetComponent().enemy; + auto handle = gameMode[0].GetComponent().enemy; auto prefabData = CreatePrefabData(10, 0, handle); ConstructPrefab(prefabData, m_registry); diff --git a/Volt/Volt/src/Volt/Physics/PhysicsScene.h b/Volt/Volt/src/Volt/Physics/PhysicsScene.h index 667caadb6..4234b391f 100644 --- a/Volt/Volt/src/Volt/Physics/PhysicsScene.h +++ b/Volt/Volt/src/Volt/Physics/PhysicsScene.h @@ -13,7 +13,7 @@ namespace Volt struct RaycastHit { - entt::entity hitEntity; + EntityID hitEntity; glm::vec3 position; glm::vec3 normal; float distance; diff --git a/Volt/Volt/src/Volt/Rendering/CommandBuffer.cpp b/Volt/Volt/src/Volt/Rendering/CommandBuffer.cpp index dfaf76f0f..d9764a906 100644 --- a/Volt/Volt/src/Volt/Rendering/CommandBuffer.cpp +++ b/Volt/Volt/src/Volt/Rendering/CommandBuffer.cpp @@ -114,9 +114,9 @@ namespace Volt device->FlushCommandBuffer(info, mySubmitFences.at(index), myQueueType); } - else if (!myInheritedCommandBuffer.expired()) + else if (myInheritedCommandBuffer) { - auto cmdBufferPtr = myInheritedCommandBuffer.lock(); + auto cmdBufferPtr = myInheritedCommandBuffer; const uint32_t index = cmdBufferPtr->GetCurrentIndex(); auto currentCmdBuffer = myCommandBuffers.at(index); @@ -153,7 +153,7 @@ namespace Volt return index; } - auto inheritedCmdBufferPtr = myInheritedCommandBuffer.lock(); + auto inheritedCmdBufferPtr = myInheritedCommandBuffer; const uint32_t index = inheritedCmdBufferPtr->GetCurrentIndex(); return index; @@ -166,7 +166,7 @@ namespace Volt return myLastCommandPool; } - auto inheritedCmdBufferPtr = myInheritedCommandBuffer.lock(); + auto inheritedCmdBufferPtr = myInheritedCommandBuffer; const uint32_t index = inheritedCmdBufferPtr->GetLastIndex(); return index; @@ -185,7 +185,7 @@ namespace Volt if (myLevel == CommandBufferLevel::Secondary) { - auto inheritedCmdBufferPtr = myInheritedCommandBuffer.lock(); + auto inheritedCmdBufferPtr = myInheritedCommandBuffer; cmdBufferPtr = inheritedCmdBufferPtr.get(); } else @@ -214,7 +214,7 @@ namespace Volt //if (myLevel == CommandBufferLevel::Secondary) //{ - // auto inheritedCmdBufferPtr = myInheritedCommandBuffer.lock(); + // auto inheritedCmdBufferPtr = myInheritedCommandBuffer; // cmdBufferPtr = inheritedCmdBufferPtr.get(); //} //else @@ -395,39 +395,39 @@ namespace Volt void CommandBuffer::FetchTimestampResults() { - if (!myHasTimestampSupport || myLastAvailableTimestampQuery == 0) - { - return; - } + //if (!myHasTimestampSupport || myLastAvailableTimestampQuery == 0) + //{ + // return; + //} - auto device = GraphicsContext::GetDevice(); - const uint32_t index = mySwapchainTarget ? Application::Get().GetWindow().GetSwapchain().GetCurrentFrame() : myLastCommandPool; + //auto device = GraphicsContext::GetDevice(); + //const uint32_t index = mySwapchainTarget ? Application::Get().GetWindow().GetSwapchain().GetCurrentFrame() : myLastCommandPool; - vkGetQueryPoolResults(device->GetHandle(), myTimestampQueryPools.at(index), 0, myLastAvailableTimestampQuery, myLastAvailableTimestampQuery * sizeof(uint64_t), myTimestampQueryResults.at(index).data(), sizeof(uint64_t), VK_QUERY_RESULT_64_BIT); - for (uint32_t i = 0; i < myLastAvailableTimestampQuery; i += 2) - { - const uint64_t startTime = myTimestampQueryResults.at(index).at(i); - const uint64_t endTime = myTimestampQueryResults.at(index).at(i + 1); + //vkGetQueryPoolResults(device->GetHandle(), myTimestampQueryPools.at(index), 0, myLastAvailableTimestampQuery, myLastAvailableTimestampQuery * sizeof(uint64_t), myTimestampQueryResults.at(index).data(), sizeof(uint64_t), VK_QUERY_RESULT_64_BIT); + //for (uint32_t i = 0; i < myLastAvailableTimestampQuery; i += 2) + //{ + // const uint64_t startTime = myTimestampQueryResults.at(index).at(i); + // const uint64_t endTime = myTimestampQueryResults.at(index).at(i + 1); - const float nsTime = endTime > startTime ? (endTime - startTime) * GraphicsContext::GetPhysicalDevice()->GetCapabilities().timestampPeriod : 0.f; - myGPUExecutionTimes[index][i / 2] = nsTime * 0.000001f; // Convert to ms - } + // const float nsTime = endTime > startTime ? (endTime - startTime) * GraphicsContext::GetPhysicalDevice()->GetCapabilities().timestampPeriod : 0.f; + // myGPUExecutionTimes[index][i / 2] = nsTime * 0.000001f; // Convert to ms + //} } void CommandBuffer::FetchPipelineStatistics() { - if (!myHasTimestampSupport) - { - return; - } + //if (!myHasTimestampSupport) + //{ + // return; + //} - auto device = GraphicsContext::GetDevice(); - const uint32_t index = mySwapchainTarget ? Application::Get().GetWindow().GetSwapchain().GetCurrentFrame() : myLastCommandPool; + //auto device = GraphicsContext::GetDevice(); + //const uint32_t index = mySwapchainTarget ? Application::Get().GetWindow().GetSwapchain().GetCurrentFrame() : myLastCommandPool; - if (myQueueType == QueueType::Graphics) - { - vkGetQueryPoolResults(device->GetHandle(), myPipelineStatisticsQueryPools.at(index), 0, 1, sizeof(RenderPipelineStatistics), &myPipelineStatisticsResults.at(index), sizeof(uint64_t), VK_QUERY_RESULT_64_BIT); - } + //if (myQueueType == QueueType::Graphics) + //{ + // //vkGetQueryPoolResults(device->GetHandle(), myPipelineStatisticsQueryPools.at(index), 0, 1, sizeof(RenderPipelineStatistics), &myPipelineStatisticsResults.at(index), sizeof(uint64_t), VK_QUERY_RESULT_64_BIT); + //} } void CommandBuffer::Release() diff --git a/Volt/Volt/src/Volt/Rendering/FrameGraph/FrameGraph.cpp b/Volt/Volt/src/Volt/Rendering/FrameGraph/FrameGraph.cpp index 4f7c3f102..4342ece0a 100644 --- a/Volt/Volt/src/Volt/Rendering/FrameGraph/FrameGraph.cpp +++ b/Volt/Volt/src/Volt/Rendering/FrameGraph/FrameGraph.cpp @@ -83,12 +83,12 @@ namespace Volt unreferencedResources.pop_back(); auto producer = unrefResource->producer; - if (producer.expired() || producer.lock()->hasSideEffect) + if (!producer || producer->hasSideEffect) { continue; } - auto producerPtr = producer.lock(); + auto producerPtr = producer; VT_CORE_ASSERT(producerPtr->refCount > 0, "Ref count cannot be zero at this time!"); @@ -217,7 +217,7 @@ namespace Volt // If this is the first access, use the images layout if (resourceAccesses[write].empty()) { - srcAccess = { VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_2_NONE, (!node.resource.image.expired()) ? node.resource.image.lock()->GetLayout() : VK_IMAGE_LAYOUT_UNDEFINED }; + srcAccess = { VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_2_NONE, (node.resource.image) ? node.resource.image->GetLayout() : VK_IMAGE_LAYOUT_UNDEFINED }; } else { @@ -268,7 +268,7 @@ namespace Volt // If this is the first access, use the images layout if (resourceAccesses[read].empty()) { - srcAccess = { VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_2_NONE, (!node.resource.image.expired()) ? node.resource.image.lock()->GetLayout() : VK_IMAGE_LAYOUT_UNDEFINED }; + srcAccess = { VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_2_NONE, (node.resource.image) ? node.resource.image->GetLayout() : VK_IMAGE_LAYOUT_UNDEFINED }; } else { @@ -309,7 +309,7 @@ namespace Volt { VT_PROFILE_FUNCTION(); - auto commandBuffer = myPrimaryCommandBuffer.lock(); + auto commandBuffer = myPrimaryCommandBuffer; myCommandBufferCache.Reset(); std::vector> commandBufferFutures; @@ -336,7 +336,7 @@ namespace Volt for (uint32_t i = 0; const auto & resource : myImageBarrierResources.at(renderPassNode->index)) { - barriers[i].image = GetImageResource(resource).image.lock()->GetHandle(); + barriers[i].image = GetImageResource(resource).image->GetHandle(); i++; } @@ -376,11 +376,11 @@ namespace Volt { const auto& pass = passNodes.at(passIndex); - Renderer::BeginSection(myPrimaryCommandBuffer.lock(), pass->name, { 1.f }); + Renderer::BeginSection(myPrimaryCommandBuffer, pass->name, { 1.f }); secondaryCmdBuffer->Submit(); - Renderer::EndSection(myPrimaryCommandBuffer.lock()); + Renderer::EndSection(myPrimaryCommandBuffer); passIndex++; } @@ -389,16 +389,16 @@ namespace Volt { if (resource.resource.isExternal) { - if (resource.lastUsage.expired()) + if (!resource.lastUsage) { continue; } - for (const auto& access : myResourceAccesses.at(resource.lastUsage.lock()->index)) + for (const auto& access : myResourceAccesses.at(resource.lastUsage->index)) { if (access.first == i) { - resource.resource.image.lock()->OverrideLayout(access.second.dstLayout); + resource.resource.image->OverrideLayout(access.second.dstLayout); break; } } @@ -457,7 +457,7 @@ namespace Volt VT_CORE_ASSERT(myResourceNodes.size() > static_cast(resourceHandle), "[FrameGraph] ResourceHandle {} is not valid!", resourceHandle); - if (myResourceNodes.at(resourceHandle).resource.image.expired()) + if (!myResourceNodes.at(resourceHandle).resource.image) { const auto& specification = myResourceNodes.at(resourceHandle).resource.specification; myResourceNodes.at(resourceHandle).resource.image = myTransientResourceSystem.AquireTexture(specification, resourceHandle); @@ -505,7 +505,7 @@ namespace Volt renderingInfo.hasDepth = true; renderingInfo.depthAttachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO; - renderingInfo.depthAttachmentInfo.imageView = resource.image.lock()->GetView(); + renderingInfo.depthAttachmentInfo.imageView = resource.image->GetView(); if (Utility::IsStencilFormat(resource.specification.format)) { @@ -523,7 +523,7 @@ namespace Volt { auto& attInfo = renderingInfo.colorAttachmentInfo.emplace_back(); attInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO; - attInfo.imageView = resource.image.lock()->GetView(); + attInfo.imageView = resource.image->GetView(); attInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; attInfo.loadOp = Utility::VoltToVulkanLoadOp(resource.specification.clearMode); attInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -542,8 +542,8 @@ namespace Volt FrameGraphResourceHandle FrameGraph::Builder::CreateTexture(const FrameGraphTextureSpecification& textureSpecification) { auto handle = myFrameGraph.CreateTexture(textureSpecification); - myRenderPass.lock()->resourceCreates.emplace_back(handle); - myRenderPass.lock()->resourceWrites.emplace_back(handle); + myRenderPass->resourceCreates.emplace_back(handle); + myRenderPass->resourceWrites.emplace_back(handle); return handle; } @@ -562,24 +562,24 @@ namespace Volt void FrameGraph::Builder::SetHasSideEffect() { - myRenderPass.lock()->hasSideEffect = true; + myRenderPass->hasSideEffect = true; } void FrameGraph::Builder::SetIsComputePass() { - myRenderPass.lock()->isComputePass = true; + myRenderPass->isComputePass = true; } void FrameGraph::Builder::ReadResource(FrameGraphResourceHandle handle) { - myRenderPass.lock()->resourceReads.emplace_back(handle); + myRenderPass->resourceReads.emplace_back(handle); } void FrameGraph::Builder::WriteResource(FrameGraphResourceHandle handle) { - if (!myRenderPass.lock()->CreatesResource(handle)) + if (!myRenderPass->CreatesResource(handle)) { - myRenderPass.lock()->resourceWrites.emplace_back(handle); + myRenderPass->resourceWrites.emplace_back(handle); } } } diff --git a/Volt/Volt/src/Volt/Rendering/RenderPipeline/RenderPipeline.cpp b/Volt/Volt/src/Volt/Rendering/RenderPipeline/RenderPipeline.cpp index 1b50faf03..0031c92b5 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderPipeline/RenderPipeline.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderPipeline/RenderPipeline.cpp @@ -223,14 +223,14 @@ namespace Volt blendInfo.blendConstants[2] = 0.f; blendInfo.blendConstants[3] = 0.f; - const bool hasRenderPass = !mySpecification.renderPass.expired(); + const bool hasRenderPass = mySpecification.renderPass; std::vector blendAttachments{}; std::vector attachments; if (hasRenderPass) { - attachments = mySpecification.renderPass.lock()->framebuffer->GetSpecification().attachments; + attachments = mySpecification.renderPass->framebuffer->GetSpecification().attachments; } else { @@ -374,11 +374,11 @@ namespace Volt if (hasRenderPass) { - attachmentFormats = mySpecification.renderPass.lock()->framebuffer->GetColorFormats(); - depthFormat = mySpecification.renderPass.lock()->framebuffer->GetDepthFormat(); - if (Utility::IsStencilFormat(mySpecification.renderPass.lock()->framebuffer->GetDepthAttachment()->GetFormat())) + attachmentFormats = mySpecification.renderPass->framebuffer->GetColorFormats(); + depthFormat = mySpecification.renderPass->framebuffer->GetDepthFormat(); + if (Utility::IsStencilFormat(mySpecification.renderPass->framebuffer->GetDepthAttachment()->GetFormat())) { - stencilFormat = mySpecification.renderPass.lock()->framebuffer->GetDepthFormat(); + stencilFormat = mySpecification.renderPass->framebuffer->GetDepthFormat(); } } else diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/BloomTechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/BloomTechnique.cpp index aea906867..025a69986 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/BloomTechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/BloomTechnique.cpp @@ -47,14 +47,14 @@ namespace Volt auto samplerDescriptorSet = Renderer::GetBindlessData().globalDescriptorSets[Sets::SAMPLERS]->GetOrAllocateDescriptorSet(currentIndex); - for (uint32_t i = 1; i < targetResource.image.lock()->GetSpecification().mips; i++) + for (uint32_t i = 1; i < targetResource.image->GetSpecification().mips; i++) { downsampleData.texelSize.x = 1.f / glm::vec2(mipSize).x; downsampleData.texelSize.y = 1.f / glm::vec2(mipSize).y; downsampleData.mipLevel = i; - downsamplePipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 1, i - 1, ImageAccess::Write); - downsamplePipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 0, i, ImageAccess::Write); + downsamplePipeline->SetImage(targetResource.image, Sets::OTHER, 1, i - 1, ImageAccess::Write); + downsamplePipeline->SetImage(targetResource.image, Sets::OTHER, 0, i, ImageAccess::Write); downsamplePipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); downsamplePipeline->BindDescriptorSet(commandBuffer->GetCurrentCommandBuffer(), samplerDescriptorSet, Sets::SAMPLERS); @@ -71,7 +71,7 @@ namespace Volt subresource.baseMipLevel = i; subresource.layerCount = 1; subresource.levelCount = 1; - Utility::InsertImageMemoryBarrier(commandBuffer->GetCurrentCommandBuffer(), targetResource.image.lock()->GetHandle(), VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, subresource); + Utility::InsertImageMemoryBarrier(commandBuffer->GetCurrentCommandBuffer(), targetResource.image->GetHandle(), VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, subresource); mipSize /= 2u; } @@ -100,13 +100,13 @@ namespace Volt glm::uvec2 mipSize = myRenderSize; auto samplerDescriptorSet = Renderer::GetBindlessData().globalDescriptorSets[Sets::SAMPLERS]->GetOrAllocateDescriptorSet(currentIndex); - for (uint32_t i = targetResource.image.lock()->GetSpecification().mips - 1; i >= 1; i--) + for (uint32_t i = targetResource.image->GetSpecification().mips - 1; i >= 1; i--) { - mipSize.x = (uint32_t)glm::max(1.0f, glm::floor(float(targetResource.image.lock()->GetWidth()) / glm::pow(2.0f, float(i - 1)))); - mipSize.y = (uint32_t)glm::max(1.0f, glm::floor(float(targetResource.image.lock()->GetHeight()) / glm::pow(2.0f, float(i - 1)))); + mipSize.x = (uint32_t)glm::max(1.0f, glm::floor(float(targetResource.image->GetWidth()) / glm::pow(2.0f, float(i - 1)))); + mipSize.y = (uint32_t)glm::max(1.0f, glm::floor(float(targetResource.image->GetHeight()) / glm::pow(2.0f, float(i - 1)))); - upsamplePipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 0, i - 1, ImageAccess::Write); - upsamplePipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 1, i, ImageAccess::Write); + upsamplePipeline->SetImage(targetResource.image, Sets::OTHER, 0, i - 1, ImageAccess::Write); + upsamplePipeline->SetImage(targetResource.image, Sets::OTHER, 1, i, ImageAccess::Write); upsamplePipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); upsamplePipeline->BindDescriptorSet(commandBuffer->GetCurrentCommandBuffer(), samplerDescriptorSet, Sets::SAMPLERS); @@ -126,7 +126,7 @@ namespace Volt subresource.baseMipLevel = i - 1; subresource.layerCount = 1; subresource.levelCount = 1; - Utility::InsertImageMemoryBarrier(commandBuffer->GetCurrentCommandBuffer(), targetResource.image.lock()->GetHandle(), VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, subresource); + Utility::InsertImageMemoryBarrier(commandBuffer->GetCurrentCommandBuffer(), targetResource.image->GetHandle(), VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, subresource); } upsamplePipeline->ClearAllResources(); @@ -151,16 +151,16 @@ namespace Volt const auto& outputImageResource = resources.GetImageResource(skyboxData.outputImage); const auto& bloomSrcImageResource = resources.GetImageResource(luminosityData.luminosityImage); - compositePipeline->SetImage(outputImageResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); - compositePipeline->SetImage(bloomSrcImageResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); + compositePipeline->SetImage(outputImageResource.image, Sets::OTHER, 0, ImageAccess::Write); + compositePipeline->SetImage(bloomSrcImageResource.image, Sets::OTHER, 1, ImageAccess::Read); compositePipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); constexpr float bloomStrength = 0.5f; compositePipeline->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &bloomStrength, sizeof(float)); constexpr uint32_t threadCount = 8; - const uint32_t dispatchX = std::max(1u, (outputImageResource.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (outputImageResource.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (outputImageResource.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (outputImageResource.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, compositePipeline, dispatchX, dispatchY, 1); }); diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/FXAATechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/FXAATechnique.cpp index 9a8cdacb1..c5a523017 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/FXAATechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/FXAATechnique.cpp @@ -45,8 +45,8 @@ namespace Volt const auto& currentColorResource = resources.GetImageResource(skyboxData.outputImage); const auto& resultResource = resources.GetImageResource(data.tempColor); - pipeline->SetImage(resultResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); - pipeline->SetImage(currentColorResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); + pipeline->SetImage(resultResource.image, Sets::OTHER, 0, ImageAccess::Write); + pipeline->SetImage(currentColorResource.image, Sets::OTHER, 1, ImageAccess::Read); pipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); @@ -83,8 +83,8 @@ namespace Volt const auto& tempColorResource = resources.GetImageResource(fxaaMainData.tempColor); const auto& resultResource = resources.GetImageResource(skyboxData.outputImage); - pipeline->SetImage(tempColorResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); - pipeline->SetImage(resultResource.image.lock(), Sets::OTHER, 1, ImageAccess::Write); + pipeline->SetImage(tempColorResource.image, Sets::OTHER, 0, ImageAccess::Read); + pipeline->SetImage(resultResource.image, Sets::OTHER, 1, ImageAccess::Write); pipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/GTAOTechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/GTAOTechnique.cpp index 487240735..2a0c79257 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/GTAOTechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/GTAOTechnique.cpp @@ -96,13 +96,13 @@ namespace Volt const auto& srcDepthResource = resources.GetImageResource(srcDepthHandle); const auto& targetResource = resources.GetImageResource(data.prefilteredDepth); - prefilterDepthPipeline->SetImage(srcDepthResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); + prefilterDepthPipeline->SetImage(srcDepthResource.image, Sets::OTHER, 0, ImageAccess::Read); - prefilterDepthPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 1, 0, ImageAccess::Write); - prefilterDepthPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 2, 1, ImageAccess::Write); - prefilterDepthPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 3, 2, ImageAccess::Write); - prefilterDepthPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 4, 3, ImageAccess::Write); - prefilterDepthPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 5, 4, ImageAccess::Write); + prefilterDepthPipeline->SetImage(targetResource.image, Sets::OTHER, 1, 0, ImageAccess::Write); + prefilterDepthPipeline->SetImage(targetResource.image, Sets::OTHER, 2, 1, ImageAccess::Write); + prefilterDepthPipeline->SetImage(targetResource.image, Sets::OTHER, 3, 2, ImageAccess::Write); + prefilterDepthPipeline->SetImage(targetResource.image, Sets::OTHER, 4, 3, ImageAccess::Write); + prefilterDepthPipeline->SetImage(targetResource.image, Sets::OTHER, 5, 4, ImageAccess::Write); prefilterDepthPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); prefilterDepthPipeline->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &myConstants, sizeof(GTAOConstants)); @@ -160,12 +160,12 @@ namespace Volt const auto& aoOutputResource = resources.GetImageResource(data.aoOutput); const auto& edgesOutputResource = resources.GetImageResource(data.edgesOutput); - mainPassPipeline->SetImage(prefilteredDepthResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); + mainPassPipeline->SetImage(prefilteredDepthResource.image, Sets::OTHER, 0, ImageAccess::Read); - mainPassPipeline->SetImage(aoOutputResource.image.lock(), Sets::OTHER, 1, ImageAccess::Write); - mainPassPipeline->SetImage(edgesOutputResource.image.lock(), Sets::OTHER, 2, ImageAccess::Write); + mainPassPipeline->SetImage(aoOutputResource.image, Sets::OTHER, 1, ImageAccess::Write); + mainPassPipeline->SetImage(edgesOutputResource.image, Sets::OTHER, 2, ImageAccess::Write); - mainPassPipeline->SetImage(viewNormalsResource.image.lock(), Sets::OTHER, 3, ImageAccess::Read); + mainPassPipeline->SetImage(viewNormalsResource.image, Sets::OTHER, 3, ImageAccess::Read); mainPassPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); mainPassPipeline->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &myConstants, sizeof(GTAOConstants)); @@ -235,16 +235,16 @@ namespace Volt if ((i % 2) == 0) { - currentPipeline->SetImage(aoTermResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); - currentPipeline->SetImage(finalOutputResource.image.lock(), Sets::OTHER, 2, ImageAccess::Write); + currentPipeline->SetImage(aoTermResource.image, Sets::OTHER, 0, ImageAccess::Write); + currentPipeline->SetImage(finalOutputResource.image, Sets::OTHER, 2, ImageAccess::Write); } else { - currentPipeline->SetImage(finalOutputResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); - currentPipeline->SetImage(aoTermResource.image.lock(), Sets::OTHER, 2, ImageAccess::Write); + currentPipeline->SetImage(finalOutputResource.image, Sets::OTHER, 0, ImageAccess::Write); + currentPipeline->SetImage(aoTermResource.image, Sets::OTHER, 2, ImageAccess::Write); } - currentPipeline->SetImage(edgeTermResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); + currentPipeline->SetImage(edgeTermResource.image, Sets::OTHER, 1, ImageAccess::Read); currentPipeline->InsertImageBarrier(Sets::OTHER, 0, readWriteBarrierInfo); currentPipeline->InsertImageBarrier(Sets::OTHER, 2, writeReadBarrierInfo); diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/OutlineTechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/OutlineTechnique.cpp index 0cd5c3432..dc7e0eec1 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/OutlineTechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/OutlineTechnique.cpp @@ -97,7 +97,7 @@ namespace Volt renderingInfo.width = myRenderSize.x; renderingInfo.height = myRenderSize.y; - material->GetSubMaterialAt(0)->Set(0, resources.GetImageResource(outlineGeomData.outputImage).image.lock()); + material->GetSubMaterialAt(0)->Set(0, resources.GetImageResource(outlineGeomData.outputImage).image); Renderer::BeginFrameGraphPass(commandBuffer, renderPassInfo, renderingInfo); Renderer::DrawFullscreenTriangleWithMaterial(commandBuffer, material, myGlobalDescriptorMap); @@ -148,11 +148,11 @@ namespace Volt if (index == 0) { - material->GetSubMaterialAt(0)->Set(0, resources.GetImageResource(jumpFloodInitData.outputImage).image.lock()); + material->GetSubMaterialAt(0)->Set(0, resources.GetImageResource(jumpFloodInitData.outputImage).image); } else { - material->GetSubMaterialAt(0)->Set(0, resources.GetImageResource(data.outputImage[0]).image.lock()); + material->GetSubMaterialAt(0)->Set(0, resources.GetImageResource(data.outputImage[0]).image); } material->GetSubMaterialAt(0)->SetValue("texelSize", floodPassData.texelSize); @@ -189,8 +189,8 @@ namespace Volt const auto& outputImageResource = resources.GetImageResource(skyboxData.outputImage); const auto& jumpFloodPassResource = resources.GetImageResource(jumpFloodPassData.outputImage[0]); - pipeline->SetImage(outputImageResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); - pipeline->SetImage(jumpFloodPassResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); + pipeline->SetImage(outputImageResource.image, Sets::OTHER, 0, ImageAccess::Write); + pipeline->SetImage(jumpFloodPassResource.image, Sets::OTHER, 1, ImageAccess::Read); pipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); const glm::vec4 color = { 1.f, 0.5f, 0.f, 1.f }; diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/SSRTechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/SSRTechnique.cpp index f6c1029b4..34a3e45a2 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/SSRTechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/SSRTechnique.cpp @@ -56,9 +56,9 @@ namespace Volt renderingInfo.width = myRenderSize.x; renderingInfo.height = myRenderSize.y; - material->GetSubMaterialAt(0)->Set(0, preDepthResource.image.lock()); - material->GetSubMaterialAt(0)->Set(1, viewNormalsResource.image.lock()); - material->GetSubMaterialAt(0)->Set(2, colorResource.image.lock()); + material->GetSubMaterialAt(0)->Set(0, preDepthResource.image); + material->GetSubMaterialAt(0)->Set(1, viewNormalsResource.image); + material->GetSubMaterialAt(0)->Set(2, colorResource.image); Renderer::BeginFrameGraphPass(commandBuffer, renderPassInfo, renderingInfo); Renderer::DrawFullscreenTriangleWithMaterial(commandBuffer, material, myGlobalDescriptorMap); @@ -98,7 +98,7 @@ namespace Volt renderingInfo.width = myRenderSize.x; renderingInfo.height = myRenderSize.y; - material->GetSubMaterialAt(0)->Set(0, ssrResource.image.lock()); + material->GetSubMaterialAt(0)->Set(0, ssrResource.image); Renderer::BeginFrameGraphPass(commandBuffer, renderPassInfo, renderingInfo); Renderer::DrawFullscreenTriangleWithMaterial(commandBuffer, material, myGlobalDescriptorMap); diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/TAATechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/TAATechnique.cpp index 51517f5ce..d275aac90 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/TAATechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/TAATechnique.cpp @@ -58,10 +58,10 @@ namespace Volt const auto& motionVectorResource = resources.GetImageResource(data.motionVectors); const auto& currentDepthResource = resources.GetImageResource(data.currentDepth); - pipeline->SetImage(srcDepthResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); + pipeline->SetImage(srcDepthResource.image, Sets::OTHER, 0, ImageAccess::Read); - pipeline->SetImage(motionVectorResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); - pipeline->SetImage(currentDepthResource.image.lock(), Sets::OTHER, 2, ImageAccess::Write); + pipeline->SetImage(motionVectorResource.image, Sets::OTHER, 1, ImageAccess::Read); + pipeline->SetImage(currentDepthResource.image, Sets::OTHER, 2, ImageAccess::Write); pipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); pipeline->BindDescriptorSet(commandBuffer->GetCurrentCommandBuffer(), rendererBuffersSet->GetOrAllocateDescriptorSet(commandBuffer->GetCurrentIndex()), Sets::RENDERER_BUFFERS); @@ -111,11 +111,11 @@ namespace Volt const auto& historyColorResource = resources.GetImageResource(data.historyColor); const auto& resultResource = resources.GetImageResource(data.tempColor); - pipeline->SetImage(resultResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); + pipeline->SetImage(resultResource.image, Sets::OTHER, 0, ImageAccess::Write); - pipeline->SetImage(depthResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); - pipeline->SetImage(currentColorResource.image.lock(), Sets::OTHER, 2, ImageAccess::Read); - pipeline->SetImage(historyColorResource.image.lock(), Sets::OTHER, 3, ImageAccess::Read); + pipeline->SetImage(depthResource.image, Sets::OTHER, 1, ImageAccess::Read); + pipeline->SetImage(currentColorResource.image, Sets::OTHER, 2, ImageAccess::Read); + pipeline->SetImage(historyColorResource.image, Sets::OTHER, 3, ImageAccess::Read); pipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); @@ -153,8 +153,8 @@ namespace Volt const auto& tempColorResource = resources.GetImageResource(taaMainData.tempColor); const auto& resultResource = resources.GetImageResource(skyboxData.outputImage); - pipeline->SetImage(tempColorResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); - pipeline->SetImage(resultResource.image.lock(), Sets::OTHER, 1, ImageAccess::Write); + pipeline->SetImage(tempColorResource.image, Sets::OTHER, 0, ImageAccess::Read); + pipeline->SetImage(resultResource.image, Sets::OTHER, 1, ImageAccess::Write); pipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); diff --git a/Volt/Volt/src/Volt/Rendering/RenderTechniques/VolumetricFogTechnique.cpp b/Volt/Volt/src/Volt/Rendering/RenderTechniques/VolumetricFogTechnique.cpp index a09025f89..025c55bbf 100644 --- a/Volt/Volt/src/Volt/Rendering/RenderTechniques/VolumetricFogTechnique.cpp +++ b/Volt/Volt/src/Volt/Rendering/RenderTechniques/VolumetricFogTechnique.cpp @@ -76,7 +76,7 @@ namespace Volt const uint32_t currentIndex = commandBuffer->GetCurrentIndex(); - injectionPipeline->SetImage(outputInjectionResource.image3D.lock(), Sets::OTHER, 0, ImageAccess::Write); + injectionPipeline->SetImage(outputInjectionResource.image3D, Sets::OTHER, 0, ImageAccess::Write); injectionPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); injectionPipeline->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &pushConstants, sizeof(PushConstants)); @@ -123,8 +123,8 @@ namespace Volt const uint32_t currentIndex = commandBuffer->GetCurrentIndex(); - rayMarchPipeline->SetImage(outputRayMarchedResource.image3D.lock(), Sets::OTHER, 0, ImageAccess::Write); - rayMarchPipeline->SetImage(injectionResource.image3D.lock(), Sets::OTHER, 1, ImageAccess::Write); + rayMarchPipeline->SetImage(outputRayMarchedResource.image3D, Sets::OTHER, 0, ImageAccess::Write); + rayMarchPipeline->SetImage(injectionResource.image3D, Sets::OTHER, 1, ImageAccess::Write); rayMarchPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); diff --git a/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp b/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp index 821d16570..c6b6bfa89 100644 --- a/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp +++ b/Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp @@ -166,7 +166,7 @@ namespace Volt Ref camera = nullptr; int32_t highestPrio = -1; - myScene.lock()->ForEachWithComponents([&](entt::entity, const CameraComponent& camComp) + myScene->ForEachWithComponents([&](entt::entity, const CameraComponent& camComp) { if ((int32_t)camComp.priority > highestPrio) { @@ -920,7 +920,7 @@ namespace Volt FetchMeshCommands(); FetchAnimatedMeshCommands(); - auto scenePtr = myScene.lock(); + auto scenePtr = myScene; scenePtr->ForEachWithComponents([&](entt::entity id, const DirectionalLightComponent& dirLightComp, const TransformComponent& transformComp) { @@ -929,7 +929,7 @@ namespace Volt return; } - auto lightEntity = Entity{ id, scenePtr.get() }; + auto lightEntity = Entity{ id, scenePtr }; DirectionalLight light{}; light.colorIntensity = glm::vec4(dirLightComp.color.x, dirLightComp.color.y, dirLightComp.color.z, dirLightComp.intensity); @@ -973,7 +973,7 @@ namespace Volt return; } - auto lightEntity = Entity{ id, scenePtr.get() }; + auto lightEntity = Entity{ id, scenePtr }; const auto position = lightEntity.GetPosition(); auto& pointLight = GetCPUData().pointLights.emplace_back(); @@ -1004,7 +1004,7 @@ namespace Volt return; } - auto lightEntity = Entity{ id, scenePtr.get() }; + auto lightEntity = Entity{ id, scenePtr }; auto& spotLight = GetCPUData().spotLights.emplace_back(); spotLight.color = spotLightComp.color; @@ -1077,7 +1077,7 @@ namespace Volt return; } - auto lightEntity = Entity{ id, scenePtr.get() }; + auto lightEntity = Entity{ id, scenePtr }; auto& sphereLight = GetCPUData().sphereLights.emplace_back(); sphereLight.position = lightEntity.GetPosition(); @@ -1093,7 +1093,7 @@ namespace Volt return; } - auto lightEntity = Entity{ id, scenePtr.get() }; + auto lightEntity = Entity{ id, scenePtr }; const glm::vec3 dir = glm::rotate(lightEntity.GetRotation(), { 0.f, 0.f, 1.f }); const glm::vec3 left = glm::rotate(lightEntity.GetRotation(), { -1.f, 0.f, 0.f }); const glm::vec3 up = glm::rotate(lightEntity.GetRotation(), { 0.f, 1.f, 0.f }); @@ -1158,7 +1158,7 @@ namespace Volt return; } - Entity entity{ id, scenePtr.get() }; + Entity entity{ id, scenePtr }; auto& newCmd = GetCPUData().decalCommands.emplace_back(); newCmd.material = material; @@ -1186,7 +1186,7 @@ namespace Volt return; } - Entity entity{ id, scenePtr.get() }; + Entity entity{ id, scenePtr }; TextCommand textCmd{}; textCmd.text = comp.text; @@ -1208,7 +1208,7 @@ namespace Volt { VT_PROFILE_FUNCTION(); - auto scenePtr = myScene.lock(); + auto scenePtr = myScene; auto& registry = scenePtr->GetRegistry(); auto& data = GetCPUData(); @@ -1242,7 +1242,7 @@ namespace Volt auto submitFunc = [&](uint32_t currentIndex, uint32_t threadIndex) { entt::entity id = meshComponentView[currentIndex]; - Entity entity{ id, scenePtr.get() }; + Entity entity{ id, scenePtr }; const MeshComponent& meshComp = entity.GetComponent(); const TransformComponent& transComp = entity.GetComponent(); @@ -1295,7 +1295,7 @@ namespace Volt cmd.subMesh = subMesh; cmd.transform = transform * subMesh.transform; cmd.subMeshIndex = i; - cmd.id = entity.GetUIntID(); + cmd.id = entity.GetID(); cmd.timeSinceCreation = dataComp.timeSinceCreation; cmd.randomValue = dataComp.randomValue; @@ -1357,7 +1357,7 @@ namespace Volt { VT_PROFILE_FUNCTION(); - auto scenePtr = myScene.lock(); + auto scenePtr = myScene; scenePtr->ForEachWithComponents([&](entt::entity id, AnimationControllerComponent& animComp, const TransformComponent& transformComp, const CommonComponent& dataComp) { @@ -1376,7 +1376,7 @@ namespace Volt return; } - auto entity = Entity(id, scenePtr.get()); + auto entity = Entity(id, scenePtr); const auto anim = animComp.controller->Sample(); @@ -1437,7 +1437,7 @@ namespace Volt return; } - auto entity = Entity(id, scenePtr.get()); + auto entity = Entity(id, scenePtr); myStatistics.triangleCount += skin->GetIndexCount() / 3; Ref material = skin->GetMaterial(); @@ -1451,7 +1451,7 @@ namespace Volt } const glm::mat4 transform = entity.GetTransform(); - SubmitMesh(skin, material, transform, dataComp.timeSinceCreation, dataComp.randomValue, entity.GetUIntID()); + SubmitMesh(skin, material, transform, dataComp.timeSinceCreation, dataComp.randomValue, entity.GetID()); } }); } @@ -1460,7 +1460,7 @@ namespace Volt { VT_PROFILE_FUNCTION(); - auto scenePtr = myScene.lock(); + auto scenePtr = myScene; const auto& particleStorage = scenePtr->GetParticleSystem().GetParticleStorage(); for (const auto& [entityId, storage] : particleStorage) @@ -1473,7 +1473,7 @@ namespace Volt const auto material = AssetManager::GetAsset(preset->material); - Entity entity{ entityId, scenePtr.get() }; + Entity entity{ entityId, scenePtr }; if (preset->type == ParticlePreset::eType::PARTICLE) { @@ -2213,12 +2213,12 @@ namespace Volt void SceneRenderer::UpdateGlobalDescriptorSet(Ref globalDescriptorSet, uint32_t set, uint32_t binding, uint32_t index, Weak image) { - UpdateGlobalDescriptorSet(globalDescriptorSet, set, binding, index, image, image.lock()->GetLayout()); + UpdateGlobalDescriptorSet(globalDescriptorSet, set, binding, index, image, image->GetLayout()); } void SceneRenderer::UpdateGlobalDescriptorSet(Ref globalDescriptorSet, uint32_t set, uint32_t binding, uint32_t index, Weak image, VkImageLayout targetLayout) { - auto imagePtr = image.lock(); + auto imagePtr = image; VkDescriptorImageInfo descriptorInfo{}; descriptorInfo.imageLayout = targetLayout; @@ -2234,7 +2234,7 @@ namespace Volt void SceneRenderer::UpdateGlobalDescriptorSet(Ref globalDescriptorSet, uint32_t set, uint32_t binding, uint32_t index, Weak image) { - auto imagePtr = image.lock(); + auto imagePtr = image; VkDescriptorImageInfo descriptorInfo{}; descriptorInfo.imageLayout = imagePtr->GetLayout(); @@ -2254,7 +2254,7 @@ namespace Volt for (const auto& image : images) { - auto imagePtr = image.lock(); + auto imagePtr = image; auto& descriptorInfo = descriptorInfos.emplace_back(); descriptorInfo.imageLayout = targetLayout; @@ -3001,7 +3001,7 @@ namespace Volt renderingInfo.width = myRenderSize.x; renderingInfo.height = myRenderSize.y; - renderingInfo.colorAttachmentInfo.at(0).clearValue.color.uint32[0] = entt::null; + renderingInfo.colorAttachmentInfo.at(0).clearValue.color.uint32[0] = Entity::NullID(); const auto& indirectPass = GetOrCreateIndirectPass(commandBuffer); @@ -3090,7 +3090,7 @@ namespace Volt const auto outputImage = resources.GetImageResource(data.skybox); myPreethamPipeline->Clear(currentIndex); - myPreethamPipeline->SetImage(outputImage.image.lock(), 0, 0, ImageAccess::Write); + myPreethamPipeline->SetImage(outputImage.image, 0, 0, ImageAccess::Write); myPreethamPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); myPreethamPipeline->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &pushData, sizeof(PreethamData)); myPreethamPipeline->Dispatch(commandBuffer->GetCurrentCommandBuffer(), cubeMapSize / groupSize, cubeMapSize / groupSize, 6, currentIndex); @@ -3148,13 +3148,13 @@ namespace Volt if (myEnvironmentSettings.radianceMap) { const auto& envResource = resources.GetImageResource(data.radianceImage); - mySkyboxMesh->GetMaterial()->GetSubMaterialAt(0)->Set(0, envResource.image.lock()); + mySkyboxMesh->GetMaterial()->GetSubMaterialAt(0)->Set(0, envResource.image); } else { const auto& preethamSkyData = frameGraph.GetBlackboard().Get(); const auto& preethamResource = resources.GetImageResource(preethamSkyData.skybox); - mySkyboxMesh->GetMaterial()->GetSubMaterialAt(0)->Set(0, preethamResource.image.lock()); + mySkyboxMesh->GetMaterial()->GetSubMaterialAt(0)->Set(0, preethamResource.image); } mySkyboxMesh->GetMaterial()->GetSubMaterialAt(0)->SetValue("intensity", myEnvironmentSettings.intensity); @@ -3294,11 +3294,11 @@ namespace Volt const uint32_t currentIndex = commandBuffer->GetCurrentIndex(); - shadingPipeline->SetImage(albedoResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); - shadingPipeline->SetImage(materialEmissiveResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); - shadingPipeline->SetImage(normalEmissiveResource.image.lock(), Sets::OTHER, 2, ImageAccess::Read); - shadingPipeline->SetImage(depthResource.image.lock(), Sets::OTHER, 3, ImageAccess::Read); - shadingPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 4, ImageAccess::Write); + shadingPipeline->SetImage(albedoResource.image, Sets::OTHER, 0, ImageAccess::Read); + shadingPipeline->SetImage(materialEmissiveResource.image, Sets::OTHER, 1, ImageAccess::Read); + shadingPipeline->SetImage(normalEmissiveResource.image, Sets::OTHER, 2, ImageAccess::Read); + shadingPipeline->SetImage(depthResource.image, Sets::OTHER, 3, ImageAccess::Read); + shadingPipeline->SetImage(targetResource.image, Sets::OTHER, 4, ImageAccess::Write); shadingPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); shadingPipeline->BindDescriptorSet(commandBuffer->GetCurrentCommandBuffer(), myGlobalDescriptorSets[Sets::RENDERER_BUFFERS]->GetOrAllocateDescriptorSet(currentIndex), Sets::RENDERER_BUFFERS); @@ -3315,8 +3315,8 @@ namespace Volt constexpr uint32_t threadCount = 8; - const uint32_t dispatchX = std::max(1u, (targetResource.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (targetResource.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (targetResource.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (targetResource.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, shadingPipeline, dispatchX, dispatchY, 1); shadingPipeline->ClearAllResources(); @@ -3366,7 +3366,7 @@ namespace Volt for (const auto& decalCmd : commands) { - decalCmd.material->GetSubMaterialAt(0)->Set(0, depthResource.image.lock()); + decalCmd.material->GetSubMaterialAt(0)->Set(0, depthResource.image); decalCmd.material->GetSubMaterialAt(0)->SetValue("targetSize", myRenderSize); decalCmd.material->GetSubMaterialAt(0)->SetValue("transform", decalCmd.transform); decalCmd.material->GetSubMaterialAt(0)->SetValue("materialIndex", Renderer::GetBindlessData().materialTable->GetIndexFromMaterial(decalCmd.material->TryGetSubMaterialAt(0).get())); @@ -3457,11 +3457,11 @@ namespace Volt if (mySettings.enableVolumetricFog) { const auto& fogResource = resources.GetImageResource(volumetricFogData.rayMarched); - UpdateGlobalDescriptorSet(resourcesDescriptor, Sets::PBR_RESOURCES, Bindings::VOLUMETRIC_FOG_TEXTURE, index, fogResource.image3D.lock()); + UpdateGlobalDescriptorSet(resourcesDescriptor, Sets::PBR_RESOURCES, Bindings::VOLUMETRIC_FOG_TEXTURE, index, fogResource.image3D); } else { - UpdateGlobalDescriptorSet(resourcesDescriptor, Sets::PBR_RESOURCES, Bindings::VOLUMETRIC_FOG_TEXTURE, index, Renderer::GetDefaultData().black3DImage); + UpdateGlobalDescriptorSet(resourcesDescriptor, Sets::PBR_RESOURCES, Bindings::VOLUMETRIC_FOG_TEXTURE, index, Weak{Renderer::GetDefaultData().black3DImage}); } } @@ -3667,14 +3667,14 @@ namespace Volt const auto& depthInputImage = resources.GetImageResource(depthData.preDepth); const auto& outputBlurImage = resources.GetImageResource(data.blurOne); - auto diffuseImage = diffuseInputImage.image.lock(); + auto diffuseImage = diffuseInputImage.image; Utility::TransitionImageLayout(commandBuffer->GetCurrentCommandBuffer(), diffuseImage->GetHandle(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, subresourceRange); diffuseImage->TransitionToLayout(commandBuffer->GetCurrentCommandBuffer(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - mySSSBlurPipeline[0]->SetImage(diffuseInputImage.image.lock(), Sets::OTHER, 0, ImageAccess::Read); - mySSSBlurPipeline[0]->SetImage(depthInputImage.image.lock(), Sets::OTHER, 1, ImageAccess::Read); - mySSSBlurPipeline[0]->SetImage(outputBlurImage.image.lock(), Sets::OTHER, 2, ImageAccess::Write); + mySSSBlurPipeline[0]->SetImage(diffuseInputImage.image, Sets::OTHER, 0, ImageAccess::Read); + mySSSBlurPipeline[0]->SetImage(depthInputImage.image, Sets::OTHER, 1, ImageAccess::Read); + mySSSBlurPipeline[0]->SetImage(outputBlurImage.image, Sets::OTHER, 2, ImageAccess::Write); mySSSBlurPipeline[0]->Bind(commandBuffer->GetCurrentCommandBuffer()); mySSSBlurPipeline[0]->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &pushConstants, sizeof(PushConstants)); @@ -3682,8 +3682,8 @@ namespace Volt constexpr uint32_t threadCount = 16; - const uint32_t dispatchX = std::max(1u, (outputBlurImage.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (outputBlurImage.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (outputBlurImage.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (outputBlurImage.image->GetHeight() / threadCount) + 1); ImageBarrierInfo imageBarrier{}; imageBarrier.srcStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; @@ -3710,12 +3710,12 @@ namespace Volt const auto& depthInputImage = resources.GetImageResource(depthData.preDepth); const auto& outputBlurImage = resources.GetImageResource(data.blurTwo); - auto outputImage = outputBlurImage.image.lock(); + auto outputImage = outputBlurImage.image; Utility::TransitionImageLayout(commandBuffer->GetCurrentCommandBuffer(), outputImage->GetHandle(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, subresourceRange); - mySSSBlurPipeline[1]->SetImage(diffuseInputImage.image.lock(), Sets::OTHER, 0, ImageAccess::Read); - mySSSBlurPipeline[1]->SetImage(depthInputImage.image.lock(), Sets::OTHER, 1, ImageAccess::Read); - mySSSBlurPipeline[1]->SetImage(outputBlurImage.image.lock(), Sets::OTHER, 2, ImageAccess::Write); + mySSSBlurPipeline[1]->SetImage(diffuseInputImage.image, Sets::OTHER, 0, ImageAccess::Read); + mySSSBlurPipeline[1]->SetImage(depthInputImage.image, Sets::OTHER, 1, ImageAccess::Read); + mySSSBlurPipeline[1]->SetImage(outputBlurImage.image, Sets::OTHER, 2, ImageAccess::Write); mySSSBlurPipeline[1]->Bind(commandBuffer->GetCurrentCommandBuffer()); mySSSBlurPipeline[1]->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &pushConstants, sizeof(PushConstants)); @@ -3723,8 +3723,8 @@ namespace Volt constexpr uint32_t threadCount = 16; - const uint32_t dispatchX = std::max(1u, (outputBlurImage.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (outputBlurImage.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (outputBlurImage.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (outputBlurImage.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, mySSSBlurPipeline[1], dispatchX, dispatchY, 1); } @@ -3755,14 +3755,14 @@ namespace Volt const auto& outputImageResource = resources.GetImageResource(skyboxData.outputImage); const auto& sssBlurResource = resources.GetImageResource(blurData.blurTwo); - mySSSCompositePipeline->SetImage(sssBlurResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); - mySSSCompositePipeline->SetImage(outputImageResource.image.lock(), Sets::OTHER, 1, ImageAccess::Write); + mySSSCompositePipeline->SetImage(sssBlurResource.image, Sets::OTHER, 0, ImageAccess::Read); + mySSSCompositePipeline->SetImage(outputImageResource.image, Sets::OTHER, 1, ImageAccess::Write); mySSSCompositePipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); constexpr uint32_t threadCount = 16; - const uint32_t dispatchX = std::max(1u, (outputImageResource.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (outputImageResource.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (outputImageResource.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (outputImageResource.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, mySSSCompositePipeline, dispatchX, dispatchY, 1); EndTimestamp(); @@ -3900,8 +3900,8 @@ namespace Volt const auto& accumResource = resources.GetImageResource(forwardTransparentData.accumulation); const auto& revealResource = resources.GetImageResource(forwardTransparentData.revealage); - myTransparentCompositeMaterial->GetSubMaterialAt(0)->Set(0, accumResource.image.lock()); - myTransparentCompositeMaterial->GetSubMaterialAt(0)->Set(1, revealResource.image.lock()); + myTransparentCompositeMaterial->GetSubMaterialAt(0)->Set(0, accumResource.image); + myTransparentCompositeMaterial->GetSubMaterialAt(0)->Set(1, revealResource.image); Renderer::BeginFrameGraphPass(commandBuffer, renderPassInfo, renderingInfo); Renderer::DrawFullscreenTriangleWithMaterial(commandBuffer, myTransparentCompositeMaterial, myGlobalDescriptorSets); @@ -4007,14 +4007,14 @@ namespace Volt const auto& srcColorResource = resources.GetImageResource(skyboxData.outputImage); const auto& targetResource = resources.GetImageResource(data.luminosityImage); - myLuminosityPipeline->SetImage(targetResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); - myLuminosityPipeline->SetImage(srcColorResource.image.lock(), Sets::OTHER, 1, ImageAccess::Read); + myLuminosityPipeline->SetImage(targetResource.image, Sets::OTHER, 0, ImageAccess::Write); + myLuminosityPipeline->SetImage(srcColorResource.image, Sets::OTHER, 1, ImageAccess::Read); myLuminosityPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); constexpr uint32_t threadCount = 8; - const uint32_t dispatchX = std::max(1u, (targetResource.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (targetResource.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (targetResource.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (targetResource.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, myLuminosityPipeline, dispatchX, dispatchY, 1); @@ -4051,7 +4051,7 @@ namespace Volt BeginTimestamp(name); const auto& outputImageResource = resources.GetImageResource(skyboxData.outputImage); - postMaterial->Render(commandBuffer, outputImageResource.image.lock()); + postMaterial->Render(commandBuffer, outputImageResource.image); EndTimestamp(); }); } @@ -4076,13 +4076,13 @@ namespace Volt const auto& outputImageResource = resources.GetImageResource(skyboxData.outputImage); - myACESPipeline->SetImage(outputImageResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); + myACESPipeline->SetImage(outputImageResource.image, Sets::OTHER, 0, ImageAccess::Write); myACESPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); constexpr uint32_t threadCount = 8; - const uint32_t dispatchX = std::max(1u, (outputImageResource.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (outputImageResource.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (outputImageResource.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (outputImageResource.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, myACESPipeline, dispatchX, dispatchY, 1); EndTimestamp(); @@ -4108,13 +4108,13 @@ namespace Volt const auto& outputImageResource = resources.GetImageResource(skyboxData.outputImage); - myGammaCorrectionPipeline->SetImage(outputImageResource.image.lock(), Sets::OTHER, 0, ImageAccess::Write); + myGammaCorrectionPipeline->SetImage(outputImageResource.image, Sets::OTHER, 0, ImageAccess::Write); myGammaCorrectionPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); constexpr uint32_t threadCount = 8; - const uint32_t dispatchX = std::max(1u, (outputImageResource.image.lock()->GetWidth() / threadCount) + 1); - const uint32_t dispatchY = std::max(1u, (outputImageResource.image.lock()->GetHeight() / threadCount) + 1); + const uint32_t dispatchX = std::max(1u, (outputImageResource.image->GetWidth() / threadCount) + 1); + const uint32_t dispatchY = std::max(1u, (outputImageResource.image->GetHeight() / threadCount) + 1); Renderer::DispatchComputePipeline(commandBuffer, myGammaCorrectionPipeline, dispatchX, dispatchY, 1); EndTimestamp(); @@ -4330,7 +4330,7 @@ namespace Volt myLightCullPipeline->Bind(commandBuffer->GetCurrentCommandBuffer()); myLightCullPipeline->PushConstants(commandBuffer->GetCurrentCommandBuffer(), &cullData, sizeof(LightCullData)); - myLightCullPipeline->SetImage(depthResource.image.lock(), Sets::OTHER, 0, ImageAccess::Read); + myLightCullPipeline->SetImage(depthResource.image, Sets::OTHER, 0, ImageAccess::Read); myLightCullPipeline->BindDescriptorSet(commandBuffer->GetCurrentCommandBuffer(), myGlobalDescriptorSets.at(Sets::RENDERER_BUFFERS)->GetOrAllocateDescriptorSet(commandBuffer->GetCurrentIndex()), Sets::RENDERER_BUFFERS); { @@ -4407,8 +4407,8 @@ namespace Volt const auto& colorHistoryResource = resources.GetImageResource(skyboxData.outputImage); const auto& motionVectorResource = resources.GetImageResource(motionVectorData.currentDepth); - myHistoryColor->CopyFromImage(commandBuffer->GetCurrentCommandBuffer(), colorHistoryResource.image.lock()); - myHistoryDepth->CopyFromImage(commandBuffer->GetCurrentCommandBuffer(), motionVectorResource.image.lock()); + myHistoryColor->CopyFromImage(commandBuffer->GetCurrentCommandBuffer(), colorHistoryResource.image); + myHistoryDepth->CopyFromImage(commandBuffer->GetCurrentCommandBuffer(), motionVectorResource.image); }); } @@ -4416,7 +4416,7 @@ namespace Volt { VT_PROFILE_FUNCTION(); - auto scenePtr = myScene.lock(); + auto scenePtr = myScene; const auto halfSize = myScaledSize / 2u; diff --git a/Volt/Volt/src/Volt/Rendering/UIRenderer.cpp b/Volt/Volt/src/Volt/Rendering/UIRenderer.cpp index 948048100..8a84091ae 100644 --- a/Volt/Volt/src/Volt/Rendering/UIRenderer.cpp +++ b/Volt/Volt/src/Volt/Rendering/UIRenderer.cpp @@ -195,7 +195,7 @@ namespace Volt vkCmdEndRendering(s_uiRendererData->commandBuffer->GetCurrentCommandBuffer()); Renderer::EndSection(s_uiRendererData->commandBuffer); - s_uiRendererData->currentRenderTarget.lock()->TransitionToLayout(s_uiRendererData->commandBuffer->GetCurrentCommandBuffer(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + s_uiRendererData->currentRenderTarget->TransitionToLayout(s_uiRendererData->commandBuffer->GetCurrentCommandBuffer(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); s_uiRendererData->commandBuffer->End(); s_uiRendererData->commandBuffer->Submit(); @@ -378,7 +378,7 @@ namespace Volt double fsScale = 1.0 / (metrics.ascenderY - metrics.descenderY); double y = 0.0; - const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget.lock()->GetWidth(), (float)s_uiRendererData->currentRenderTarget.lock()->GetHeight() }; + const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget->GetWidth(), (float)s_uiRendererData->currentRenderTarget->GetHeight() }; const glm::vec2 halfSize = currentSize / 2.f; const glm::vec3 remappedPosition = { Remap(position.x, -CORE_SIZE.x, CORE_SIZE.x, -halfSize.x, halfSize.x), Remap(position.y, -CORE_SIZE.y, CORE_SIZE.y, -halfSize.y, halfSize.y), position.z }; @@ -490,7 +490,7 @@ namespace Volt { auto subMat = s_uiRendererData->quadData.quadMaterial->GetSubMaterialAt(0); - const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget.lock()->GetWidth(), (float)s_uiRendererData->currentRenderTarget.lock()->GetHeight() }; + const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget->GetWidth(), (float)s_uiRendererData->currentRenderTarget->GetHeight() }; const glm::vec2 halfSize = currentSize / 2.f; const glm::vec3 remappedPosition = { Remap(cmd.position.x, -CORE_SIZE.x, CORE_SIZE.x, -halfSize.x, halfSize.x), Remap(cmd.position.y, -CORE_SIZE.y, CORE_SIZE.y, -halfSize.y, halfSize.y), cmd.position.z }; @@ -543,12 +543,12 @@ namespace Volt float UIRenderer::GetCurrentScaleModifier() { - if (s_uiRendererData->currentRenderTarget.expired()) + if (!s_uiRendererData->currentRenderTarget) { return 0.f; } - const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget.lock()->GetWidth(), (float)s_uiRendererData->currentRenderTarget.lock()->GetHeight() }; + const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget->GetWidth(), (float)s_uiRendererData->currentRenderTarget->GetHeight() }; const glm::vec2 newScale = { currentSize.x / CORE_SIZE.x, currentSize.y / CORE_SIZE.y }; const float minScale = glm::min(newScale.x, newScale.y); @@ -557,12 +557,12 @@ namespace Volt float UIRenderer::GetCurrentScaleModifierX() { - if (s_uiRendererData->currentRenderTarget.expired()) + if (!s_uiRendererData->currentRenderTarget) { return 0.f; } - const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget.lock()->GetWidth(), (float)s_uiRendererData->currentRenderTarget.lock()->GetHeight() }; + const glm::vec2 currentSize = { (float)s_uiRendererData->currentRenderTarget->GetWidth(), (float)s_uiRendererData->currentRenderTarget->GetHeight() }; const glm::vec2 newScale = { currentSize.x / CORE_SIZE.x, currentSize.y / CORE_SIZE.y }; return newScale.x; diff --git a/Volt/Volt/src/Volt/Scene/Entity.cpp b/Volt/Volt/src/Volt/Scene/Entity.cpp index 70baa782f..0e0ddd243 100644 --- a/Volt/Volt/src/Volt/Scene/Entity.cpp +++ b/Volt/Volt/src/Volt/Scene/Entity.cpp @@ -17,7 +17,7 @@ namespace Volt { Entity::Entity() - : m_id(entt::null) + : m_handle(entt::null) { } @@ -35,13 +35,13 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have tag component!"); - return registry.get(m_id).tag; + assert(registry.any_of(m_handle) && "Entity must have tag component!"); + return registry.get(m_handle).tag; } const std::string Entity::ToString() const { - return std::to_string(static_cast(m_id)); + return std::to_string(static_cast(m_handle)); } const uint32_t Entity::GetLayerID() const @@ -49,8 +49,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have common component!"); - return registry.get(m_id).layerId; + assert(registry.any_of(m_handle) && "Entity must have common component!"); + return registry.get(m_handle).layerId; } void Entity::SetTag(std::string_view tag) @@ -58,8 +58,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have tag component!"); - registry.get(m_id).tag = tag; + assert(registry.any_of(m_handle) && "Entity must have tag component!"); + registry.get(m_handle).tag = tag; } const glm::mat4 Entity::GetTransform() const @@ -73,8 +73,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).GetTransform(); + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).GetTransform(); } const glm::vec3 Entity::GetForward() const @@ -97,8 +97,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).GetForward(); + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).GetForward(); } const glm::vec3 Entity::GetLocalRight() const @@ -106,8 +106,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).GetRight(); + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).GetRight(); } const glm::vec3 Entity::GetLocalUp() const @@ -115,8 +115,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).GetUp(); + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).GetUp(); } const glm::vec3 Entity::GetPosition() const @@ -145,8 +145,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).position; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).position; } const glm::quat& Entity::GetLocalRotation() const @@ -154,8 +154,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).rotation; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).rotation; } const glm::vec3& Entity::GetLocalScale() const @@ -163,8 +163,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).scale; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).scale; } void Entity::SetPosition(const glm::vec3& position, bool updatePhysics) @@ -174,7 +174,7 @@ namespace Volt if (parent) { - parentTransform = m_scene.lock()->GetWorldTQS(parent); + parentTransform = m_scene->GetWorldTQS(parent); } const glm::vec3 translatedPoint = position - parentTransform.position; @@ -192,7 +192,7 @@ namespace Volt if (parent) { - parentTransform = m_scene.lock()->GetWorldTQS(parent); + parentTransform = m_scene->GetWorldTQS(parent); } const glm::quat localRotation = glm::conjugate(parentTransform.rotation) * rotation; @@ -206,7 +206,7 @@ namespace Volt if (parent) { - parentTransform = m_scene.lock()->GetWorldTQS(parent); + parentTransform = m_scene->GetWorldTQS(parent); } const glm::vec3 inverseScale = 1.f / parentTransform.scale; @@ -220,11 +220,11 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - registry.get(m_id).position = position; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + registry.get(m_handle).position = position; UpdatePhysicsTranslation(updatePhysics); - scenePtr->InvalidateEntityTransform(m_id); + scenePtr->InvalidateEntityTransform(GetID()); } void Entity::SetLocalRotation(const glm::quat& rotation, bool updatePhysics) @@ -232,11 +232,11 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - registry.get(m_id).rotation = rotation; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + registry.get(m_handle).rotation = rotation; UpdatePhysicsRotation(updatePhysics); - scenePtr->InvalidateEntityTransform(m_id); + scenePtr->InvalidateEntityTransform(GetID()); } void Entity::SetLocalScale(const glm::vec3& scale) @@ -244,10 +244,10 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - registry.get(m_id).scale = scale; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + registry.get(m_handle).scale = scale; - scenePtr->InvalidateEntityTransform(m_id); + scenePtr->InvalidateEntityTransform(GetID()); } void Entity::SetParent(Entity parentEntity) @@ -267,12 +267,12 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have relationship component!"); + assert(registry.any_of(m_handle) && "Entity must have relationship component!"); auto parent = GetParent(); parent.RemoveChild(*this); - registry.get(m_id).parent = entt::null; + registry.get(m_handle).parent = Entity::NullID(); } void Entity::ClearChildren() @@ -280,17 +280,17 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have relationship component!"); + assert(registry.any_of(m_handle) && "Entity must have relationship component!"); - auto& children = registry.get(m_id).children; + auto& children = registry.get(m_handle).children; for (auto& childId : children) { - Entity child{ childId, m_scene }; + auto child = scenePtr->GetEntityFromUUID(childId); - if (child.GetParent().GetID() == m_id) + if (child.GetParent().GetID() == GetID()) { - child.GetComponent().parent = entt::null; + child.GetComponent().parent = NullID(); } } @@ -302,16 +302,16 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have relationship component!"); + assert(registry.any_of(m_handle) && "Entity must have relationship component!"); - auto& relComp = registry.get(m_id); + auto& relComp = registry.get(m_handle); for (uint32_t index = 0; auto & childId : relComp.children) { - Entity childEnt{ childId, m_scene }; + auto childEnt = scenePtr->GetEntityFromUUID(childId); if (childEnt.GetID() == entity.GetID()) { - childEnt.GetComponent().parent = entt::null; + childEnt.GetComponent().parent = Entity::NullID(); relComp.children.erase(relComp.children.begin() + index); break; @@ -336,15 +336,15 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have relationship component!"); + assert(registry.any_of(m_handle) && "Entity must have relationship component!"); - auto& relComp = registry.get(m_id); - if (relComp.parent == entt::null) + auto& relComp = registry.get(m_handle); + if (relComp.parent == Entity::NullID()) { return Null(); } - return { relComp.parent, m_scene }; + return scenePtr->GetEntityFromUUID(relComp.parent); } const std::vector Entity::GetChildren() const @@ -352,19 +352,19 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - if (!registry.any_of(m_id)) + if (!registry.any_of(m_handle)) { return {}; } - assert(registry.any_of(m_id) && "Entity must have relationship component!"); + assert(registry.any_of(m_handle) && "Entity must have relationship component!"); - const auto& children = registry.get(m_id).children; + const auto& children = registry.get(m_handle).children; std::vector result{}; for (const auto& id : children) { - result.emplace_back(id, m_scene); + result.emplace_back(m_scene->GetEntityFromUUID(id)); } return result; @@ -375,15 +375,15 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - if (!registry.any_of(m_id)) + if (!registry.any_of(m_handle)) { return false; } - assert(registry.any_of(m_id) && "Entity must have relationship component!"); + assert(registry.any_of(m_handle) && "Entity must have relationship component!"); - auto& relComp = registry.get(m_id); - Entity parentEntity{ relComp.parent, m_scene }; + auto& relComp = registry.get(m_handle); + auto parentEntity = scenePtr->GetEntityFromUUID(relComp.parent); return parentEntity.IsValid(); } @@ -397,7 +397,7 @@ namespace Volt for (auto&& curr : registry.storage()) { - if (auto& storage = curr.second; storage.contains(m_id)) + if (auto& storage = curr.second; storage.contains(m_handle)) { std::string tempStr(storage.type().name()); @@ -468,8 +468,8 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).visible; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).visible; } const bool Entity::IsLocked() const @@ -477,25 +477,30 @@ namespace Volt auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - assert(registry.any_of(m_id) && "Entity must have transform component!"); - return registry.get(m_id).locked; + assert(registry.any_of(m_handle) && "Entity must have transform component!"); + return registry.get(m_handle).locked; } const bool Entity::IsValid() const { - if (m_scene.expired() || m_id == entt::null) + if (!m_scene || m_handle == entt::null) { return false; } - auto scenePtr = m_scene.lock(); - return scenePtr->GetRegistry().valid(m_id); + auto scenePtr = m_scene; + return scenePtr->GetRegistry().valid(m_handle); + } + + const EntityID Entity::GetID() const + { + return GetComponent().id; } Entity& Entity::operator=(const Entity& entity) { m_scene = entity.m_scene; - m_id = entity.m_id; + m_handle = entity.m_handle; return *this; } @@ -517,7 +522,7 @@ namespace Volt { auto& storage = curr.second; - if (!storage.contains(srcEntity.GetID())) + if (!storage.contains(srcEntity)) { continue; } @@ -533,12 +538,12 @@ namespace Volt continue; } - if (!ComponentRegistry::Helpers::HasComponentWithGUID(componentDesc->GetGUID(), dstRegistry, dstEntity.GetID())) + if (!ComponentRegistry::Helpers::HasComponentWithGUID(componentDesc->GetGUID(), dstRegistry, dstEntity)) { - ComponentRegistry::Helpers::AddComponentWithGUID(componentDesc->GetGUID(), dstRegistry, dstEntity.GetID()); + ComponentRegistry::Helpers::AddComponentWithGUID(componentDesc->GetGUID(), dstRegistry, dstEntity); } - void* voidCompPtr = Volt::ComponentRegistry::Helpers::GetComponentWithGUID(componentDesc->GetGUID(), dstRegistry, dstEntity.GetID()); + void* voidCompPtr = Volt::ComponentRegistry::Helpers::GetComponentWithGUID(componentDesc->GetGUID(), dstRegistry, dstEntity); uint8_t* componentData = reinterpret_cast(voidCompPtr); if (componentDesc->GetGUID() == GetTypeGUID() && (copyFlags & EntityCopyFlags::SkipPrefab) != EntityCopyFlags::None) @@ -558,7 +563,7 @@ namespace Volt continue; } - CopyComponent(reinterpret_cast(storage.get(srcEntity.GetID())), componentData, 0, componentDesc); + CopyComponent(reinterpret_cast(storage.get(srcEntity)), componentData, 0, componentDesc); } CopyMonoScripts(srcEntity, dstEntity); @@ -566,7 +571,7 @@ namespace Volt Entity Entity::Duplicate(Entity srcEntity, Ref targetScene, Entity parent) { - auto scene = targetScene ? targetScene : srcEntity.GetScene(); + auto scene = targetScene ? targetScene : srcEntity.GetScene().GetSharedPtr(); Entity newEntity = scene->CreateEntity(); @@ -577,7 +582,7 @@ namespace Volt newEntity.GetComponent().repId = Nexus::RandRepID(); } - std::vector newChildren; + std::vector newChildren; for (const auto& child : srcEntity.GetChildren()) { @@ -585,7 +590,7 @@ namespace Volt } newEntity.GetComponent().children = newChildren; - newEntity.GetComponent().parent = parent ? parent.GetID() : entt::null; + newEntity.GetComponent().parent = parent ? parent.GetID() : Entity::NullID(); return newEntity; } @@ -681,7 +686,7 @@ namespace Volt void Entity::UpdatePhysicsTranslation(bool updateThis) { - if (updateThis && m_scene.lock()->IsPlaying() && (HasComponent() || HasComponent())) + if (updateThis && m_scene->IsPlaying() && (HasComponent() || HasComponent())) { auto actor = Physics::GetScene()->GetActor(*this); if (actor) @@ -699,7 +704,7 @@ namespace Volt void Entity::UpdatePhysicsRotation(bool updateThis) { - if (updateThis && m_scene.lock()->IsPlaying() && HasComponent()) + if (updateThis && m_scene->IsPlaying() && HasComponent()) { auto actor = Physics::GetScene()->GetActor(*this); if (actor) diff --git a/Volt/Volt/src/Volt/Scene/Entity.h b/Volt/Volt/src/Volt/Scene/Entity.h index d673e20b2..3cb8ee78e 100644 --- a/Volt/Volt/src/Volt/Scene/Entity.h +++ b/Volt/Volt/src/Volt/Scene/Entity.h @@ -2,6 +2,9 @@ #include "Volt/Core/Base.h" #include "Volt/Scene/Scene.h" +#include "Volt/Scene/EntityID.h" + +#include namespace Volt { @@ -22,6 +25,7 @@ namespace Volt VT_SETUP_ENUM_CLASS_OPERATORS(EntityCopyFlags); + class Entity { public: @@ -37,7 +41,7 @@ namespace Volt ~Entity(); - Ref GetScene() const { return m_scene.lock(); } + Weak GetScene() const { return m_scene; } const std::string& GetTag() const; const std::string ToString() const; @@ -94,8 +98,7 @@ namespace Volt const bool IsLocked() const; const bool IsValid() const; - inline const entt::entity GetID() const { return m_id; } - inline const uint32_t GetUIntID() const { return static_cast(m_id); } + const EntityID GetID() const; template T& GetComponent(); template const T& GetComponent() const; @@ -107,12 +110,15 @@ namespace Volt Entity& operator=(const Entity& entity); - inline bool operator==(const Entity& entity) const { return m_id == entity.m_id; } + inline bool operator==(const Entity& entity) const { return m_handle == entity.m_handle; } inline bool operator!() const { return !IsValid(); } inline explicit operator bool() const { return IsValid(); } inline explicit operator std::string() const { return ToString(); } + inline operator entt::entity() const { return m_handle; } + inline operator uint32_t() const { return static_cast(m_handle); } static Entity Null(); + constexpr static EntityID NullID() { return EntityID(0); } // Copies a single entity static void Copy(Entity srcEntity, Entity dstEntity, const EntityCopyFlags copyFlags = EntityCopyFlags::SkipRelationships); @@ -128,18 +134,18 @@ namespace Volt void UpdatePhysicsRotation(bool updateThis); Weak m_scene; - entt::entity m_id = entt::null; + entt::entity m_handle = entt::null; }; template inline Entity::Entity(T id, Weak scene) - : m_id(static_cast(id)), m_scene(scene) + : m_handle(static_cast(id)), m_scene(scene) { } template inline Entity::Entity(T id, Scene* scene) - : m_id(static_cast(id)) + : m_handle(static_cast(id)) { m_scene = scene->shared_from_this(); } @@ -149,7 +155,7 @@ namespace Volt { auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - return registry.get(m_id); + return registry.get(m_handle); } template @@ -157,7 +163,7 @@ namespace Volt { auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - return registry.get(m_id); + return registry.get(m_handle); } template @@ -165,7 +171,7 @@ namespace Volt { auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - return registry.any_of(m_id); + return registry.any_of(m_handle); } template @@ -173,7 +179,7 @@ namespace Volt { auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - return registry.emplace(m_id); + return registry.emplace(m_handle); } template @@ -181,7 +187,7 @@ namespace Volt { auto scenePtr = GetScene(); auto& registry = scenePtr->GetRegistry(); - registry.remove(m_id); + registry.remove(m_handle); } diff --git a/Volt/Volt/src/Volt/Scene/EntityID.h b/Volt/Volt/src/Volt/Scene/EntityID.h new file mode 100644 index 000000000..008a11a8b --- /dev/null +++ b/Volt/Volt/src/Volt/Scene/EntityID.h @@ -0,0 +1,8 @@ +#pragma once + +#include "Volt/Core/UUID.h" + +namespace Volt +{ + typedef UUID32 EntityID; +} diff --git a/Volt/Volt/src/Volt/Scene/EntityRegistry.cpp b/Volt/Volt/src/Volt/Scene/EntityRegistry.cpp new file mode 100644 index 000000000..d2460b4c5 --- /dev/null +++ b/Volt/Volt/src/Volt/Scene/EntityRegistry.cpp @@ -0,0 +1,61 @@ +#include "vtpch.h" +#include "EntityRegistry.h" + +#include "Volt/Scene/Entity.h" + +namespace Volt +{ + void EntityRegistry::AddEntity(const Entity& entity) + { + if (m_entityMap.contains(entity.GetID()) || m_handleMap.contains(entity)) + { + return; + } + + m_entityMap.emplace(entity.GetID(), entity); + m_handleMap.emplace(entity, entity.GetID()); + } + + void EntityRegistry::RemoveEntity(const Entity& entity) + { + if (m_entityMap.contains(entity.GetID())) + { + m_entityMap.erase(entity.GetID()); + } + + if (m_handleMap.contains(entity)) + { + m_handleMap.erase(entity); + } + } + + EntityID EntityRegistry::GetUUIDFromHandle(entt::entity handle) const + { + if (!m_handleMap.contains(handle)) + { + return Entity::NullID(); + } + + return m_handleMap.at(handle); + } + + entt::entity EntityRegistry::GetHandleFromUUID(EntityID uuid) const + { + if (!m_entityMap.contains(uuid)) + { + return entt::null; + } + + return m_entityMap.at(uuid); + } + + const bool EntityRegistry::Contains(EntityID uuid) const + { + return m_entityMap.contains(uuid); + } + + const bool EntityRegistry::Contains(entt::entity handle) const + { + return m_handleMap.contains(handle); + } +} diff --git a/Volt/Volt/src/Volt/Scene/EntityRegistry.h b/Volt/Volt/src/Volt/Scene/EntityRegistry.h new file mode 100644 index 000000000..a37c023d8 --- /dev/null +++ b/Volt/Volt/src/Volt/Scene/EntityRegistry.h @@ -0,0 +1,27 @@ +#pragma once + +#include "Volt/Scene/EntityID.h" + +#include + +namespace Volt +{ + class Entity; + + class EntityRegistry + { + public: + void AddEntity(const Entity& entity); + void RemoveEntity(const Entity& entity); + + EntityID GetUUIDFromHandle(entt::entity handle) const; + entt::entity GetHandleFromUUID(EntityID uuid) const; + + const bool Contains(EntityID uuid) const; + const bool Contains(entt::entity handle) const; + + private: + std::unordered_map m_entityMap; + std::unordered_map m_handleMap; + }; +} diff --git a/Volt/Volt/src/Volt/Scene/Scene.cpp b/Volt/Volt/src/Volt/Scene/Scene.cpp index 37f02be2d..4b4388e1c 100644 --- a/Volt/Volt/src/Volt/Scene/Scene.cpp +++ b/Volt/Volt/src/Volt/Scene/Scene.cpp @@ -107,7 +107,7 @@ namespace Volt // Awake { - ForEachWithComponents([](const entt::entity id, const MonoScriptComponent& scriptComp) + ForEachWithComponents([](const entt::entity id, const MonoScriptComponent& scriptComp, const IDComponent& idComponent) { for (uint32_t i = 0; i < scriptComp.scriptIds.size(); i++) { @@ -115,7 +115,7 @@ namespace Volt if (scriptClass && scriptClass->IsEngineScript()) { - MonoScriptEngine::OnAwakeInstance(scriptComp.scriptIds[i], id, scriptComp.scriptNames[i]); + MonoScriptEngine::OnAwakeInstance(scriptComp.scriptIds[i], idComponent.id, scriptComp.scriptNames[i]); } } }); @@ -125,7 +125,7 @@ namespace Volt // Create { - ForEachWithComponents([&](entt::entity id, const MonoScriptComponent& scriptComp) + ForEachWithComponents([&](entt::entity id, const MonoScriptComponent& scriptComp, const IDComponent& idComponent) { for (uint32_t i = 0; i < scriptComp.scriptIds.size(); i++) { @@ -133,7 +133,7 @@ namespace Volt if (scriptClass && scriptClass->IsEngineScript()) { - MonoScriptEngine::OnCreateInstance(scriptComp.scriptIds[i], id, scriptComp.scriptNames[i]); + MonoScriptEngine::OnCreateInstance(scriptComp.scriptIds[i], idComponent.id, scriptComp.scriptNames[i]); } } }); @@ -182,21 +182,21 @@ namespace Volt m_visionSystem->Initialize(); m_animationSystem.OnRuntimeStart(m_registry); - ForEachWithComponents([&](entt::entity id, const MonoScriptComponent& scriptComp) + ForEachWithComponents([&](entt::entity id, const MonoScriptComponent& scriptComp, const IDComponent& idComponent) { for (uint32_t i = 0; i < scriptComp.scriptIds.size(); i++) { - MonoScriptEngine::OnAwakeInstance(scriptComp.scriptIds[i], id, scriptComp.scriptNames[i]); + MonoScriptEngine::OnAwakeInstance(scriptComp.scriptIds[i], idComponent.id, scriptComp.scriptNames[i]); } }); MonoScriptEngine::DoOnAwakeInstance(); - ForEachWithComponents([&](entt::entity id, const MonoScriptComponent& scriptComp) + ForEachWithComponents([&](entt::entity id, const MonoScriptComponent& scriptComp, const IDComponent& idComponent) { for (uint32_t i = 0; i < scriptComp.scriptIds.size(); i++) { - MonoScriptEngine::OnCreateInstance(scriptComp.scriptIds[i], id, scriptComp.scriptNames[i]); + MonoScriptEngine::OnCreateInstance(scriptComp.scriptIds[i], idComponent.id, scriptComp.scriptNames[i]); } }); } @@ -345,9 +345,48 @@ namespace Volt m_statistics.entityCount = static_cast(m_registry.alive()); } - Entity Scene::CreateEntity(const std::string& tag, const entt::entity hintId) + Entity Scene::CreateEntity(const std::string& tag) + { + entt::entity id = m_registry.create(); + + Entity newEntity = Entity(id, this); + auto& transform = newEntity.AddComponent(); + transform.position = { 0.f, 0.f, 0.f }; + transform.rotation = { 1.f, 0.f, 0.f, 0.f }; + transform.scale = { 1.f, 1.f, 1.f }; + + // Tag + { + auto& tagComp = newEntity.AddComponent(); + if (tag.empty()) + { + tagComp.tag = "New Entity"; + } + else + { + tagComp.tag = tag; + } + } + newEntity.AddComponent(); + newEntity.AddComponent(); + newEntity.AddComponent(); + + newEntity.GetComponent().layerId = m_sceneLayers.at(m_activeLayerIndex).id; + newEntity.GetComponent().randomValue = Random::Float(0.f, 1.f); + newEntity.GetComponent().timeSinceCreation = 0.f; + + const auto uuid = newEntity.GetComponent().id; + + m_entityRegistry.AddEntity(newEntity); + + InvalidateEntityTransform(uuid); + SortScene(); + return newEntity; + } + + Entity Scene::CreateEntityWithUUID(const EntityID& uuid, const std::string& tag) { - entt::entity id = m_registry.create(hintId); + entt::entity id = m_registry.create(); Entity newEntity = Entity(id, this); auto& transform = newEntity.AddComponent(); @@ -369,17 +408,36 @@ namespace Volt } newEntity.AddComponent(); newEntity.AddComponent(); + newEntity.AddComponent(); newEntity.GetComponent().layerId = m_sceneLayers.at(m_activeLayerIndex).id; newEntity.GetComponent().randomValue = Random::Float(0.f, 1.f); newEntity.GetComponent().timeSinceCreation = 0.f; - InvalidateEntityTransform(id); + newEntity.GetComponent().id = uuid; + m_entityRegistry.AddEntity(newEntity); + + InvalidateEntityTransform(uuid); SortScene(); return newEntity; } + Entity Scene::GetEntityFromUUID(const EntityID uuid) const + { + if (!m_entityRegistry.Contains(uuid)) + { + return Entity::Null(); + } + + return { m_entityRegistry.GetHandleFromUUID(uuid), const_cast(this) }; // #TODO_Ivar: Doubtable + } + + entt::entity Scene::GetHandleFromUUID(const EntityID uuid) const + { + return m_entityRegistry.GetHandleFromUUID(uuid); + } + void Scene::RemoveEntity(Entity entity) { RemoveEntityInternal(entity, false); @@ -443,21 +501,21 @@ namespace Volt } ConvertToWorldSpace(entity); - entity.GetComponent().parent = entt::null; + entity.GetComponent().parent = Entity::NullID(); } - void Scene::InvalidateEntityTransform(entt::entity entity) + void Scene::InvalidateEntityTransform(const EntityID& entityUUID) { - std::vector entityStack; + std::vector entityStack; entityStack.reserve(10); - entityStack.push_back(entity); + entityStack.push_back(entityUUID); while (!entityStack.empty()) { - entt::entity currentEntity = entityStack.back(); + const EntityID currentUUID = entityStack.back(); entityStack.pop_back(); - Volt::Entity ent{ currentEntity, this }; + Volt::Entity ent{ m_entityRegistry.GetHandleFromUUID(currentUUID), this }; if (!ent.HasComponent()) { @@ -473,9 +531,9 @@ namespace Volt { std::unique_lock lock{ m_cachedEntityTransformMutex }; - if (m_cachedEntityTransforms.contains(currentEntity)) + if (m_cachedEntityTransforms.contains(currentUUID)) { - m_cachedEntityTransforms.erase(currentEntity); + m_cachedEntityTransforms.erase(currentUUID); } } } @@ -523,6 +581,11 @@ namespace Volt return entity; } + const bool Scene::IsEntityValid(EntityID entityId) const + { + return m_registry.valid(m_entityRegistry.GetHandleFromUUID(entityId)); + } + const std::set Scene::GetDependencyList(const std::filesystem::path& scenePath) { const auto folderPath = scenePath.parent_path(); @@ -617,6 +680,9 @@ namespace Volt if (createDefaultMesh) { auto ent = newScene->CreateEntity("Cube"); + + auto id = ent.GetComponent(); + auto& meshComp = ent.AddComponent(); meshComp.handle = AssetManager::GetAssetHandleFromFilePath("Engine/Meshes/Primitives/SM_Cube.vtmesh"); @@ -729,7 +795,7 @@ namespace Volt TQS resultTransform{}; for (const auto& ent : std::ranges::reverse_view(hierarchy)) { - const auto& transComp = m_registry.get(ent.GetID()); + const auto& transComp = m_registry.get((entt::entity)ent); resultTransform.position = resultTransform.position + resultTransform.rotation * transComp.position; resultTransform.rotation = resultTransform.rotation * transComp.rotation; @@ -795,7 +861,7 @@ namespace Volt auto& relComp = currentEntity.GetComponent(); for (const auto& childId : relComp.children) { - Entity child{ childId, this }; + Entity child{ m_entityRegistry.GetHandleFromUUID(childId), this }; outChild |= (parent.GetID() == childId) && (childId != parent.GetID()); @@ -847,7 +913,7 @@ namespace Volt void Scene::RemoveEntityInternal(Entity entity, bool removingParent) { - if (!m_registry.valid(entity.GetID())) + if (!m_registry.valid(entity)) { return; } @@ -855,9 +921,9 @@ namespace Volt if (entity.HasComponent()) { auto& relComp = entity.GetComponent(); - if (relComp.parent != entt::null) + if (relComp.parent != Entity::NullID()) { - Entity parentEnt = { relComp.parent, this }; + Entity parentEnt = { m_entityRegistry.GetHandleFromUUID(relComp.parent), this }; if (parentEnt.HasComponent() && !removingParent) { @@ -873,7 +939,7 @@ namespace Volt for (int32_t i = static_cast(relComp.children.size()) - 1; i >= 0; --i) { - Entity childEnt{ relComp.children.at(i), this }; + Entity childEnt{ m_entityRegistry.GetHandleFromUUID(relComp.children.at(i)), this }; RemoveEntityInternal(childEnt, true); relComp = entity.GetComponent(); @@ -888,7 +954,8 @@ namespace Volt } } - m_registry.destroy(entity.GetID()); + m_entityRegistry.RemoveEntity(entity); + m_registry.destroy(entity); } void Scene::AddLayer(const std::string& layerName, uint32_t layerId) @@ -1182,14 +1249,14 @@ namespace Volt return std::find_if(m_sceneLayers.begin(), m_sceneLayers.end(), [layerId](const auto& lhs) { return lhs.id == layerId; }) != m_sceneLayers.end(); } - const std::vector Scene::GetAllEntities() const + const std::vector Scene::GetAllEntities() const { - std::vector result{}; + std::vector result{}; result.reserve(m_registry.alive()); m_registry.each([&](const entt::entity id) { - result.emplace_back(id); + result.emplace_back(Entity{ id, const_cast(this) }); // Doubtable }); return result; diff --git a/Volt/Volt/src/Volt/Scene/Scene.h b/Volt/Volt/src/Volt/Scene/Scene.h index fe2eccdc4..6c7732683 100644 --- a/Volt/Volt/src/Volt/Scene/Scene.h +++ b/Volt/Volt/src/Volt/Scene/Scene.h @@ -7,12 +7,12 @@ #include "Volt/Audio/AudioSystem.h" #include "Volt/Vision/TimelinePlayer.h" +#include "Volt/Scene/EntityRegistry.h" + #include "Volt/Scripting/Mono/MonoScriptFieldCache.h" #include -#include - #include #include @@ -110,13 +110,18 @@ namespace Volt void SetRenderSize(uint32_t aWidth, uint32_t aHeight); - Entity CreateEntity(const std::string& tag = "", const entt::entity hintId = entt::null); + Entity CreateEntity(const std::string& tag = ""); + Entity CreateEntityWithUUID(const EntityID& uuid, const std::string& tag = ""); + + Entity GetEntityFromUUID(const EntityID uuid) const; + entt::entity GetHandleFromUUID(const EntityID uuid) const; + void RemoveEntity(Entity entity); void ParentEntity(Entity parent, Entity child); void UnparentEntity(Entity entity); - void InvalidateEntityTransform(entt::entity entity); + void InvalidateEntityTransform(const EntityID& entityUUID); Vision& GetVision() { return *m_visionSystem; } TimelinePlayer& GetTimelinePlayer() { return m_timelinePlayer; }; @@ -124,18 +129,21 @@ namespace Volt Entity InstantiateSplitMesh(AssetHandle meshHandle); const TQS GetWorldTQS(Entity entity) const; - const Entity GetEntityWithName(std::string name); + const bool IsEntityValid(EntityID entityId) const; inline ParticleSystem& GetParticleSystem() { return m_particleSystem; } template - const std::vector GetAllEntitiesWith() const; + const std::vector GetAllEntitiesWith() const; + + template + std::vector GetAllEntitiesWith(); template void ForEachWithComponents(const F& func); - const std::vector GetAllEntities() const; + const std::vector GetAllEntities() const; static const std::set GetDependencyList(const std::filesystem::path& scenePath); static bool IsSceneFullyLoaded(const std::filesystem::path& scenePath); @@ -198,9 +206,11 @@ namespace Volt std::vector m_sceneLayers; - mutable std::unordered_map m_cachedEntityTransforms; + mutable std::unordered_map m_cachedEntityTransforms; mutable std::shared_mutex m_cachedEntityTransformMutex; + EntityRegistry m_entityRegistry{}; + uint32_t m_viewportWidth = 1; uint32_t m_viewportHeight = 1; @@ -217,14 +227,28 @@ namespace Volt }; template - inline const std::vector Scene::GetAllEntitiesWith() const + inline std::vector Scene::GetAllEntitiesWith() + { + std::vector result{}; + + auto view = m_registry.view(); + for (const auto& ent : view) + { + result.emplace_back(GetEntityFromUUID(m_entityRegistry.GetUUIDFromHandle(ent))); + } + + return result; + } + + template + inline const std::vector Scene::GetAllEntitiesWith() const { - std::vector result{}; + std::vector result{}; auto view = m_registry.view(); for (const auto& ent : view) { - result.emplace_back(ent); + result.emplace_back(GetEntityFromUUID(m_entityRegistry.GetUUIDFromHandle(ent))); } return result; diff --git a/Volt/Volt/src/Volt/Scene/SceneManager.cpp b/Volt/Volt/src/Volt/Scene/SceneManager.cpp index adc6cef43..0535b7fb1 100644 --- a/Volt/Volt/src/Volt/Scene/SceneManager.cpp +++ b/Volt/Volt/src/Volt/Scene/SceneManager.cpp @@ -5,6 +5,6 @@ namespace Volt { void SceneManager::Shutdown() { - myActiveScene.reset(); + myActiveScene.Reset(); } } diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.cpp b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.cpp index 9a76b69c1..214ca633e 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.cpp +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.cpp @@ -59,7 +59,7 @@ namespace Volt std::map> scriptInstances; std::map> coreInstances; - std::unordered_map> scriptEntities; + std::unordered_map> scriptEntities; std::unordered_map scriptFieldsDefault; std::vector scriptOnCreateQueue; @@ -359,7 +359,7 @@ namespace Volt if (scriptClass->IsSubclassOf(s_monoData->coreScriptClass)) { s_monoData->scriptClasses.emplace(typeName, scriptClass); - SetScriptFieldDefaultData(1, entt::null, typeName); + SetScriptFieldDefaultData(1, Entity::NullID(), typeName); } else { @@ -435,7 +435,7 @@ namespace Volt s_monoData->scriptClasses.emplace(typeName, scriptClass); } - SetScriptFieldDefaultData(1, entt::null, typeName); + SetScriptFieldDefaultData(1, Entity::NullID(), typeName); } MonoScriptUtils::RegisterArrayTypes(); @@ -511,7 +511,7 @@ namespace Volt VT_CORE_INFO("[MonoScriptEngine] C# Assembly has been reloaded!"); } - void MonoScriptEngine::OnAwakeInstance(UUID instanceId, entt::entity entity, const std::string& fullClassName) + void MonoScriptEngine::OnAwakeInstance(UUID instanceId, EntityID entity, const std::string& fullClassName) { if (!EntityClassExists(fullClassName)) { @@ -540,7 +540,7 @@ namespace Volt { if (fieldInstance->field.type.IsEntity()) { - entt::entity fieldEnt = *fieldInstance->data.As(); + EntityID fieldEnt = *fieldInstance->data.As(); auto fieldEntInstance = GetOrCreateMonoEntity(fieldEnt); auto instanceObject = MonoGCManager::GetObjectFromHandle(instance->GetHandle()); @@ -602,7 +602,7 @@ namespace Volt } } - void MonoScriptEngine::OnCreateInstance(UUID instanceId, entt::entity entity, const std::string& fullClassName) + void MonoScriptEngine::OnCreateInstance(UUID instanceId, EntityID entity, const std::string& fullClassName) { if (s_monoData->scriptInstances.contains(instanceId)) { @@ -770,7 +770,7 @@ namespace Volt return s_monoData->scriptInstances.at(instanceId); } - Ref MonoScriptEngine::GetEntityFromId(entt::entity id) + Ref MonoScriptEngine::GetEntityFromId(EntityID id) { if (!s_monoData->scriptEntities.contains(id)) { @@ -780,12 +780,12 @@ namespace Volt return s_monoData->scriptEntities.at(id); } - Ref MonoScriptEngine::GetOrCreateMonoEntity(entt::entity id) + Ref MonoScriptEngine::GetOrCreateMonoEntity(EntityID id) { if (!s_monoData->scriptEntities.contains(id)) { std::vector scriptIds; - Entity entity = { id, s_monoData->sceneContext }; + Entity entity = s_monoData->sceneContext->GetEntityFromUUID(id); if (entity.HasComponent()) { @@ -808,7 +808,7 @@ namespace Volt return s_monoData->scriptFieldsDefault[fullClassName]; } - void MonoScriptEngine::SetScriptFieldDefaultData(UUID instanceId, entt::entity entity, const std::string& fullClassName) + void MonoScriptEngine::SetScriptFieldDefaultData(UUID instanceId, EntityID entity, const std::string& fullClassName) { if (!EntityClassExists(fullClassName)) { diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.h b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.h index 062e93ced..df56bd9bb 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.h +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEngine.h @@ -48,8 +48,8 @@ namespace Volt static bool EntityClassExists(const std::string& fullClassName); - static void OnAwakeInstance(UUID instanceId, entt::entity entity, const std::string& fullClassName); - static void OnCreateInstance(UUID instanceId, entt::entity entity, const std::string& fullClassName); + static void OnAwakeInstance(UUID instanceId, EntityID entity, const std::string& fullClassName); + static void OnCreateInstance(UUID instanceId, EntityID entity, const std::string& fullClassName); static void OnUpdateInstance(UUID instanceId, float deltaTime); static void OnRenderUIInstance(UUID instanceId); static void OnDestroyInstance(UUID instanceId); @@ -79,12 +79,12 @@ namespace Volt static const Ref GetScriptClass(const std::string& name); static Ref GetInstanceFromId(UUID instanceId); - static Ref GetEntityFromId(entt::entity entityId); - static Ref GetOrCreateMonoEntity(entt::entity entity); + static Ref GetEntityFromId(EntityID entityId); + static Ref GetOrCreateMonoEntity(EntityID entity); static MonoScriptFieldMap& GetDefaultScriptFieldMap(std::string fullClassName); - static void SetScriptFieldDefaultData(UUID instanceId, entt::entity entity, const std::string& fullClassName); + static void SetScriptFieldDefaultData(UUID instanceId, EntityID entity, const std::string& fullClassName); static void CallMethod(GCHandle instanceHandle, MonoMethod* method, void** args = nullptr); static void CallStaticMethod(MonoMethod* method, void** args = nullptr); diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.cpp b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.cpp index 46fee4315..b903baa95 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.cpp +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.cpp @@ -6,7 +6,7 @@ namespace Volt { - MonoScriptEntity::MonoScriptEntity(const entt::entity& id, const std::vector& scripts, Ref klass) + MonoScriptEntity::MonoScriptEntity(const EntityID& id, const std::vector& scripts, Ref klass) { myEntity = id; myMonoClass = klass; diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.h b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.h index 5bd9fe731..1d232fd04 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.h +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptEntity.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "Volt/Scene/EntityID.h" extern "C" { @@ -17,7 +17,7 @@ namespace Volt { struct EntityParams { - entt::entity id; + EntityID id; MonoArray* scriptIds; }; @@ -27,13 +27,13 @@ namespace Volt class MonoScriptEntity { public: - MonoScriptEntity(const entt::entity& id, const std::vector& scripts, Ref klass); + MonoScriptEntity(const EntityID& id, const std::vector& scripts, Ref klass); ~MonoScriptEntity(); void UpdateTimers(); inline Ref GetClass() const { return myMonoClass; } - inline entt::entity GetEntityId() const { return myEntity; } + inline EntityID GetEntityId() const { return myEntity; } inline const GCHandle GetHandle() const { return myHandle; } private: @@ -42,6 +42,6 @@ namespace Volt MonoMethod* myUpdateTimersMethod = nullptr; GCHandle myHandle = nullptr; - entt::entity myEntity; + EntityID myEntity; }; } diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptGlue.cpp b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptGlue.cpp index e4bc3385b..f518a4d31 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptGlue.cpp +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptGlue.cpp @@ -111,29 +111,29 @@ namespace Volt #pragma region Entity - inline static bool Entity_IsValid(entt::entity entityId) + inline static bool Entity_IsValid(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - return scene->GetRegistry().valid(entityId); + return scene->IsEntityValid(entityId); } - inline static bool Entity_HasComponent(entt::entity entityId, MonoString* componentType) + inline static bool Entity_HasComponent(EntityID entityId, MonoString* componentType) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); const auto compName = MonoScriptUtils::GetStringFromMonoString(componentType); const VoltGUID guid = VoltGUID::FromStringInternal(compName.c_str() + 1); - return ComponentRegistry::Helpers::HasComponentWithGUID(guid, scene->GetRegistry(), entityId); + return ComponentRegistry::Helpers::HasComponentWithGUID(guid, scene->GetRegistry(), entity); } - inline static bool Entity_HasScript(entt::entity entityId, MonoString* scriptType) + inline static bool Entity_HasScript(EntityID entityId, MonoString* scriptType) { Scene* scene = MonoScriptEngine::GetSceneContext(); const auto scriptName = MonoScriptUtils::GetStringFromMonoString(scriptType); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -168,12 +168,12 @@ namespace Volt return false; } - inline static MonoObject* Entity_GetScript(entt::entity entityId, MonoString* scriptType) + inline static MonoObject* Entity_GetScript(EntityID entityId, MonoString* scriptType) { Scene* scene = MonoScriptEngine::GetSceneContext(); const auto scriptName = MonoScriptUtils::GetStringFromMonoString(scriptType); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -218,18 +218,19 @@ namespace Volt return nullptr; } - inline static void Entity_RemoveComponent(entt::entity entityId, MonoString* componentType) + inline static void Entity_RemoveComponent(EntityID entityId, MonoString* componentType) { Scene* scene = MonoScriptEngine::GetSceneContext(); + Entity entity = scene->GetEntityFromUUID(entityId); const auto compName = MonoScriptUtils::GetStringFromMonoString(componentType); - ComponentRegistry::Helpers::RemoveComponentWithGUID(VoltGUID::FromStringInternal(compName.c_str() + 1), scene->GetRegistry(), entityId); + ComponentRegistry::Helpers::RemoveComponentWithGUID(VoltGUID::FromStringInternal(compName.c_str() + 1), scene->GetRegistry(), entity); } - inline static void Entity_RemoveScript(entt::entity entityId, UUID scriptId) + inline static void Entity_RemoveScript(EntityID entityId, UUID scriptId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto& scriptsIdList = entity.GetComponent().scriptIds; auto& scriptsNamesList = entity.GetComponent().scriptNames; @@ -243,23 +244,24 @@ namespace Volt MonoScriptEngine::OnDestroyInstance(scriptId); } - inline static void Entity_AddComponent(entt::entity entityId, MonoString* componentType) + inline static void Entity_AddComponent(EntityID entityId, MonoString* componentType) { Scene* scene = MonoScriptEngine::GetSceneContext(); - const auto compName = MonoScriptUtils::GetStringFromMonoString(componentType); + Entity entity = scene->GetEntityFromUUID(entityId); + const auto compName = MonoScriptUtils::GetStringFromMonoString(componentType); const auto guid = VoltGUID::FromStringInternal(compName.c_str() + 1); - if (!ComponentRegistry::Helpers::HasComponentWithGUID(guid, scene->GetRegistry(), entityId)) + if (!ComponentRegistry::Helpers::HasComponentWithGUID(guid, scene->GetRegistry(), entity)) { - ComponentRegistry::Helpers::AddComponentWithGUID(guid, scene->GetRegistry(), entityId); + ComponentRegistry::Helpers::AddComponentWithGUID(guid, scene->GetRegistry(), entity); } } - inline static void Entity_AddScript(entt::entity entityId, MonoString* scriptType, UUID* outScriptId) + inline static void Entity_AddScript(EntityID entityId, MonoString* scriptType, UUID* outScriptId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId);; const auto scriptName = MonoScriptUtils::GetStringFromMonoString(scriptType); if (!entity.HasComponent()) @@ -297,10 +299,10 @@ namespace Volt return nullptr; } - inline static MonoObject* Entity_FindById(entt::entity entityId) + inline static MonoObject* Entity_FindById(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity = { entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.IsValid()) { @@ -335,10 +337,10 @@ namespace Volt return nullptr; } - inline static void RecursiveCreatePrefabEntities(entt::entity entId) + inline static void RecursiveCreatePrefabEntities(EntityID entId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity = { entId, scene }; + Entity entity = scene->GetEntityFromUUID(entId); Volt::MonoScriptEngine::GetOrCreateMonoEntity(entId); if (entity.HasComponent()) @@ -384,11 +386,11 @@ namespace Volt return nullptr; } - inline static void Entity_DeleteEntity(entt::entity entityId) + inline static void Entity_DeleteEntity(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity) { @@ -400,10 +402,10 @@ namespace Volt } } - inline static MonoObject* Entity_Clone(entt::entity entityId) + inline static MonoObject* Entity_Clone(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity oldEntity = { entityId, scene }; + Entity oldEntity = scene->GetEntityFromUUID(entityId); Entity newEntity = scene->CreateEntity(); Entity::Copy(oldEntity, newEntity); @@ -510,7 +512,7 @@ namespace Volt const auto compName = MonoScriptUtils::GetStringFromMonoString(componentType); const VoltGUID guid = VoltGUID::FromStringInternal(compName.c_str() + 1); - std::vector entities; + std::vector entities; scene->GetRegistry().each([&](const entt::entity id) { @@ -537,7 +539,7 @@ namespace Volt for (uint32_t i = 0; i < entities.size(); ++i) { - Entity entity{ entities[i], scene }; + auto entity = entities[i]; if (entity.HasComponent()) { @@ -585,20 +587,20 @@ namespace Volt return MonoGCManager::GetObjectFromHandle(monoEntity->GetHandle()); } - inline static void Scene_CreateDynamicPhysicsActor(entt::entity id) + inline static void Scene_CreateDynamicPhysicsActor(EntityID id) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); entity.AddComponent(BodyType::Dynamic); } #pragma endregion #pragma region TransformComponent - inline static void TransformComponent_GetPosition(entt::entity entityId, glm::vec3* outPosition) + inline static void TransformComponent_GetPosition(EntityID entityId, glm::vec3* outPosition) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -613,10 +615,10 @@ namespace Volt *outPosition = entity.GetPosition(); } - inline static void TransformComponent_SetPosition(entt::entity entityId, glm::vec3* translation) + inline static void TransformComponent_SetPosition(EntityID entityId, glm::vec3* translation) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -631,10 +633,10 @@ namespace Volt entity.SetPosition(*translation); } - inline static void TransformComponent_GetRotation(entt::entity entityId, glm::quat* outRotation) + inline static void TransformComponent_GetRotation(EntityID entityId, glm::quat* outRotation) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -649,10 +651,10 @@ namespace Volt *outRotation = entity.GetRotation(); } - inline static void TransformComponent_SetRotation(entt::entity entityId, glm::quat* rotation) + inline static void TransformComponent_SetRotation(EntityID entityId, glm::quat* rotation) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -667,10 +669,10 @@ namespace Volt entity.SetRotation(*rotation); } - inline static void TransformComponent_GetScale(entt::entity entityId, glm::vec3* outScale) + inline static void TransformComponent_GetScale(EntityID entityId, glm::vec3* outScale) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -685,10 +687,10 @@ namespace Volt *outScale = entity.GetLocalScale(); } - inline static void TransformComponent_SetScale(entt::entity entityId, glm::vec3* scale) + inline static void TransformComponent_SetScale(EntityID entityId, glm::vec3* scale) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -703,10 +705,10 @@ namespace Volt entity.SetLocalScale(*scale); } - inline static void TransformComponent_GetForward(entt::entity entityId, glm::vec3* outForward) + inline static void TransformComponent_GetForward(EntityID entityId, glm::vec3* outForward) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -721,10 +723,10 @@ namespace Volt *outForward = entity.GetForward(); } - inline static void TransformComponent_GetRight(entt::entity entityId, glm::vec3* outRight) + inline static void TransformComponent_GetRight(EntityID entityId, glm::vec3* outRight) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -739,10 +741,10 @@ namespace Volt *outRight = entity.GetRight(); } - inline static void TransformComponent_GetUp(entt::entity entityId, glm::vec3* outUp) + inline static void TransformComponent_GetUp(EntityID entityId, glm::vec3* outUp) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -757,10 +759,10 @@ namespace Volt *outUp = entity.GetUp(); } - inline static void TransformComponent_GetLocalPosition(entt::entity entityId, glm::vec3* outPosition) + inline static void TransformComponent_GetLocalPosition(EntityID entityId, glm::vec3* outPosition) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -775,10 +777,10 @@ namespace Volt *outPosition = entity.GetLocalPosition(); } - inline static void TransformComponent_SetLocalPosition(entt::entity entityId, glm::vec3* translation) + inline static void TransformComponent_SetLocalPosition(EntityID entityId, glm::vec3* translation) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -793,10 +795,10 @@ namespace Volt entity.SetLocalPosition(*translation); } - inline static void TransformComponent_GetLocalRotation(entt::entity entityId, glm::quat* outRotation) + inline static void TransformComponent_GetLocalRotation(EntityID entityId, glm::quat* outRotation) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -811,10 +813,10 @@ namespace Volt *outRotation = entity.GetLocalRotation(); } - inline static void TransformComponent_SetLocalRotation(entt::entity entityId, glm::quat* rotation) + inline static void TransformComponent_SetLocalRotation(EntityID entityId, glm::quat* rotation) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -829,10 +831,10 @@ namespace Volt entity.SetLocalRotation(*rotation); } - inline static void TransformComponent_GetLocalScale(entt::entity entityId, glm::vec3* outScale) + inline static void TransformComponent_GetLocalScale(EntityID entityId, glm::vec3* outScale) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -847,10 +849,10 @@ namespace Volt *outScale = entity.GetLocalScale(); } - inline static void TransformComponent_SetLocalScale(entt::entity entityId, glm::vec3* scale) + inline static void TransformComponent_SetLocalScale(EntityID entityId, glm::vec3* scale) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -865,10 +867,10 @@ namespace Volt entity.SetLocalScale(*scale); } - inline static void TransformComponent_GetLocalForward(entt::entity entityId, glm::vec3* outForward) + inline static void TransformComponent_GetLocalForward(EntityID entityId, glm::vec3* outForward) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -883,10 +885,10 @@ namespace Volt *outForward = entity.GetLocalForward(); } - inline static void TransformComponent_GetLocalRight(entt::entity entityId, glm::vec3* outRight) + inline static void TransformComponent_GetLocalRight(EntityID entityId, glm::vec3* outRight) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -901,10 +903,10 @@ namespace Volt *outRight = entity.GetLocalRight(); } - inline static void TransformComponent_GetLocalUp(entt::entity entityId, glm::vec3* outUp) + inline static void TransformComponent_GetLocalUp(EntityID entityId, glm::vec3* outUp) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -919,10 +921,10 @@ namespace Volt *outUp = entity.GetLocalUp(); } - inline static bool TransformComponent_GetVisible(entt::entity entityId) + inline static bool TransformComponent_GetVisible(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -932,10 +934,10 @@ namespace Volt return entity.IsVisible(); } - inline static void TransformComponent_SetVisible(entt::entity entityId, bool value) + inline static void TransformComponent_SetVisible(EntityID entityId, bool value) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -947,10 +949,10 @@ namespace Volt #pragma endregion #pragma region TagComponent - inline static void TagComponent_SetTag(entt::entity entityId, MonoString* tag) + inline static void TagComponent_SetTag(EntityID entityId, MonoString* tag) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -966,10 +968,10 @@ namespace Volt entity.GetComponent().tag = str; } - inline static MonoString* TagComponent_GetTag(entt::entity entityId) + inline static MonoString* TagComponent_GetTag(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity) { @@ -1013,18 +1015,18 @@ namespace Volt #pragma endregion #pragma region RelationshipComponent - inline static MonoArray* RelationshipComponent_GetChildren(entt::entity entityId) + inline static MonoArray* RelationshipComponent_GetChildren(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); return MonoScriptUtils::CreateMonoArrayEntity(entity.GetComponent().children); } - inline static MonoObject* RelationshipComponent_FindByName(entt::entity entityId, MonoString* name) + inline static MonoObject* RelationshipComponent_FindByName(EntityID entityId, MonoString* name) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); const auto entityName = MonoScriptUtils::GetStringFromMonoString(name); @@ -1033,10 +1035,10 @@ namespace Volt return nullptr; } - entt::entity childId = entt::null; + EntityID childId = Entity::NullID(); for (const auto& c : entity.GetComponent().children) { - Entity child{ c, scene }; + Entity child = scene->GetEntityFromUUID(c); if (child.GetTag() == entityName) { @@ -1045,7 +1047,7 @@ namespace Volt } } - Entity child{ childId, scene }; + Entity child = scene->GetEntityFromUUID(childId); if (child.IsValid()) { @@ -1061,10 +1063,10 @@ namespace Volt return nullptr; } - inline static MonoObject* RelationshipComponent_GetParent(uint32_t entityId) + inline static MonoObject* RelationshipComponent_GetParent(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.IsValid()) { @@ -1082,11 +1084,11 @@ namespace Volt return monoObject; } - inline static void RelationshipComponent_SetParent(entt::entity entityId, entt::entity parentEntityId) + inline static void RelationshipComponent_SetParent(EntityID entityId, EntityID parentEntityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; - Volt::Entity parentEntity{ parentEntityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); + Entity parentEntity = scene->GetEntityFromUUID(parentEntityId); if (entity.GetParent()) { @@ -1101,10 +1103,10 @@ namespace Volt #pragma endregion #pragma region RigidbodyComponent - inline static BodyType RigidbodyComponent_GetBodyType(entt::entity entityId) + inline static BodyType RigidbodyComponent_GetBodyType(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1115,10 +1117,10 @@ namespace Volt return BodyType::Static; } - inline static void RigidbodyComponent_SetBodyType(entt::entity entityId, BodyType* bodyType) + inline static void RigidbodyComponent_SetBodyType(EntityID entityId, BodyType* bodyType) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1139,10 +1141,10 @@ namespace Volt } } - inline static uint32_t RigidbodyComponent_GetLayerId(entt::entity entityId) + inline static uint32_t RigidbodyComponent_GetLayerId(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1153,10 +1155,10 @@ namespace Volt return 0; } - inline static void RigidbodyComponent_SetLayerId(entt::entity entityId, uint32_t* layerId) + inline static void RigidbodyComponent_SetLayerId(EntityID entityId, uint32_t* layerId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1174,10 +1176,10 @@ namespace Volt actor->SetSimulationData(*layerId); } - inline static float RigidbodyComponent_GetMass(entt::entity entityId) + inline static float RigidbodyComponent_GetMass(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1188,10 +1190,10 @@ namespace Volt return 0.f; } - inline static void RigidbodyComponent_SetMass(entt::entity entityId, float* mass) + inline static void RigidbodyComponent_SetMass(EntityID entityId, float* mass) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1209,10 +1211,10 @@ namespace Volt actor->SetMass(*mass); } - inline static void RigidbodyComponent_SetLinearDrag(entt::entity entityId, float* linearDrag) + inline static void RigidbodyComponent_SetLinearDrag(EntityID entityId, float* linearDrag) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1230,10 +1232,10 @@ namespace Volt actor->SetLinearDrag(*linearDrag); } - inline static float RigidbodyComponent_GetLinearDrag(entt::entity entityId) + inline static float RigidbodyComponent_GetLinearDrag(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1244,10 +1246,10 @@ namespace Volt return 0.f; } - inline static void RigidbodyComponent_SetAngularDrag(entt::entity entityId, float* angularDrag) + inline static void RigidbodyComponent_SetAngularDrag(EntityID entityId, float* angularDrag) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1265,10 +1267,10 @@ namespace Volt actor->SetAngularDrag(*angularDrag); } - inline static float RigidbodyComponent_GetAngularDrag(entt::entity entityId) + inline static float RigidbodyComponent_GetAngularDrag(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1279,10 +1281,10 @@ namespace Volt return 0.f; } - inline static uint32_t RigidbodyComponent_GetLockFlags(entt::entity entityId) + inline static uint32_t RigidbodyComponent_GetLockFlags(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1293,10 +1295,10 @@ namespace Volt return 0; } - inline static void RigidbodyComponent_SetLockFlags(entt::entity entityId, uint32_t* flags) + inline static void RigidbodyComponent_SetLockFlags(EntityID entityId, uint32_t* flags) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1314,10 +1316,10 @@ namespace Volt actor->SetLockFlags(*flags); } - inline static bool RigidbodyComponent_GetDisableGravity(entt::entity entityId) + inline static bool RigidbodyComponent_GetDisableGravity(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1328,10 +1330,10 @@ namespace Volt return false; } - inline static void RigidbodyComponent_SetDisableGravity(entt::entity entityId, bool* state) + inline static void RigidbodyComponent_SetDisableGravity(EntityID entityId, bool* state) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1349,10 +1351,10 @@ namespace Volt actor->SetGravityDisabled(*state); } - inline static bool RigidbodyComponent_GetIsKinematic(entt::entity entityId) + inline static bool RigidbodyComponent_GetIsKinematic(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1363,10 +1365,10 @@ namespace Volt return false; } - inline static void RigidbodyComponent_SetIsKinematic(entt::entity entityId, bool* state) + inline static void RigidbodyComponent_SetIsKinematic(EntityID entityId, bool* state) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1384,10 +1386,10 @@ namespace Volt actor->SetKinematic(*state); } - inline static CollisionDetectionType RigidbodyComponent_GetCollisionDetectionType(entt::entity entityId) + inline static CollisionDetectionType RigidbodyComponent_GetCollisionDetectionType(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1398,10 +1400,10 @@ namespace Volt return CollisionDetectionType::Discrete; } - inline static void RigidbodyComponent_SetCollisionDetectionType(entt::entity entityId, CollisionDetectionType* collisionDetectionType) + inline static void RigidbodyComponent_SetCollisionDetectionType(EntityID entityId, CollisionDetectionType* collisionDetectionType) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1411,10 +1413,10 @@ namespace Volt #pragma endregion #pragma region CharacterControllerComponent - inline static float CharacterControllerComponent_GetSlopeLimit(entt::entity entityId) + inline static float CharacterControllerComponent_GetSlopeLimit(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1425,10 +1427,10 @@ namespace Volt return 0.f; } - inline static void CharacterControllerComponent_SetSlopeLimit(entt::entity entityId, float slopeLimit) + inline static void CharacterControllerComponent_SetSlopeLimit(EntityID entityId, float slopeLimit) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -1438,10 +1440,10 @@ namespace Volt entity.GetComponent().slopeLimit = slopeLimit; } - inline static float CharacterControllerComponent_GetInvisibleWallHeight(entt::entity entityId) + inline static float CharacterControllerComponent_GetInvisibleWallHeight(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1452,10 +1454,10 @@ namespace Volt return 0.f; } - inline static void CharacterControllerComponent_SetInvisibleWallHeight(entt::entity entityId, float invisibleWallHeight) + inline static void CharacterControllerComponent_SetInvisibleWallHeight(EntityID entityId, float invisibleWallHeight) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1463,10 +1465,10 @@ namespace Volt } } - inline static float CharacterControllerComponent_GetMaxJumpHeight(entt::entity entityId) + inline static float CharacterControllerComponent_GetMaxJumpHeight(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1477,10 +1479,10 @@ namespace Volt return 0.f; } - inline static void CharacterControllerComponent_SetMaxJumpHeight(entt::entity entityId, float maxJumpHeight) + inline static void CharacterControllerComponent_SetMaxJumpHeight(EntityID entityId, float maxJumpHeight) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1488,10 +1490,10 @@ namespace Volt } } - inline static float CharacterControllerComponent_GetContactOffset(entt::entity entityId) + inline static float CharacterControllerComponent_GetContactOffset(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1502,10 +1504,10 @@ namespace Volt return 0.f; } - inline static void CharacterControllerComponent_SetContactOffset(entt::entity entityId, float contactOffset) + inline static void CharacterControllerComponent_SetContactOffset(EntityID entityId, float contactOffset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1513,10 +1515,10 @@ namespace Volt } } - inline static float CharacterControllerComponent_GetStepOffset(entt::entity entityId) + inline static float CharacterControllerComponent_GetStepOffset(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1527,10 +1529,10 @@ namespace Volt return 0.f; } - inline static void CharacterControllerComponent_SetStepOffset(entt::entity entityId, float stepOffset) + inline static void CharacterControllerComponent_SetStepOffset(EntityID entityId, float stepOffset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1538,10 +1540,10 @@ namespace Volt } } - inline static float CharacterControllerComponent_GetDensity(entt::entity entityId) + inline static float CharacterControllerComponent_GetDensity(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1552,10 +1554,10 @@ namespace Volt return 0.f; } - inline static void CharacterControllerComponent_SetDensity(entt::entity entityId, float density) + inline static void CharacterControllerComponent_SetDensity(EntityID entityId, float density) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1563,7 +1565,7 @@ namespace Volt } } - inline static float CharacterControllerComponent_GetGravity(entt::entity entityId) + inline static float CharacterControllerComponent_GetGravity(EntityID entityId) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -1573,7 +1575,7 @@ namespace Volt } Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -1585,7 +1587,7 @@ namespace Volt return actor->GetGravity(); } - inline static void CharacterControllerComponent_SetGravity(entt::entity entityId, float gravity) + inline static void CharacterControllerComponent_SetGravity(EntityID entityId, float gravity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -1595,7 +1597,7 @@ namespace Volt } Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -1607,7 +1609,7 @@ namespace Volt actor->SetGravity(gravity); } - inline static void CharacterControllerComponent_GetAngularVelocity(entt::entity entityId, glm::vec3* outLinearVelocity) + inline static void CharacterControllerComponent_GetAngularVelocity(EntityID entityId, glm::vec3* outLinearVelocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -1617,7 +1619,7 @@ namespace Volt } Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -1629,7 +1631,7 @@ namespace Volt *outLinearVelocity = actor->GetAngularVelocity(); } - inline static void CharacterControllerComponent_GetLinearVelocity(entt::entity entityId, glm::vec3* outLinearVelocity) + inline static void CharacterControllerComponent_GetLinearVelocity(EntityID entityId, glm::vec3* outLinearVelocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -1639,7 +1641,7 @@ namespace Volt } Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -1651,7 +1653,7 @@ namespace Volt *outLinearVelocity = actor->GetLinearVelocity(); } - inline static void CharacterControllerComponent_SetAngularVelocity(entt::entity entityId, glm::vec3* linearVelocity) + inline static void CharacterControllerComponent_SetAngularVelocity(EntityID entityId, glm::vec3* linearVelocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -1661,7 +1663,7 @@ namespace Volt } Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -1673,7 +1675,7 @@ namespace Volt actor->SetAngularVelocity(*linearVelocity); } - inline static void CharacterControllerComponent_SetLinearVelocity(entt::entity entityId, glm::vec3* linearVelocity) + inline static void CharacterControllerComponent_SetLinearVelocity(EntityID entityId, glm::vec3* linearVelocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -1683,7 +1685,7 @@ namespace Volt } Scene* scene = MonoScriptEngine::GetSceneContext(); - Volt::Entity entity{ entityId, scene }; + Volt::Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -1697,10 +1699,10 @@ namespace Volt #pragma endregion #pragma region BoxColliderComponent - inline static void BoxColliderComponent_GetHalfSize(entt::entity entityId, glm::vec3* outHalfSize) + inline static void BoxColliderComponent_GetHalfSize(EntityID entityId, glm::vec3* outHalfSize) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1713,10 +1715,10 @@ namespace Volt } } - inline static void BoxColliderComponent_SetHalfSize(entt::entity entityId, glm::vec3* halfSize) + inline static void BoxColliderComponent_SetHalfSize(EntityID entityId, glm::vec3* halfSize) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().halfSize = *halfSize; @@ -1742,10 +1744,10 @@ namespace Volt } } - inline static void BoxColliderComponent_GetOffset(entt::entity entityId, glm::vec3* outOffset) + inline static void BoxColliderComponent_GetOffset(EntityID entityId, glm::vec3* outOffset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { *outOffset = entity.GetComponent().offset; @@ -1757,10 +1759,10 @@ namespace Volt } } - inline static void BoxColliderComponent_SetOffset(entt::entity entityId, glm::vec3* offset) + inline static void BoxColliderComponent_SetOffset(EntityID entityId, glm::vec3* offset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().offset = *offset; @@ -1786,10 +1788,10 @@ namespace Volt } } - inline static bool BoxColliderComponent_GetIsTrigger(entt::entity entityId) + inline static bool BoxColliderComponent_GetIsTrigger(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { return entity.GetComponent().isTrigger; @@ -1799,10 +1801,10 @@ namespace Volt return false; } - inline static void BoxColliderComponent_SetIsTrigger(entt::entity entityId, bool* isTrigger) + inline static void BoxColliderComponent_SetIsTrigger(EntityID entityId, bool* isTrigger) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().isTrigger = *isTrigger; @@ -1830,10 +1832,10 @@ namespace Volt #pragma endregion #pragma region SphereColliderComponent - inline static float SphereColliderComponent_GetRadius(entt::entity entityId) + inline static float SphereColliderComponent_GetRadius(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1844,10 +1846,10 @@ namespace Volt return 0.f; } - inline static void SphereColliderComponent_SetRadius(entt::entity entityId, float* radius) + inline static void SphereColliderComponent_SetRadius(EntityID entityId, float* radius) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().radius = *radius; @@ -1873,10 +1875,10 @@ namespace Volt } } - inline static void SphereColliderComponent_GetOffset(entt::entity entityId, glm::vec3* outOffset) + inline static void SphereColliderComponent_GetOffset(EntityID entityId, glm::vec3* outOffset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { *outOffset = entity.GetComponent().offset; @@ -1888,10 +1890,10 @@ namespace Volt } } - inline static void SphereColliderComponent_SetOffset(entt::entity entityId, glm::vec3* offset) + inline static void SphereColliderComponent_SetOffset(EntityID entityId, glm::vec3* offset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().offset = *offset; @@ -1917,10 +1919,10 @@ namespace Volt } } - inline static bool SphereColliderComponent_GetIsTrigger(entt::entity entityId) + inline static bool SphereColliderComponent_GetIsTrigger(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { return entity.GetComponent().isTrigger; @@ -1930,10 +1932,10 @@ namespace Volt return false; } - inline static void SphereColliderComponent_SetIsTrigger(entt::entity entityId, bool* isTrigger) + inline static void SphereColliderComponent_SetIsTrigger(EntityID entityId, bool* isTrigger) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().isTrigger = *isTrigger; @@ -1961,10 +1963,10 @@ namespace Volt #pragma endregion #pragma region CapsuleColliderComponent - inline static float CapsuleColliderComponent_GetRadius(entt::entity entityId) + inline static float CapsuleColliderComponent_GetRadius(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -1975,10 +1977,10 @@ namespace Volt return 0.f; } - inline static void CapsuleColliderComponent_SetRadius(entt::entity entityId, float* radius) + inline static void CapsuleColliderComponent_SetRadius(EntityID entityId, float* radius) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().radius = *radius; @@ -2004,10 +2006,10 @@ namespace Volt } } - inline static float CapsuleColliderComponent_GetHeight(entt::entity entityId) + inline static float CapsuleColliderComponent_GetHeight(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { @@ -2018,10 +2020,10 @@ namespace Volt return 0.f; } - inline static void CapsuleColliderComponent_SetHeight(entt::entity entityId, float* height) + inline static void CapsuleColliderComponent_SetHeight(EntityID entityId, float* height) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().height = *height; @@ -2047,10 +2049,10 @@ namespace Volt } } - inline static void CapsuleColliderComponent_GetOffset(entt::entity entityId, glm::vec3* outOffset) + inline static void CapsuleColliderComponent_GetOffset(EntityID entityId, glm::vec3* outOffset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { *outOffset = entity.GetComponent().offset; @@ -2062,10 +2064,10 @@ namespace Volt } } - inline static void CapsuleColliderComponent_SetOffset(entt::entity entityId, glm::vec3* offset) + inline static void CapsuleColliderComponent_SetOffset(EntityID entityId, glm::vec3* offset) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene, }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().offset = *offset; @@ -2091,10 +2093,10 @@ namespace Volt } } - inline static bool CapsuleColliderComponent_GetIsTrigger(entt::entity entityId) + inline static bool CapsuleColliderComponent_GetIsTrigger(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { return entity.GetComponent().isTrigger; @@ -2104,10 +2106,10 @@ namespace Volt return false; } - inline static void CapsuleColliderComponent_SetIsTrigger(entt::entity entityId, bool* isTrigger) + inline static void CapsuleColliderComponent_SetIsTrigger(EntityID entityId, bool* isTrigger) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().isTrigger = *isTrigger; @@ -2135,10 +2137,10 @@ namespace Volt #pragma endregion #pragma region MeshColliderComponent - inline static bool MeshColliderComponent_GetIsConvex(entt::entity entityId) + inline static bool MeshColliderComponent_GetIsConvex(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { return entity.GetComponent().isConvex; @@ -2148,10 +2150,10 @@ namespace Volt return false; } - inline static void MeshColliderComponent_SetIsConvex(entt::entity entityId, bool* isConvex) + inline static void MeshColliderComponent_SetIsConvex(EntityID entityId, bool* isConvex) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().isConvex = *isConvex; @@ -2162,10 +2164,10 @@ namespace Volt } } - inline static bool MeshColliderComponent_GetIsTrigger(entt::entity entityId) + inline static bool MeshColliderComponent_GetIsTrigger(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { return entity.GetComponent().isTrigger; @@ -2175,10 +2177,10 @@ namespace Volt return false; } - inline static void MeshColliderComponent_SetIsTrigger(entt::entity entityId, bool* isTrigger) + inline static void MeshColliderComponent_SetIsTrigger(EntityID entityId, bool* isTrigger) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().isTrigger = *isTrigger; @@ -2189,10 +2191,10 @@ namespace Volt } } - inline static int32_t MeshColliderComponent_GetSubMeshIndex(entt::entity entityId) + inline static int32_t MeshColliderComponent_GetSubMeshIndex(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { return entity.GetComponent().subMeshIndex; @@ -2202,10 +2204,10 @@ namespace Volt return -1; } - inline static void MeshColliderComponent_SetSubMeshIndex(entt::entity entityId, int32_t* subMeshIndex) + inline static void MeshColliderComponent_SetSubMeshIndex(EntityID entityId, int32_t* subMeshIndex) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (entity.HasComponent()) { entity.GetComponent().subMeshIndex = *subMeshIndex; @@ -2216,10 +2218,10 @@ namespace Volt } } - inline static uint64_t MeshColliderComponent_GetColliderMesh(entt::entity entityId) + inline static uint64_t MeshColliderComponent_GetColliderMesh(EntityID entityId) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -2229,10 +2231,10 @@ namespace Volt return entity.GetComponent().colliderMesh; } - inline static void MeshColliderComponent_SetColliderMesh(entt::entity entityId, uint64_t meshHandle) + inline static void MeshColliderComponent_SetColliderMesh(EntityID entityId, uint64_t meshHandle) { Scene* scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -2395,7 +2397,7 @@ namespace Volt #pragma endregion #pragma region PhysicsActor - inline static void PhysicsActor_SetKinematicTarget(entt::entity entityId, glm::vec3* position, glm::quat* rotation) + inline static void PhysicsActor_SetKinematicTarget(EntityID entityId, glm::vec3* position, glm::quat* rotation) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2405,7 +2407,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2417,7 +2419,7 @@ namespace Volt actor->SetKinematicTarget(*position, glm::eulerAngles(*rotation)); } - inline static void PhysicsActor_SetLinearVelocity(entt::entity entityId, glm::vec3* velocity) + inline static void PhysicsActor_SetLinearVelocity(EntityID entityId, glm::vec3* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2427,7 +2429,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2439,7 +2441,7 @@ namespace Volt actor->SetLinearVelocity(*velocity); } - inline static void PhysicsActor_SetAngularVelocity(entt::entity entityId, glm::vec3* velocity) + inline static void PhysicsActor_SetAngularVelocity(EntityID entityId, glm::vec3* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2449,7 +2451,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2461,7 +2463,7 @@ namespace Volt actor->SetAngularVelocity(*velocity); } - inline static void PhysicsActor_GetLinearVelocity(entt::entity entityId, glm::vec3* velocity) + inline static void PhysicsActor_GetLinearVelocity(EntityID entityId, glm::vec3* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2471,7 +2473,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2483,7 +2485,7 @@ namespace Volt *velocity = actor->GetLinearVelocity(); } - inline static void PhysicsActor_GetAngularVelocity(entt::entity entityId, glm::vec3* velocity) + inline static void PhysicsActor_GetAngularVelocity(EntityID entityId, glm::vec3* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2493,7 +2495,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2505,7 +2507,7 @@ namespace Volt *velocity = actor->GetAngularVelocity(); } - inline static void PhysicsActor_SetMaxLinearVelocity(entt::entity entityId, float* velocity) + inline static void PhysicsActor_SetMaxLinearVelocity(EntityID entityId, float* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2515,7 +2517,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2527,7 +2529,7 @@ namespace Volt actor->SetMaxLinearVelocity(*velocity); } - inline static void PhysicsActor_SetMaxAngularVelocity(entt::entity entityId, float* velocity) + inline static void PhysicsActor_SetMaxAngularVelocity(EntityID entityId, float* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2537,7 +2539,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2549,7 +2551,7 @@ namespace Volt actor->SetMaxAngularVelocity(*velocity); } - inline static void PhysicsActor_GetKinematicTargetPosition(entt::entity entityId, glm::vec3* outPosition) + inline static void PhysicsActor_GetKinematicTargetPosition(EntityID entityId, glm::vec3* outPosition) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2559,7 +2561,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2571,7 +2573,7 @@ namespace Volt *outPosition = actor->GetKinematicTargetPosition(); } - inline static void PhysicsActor_GetKinematicTargetRotation(entt::entity entityId, glm::quat* outRotation) + inline static void PhysicsActor_GetKinematicTargetRotation(EntityID entityId, glm::quat* outRotation) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2581,7 +2583,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2593,7 +2595,7 @@ namespace Volt *outRotation = actor->GetKinematicTargetRotation(); } - inline static void PhysicsActor_AddForce(entt::entity entityId, glm::vec3* force, ForceMode forceMode) + inline static void PhysicsActor_AddForce(EntityID entityId, glm::vec3* force, ForceMode forceMode) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2603,7 +2605,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2615,7 +2617,7 @@ namespace Volt actor->AddForce(*force, forceMode); } - inline static void PhysicsActor_AddTorque(entt::entity entityId, glm::vec3* torque, ForceMode forceMode) + inline static void PhysicsActor_AddTorque(EntityID entityId, glm::vec3* torque, ForceMode forceMode) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2625,7 +2627,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2637,7 +2639,7 @@ namespace Volt actor->AddTorque(*torque, forceMode); } - inline static void PhysicsActor_WakeUp(entt::entity entityId) + inline static void PhysicsActor_WakeUp(EntityID entityId) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2647,7 +2649,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2659,7 +2661,7 @@ namespace Volt actor->WakeUp(); } - inline static void PhysicsActor_PutToSleep(entt::entity entityId) + inline static void PhysicsActor_PutToSleep(EntityID entityId) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2669,7 +2671,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetActor(entity); if (!actor) @@ -2683,7 +2685,7 @@ namespace Volt #pragma endregion #pragma region PhysicsControllerActor - inline static float PhysicsControllerActor_GetHeight(entt::entity entityId) + inline static float PhysicsControllerActor_GetHeight(EntityID entityId) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2693,7 +2695,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2705,7 +2707,7 @@ namespace Volt return actor->GetHeight(); } - inline static void PhysicsControllerActor_SetHeight(entt::entity entityId, float height) + inline static void PhysicsControllerActor_SetHeight(EntityID entityId, float height) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2715,7 +2717,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2727,7 +2729,7 @@ namespace Volt actor->SetHeight(height); } - inline static float PhysicsControllerActor_GetRadius(entt::entity entityId) + inline static float PhysicsControllerActor_GetRadius(EntityID entityId) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2737,7 +2739,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2749,7 +2751,7 @@ namespace Volt return actor->GetRadius(); } - inline static void PhysicsControllerActor_SetRadius(entt::entity entityId, float radius) + inline static void PhysicsControllerActor_SetRadius(EntityID entityId, float radius) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2759,7 +2761,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2771,7 +2773,7 @@ namespace Volt actor->SetRadius(radius); } - inline static void PhysicsControllerActor_Move(entt::entity entityId, glm::vec3* velocity) + inline static void PhysicsControllerActor_Move(EntityID entityId, glm::vec3* velocity) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2781,7 +2783,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2793,7 +2795,7 @@ namespace Volt actor->Move(*velocity); } - inline static void PhysicsControllerActor_SetPosition(entt::entity entityId, glm::vec3* position) + inline static void PhysicsControllerActor_SetPosition(EntityID entityId, glm::vec3* position) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2803,7 +2805,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2815,7 +2817,7 @@ namespace Volt actor->SetPosition(*position); } - inline static void PhysicsControllerActor_SetFootPosition(entt::entity entityId, glm::vec3* position) + inline static void PhysicsControllerActor_SetFootPosition(EntityID entityId, glm::vec3* position) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2825,7 +2827,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2837,7 +2839,7 @@ namespace Volt actor->SetFootPosition(*position); } - inline static void PhysicsControllerActor_GetPosition(entt::entity entityId, glm::vec3* position) + inline static void PhysicsControllerActor_GetPosition(EntityID entityId, glm::vec3* position) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2847,7 +2849,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2859,7 +2861,7 @@ namespace Volt *position = actor->GetPosition(); } - inline static void PhysicsControllerActor_GetFootPosition(entt::entity entityId, glm::vec3* position) + inline static void PhysicsControllerActor_GetFootPosition(EntityID entityId, glm::vec3* position) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2869,7 +2871,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2881,7 +2883,7 @@ namespace Volt *position = actor->GetFootPosition(); } - inline static bool PhysicsControllerActor_IsGrounded(entt::entity entityId) + inline static bool PhysicsControllerActor_IsGrounded(EntityID entityId) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2891,7 +2893,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -2903,7 +2905,7 @@ namespace Volt return actor->IsGrounded(); } - inline static void PhysicsControllerActor_Jump(entt::entity entityId, float jumpForce) + inline static void PhysicsControllerActor_Jump(EntityID entityId, float jumpForce) { auto physicsScene = Physics::GetScene(); if (!physicsScene) @@ -2913,7 +2915,7 @@ namespace Volt } auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto actor = physicsScene->GetControllerActor(entity); if (!actor) @@ -3040,10 +3042,10 @@ namespace Volt //EVENT - inline static uint32_t AudioSourceComponent_PlayEvent(entt::entity entityId, MonoString* aEventName) + inline static uint32_t AudioSourceComponent_PlayEvent(EntityID entityId, MonoString* aEventName) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); std::string eventName = MonoScriptUtils::GetStringFromMonoString(aEventName); if (!entity.HasComponent()) @@ -3057,10 +3059,10 @@ namespace Volt return playingID; } - inline static bool AudioSourceComponent_PlayOneshotEvent(entt::entity entityId, MonoString* aEventName) + inline static bool AudioSourceComponent_PlayOneshotEvent(EntityID entityId, MonoString* aEventName) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); std::string eventName = MonoScriptUtils::GetStringFromMonoString(aEventName); if (!entity.HasComponent()) @@ -3071,10 +3073,10 @@ namespace Volt return entity.GetComponent().PlayOneshotEvent(eventName.c_str(), entity.GetPosition(), entity.GetForward(), entity.GetUp()); } - inline static bool AudioSourceComponent_StopEvent(entt::entity entityId, uint32_t aPlayingID) + inline static bool AudioSourceComponent_StopEvent(EntityID entityId, uint32_t aPlayingID) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3084,10 +3086,10 @@ namespace Volt return entity.GetComponent().StopEvent(aPlayingID); } - inline static bool AudioSourceComponent_PauseEvent(entt::entity entityId, uint32_t aPlayingID) + inline static bool AudioSourceComponent_PauseEvent(EntityID entityId, uint32_t aPlayingID) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3097,10 +3099,10 @@ namespace Volt return entity.GetComponent().PauseEvent(aPlayingID); } - inline static bool AudioSourceComponent_ResumeEvent(entt::entity entityId, uint32_t aPlayingID) + inline static bool AudioSourceComponent_ResumeEvent(EntityID entityId, uint32_t aPlayingID) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3110,25 +3112,25 @@ namespace Volt return entity.GetComponent().ResumeEvent(aPlayingID); } - inline static void AudioSourceComponent_StopAllEvents(entt::entity entityId) + inline static void AudioSourceComponent_StopAllEvents(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { return; } - entity.GetComponent().StopEvent(entity.GetUIntID()); + entity.GetComponent().StopEvent(entity.GetID()); } //GAME SYNCS - inline static bool AudioSourceComponent_SetState(entt::entity entityId, MonoString* aStateGroup, MonoString* aState) + inline static bool AudioSourceComponent_SetState(EntityID entityId, MonoString* aStateGroup, MonoString* aState) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3141,10 +3143,10 @@ namespace Volt return entity.GetComponent().SetState(stateGroup.c_str(), stateName.c_str()); } - inline static bool AudioSourceComponent_SetSwitch(entt::entity entityId, MonoString* aSwitchGroup, MonoString* aState) + inline static bool AudioSourceComponent_SetSwitch(EntityID entityId, MonoString* aSwitchGroup, MonoString* aState) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3157,10 +3159,10 @@ namespace Volt return entity.GetComponent().SetSwitch(switchGroup.c_str(), stateName.c_str()); } - inline static bool AudioSourceComponent_SetParameter(entt::entity entityId, MonoString* aParameterName, float aValue) + inline static bool AudioSourceComponent_SetParameter(EntityID entityId, MonoString* aParameterName, float aValue) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3172,10 +3174,10 @@ namespace Volt return entity.GetComponent().SetParameter(parameterName.c_str(), aValue); } - inline static bool AudioSourceComponent_SetParameterOverTime(entt::entity entityId, MonoString* aParameterName, float aValue, uint32_t aOvertime) + inline static bool AudioSourceComponent_SetParameterOverTime(EntityID entityId, MonoString* aParameterName, float aValue, uint32_t aOvertime) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3192,12 +3194,12 @@ namespace Volt #pragma region Vision - inline static void Vision_SetActiveCamera(entt::entity entityId) + inline static void Vision_SetActiveCamera(EntityID entityId) { - MonoScriptEngine::GetSceneContext()->GetVision().SetActiveCamera(Volt::Entity{ entityId, MonoScriptEngine::GetSceneContext() }); + MonoScriptEngine::GetSceneContext()->GetVision().SetActiveCamera(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(entityId)); } - inline static entt::entity Vision_GetActiveCamera() + inline static EntityID Vision_GetActiveCamera() { const Volt::Entity ent = MonoScriptEngine::GetSceneContext()->GetVision().GetActiveCamera(); if (ent) @@ -3205,47 +3207,47 @@ namespace Volt return ent.GetID(); } - return entt::null; + return Entity::NullID(); } - inline static void Vision_DoCameraShake(entt::entity entityId, Volt::CameraShakeSettings* shakeSettings) + inline static void Vision_DoCameraShake(EntityID entityId, Volt::CameraShakeSettings* shakeSettings) { - MonoScriptEngine::GetSceneContext()->GetVision().DoCameraShake(Volt::Entity{ entityId, MonoScriptEngine::GetSceneContext() }, *shakeSettings); + MonoScriptEngine::GetSceneContext()->GetVision().DoCameraShake(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(entityId), *shakeSettings); } - inline static void Vision_SetCameraFollow(entt::entity cameraId, entt::entity followId) + inline static void Vision_SetCameraFollow(EntityID cameraId, EntityID followId) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraFollow(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, Volt::Entity{ followId, MonoScriptEngine::GetSceneContext() }); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraFollow(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(followId)); } - inline static void Vision_SetCameraLookAt(entt::entity cameraId, entt::entity followId) + inline static void Vision_SetCameraLookAt(EntityID cameraId, EntityID followId) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraLookAt(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, Volt::Entity{ followId, MonoScriptEngine::GetSceneContext() }); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraLookAt(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(followId)); } - inline static void Vision_SetCameraFocusPoint(entt::entity cameraId, entt::entity focusId) + inline static void Vision_SetCameraFocusPoint(EntityID cameraId, EntityID focusId) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraFocusPoint(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, Volt::Entity{ focusId, MonoScriptEngine::GetSceneContext() }); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraFocusPoint(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(focusId)); } - inline static void Vision_SetCameraDampAmount(entt::entity cameraId, float dampAmount) + inline static void Vision_SetCameraDampAmount(EntityID cameraId, float dampAmount) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraDampAmount(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, dampAmount); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraDampAmount(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), dampAmount); } - inline static void Vision_SetCameraFieldOfView(entt::entity cameraId, float aFov) + inline static void Vision_SetCameraFieldOfView(EntityID cameraId, float aFov) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraFieldOfView(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, aFov); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraFieldOfView(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), aFov); } - inline static void Vision_SetCameraLocked(entt::entity cameraId, bool locked) + inline static void Vision_SetCameraLocked(EntityID cameraId, bool locked) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraLocked(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, locked); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraLocked(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), locked); } - inline static void Vision_SetCameraMouseSensentivity(entt::entity cameraId, float mouseSens) + inline static void Vision_SetCameraMouseSensentivity(EntityID cameraId, float mouseSens) { - MonoScriptEngine::GetSceneContext()->GetVision().SetCameraMouseSensentivity(Volt::Entity{ cameraId, MonoScriptEngine::GetSceneContext() }, mouseSens); + MonoScriptEngine::GetSceneContext()->GetVision().SetCameraMouseSensentivity(MonoScriptEngine::GetSceneContext()->GetEntityFromUUID(cameraId), mouseSens); } #pragma endregion @@ -3298,7 +3300,7 @@ namespace Volt #pragma region NavAgentComponent - inline static void NavAgentComponent_GetTarget(entt::entity entityId, glm::vec3* position) + inline static void NavAgentComponent_GetTarget(EntityID entityId, glm::vec3* position) { auto navmesh = Volt::Application::Get().GetNavigationSystem().GetVTNavMesh(); @@ -3308,10 +3310,10 @@ namespace Volt } } - inline static void NavAgentComponent_SetTarget(entt::entity entityId, glm::vec3* position) + inline static void NavAgentComponent_SetTarget(EntityID entityId, glm::vec3* position) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto navmesh = Volt::Application::Get().GetNavigationSystem().GetVTNavMesh(); @@ -3321,7 +3323,7 @@ namespace Volt } } - inline static void NavAgentComponent_GetPosition(entt::entity entityId, glm::vec3* position) + inline static void NavAgentComponent_GetPosition(EntityID entityId, glm::vec3* position) { auto navmesh = Volt::Application::Get().GetNavigationSystem().GetVTNavMesh(); @@ -3331,10 +3333,10 @@ namespace Volt } } - inline static void NavAgentComponent_SetPosition(entt::entity entityId, glm::vec3* position) + inline static void NavAgentComponent_SetPosition(EntityID entityId, glm::vec3* position) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); auto navmesh = Volt::Application::Get().GetNavigationSystem().GetVTNavMesh(); @@ -3344,7 +3346,7 @@ namespace Volt } } - inline static void NavAgentComponent_GetVelocity(entt::entity entityId, glm::vec3* velocity) + inline static void NavAgentComponent_GetVelocity(EntityID entityId, glm::vec3* velocity) { auto navmesh = Volt::Application::Get().GetNavigationSystem().GetVTNavMesh(); @@ -3354,10 +3356,10 @@ namespace Volt } } - inline static void NavAgentComponent_UpdateParams(entt::entity entityId) + inline static void NavAgentComponent_UpdateParams(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3372,10 +3374,10 @@ namespace Volt } } - inline static bool NavAgentComponent_GetActive(entt::entity entityId) + inline static bool NavAgentComponent_GetActive(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3385,10 +3387,10 @@ namespace Volt return entity.GetComponent().active; } - inline static void NavAgentComponent_SetActive(entt::entity entityId, bool value) + inline static void NavAgentComponent_SetActive(EntityID entityId, bool value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3405,10 +3407,10 @@ namespace Volt } } - inline static float NavAgentComponent_GetRadius(entt::entity entityId) + inline static float NavAgentComponent_GetRadius(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3418,10 +3420,10 @@ namespace Volt return entity.GetComponent().radius; } - inline static void NavAgentComponent_SetRadius(entt::entity entityId, float value) + inline static void NavAgentComponent_SetRadius(EntityID entityId, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3432,10 +3434,10 @@ namespace Volt NavAgentComponent_UpdateParams(entityId); } - inline static float NavAgentComponent_GetHeight(entt::entity entityId) + inline static float NavAgentComponent_GetHeight(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3445,10 +3447,10 @@ namespace Volt return entity.GetComponent().height; } - inline static void NavAgentComponent_SetHeight(entt::entity entityId, float value) + inline static void NavAgentComponent_SetHeight(EntityID entityId, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3459,10 +3461,10 @@ namespace Volt NavAgentComponent_UpdateParams(entityId); } - inline static float NavAgentComponent_GetMaxSpeed(entt::entity entityId) + inline static float NavAgentComponent_GetMaxSpeed(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3472,10 +3474,10 @@ namespace Volt return entity.GetComponent().maxSpeed; } - inline static void NavAgentComponent_SetMaxSpeed(entt::entity entityId, float value) + inline static void NavAgentComponent_SetMaxSpeed(EntityID entityId, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3486,10 +3488,10 @@ namespace Volt NavAgentComponent_UpdateParams(entityId); } - inline static float NavAgentComponent_GetAcceleration(entt::entity entityId) + inline static float NavAgentComponent_GetAcceleration(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3499,10 +3501,10 @@ namespace Volt return entity.GetComponent().acceleration; } - inline static void NavAgentComponent_SetAcceleration(entt::entity entityId, float value) + inline static void NavAgentComponent_SetAcceleration(EntityID entityId, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3513,10 +3515,10 @@ namespace Volt NavAgentComponent_UpdateParams(entityId); } - inline static float NavAgentComponent_GetSeperationWeight(entt::entity entityId) + inline static float NavAgentComponent_GetSeperationWeight(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3526,10 +3528,10 @@ namespace Volt return entity.GetComponent().separationWeight; } - inline static void NavAgentComponent_SetSeperationWeight(entt::entity entityId, float value) + inline static void NavAgentComponent_SetSeperationWeight(EntityID entityId, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3540,10 +3542,10 @@ namespace Volt NavAgentComponent_UpdateParams(entityId); } - inline static ObstacleAvoidanceQuality NavAgentComponent_GetObstacleAvoidanceQuality(entt::entity entityId) + inline static ObstacleAvoidanceQuality NavAgentComponent_GetObstacleAvoidanceQuality(EntityID entityId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3553,10 +3555,10 @@ namespace Volt return entity.GetComponent().obstacleAvoidanceQuality; } - inline static void NavAgentComponent_SetObstacleAvoidanceQuality(entt::entity entityId, ObstacleAvoidanceQuality* value) + inline static void NavAgentComponent_SetObstacleAvoidanceQuality(EntityID entityId, ObstacleAvoidanceQuality* value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ entityId, scene }; + Entity entity = scene->GetEntityFromUUID(entityId); if (!entity.HasComponent()) { @@ -3571,10 +3573,10 @@ namespace Volt #pragma region AnimationControllerComponent - inline static void AnimationControllerComponent_SetParameterFloat(entt::entity id, MonoString* name, float value) + inline static void AnimationControllerComponent_SetParameterFloat(EntityID id, MonoString* name, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3596,10 +3598,10 @@ namespace Volt controller->GetGraph()->SetParameterValue(paramName, value); } - inline static void AnimationControllerComponent_SetParameterInt(entt::entity id, MonoString* name, int32_t value) + inline static void AnimationControllerComponent_SetParameterInt(EntityID id, MonoString* name, int32_t value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3621,10 +3623,10 @@ namespace Volt controller->GetGraph()->SetParameterValue(paramName, value); } - inline static void AnimationControllerComponent_SetParameterBool(entt::entity id, MonoString* name, bool value) + inline static void AnimationControllerComponent_SetParameterBool(EntityID id, MonoString* name, bool value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3646,10 +3648,10 @@ namespace Volt controller->GetGraph()->SetParameterValue(paramName, value); } - inline static void AnimationControllerComponent_SetParameterVector3(entt::entity id, MonoString* name, glm::vec3* value) + inline static void AnimationControllerComponent_SetParameterVector3(EntityID id, MonoString* name, glm::vec3* value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3671,10 +3673,10 @@ namespace Volt controller->GetGraph()->SetParameterValue(paramName, value); } - inline static void AnimationControllerComponent_SetParameterString(entt::entity id, MonoString* name, MonoString* value) + inline static void AnimationControllerComponent_SetParameterString(EntityID id, MonoString* name, MonoString* value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3696,10 +3698,10 @@ namespace Volt controller->GetGraph()->SetParameterValue(paramName, value); } - inline static void AnimationControllerComponent_GetBoundingSphere(entt::entity id, glm::vec3* center, float* radius) + inline static void AnimationControllerComponent_GetBoundingSphere(EntityID id, glm::vec3* center, float* radius) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity.HasComponent()) { @@ -3717,10 +3719,10 @@ namespace Volt *radius = animatedCharacter->GetSkin()->GetBoundingSphere().radius; } - inline static float AnimationControllerComponent_GetParameterFloat(entt::entity id, MonoString* name) + inline static float AnimationControllerComponent_GetParameterFloat(EntityID id, MonoString* name) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3742,10 +3744,10 @@ namespace Volt return controller->GetGraph()->GetParameterValue(paramName); } - inline static int AnimationControllerComponent_GetParameterInt(entt::entity id, MonoString* name) + inline static int AnimationControllerComponent_GetParameterInt(EntityID id, MonoString* name) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3767,10 +3769,10 @@ namespace Volt return controller->GetGraph()->GetParameterValue(paramName); } - inline static bool AnimationControllerComponent_GetParameterBool(entt::entity id, MonoString* name) + inline static bool AnimationControllerComponent_GetParameterBool(EntityID id, MonoString* name) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3792,10 +3794,10 @@ namespace Volt return controller->GetGraph()->GetParameterValue(paramName); } - inline static glm::vec3 AnimationControllerComponent_GetParameterVector3(entt::entity id, MonoString* name) + inline static glm::vec3 AnimationControllerComponent_GetParameterVector3(EntityID id, MonoString* name) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3817,10 +3819,10 @@ namespace Volt return controller->GetGraph()->GetParameterValue(paramName); } - inline static std::string AnimationControllerComponent_GetParameterString(entt::entity id, MonoString* name) + inline static std::string AnimationControllerComponent_GetParameterString(EntityID id, MonoString* name) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3842,10 +3844,10 @@ namespace Volt return controller->GetGraph()->GetParameterValue(paramName); } - inline static void AnimationControllerComponent_GetRootMotion(entt::entity id, glm::vec3* value) + inline static void AnimationControllerComponent_GetRootMotion(EntityID id, glm::vec3* value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3865,10 +3867,10 @@ namespace Volt *value = entity.GetComponent().controller->GetRootMotion().position; } - inline static void AnimationControllerComponent_AttachEntity(MonoString* attachmentName, entt::entity id, entt::entity attachId) + inline static void AnimationControllerComponent_AttachEntity(MonoString* attachmentName, EntityID id, EntityID attachId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3886,15 +3888,15 @@ namespace Volt } const std::string str = MonoScriptUtils::GetStringFromMonoString(attachmentName); - Entity attachEntity{ attachId, scene }; + Entity attachEntity = scene->GetEntityFromUUID(attachId); entity.GetComponent().controller->AttachEntity(str, attachEntity); } - inline static void AnimationControllerComponent_DetachEntity(entt::entity id, entt::entity attachId) + inline static void AnimationControllerComponent_DetachEntity(EntityID id, EntityID attachId) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3911,14 +3913,14 @@ namespace Volt return; } - Entity attachEntity{ attachId, scene }; + Entity attachEntity = scene->GetEntityFromUUID(attachId); entity.GetComponent().controller->DetachEntity(attachEntity); } - inline static bool AnimationControllerComponent_HasOverrideMaterial(entt::entity id) + inline static bool AnimationControllerComponent_HasOverrideMaterial(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3933,10 +3935,10 @@ namespace Volt return entity.GetComponent().material != Asset::Null(); } - inline static void AnimationControllerComponent_SetOverrideMaterial(entt::entity id, uint64_t materialHandle) + inline static void AnimationControllerComponent_SetOverrideMaterial(EntityID id, uint64_t materialHandle) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3951,10 +3953,10 @@ namespace Volt entity.GetComponent().material = materialHandle; } - inline static uint64_t AnimationControllerComponent_GetOverrideMaterial(entt::entity id) + inline static uint64_t AnimationControllerComponent_GetOverrideMaterial(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3969,10 +3971,10 @@ namespace Volt return entity.GetComponent().material; } - inline static void AnimationControllerComponent_SetOverrideSkin(entt::entity id, uint64_t skinHandle) + inline static void AnimationControllerComponent_SetOverrideSkin(EntityID id, uint64_t skinHandle) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -3987,10 +3989,10 @@ namespace Volt entity.GetComponent().skin = skinHandle; } - inline static uint64_t AnimationControllerComponent_GetOverrideSkin(entt::entity id) + inline static uint64_t AnimationControllerComponent_GetOverrideSkin(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4005,10 +4007,10 @@ namespace Volt return entity.GetComponent().skin; } - inline static void AnimationControllerComponent_SetController(entt::entity id, uint64_t animGraphHandle) + inline static void AnimationControllerComponent_SetController(EntityID id, uint64_t animGraphHandle) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4029,10 +4031,10 @@ namespace Volt #pragma endregion #pragma region TextRendererComponent - inline static void TextRendererComponent_GetText(entt::entity id, MonoString* outText) + inline static void TextRendererComponent_GetText(EntityID id, MonoString* outText) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4047,10 +4049,10 @@ namespace Volt outText = MonoScriptUtils::GetMonoStringFromString(entity.GetComponent().text); } - inline static void TextRendererComponent_SetText(entt::entity id, MonoString* text) + inline static void TextRendererComponent_SetText(EntityID id, MonoString* text) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4065,10 +4067,10 @@ namespace Volt entity.GetComponent().text = MonoScriptUtils::GetStringFromMonoString(text); } - inline static float TextRendererComponent_GetMaxWidth(entt::entity id) + inline static float TextRendererComponent_GetMaxWidth(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4083,10 +4085,10 @@ namespace Volt return entity.GetComponent().maxWidth; } - inline static void TextRendererComponent_SetMaxWidth(entt::entity id, float value) + inline static void TextRendererComponent_SetMaxWidth(EntityID id, float value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4101,10 +4103,10 @@ namespace Volt entity.GetComponent().maxWidth = value; } - inline static void TextRendererComponent_GetColor(entt::entity id, glm::vec4* outColor) + inline static void TextRendererComponent_GetColor(EntityID id, glm::vec4* outColor) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4119,10 +4121,10 @@ namespace Volt *outColor = entity.GetComponent().color; } - inline static void TextRendererComponent_SetColor(entt::entity id, glm::vec4* value) + inline static void TextRendererComponent_SetColor(EntityID id, glm::vec4* value) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4171,10 +4173,10 @@ namespace Volt #pragma endregion #pragma region MeshComponent - inline static uint64_t MeshComponent_GetMeshHandle(entt::entity id) + inline static uint64_t MeshComponent_GetMeshHandle(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4189,10 +4191,10 @@ namespace Volt return entity.GetComponent().handle; } - inline static void MeshComponent_SetMeshHandle(entt::entity id, AssetHandle handle) + inline static void MeshComponent_SetMeshHandle(EntityID id, AssetHandle handle) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity.HasComponent()) { @@ -4202,10 +4204,10 @@ namespace Volt entity.GetComponent().handle = handle; } - inline static bool MeshComponent_HasOverrideMaterial(entt::entity id) + inline static bool MeshComponent_HasOverrideMaterial(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4220,10 +4222,10 @@ namespace Volt return entity.GetComponent().material != Asset::Null(); } - inline static void MeshComponent_SetOverrideMaterial(entt::entity id, uint64_t materialHandle) + inline static void MeshComponent_SetOverrideMaterial(EntityID id, uint64_t materialHandle) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4238,10 +4240,10 @@ namespace Volt entity.GetComponent().material = materialHandle; } - inline static uint64_t MeshComponent_GetOverrideMaterial(entt::entity id) + inline static uint64_t MeshComponent_GetOverrideMaterial(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4259,10 +4261,10 @@ namespace Volt #pragma region SpotlightComponent - inline static void SpotlightComponent_GetColor(entt::entity id, glm::vec3* outColor) + inline static void SpotlightComponent_GetColor(EntityID id, glm::vec3* outColor) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4277,10 +4279,10 @@ namespace Volt *outColor = entity.GetComponent().color; } - inline static void SpotlightComponent_SetColor(entt::entity id, glm::vec3* color) + inline static void SpotlightComponent_SetColor(EntityID id, glm::vec3* color) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4295,10 +4297,10 @@ namespace Volt entity.GetComponent().color = *color; } - inline static bool SpotlightComponent_GetIntensity(entt::entity id) + inline static bool SpotlightComponent_GetIntensity(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4315,10 +4317,10 @@ namespace Volt return intens; } - inline static void SpotlightComponent_SetIntensity(entt::entity id, float intensity) + inline static void SpotlightComponent_SetIntensity(EntityID id, float intensity) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4338,10 +4340,10 @@ namespace Volt #pragma region PointlightComponent - inline static void PointlightComponent_GetColor(entt::entity id, glm::vec3* outColor) + inline static void PointlightComponent_GetColor(EntityID id, glm::vec3* outColor) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4356,10 +4358,10 @@ namespace Volt *outColor = entity.GetComponent().color; } - inline static void PointlightComponent_SetColor(entt::entity id, glm::vec3* color) + inline static void PointlightComponent_SetColor(EntityID id, glm::vec3* color) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4374,10 +4376,10 @@ namespace Volt entity.GetComponent().color = *color; } - inline static bool PointlightComponent_GetIntensity(entt::entity id) + inline static bool PointlightComponent_GetIntensity(EntityID id) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4392,10 +4394,10 @@ namespace Volt return entity.GetComponent().intensity; } - inline static void PointlightComponent_SetIntensity(entt::entity id, float intensity) + inline static void PointlightComponent_SetIntensity(EntityID id, float intensity) { auto scene = MonoScriptEngine::GetSceneContext(); - Entity entity{ id, scene }; + Entity entity = scene->GetEntityFromUUID(id); if (!entity) { @@ -4811,13 +4813,13 @@ namespace Volt #pragma endregion Animation #pragma region Net - inline static Nexus::TYPE::REP_ID NetActorComponent_GetRepId(uint32_t id) + inline static Nexus::TYPE::REP_ID NetActorComponent_GetRepId(EntityID id) { Scene* scene = MonoScriptEngine::GetSceneContext(); - auto entity = Entity(static_cast(id), scene); + auto entity = scene->GetEntityFromUUID(id); while (!entity.HasComponent()) { - if (entity.GetParent().GetID() == entt::null) return 0; + if (entity.GetParent().GetID() == Entity::NullID()) return 0; entity = entity.GetParent(); } auto netId = entity.GetComponent().repId; @@ -4843,7 +4845,7 @@ namespace Volt Application::Get().GetNetHandler().GetEventContainer().AddOutgoing(NetEvent(netEvent, id, byteVec)); } - inline static void NetEvent_TriggerEventFromLocalId(uint32_t id, eNetEvent netEvent, MonoArray* data) + inline static void NetEvent_TriggerEventFromLocalId(EntityID id, eNetEvent netEvent, MonoArray* data) { NetEvent_TriggerEventFromNetId(NetActorComponent_GetRepId(id), netEvent, data); } @@ -4872,12 +4874,12 @@ namespace Volt else backend->Transmit(packet); } - inline static void NetScene_DestroyFromLocalId(uint32_t id) + inline static void NetScene_DestroyFromLocalId(EntityID id) { NetScene_DestroyFromNetId(NetActorComponent_GetRepId(id)); } - inline static void NetScene_InstantiatePrefabAtEntity(uint64_t handle, uint32_t spawnPoint) + inline static void NetScene_InstantiatePrefabAtEntity(uint64_t handle, EntityID spawnPoint) { auto& handler = Application::Get().GetNetHandler(); @@ -4887,7 +4889,7 @@ namespace Volt auto prefabData = CreatePrefabData(0, clientId, handle); auto scene = MonoScriptEngine::GetSceneContext(); - auto ent = Entity(static_cast(spawnPoint), scene); + auto ent = scene->GetEntityFromUUID(spawnPoint); TransformComponent temp; temp.position = ent.GetPosition(); @@ -4935,7 +4937,7 @@ namespace Volt backend->Transmit(packet); } - inline static void Net_Notify(uint32_t repId, MonoString* fieldName) + inline static void Net_Notify(EntityID repId, MonoString* fieldName) { Net_NotifyFromNetId(NetActorComponent_GetRepId(repId), fieldName); } diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.cpp b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.cpp index 3ecc2a569..28917a0fe 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.cpp +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.cpp @@ -170,7 +170,7 @@ namespace Volt return array; } - MonoArray* MonoScriptUtils::CreateMonoArrayEntity(const std::vector& vector) + MonoArray* MonoScriptUtils::CreateMonoArrayEntity(const std::vector& vector) { auto& coreAssembly = MonoScriptEngine::GetCoreAssembly(); std::vector monoVector; @@ -193,6 +193,29 @@ namespace Volt return array; } + MonoArray* MonoScriptUtils::CreateMonoArrayEntity(const std::vector& vector) + { + auto& coreAssembly = MonoScriptEngine::GetCoreAssembly(); + std::vector monoVector; + + for (uint16_t i = 0; i < vector.size(); ++i) + { + auto monoEnt = MonoScriptEngine::GetEntityFromId(vector[i].GetID()); + if (!monoEnt) + { + monoEnt = MonoScriptEngine::GetOrCreateMonoEntity(vector[i].GetID()); + } + monoVector.emplace_back(MonoGCManager::GetObjectFromHandle(monoEnt->GetHandle())); + } + + MonoArray* array = mono_array_new(coreAssembly.domain, MonoScriptEngine::GetEntityClass()->GetClass(), vector.size()); + for (uint16_t i = 0; i < monoVector.size(); ++i) + { + mono_array_set(array, MonoObject*, i, monoVector[i]); + } + return array; + } + bool MonoScriptUtils::CreateNewCSFile(std::string name, std::filesystem::path directoryFromAssets, bool regenerate) { auto parentDir = Volt::ProjectManager::GetDirectory() / ((directoryFromAssets.empty()) ? "Assets/Scripts" : directoryFromAssets.string()); diff --git a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.h b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.h index c808bf53d..e372139fd 100644 --- a/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.h +++ b/Volt/Volt/src/Volt/Scripting/Mono/MonoScriptUtils.h @@ -1,8 +1,7 @@ #pragma once #include "Volt/Scripting/Mono/MonoScriptClass.h" - -#include +#include "Volt/Scene/Entity.h" #include #include @@ -34,7 +33,8 @@ namespace Volt static MonoArray* CreateMonoArray(const std::vector& vector); static MonoArray* CreateMonoArrayUInt32(const std::vector& vector); static MonoArray* CreateMonoArrayUInt64(const std::vector& vector); - static MonoArray* CreateMonoArrayEntity(const std::vector& vector); + static MonoArray* CreateMonoArrayEntity(const std::vector& vector); + static MonoArray* CreateMonoArrayEntity(const std::vector& vector); static bool CreateNewCSFile(std::string name, std::filesystem::path directoryFromAssets, bool regenerate); diff --git a/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.cpp b/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.cpp index 6fc0cac7c..434c00688 100644 --- a/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.cpp +++ b/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.cpp @@ -3,10 +3,19 @@ #include "Volt/Log/Log.h" +#include "Volt/Core/Profiling.h" + namespace Volt { + YAMLStreamReader::YAMLStreamReader() + { + m_nodeStack.reserve(100); + } + const bool YAMLStreamReader::OpenFile(const std::filesystem::path& filePath) { + VT_PROFILE_FUNCTION(); + if (!std::filesystem::exists(filePath)) { return false; @@ -24,6 +33,7 @@ namespace Volt try { + VT_PROFILE_SCOPE("Parse YAML"); m_rootNode = YAML::Load(strStream.str()); m_currentNode = m_rootNode; } diff --git a/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.h b/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.h index 8cc0090ce..7ca9f79b1 100644 --- a/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.h +++ b/Volt/Volt/src/Volt/Utility/FileIO/YAMLStreamReader.h @@ -9,7 +9,7 @@ namespace Volt class YAMLStreamReader { public: - YAMLStreamReader() = default; + YAMLStreamReader(); const bool OpenFile(const std::filesystem::path& filePath); diff --git a/Volt/Volt/src/Volt/Utility/UIUtility.cpp b/Volt/Volt/src/Volt/Utility/UIUtility.cpp index a5fac43e8..c201659e1 100644 --- a/Volt/Volt/src/Volt/Utility/UIUtility.cpp +++ b/Volt/Volt/src/Volt/Utility/UIUtility.cpp @@ -1541,7 +1541,7 @@ bool UI::PropertyTextBox(const std::string& text, const std::string& value, bool return changed; } -bool UI::PropertyEntity(const std::string& text, Weak scene, entt::entity& value, const std::string& toolTip) +bool UI::PropertyEntity(const std::string& text, Weak scene, Volt::EntityID& value, const std::string& toolTip) { bool changed = false; @@ -1553,7 +1553,7 @@ bool UI::PropertyEntity(const std::string& text, Weak scene, entt:: ImGui::TableNextColumn(); std::string id = "##" + std::to_string(s_stackId++); - Volt::Entity entity{ value, scene.lock().get() }; + Volt::Entity entity = scene->GetEntityFromUUID(value); std::string entityName; if (entity) @@ -1572,7 +1572,7 @@ bool UI::PropertyEntity(const std::string& text, Weak scene, entt:: if (auto ptr = UI::DragDropTarget("scene_entity_hierarchy")) { - entt::entity entityId = *(entt::entity*)ptr; + Volt::EntityID entityId = *(Volt::EntityID*)ptr; value = entityId; changed = true; } @@ -1582,14 +1582,14 @@ bool UI::PropertyEntity(const std::string& text, Weak scene, entt:: return changed; } -bool UI::PropertyEntity(Weak scene, entt::entity& value, const float width, const std::string& toolTip) +bool UI::PropertyEntity(Weak scene, Volt::EntityID& value, const float width, const std::string& toolTip) { bool changed = false; SimpleToolTip(toolTip); std::string id = "##" + std::to_string(s_stackId++); - Volt::Entity entity{ value, scene.lock().get() }; + Volt::Entity entity = scene->GetEntityFromUUID(value); std::string entityName; if (entity) @@ -1608,7 +1608,7 @@ bool UI::PropertyEntity(Weak scene, entt::entity& value, const floa if (auto ptr = UI::DragDropTarget("scene_entity_hierarchy")) { - entt::entity entityId = *(entt::entity*)ptr; + Volt::EntityID entityId = *(Volt::EntityID*)ptr; value = entityId; changed = true; } diff --git a/Volt/Volt/src/Volt/Utility/UIUtility.h b/Volt/Volt/src/Volt/Utility/UIUtility.h index 5e53ebc8c..eac636aee 100644 --- a/Volt/Volt/src/Volt/Utility/UIUtility.h +++ b/Volt/Volt/src/Volt/Utility/UIUtility.h @@ -266,8 +266,8 @@ class UI static bool PropertyAxisColor(const std::string& text, glm::vec3& value, float resetValue = 0.f); static bool PropertyAxisColor(const std::string& text, glm::vec2& value, float resetValue = 0.f); - static bool PropertyEntity(const std::string& text, Weak scene, entt::entity& value, const std::string& toolTip = ""); - static bool PropertyEntity(Weak scene, entt::entity& value, const float width, const std::string& toolTip = ""); + static bool PropertyEntity(const std::string& text, Weak scene, Volt::EntityID& value, const std::string& toolTip = ""); + static bool PropertyEntity(Weak scene, Volt::EntityID& value, const float width, const std::string& toolTip = ""); static bool PropertyDragFloat(const std::string& text, float& value, float increment, float min = 0.f, float max = 0.f, const std::string& toolTip = ""); static bool PropertyTextBox(const std::string& text, const std::string& value, bool readOnly = false, const std::string& toolTip = ""); diff --git a/Volt/Volt/src/Volt/Utility/YAMLSerializationHelpers.h b/Volt/Volt/src/Volt/Utility/YAMLSerializationHelpers.h index b031646ec..c0bd5c4ea 100644 --- a/Volt/Volt/src/Volt/Utility/YAMLSerializationHelpers.h +++ b/Volt/Volt/src/Volt/Utility/YAMLSerializationHelpers.h @@ -337,22 +337,39 @@ namespace YAML }; template<> - struct convert + struct convert { - static Node encode(const Volt::AssetHandle& rhs) + static Node encode(const Volt::UUID& rhs) { Node node; node.push_back((uint64_t)rhs); return node; }; - static bool decode(const Node& node, Volt::AssetHandle& v) + static bool decode(const Node& node, Volt::UUID& v) { v = node.as(); return true; }; }; + template<> + struct convert + { + static Node encode(const Volt::UUID32& rhs) + { + Node node; + node.push_back((uint32_t)rhs); + return node; + }; + + static bool decode(const Node& node, Volt::UUID32& v) + { + v = node.as(); + return true; + }; + }; + template<> struct convert { diff --git a/Volt/Volt/src/Volt/Vision/TimelinePlayer.cpp b/Volt/Volt/src/Volt/Vision/TimelinePlayer.cpp index 69b9fcb69..d81e5dae0 100644 --- a/Volt/Volt/src/Volt/Vision/TimelinePlayer.cpp +++ b/Volt/Volt/src/Volt/Vision/TimelinePlayer.cpp @@ -46,11 +46,11 @@ void Volt::TimelinePlayer::StartTimeline(const TimelinePreset timelinePreset, Sc myEntityStartValues.resize(timelinePreset.myTracks.size(), StartValue()); for (size_t i = 0; i < timelinePreset.myTracks.size(); i++) { - Entity ent{ timelinePreset.myTracks[i].targetEntity, scene }; + Entity ent = scene->GetEntityFromUUID(timelinePreset.myTracks[i].targetEntity); if (ent) { - myEntityStartValues[i].entID = ent.GetID(); + myEntityStartValues[i].entID = ent; myEntityStartValues[i].Position = ent.GetPosition(); myEntityStartValues[i].Rotation = ent.GetRotation(); } @@ -71,7 +71,7 @@ void Volt::TimelinePlayer::StopTimeline() for (size_t i = 0; i < myTimelinePreset.myTracks.size(); i++) { - Entity ent{ myTimelinePreset.myTracks[i].targetEntity, myCurrentScene }; + Entity ent = myCurrentScene->GetEntityFromUUID(myTimelinePreset.myTracks[i].targetEntity); if (ent) { @@ -93,9 +93,9 @@ void Volt::TimelinePlayer::PlayTimeline(const float& deltaTime, Scene* scene) { #pragma region AnimationTrack - if (track.keyframes.empty() || track.targetEntity == entt::null || myCurrentKeyAndTime[trackIndex].first == track.keyframes.size() - 1) { continue; } + if (track.keyframes.empty() || track.targetEntity == Entity::NullID() || myCurrentKeyAndTime[trackIndex].first == track.keyframes.size() - 1) { continue; } - Entity trackEntity{ track.targetEntity, scene }; + Entity trackEntity = scene->GetEntityFromUUID(track.targetEntity); if (myCurrentPlaybackTime <= track.keyframes.at(0).time) { @@ -118,12 +118,12 @@ void Volt::TimelinePlayer::PlayTimeline(const float& deltaTime, Scene* scene) if (trackEntity.HasComponent()) { const auto& VCamComp = trackEntity.GetComponent(); - if (VCamComp.followId == entt::null) + if (VCamComp.followId == Entity::NullID()) { trackEntity.SetPosition(glm::mix(fromKeyframe.position, toKeyframe.position, currentTimePercentage)); } - if (VCamComp.lookAtId == entt::null) + if (VCamComp.lookAtId == Entity::NullID()) { trackEntity.SetRotation(glm::slerp(fromKeyframe.rotation, toKeyframe.rotation, currentTimePercentage)); } @@ -153,7 +153,7 @@ void Volt::TimelinePlayer::PlayTimeline(const float& deltaTime, Scene* scene) if (myCurrentPlaybackTime <= track.clips.at(0).startTime) { - if (vision.GetActiveCamera().GetID() != track.clips[0].activeCamera) + if (vision.GetActiveCamera() != track.clips[0].activeCamera) { vision.SetActiveCamera(track.clips[0].activeCamera, 0, Volt::eBlendType::None); myCurrentPlaybackTime += deltaTime; @@ -206,9 +206,9 @@ void Volt::TimelinePlayer::GetPreviewOnTime(TimelinePreset& timelinePreset, cons { const Volt::Track track = timelinePreset.myTracks[trackIndex]; - if (&selectedTrack == &timelinePreset.myTracks[trackIndex] || track.keyframes.empty() || track.targetEntity == entt::null) { continue; } + if (&selectedTrack == &timelinePreset.myTracks[trackIndex] || track.keyframes.empty() || track.targetEntity == Entity::NullID()) { continue; } - Entity trackEntity{ track.targetEntity, scene }; + Entity trackEntity = scene->GetEntityFromUUID(track.targetEntity); if (timeStamp <= track.keyframes.at(0).time) { diff --git a/Volt/Volt/src/Volt/Vision/Vision.cpp b/Volt/Volt/src/Volt/Vision/Vision.cpp index 46f39f62f..a36500a6d 100644 --- a/Volt/Volt/src/Volt/Vision/Vision.cpp +++ b/Volt/Volt/src/Volt/Vision/Vision.cpp @@ -23,14 +23,12 @@ void Volt::Vision::OnEvent(Volt::Event& e) void Volt::Vision::Initialize() { - std::vector camEntIDs = myScene->GetAllEntitiesWith(); + std::vector camEntIDs = myScene->GetAllEntitiesWith(); myVTCams.clear(); - for (auto ID : camEntIDs) + for (auto ent : camEntIDs) { - Volt::Entity ent = { ID, myScene }; - auto& camComp = ent.GetComponent(); camComp.priority = 0; @@ -76,10 +74,8 @@ void Volt::Vision::Update(float aDeltaTime) if (myVTCams.size() != cams.size()) { myVTCams.clear(); - for (auto& cam : cams) + for (auto& newCam : cams) { - Volt::Entity newCam{ cam, myScene }; - newCam.GetComponent().Init(newCam); myVTCams.push_back(newCam); @@ -352,9 +348,10 @@ void Volt::Vision::SetActiveCamera(const Volt::Entity aCamEntity) } } -void Volt::Vision::SetActiveCamera(const entt::entity aEntityID, const float& aBlendTime, eBlendType blendType) +void Volt::Vision::SetActiveCamera(const EntityID aEntityID, const float& aBlendTime, eBlendType blendType) { - Volt::Entity camEnt = Volt::Entity{ aEntityID, myScene }; + Volt::Entity camEnt = myScene->GetEntityFromUUID(aEntityID); + if (camEnt) { @@ -378,9 +375,9 @@ void Volt::Vision::SetActiveCamera(const entt::entity aEntityID, const float& aB } } -void Volt::Vision::SetActiveCamera(const entt::entity aEntityID) +void Volt::Vision::SetActiveCamera(const EntityID aEntityID) { - Volt::Entity ent = Volt::Entity{ aEntityID, myScene }; + Volt::Entity ent = myScene->GetEntityFromUUID(aEntityID); if (ent) { diff --git a/Volt/Volt/src/Volt/Vision/Vision.h b/Volt/Volt/src/Volt/Vision/Vision.h index 42af904df..12308d62c 100644 --- a/Volt/Volt/src/Volt/Vision/Vision.h +++ b/Volt/Volt/src/Volt/Vision/Vision.h @@ -33,8 +33,8 @@ namespace Volt void SetActiveCamera(const std::string aCamName); void SetActiveCamera(const size_t aIndex); void SetActiveCamera(const Volt::Entity aCamEntity); - void SetActiveCamera(const entt::entity aEntityID); - void SetActiveCamera(const entt::entity aEntityID, const float& aBlendTime, Volt::eBlendType blendType); + void SetActiveCamera(const EntityID aEntityID); + void SetActiveCamera(const EntityID aEntityID, const float& aBlendTime, Volt::eBlendType blendType); const Volt::Entity GetActiveCamera() { return myActiveCamera.IsValid() ? myActiveCamera : Volt::Entity::Null(); } const Volt::Entity GetTriggerCamera() { return myActiveTiggerCamera.IsValid() ? myActiveTiggerCamera : Volt::Entity::Null(); } diff --git a/Volt/Volt/src/Volt/Vision/VisionComponents.cpp b/Volt/Volt/src/Volt/Vision/VisionComponents.cpp index 94a4c9307..7b645beaa 100644 --- a/Volt/Volt/src/Volt/Vision/VisionComponents.cpp +++ b/Volt/Volt/src/Volt/Vision/VisionComponents.cpp @@ -59,7 +59,7 @@ void Volt::VisionCameraComponent::Init(Entity& camEntity) if (damping > 0) { - Volt::Entity target = Volt::Entity{ followId, camEntity.GetScene() }; + Volt::Entity target = camEntity.GetScene()->GetEntityFromUUID(followId); if (target) { @@ -96,9 +96,9 @@ void Volt::VisionCameraComponent::Update(Entity& camEntity, float aDeltaTime) void Volt::VisionCameraComponent::FreeController(Entity& camEntity, float aDeltaTime) { - if (followId != entt::null) + if (followId != Entity::NullID()) { - Volt::Entity followEnt = Volt::Entity{ followId, camEntity.GetScene() }; + Volt::Entity followEnt = camEntity.GetScene()->GetEntityFromUUID(followId); if (followEnt) { @@ -120,9 +120,9 @@ void Volt::VisionCameraComponent::FreeController(Entity& camEntity, float aDelta } } - if (lookAtId != entt::null) + if (lookAtId != Entity::NullID()) { - Entity lookAtEnt = Entity{ lookAtId, camEntity.GetScene() }; + Entity lookAtEnt = camEntity.GetScene()->GetEntityFromUUID(lookAtId); if (lookAtEnt) { @@ -134,7 +134,7 @@ void Volt::VisionCameraComponent::FreeController(Entity& camEntity, float aDelta void Volt::VisionCameraComponent::FPSController(Entity& camEntity, float aDeltaTime) { - Volt::Entity target = Volt::Entity{ followId, camEntity.GetScene() }; + Volt::Entity target = camEntity.GetScene()->GetEntityFromUUID(followId); if (!target) { return; } @@ -171,7 +171,7 @@ void Volt::VisionCameraComponent::TPSController(Entity& camEntity, float aDeltaT myRotation.x = glm::clamp(myRotation.x, -1.35f, 1.35f); - Volt::Entity target = Volt::Entity{ followId, camEntity.GetScene() }; + Volt::Entity target = camEntity.GetScene()->GetEntityFromUUID(followId); if (target) { @@ -184,7 +184,7 @@ void Volt::VisionCameraComponent::TPSController(Entity& camEntity, float aDeltaT const glm::vec3 dir = camEntity.GetPosition() - focalTargetPoint; glm::vec3 position = { 0 }; - Volt::Entity rayFocalPointEnt = Volt::Entity{ collisionRayPoint, camEntity.GetScene() }; + Volt::Entity rayFocalPointEnt = camEntity.GetScene()->GetEntityFromUUID(collisionRayPoint); if (isColliding) { diff --git a/Volt/Volt/src/Volt/Vision/VisionComponents.h b/Volt/Volt/src/Volt/Vision/VisionComponents.h index eece00e79..166fd9a64 100644 --- a/Volt/Volt/src/Volt/Vision/VisionComponents.h +++ b/Volt/Volt/src/Volt/Vision/VisionComponents.h @@ -2,7 +2,8 @@ #include "Volt/Scene/Reflection/ComponentRegistry.h" #include "Volt/Scene/Reflection/ComponentReflection.h" -#include +#include "Volt/Scene/Entity.h" + #include #include @@ -48,14 +49,14 @@ namespace Volt struct VisionTriggerComponent { - entt::entity triggerCam = entt::null; + EntityID triggerCam = Entity::NullID(); bool forceActiveCam = false; static void ReflectType(TypeDesc& reflect) { reflect.SetGUID("{E846C1DE-F199-4BFF-9D15-9E73B8D1C941}"_guid); reflect.SetLabel("Vision Trigger Component"); - reflect.AddMember(&VisionTriggerComponent::triggerCam, "triggerCam", "Trigger Camera", "", entt::null); + reflect.AddMember(&VisionTriggerComponent::triggerCam, "triggerCam", "Trigger Camera", "", Entity::NullID()); reflect.AddMember(&VisionTriggerComponent::forceActiveCam, "forceActiveCam", "Force Active Camera", "", false); } }; @@ -69,9 +70,9 @@ namespace Volt eBlendType blendType = eBlendType::None; float damping = 0.f; glm::vec3 offset = { 0 }; - entt::entity followId = entt::null; - entt::entity lookAtId = entt::null; - entt::entity collisionRayPoint = entt::null; + EntityID followId = Entity::NullID(); + EntityID lookAtId = Entity::NullID(); + EntityID collisionRayPoint = Entity::NullID(); float focalDistance = 1000.f; float mouseSensitivity = 0.15f; float collisionRadius = 100.f; @@ -96,9 +97,9 @@ namespace Volt reflect.AddMember(&VisionCameraComponent::blendType, "blendType", "Blend Type", "", eBlendType::None); reflect.AddMember(&VisionCameraComponent::damping, "damping", "Damping", "", 0.f); reflect.AddMember(&VisionCameraComponent::offset, "offset", "Offset", "", glm::vec3{ 0.f }); - reflect.AddMember(&VisionCameraComponent::followId, "followId", "Follow ID", "", entt::null); - reflect.AddMember(&VisionCameraComponent::lookAtId, "lookAtId", "Look At ID", "", entt::null); - reflect.AddMember(&VisionCameraComponent::collisionRayPoint, "collisionRayPoint", "Collision Ray Point", "", entt::null); + reflect.AddMember(&VisionCameraComponent::followId, "followId", "Follow ID", "", Entity::NullID()); + reflect.AddMember(&VisionCameraComponent::lookAtId, "lookAtId", "Look At ID", "", Entity::NullID()); + reflect.AddMember(&VisionCameraComponent::collisionRayPoint, "collisionRayPoint", "Collision Ray Point", "", Entity::NullID()); reflect.AddMember(&VisionCameraComponent::focalDistance, "focalDistance", "Focal Distance", "", 1000.f); reflect.AddMember(&VisionCameraComponent::mouseSensitivity, "mouseSensitivity", "Mouse Sensitivity", "", 0.15f); reflect.AddMember(&VisionCameraComponent::collisionRadius, "collisionRadius", "Collision Radius", "", 100.f); diff --git a/Volt/premake5.lua b/Volt/premake5.lua index 535ac3a30..dad443f83 100644 --- a/Volt/premake5.lua +++ b/Volt/premake5.lua @@ -1,5 +1,6 @@ local VoltRootDirectory = os.getenv("VOLT_PATH") +include "./scripts/premakeCustomization/premakeCommon.lua" include "./scripts/premakeCustomization/solution_items.lua" include "Dependencies.lua" diff --git a/Volt/scripts/premakeCustomization/premakeCommon.lua b/Volt/scripts/premakeCustomization/premakeCommon.lua new file mode 100644 index 000000000..21c0ad26e --- /dev/null +++ b/Volt/scripts/premakeCustomization/premakeCommon.lua @@ -0,0 +1,54 @@ +function AddCommonFlags() + flags + { + "FatalWarnings" + } +end + +function AddCommonWarnings() + disablewarnings + { + "4201", + "4100", + "4505", + "4005" + } +end + +function AddCommonLinkOptions() + linkoptions + { + "/ignore:4006", + "/ignore:4099", + } +end + +function AddCommonIncludeDirs() + includedirs + { + "%{IncludeDir.CoreUtilities}", + + "%{IncludeDir.glm}", + "%{IncludeDir.Optick}", + "%{IncludeDir.tracy}", + } +end + +function AddCommonDefines() + defines + { + "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS", + "_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS", + "_CRT_SECURE_NO_WARNINGS", + "_HAS_STD_BYTE=0", + "_USE_MATH_DEFINES", + "_WINSOCK_DEPRECATED_NO_WARNINGS", + + "NOMINMAX", + + "GLM_FORCE_DEPTH_ZERO_TO_ONE", + "GLM_FORCE_LEFT_HANDED", + + "TRACY_ENABLE" + } +end \ No newline at end of file