diff --git a/examples/PhysicallyBasedRendering/main.cpp b/examples/PhysicallyBasedRendering/main.cpp index 5e53e1dc5..4d349a570 100644 --- a/examples/PhysicallyBasedRendering/main.cpp +++ b/examples/PhysicallyBasedRendering/main.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/examples/Physics2DDemo/main.cpp b/examples/Physics2DDemo/main.cpp index 83a842ac0..fbcfa74d7 100644 --- a/examples/Physics2DDemo/main.cpp +++ b/examples/Physics2DDemo/main.cpp @@ -1,17 +1,10 @@ #include -#include -#include #include #include -#include -#include #include #include -#include -#include #include #include -#include #include #include #include @@ -42,8 +35,10 @@ int main() auto& windowing = app.AddComponent(); auto& ecs = app.AddComponent(); - Nz::Physics2DSystem& physSytem = ecs.AddSystem(); - Nz::RenderSystem& renderSystem = ecs.AddSystem(); + + auto& world = ecs.AddWorld(); + Nz::Physics2DSystem& physSytem = world.AddSystem(); + Nz::RenderSystem& renderSystem = world.AddSystem(); std::string windowTitle = "Physics 2D"; Nz::Window& window = windowing.CreateWindow(Nz::VideoMode(1920, 1080, 32), windowTitle); @@ -55,7 +50,7 @@ int main() physSytem.GetPhysWorld().SetGravity({ 0.f, -98.1f }); - entt::handle viewer = ecs.CreateEntity(); + entt::handle viewer = world.CreateEntity(); { viewer.emplace(); auto& cameraComponent = viewer.emplace(&windowSwapchain.GetSwapchain(), Nz::ProjectionType::Orthographic); @@ -77,7 +72,7 @@ int main() { for (std::size_t x = 0; x < 30; ++x) { - entt::handle spriteEntity = ecs.CreateEntity(); + entt::handle spriteEntity = world.CreateEntity(); { std::shared_ptr sprite = std::make_shared(spriteMaterial); sprite->SetSize({ 32.f, 32.f }); @@ -93,7 +88,7 @@ int main() } } - entt::handle groundEntity = ecs.CreateEntity(); + entt::handle groundEntity = world.CreateEntity(); { std::shared_ptr tilemap = std::make_shared(Nz::Vector2ui(40, 20), Nz::Vector2f(64.f, 64.f), 18); tilemap->SetOrigin({ 0.5f, 0.5f }); @@ -138,7 +133,7 @@ int main() if (secondClock.RestartIfOver(Nz::Time::Second())) { - window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(ecs.GetRegistry().alive()) + " entities"); + window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetRegistry().alive()) + " entities"); fps = 0; } }); diff --git a/examples/Physics2DDemo/xmake.lua b/examples/Physics2DDemo/xmake.lua index 5742a9436..9fd5ccd4a 100644 --- a/examples/Physics2DDemo/xmake.lua +++ b/examples/Physics2DDemo/xmake.lua @@ -2,3 +2,4 @@ target("Physics2DDemo") add_deps("NazaraGraphics", "NazaraPhysics2D") add_packages("entt") add_files("main.cpp") + add_defines("NAZARA_ENTT") diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index 92db9b288..3b7d2c53c 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -1,18 +1,10 @@ #include -#include -#include #include #include -#include -#include -#include #include #include -#include -#include #include #include -#include #include #include #include @@ -42,8 +34,10 @@ int main() auto& windowing = app.AddComponent(); auto& ecs = app.AddComponent(); - Nz::Physics3DSystem& physSytem = ecs.AddSystem(); - Nz::RenderSystem& renderSystem = ecs.AddSystem(); + + auto& world = ecs.AddWorld(); + Nz::Physics3DSystem& physSytem = world.AddSystem(); + Nz::RenderSystem& renderSystem = world.AddSystem(); std::string windowTitle = "Physics 3D"; Nz::Window& window = windowing.CreateWindow(Nz::VideoMode(1920, 1080, 32), windowTitle); @@ -107,7 +101,7 @@ int main() Nz::Vector2ui windowSize = window.GetSize(); - entt::handle viewer = ecs.CreateEntity(); + entt::handle viewer = world.CreateEntity(); { viewer.emplace(); auto& cameraComponent = viewer.emplace(&windowSwapchain.GetSwapchain()); @@ -138,7 +132,7 @@ int main() colliderModel->SetMaterial(i, colliderMat); } - entt::handle textEntity = ecs.CreateEntity(); + entt::handle textEntity = world.CreateEntity(); { auto& entityGfx = textEntity.emplace(); entityGfx.AttachRenderable(sprite, 1); @@ -146,9 +140,9 @@ int main() auto& entityNode = textEntity.emplace(); entityNode.SetPosition(0.f, 5.f, 0.f); } - entt::handle playerEntity = ecs.CreateEntity(); + entt::handle playerEntity = world.CreateEntity(); - entt::handle headingEntity = ecs.CreateEntity(); + entt::handle headingEntity = world.CreateEntity(); { auto& entityLight = playerEntity.emplace(); auto& spotLight = entityLight.AddLight(1); @@ -179,7 +173,7 @@ int main() { for (std::size_t z = 0; z < 3; ++z) { - entt::handle entity = ecs.CreateEntity(); + entt::handle entity = world.CreateEntity(); auto& entityGfx = entity.emplace(); entityGfx.AttachRenderable(model, 1); @@ -222,20 +216,20 @@ int main() showColliders = !showColliders; if (showColliders) { - auto view = ecs.GetRegistry().view(); + auto view = world.GetRegistry().view(); for (auto [entity, gfxComponent, _] : view.each()) gfxComponent.AttachRenderable(colliderModel, 1); } else { - auto view = ecs.GetRegistry().view(); + auto view = world.GetRegistry().view(); for (auto [entity, gfxComponent, _] : view.each()) gfxComponent.DetachRenderable(colliderModel); } } else if (event.virtualKey == Nz::Keyboard::VKey::Space) { - entt::handle entity = ecs.CreateEntity(); + entt::handle entity = world.CreateEntity(); auto& entityGfx = entity.emplace(); entityGfx.AttachRenderable(model, 1); if (showColliders) @@ -270,7 +264,7 @@ int main() { float elapsedTime = deltaTime->AsSeconds(); - auto spaceshipView = ecs.GetRegistry().view(); + auto spaceshipView = world.GetRegistry().view(); for (auto&& [entity, node, _] : spaceshipView.each()) { if (entity == playerEntity) @@ -278,7 +272,7 @@ int main() Nz::Vector3f spaceshipPos = node.GetPosition(Nz::CoordSys::Global); if (spaceshipPos.GetSquaredLength() > Nz::IntegralPow(20.f, 2)) - ecs.GetRegistry().destroy(entity); + world.GetRegistry().destroy(entity); } Nz::RigidBody3DComponent& playerShipBody = playerEntity.get(); @@ -320,7 +314,7 @@ int main() if (fpsClock.RestartIfOver(Nz::Time::Second())) { - window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(ecs.GetRegistry().alive()) + " entities"); + window.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetRegistry().alive()) + " entities"); fps = 0; } }); diff --git a/examples/PhysicsDemo/xmake.lua b/examples/PhysicsDemo/xmake.lua index 043087086..ed19da755 100644 --- a/examples/PhysicsDemo/xmake.lua +++ b/examples/PhysicsDemo/xmake.lua @@ -2,3 +2,4 @@ target("PhysicsDemo") add_deps("NazaraGraphics", "NazaraPhysics3D") add_packages("entt") add_files("main.cpp") + add_defines("NAZARA_ENTT") diff --git a/examples/Showcase/main.cpp b/examples/Showcase/main.cpp index 9591066c8..07025f99e 100644 --- a/examples/Showcase/main.cpp +++ b/examples/Showcase/main.cpp @@ -1,19 +1,10 @@ #include -#include -#include #include #include -#include -#include -#include #include #include -#include -#include #include #include -#include -#include #include #include #include @@ -46,10 +37,12 @@ int main() std::shared_ptr device = Nz::Graphics::Instance()->GetRenderDevice(); auto& ecs = app.AddComponent(); - ecs.AddSystem(); - Nz::Physics3DSystem& physSytem = ecs.AddSystem(); - Nz::RenderSystem& renderSystem = ecs.AddSystem(); + auto& world = ecs.AddWorld(); + world.AddSystem(); + + Nz::Physics3DSystem& physSytem = world.AddSystem(); + Nz::RenderSystem& renderSystem = world.AddSystem(); auto& windowing = app.AddComponent(); @@ -62,9 +55,9 @@ int main() Nz::TextureParams texParams; texParams.renderDevice = device; - entt::handle playerEntity = ecs.CreateEntity(); - entt::handle playerRotation = ecs.CreateEntity(); - entt::handle playerCamera = ecs.CreateEntity(); + entt::handle playerEntity = world.CreateEntity(); + entt::handle playerRotation = world.CreateEntity(); + entt::handle playerCamera = world.CreateEntity(); { auto& playerNode = playerEntity.emplace(); playerNode.SetPosition(0.f, 1.8f, 1.f); @@ -166,8 +159,8 @@ int main() } }*/ - entt::handle bobEntity = ecs.CreateEntity(); - entt::handle lightEntity1 = ecs.CreateEntity(); + entt::handle bobEntity = world.CreateEntity(); + entt::handle lightEntity1 = world.CreateEntity(); { auto& lightNode = lightEntity1.emplace(); lightNode.SetPosition(Nz::Vector3f::Up() * 3.f + Nz::Vector3f::Backward() * 1.f); @@ -182,7 +175,7 @@ int main() spotLight.EnableShadowCasting(true); } - entt::handle lightEntity2 = ecs.CreateEntity(); + entt::handle lightEntity2 = world.CreateEntity(); { auto& lightNode = lightEntity2.emplace(); lightNode.SetPosition(Nz::Vector3f::Up() * 3.5f + Nz::Vector3f::Right() * 1.5f); @@ -196,7 +189,7 @@ int main() spotLight.UpdateShadowMapSize(1024); } - entt::handle lightEntity3 = ecs.CreateEntity(); + entt::handle lightEntity3 = world.CreateEntity(); { auto& bobNode = bobEntity.emplace(); @@ -209,7 +202,7 @@ int main() auto& sharedSkeleton = bobEntity.emplace(skeleton); - entt::handle sphereEntity = ecs.CreateEntity(); + entt::handle sphereEntity = world.CreateEntity(); { std::shared_ptr sphereMesh = std::make_shared(); sphereMesh->CreateStatic(); @@ -242,7 +235,7 @@ int main() sphereGfx.AttachRenderable(sphereModel, 0xFFFFFFFF); } - entt::handle smallBobEntity = ecs.CreateEntity(); + entt::handle smallBobEntity = world.CreateEntity(); auto& smallBobNode = smallBobEntity.emplace(); smallBobNode.SetParentJoint(bobEntity, "LeftHand"); @@ -297,7 +290,7 @@ int main() sprite->UpdateRenderLayer(1); sprite->Update(Nz::SimpleTextDrawer::Draw("Shadow-mapping !", 72), 0.002f); - entt::handle textEntity = ecs.CreateEntity(); + entt::handle textEntity = world.CreateEntity(); { auto& entityGfx = textEntity.emplace(); entityGfx.AttachRenderable(sprite, 1); @@ -307,7 +300,7 @@ int main() entityNode.SetRotation(Nz::EulerAnglesf(-45.f, 0.f, 0.f)); } - entt::handle planeEntity = ecs.CreateEntity(); + entt::handle planeEntity = world.CreateEntity(); Nz::Boxf floorBox; { Nz::MeshParams meshPrimitiveParams; @@ -353,7 +346,7 @@ int main() std::shared_ptr boxModel = std::make_shared(std::move(boxMeshGfx), boxMesh.GetAABB()); boxModel->SetMaterial(0, planeMat); - entt::handle boxEntity = ecs.CreateEntity(); + entt::handle boxEntity = world.CreateEntity(); boxEntity.emplace().SetPosition(Nz::Vector3f(0.f, 0.25f, -0.5f)); boxEntity.emplace().AttachRenderable(boxModel, 0xFFFFFFFF); } @@ -517,7 +510,7 @@ int main() if (fpsClock.RestartIfOver(Nz::Time::Second())) { - mainWindow.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(ecs.GetRegistry().alive()) + " entities"); + mainWindow.SetTitle(windowTitle + " - " + Nz::NumberToString(fps) + " FPS" + " - " + Nz::NumberToString(world.GetRegistry().alive()) + " entities"); fps = 0; } }); diff --git a/examples/Showcase/xmake.lua b/examples/Showcase/xmake.lua index dc8e1d5a9..4d78a517b 100644 --- a/examples/Showcase/xmake.lua +++ b/examples/Showcase/xmake.lua @@ -5,3 +5,4 @@ target("Showcase") add_deps("PluginAssimp", { links = {} }) add_packages("entt") add_files("main.cpp") + add_defines("NAZARA_ENTT") diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index 77078ac57..c9b572ecb 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -1,15 +1,10 @@ // Sources pour https://github.com/NazaraEngine/NazaraEngine/wiki/(FR)-Tutoriel:-%5B01%5D-Hello-World -#include -#include -#include +#include #include -#include -#include #include #include #include -#include #include int main() @@ -20,11 +15,12 @@ int main() Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), "Tut01 - Hello world"); auto& ecs = app.AddComponent(); + auto& world = ecs.AddWorld(); - Nz::RenderSystem& renderSystem = ecs.AddSystem(); + Nz::RenderSystem& renderSystem = world.AddSystem(); auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow); - entt::handle cameraEntity = ecs.CreateEntity(); + entt::handle cameraEntity = world.CreateEntity(); { cameraEntity.emplace(); @@ -40,7 +36,7 @@ int main() std::shared_ptr textSprite = std::make_shared(); textSprite->Update(textDrawer); - entt::handle textEntity = ecs.CreateEntity(); + entt::handle textEntity = world.CreateEntity(); { auto& nodeComponent = textEntity.emplace(); auto& gfxComponent = textEntity.emplace(); diff --git a/examples/Tut01/xmake.lua b/examples/Tut01/xmake.lua index 40134955e..e14b65f34 100644 --- a/examples/Tut01/xmake.lua +++ b/examples/Tut01/xmake.lua @@ -2,3 +2,4 @@ target("Tut01_HelloWorld") add_deps("NazaraGraphics") add_packages("entt") add_files("main.cpp") + add_defines("NAZARA_ENTT") diff --git a/examples/Tut02/main.cpp b/examples/Tut02/main.cpp index 375aa2d79..91f9e167d 100644 --- a/examples/Tut02/main.cpp +++ b/examples/Tut02/main.cpp @@ -1,15 +1,10 @@ // Sources pour https://github.com/NazaraEngine/NazaraEngine/wiki/(FR)-Tutoriel:-%5B02%5D-Gestion-des-événements -#include -#include -#include +#include #include -#include -#include #include #include #include -#include #include int main() @@ -20,11 +15,12 @@ int main() Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), "Tut02 - Hello world"); auto& ecs = app.AddComponent(); + auto& world = ecs.AddWorld(); - Nz::RenderSystem& renderSystem = ecs.AddSystem(); + Nz::RenderSystem& renderSystem = world.AddSystem(); auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow); - entt::handle cameraEntity = ecs.CreateEntity(); + entt::handle cameraEntity = world.CreateEntity(); { cameraEntity.emplace(); @@ -40,7 +36,7 @@ int main() std::shared_ptr textSprite = std::make_shared(); textSprite->Update(textDrawer); - entt::handle textEntity = ecs.CreateEntity(); + entt::handle textEntity = world.CreateEntity(); { auto& nodeComponent = textEntity.emplace(); auto& gfxComponent = textEntity.emplace(); diff --git a/examples/Tut02/xmake.lua b/examples/Tut02/xmake.lua index d9ce2d7fc..de9079f80 100644 --- a/examples/Tut02/xmake.lua +++ b/examples/Tut02/xmake.lua @@ -2,3 +2,4 @@ target("Tut02_Events") add_deps("NazaraGraphics") add_packages("entt") add_files("main.cpp") + add_defines("NAZARA_ENTT") diff --git a/examples/WidgetDemo/main.cpp b/examples/WidgetDemo/main.cpp index d1294dea3..f382c1f98 100644 --- a/examples/WidgetDemo/main.cpp +++ b/examples/WidgetDemo/main.cpp @@ -1,21 +1,11 @@ #include -#include -#include #include #include -#include -#include -#include #include #include -#include -#include #include #include -#include #include -#include -#include #include #include #include @@ -40,6 +30,7 @@ int main() Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1920, 1080), "Widget demo"); auto& ecs = app.AddComponent(); + auto& world = ecs.AddWorld(); auto& fs = app.AddComponent(); { @@ -50,10 +41,10 @@ int main() fs.Mount("assets", resourceDir); } - Nz::RenderSystem& renderSystem = ecs.AddSystem(); + Nz::RenderSystem& renderSystem = world.AddSystem(); auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow); - Nz::Canvas canvas2D(ecs.GetRegistry(), mainWindow.GetEventHandler(), mainWindow.GetCursorController().CreateHandle(), 0xFFFFFFFF); + Nz::Canvas canvas2D(world, mainWindow.GetEventHandler(), mainWindow.GetCursorController().CreateHandle(), 0xFFFFFFFF); canvas2D.Resize(Nz::Vector2f(mainWindow.GetSize())); Nz::LabelWidget* labelWidget = canvas2D.Add(); @@ -119,7 +110,7 @@ int main() textAreaWidget2->SetBackgroundColor(Nz::Color::White()); textAreaWidget2->SetTextColor(Nz::Color::Black());*/ - entt::handle viewer2D = ecs.CreateEntity(); + entt::handle viewer2D = world.CreateEntity(); { viewer2D.emplace(); diff --git a/examples/WidgetDemo/xmake.lua b/examples/WidgetDemo/xmake.lua index c1273b526..78083420a 100644 --- a/examples/WidgetDemo/xmake.lua +++ b/examples/WidgetDemo/xmake.lua @@ -2,3 +2,4 @@ target("WidgetDemo") add_deps("NazaraGraphics", "NazaraPhysics3D", "NazaraWidgets") add_packages("entt") add_files("main.cpp") + add_defines("NAZARA_ENTT") diff --git a/include/Nazara/Audio.hpp b/include/Nazara/Audio.hpp index 5b2ad2252..28d944248 100644 --- a/include/Nazara/Audio.hpp +++ b/include/Nazara/Audio.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Audio module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp index c1279509c..5fe79954c 100644 --- a/include/Nazara/Core.hpp +++ b/include/Nazara/Core.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Core module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -89,4 +91,14 @@ #include #include +#ifdef NAZARA_ENTT + +#include +#include +#include +#include +#include + +#endif + #endif // NAZARA_GLOBAL_CORE_HPP diff --git a/include/Nazara/Core/AppEntitySystemComponent.hpp b/include/Nazara/Core/AppEntitySystemComponent.hpp index a63d551a3..60449a5ca 100644 --- a/include/Nazara/Core/AppEntitySystemComponent.hpp +++ b/include/Nazara/Core/AppEntitySystemComponent.hpp @@ -10,25 +10,19 @@ #include #include #include -#include +#include namespace Nz { class NAZARA_CORE_API AppEntitySystemComponent : public ApplicationComponent { public: - inline AppEntitySystemComponent(ApplicationBase& app); + using ApplicationComponent::ApplicationComponent; AppEntitySystemComponent(const AppEntitySystemComponent&) = delete; AppEntitySystemComponent(AppEntitySystemComponent&&) = delete; ~AppEntitySystemComponent() = default; - template T& AddSystem(Args&&... args); - - entt::handle CreateEntity(); - - entt::registry& GetRegistry(); - const entt::registry& GetRegistry() const; - template T& GetSystem() const; + template T& AddWorld(Args&&... args); void Update(Time elapsedTime) override; @@ -36,8 +30,7 @@ namespace Nz AppEntitySystemComponent& operator=(AppEntitySystemComponent&&) = delete; private: - entt::registry m_registry; - SystemGraph m_systemGraph; + std::vector> m_worlds; }; } diff --git a/include/Nazara/Core/AppEntitySystemComponent.inl b/include/Nazara/Core/AppEntitySystemComponent.inl index 7b0dbc234..74b756fba 100644 --- a/include/Nazara/Core/AppEntitySystemComponent.inl +++ b/include/Nazara/Core/AppEntitySystemComponent.inl @@ -7,37 +7,10 @@ namespace Nz { - inline AppEntitySystemComponent::AppEntitySystemComponent(ApplicationBase& app) : - ApplicationComponent(app), - m_systemGraph(m_registry) - { - } - template - T& AppEntitySystemComponent::AddSystem(Args&&... args) + T& AppEntitySystemComponent::AddWorld(Args&&... args) { - return m_systemGraph.AddSystem(std::forward(args)...); - } - - inline entt::handle AppEntitySystemComponent::CreateEntity() - { - return entt::handle(m_registry, m_registry.create()); - } - - inline entt::registry& AppEntitySystemComponent::GetRegistry() - { - return m_registry; - } - - inline const entt::registry& AppEntitySystemComponent::GetRegistry() const - { - return m_registry; - } - - template - T& AppEntitySystemComponent::GetSystem() const - { - return m_systemGraph.GetSystem(); + return static_cast(*m_worlds.emplace_back(std::make_unique(std::forward(args)...))); } } diff --git a/include/Nazara/Core/Components.hpp b/include/Nazara/Core/Components.hpp index 230da2f39..31f616fc8 100644 --- a/include/Nazara/Core/Components.hpp +++ b/include/Nazara/Core/Components.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Core module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Core/EntityWorld.hpp b/include/Nazara/Core/EntityWorld.hpp new file mode 100644 index 000000000..468f043b4 --- /dev/null +++ b/include/Nazara/Core/EntityWorld.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CORE_ENTITYWORLD_HPP +#define NAZARA_CORE_ENTITYWORLD_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_CORE_API EntityWorld + { + public: + EntityWorld() = default; + EntityWorld(const EntityWorld&) = default; + EntityWorld(EntityWorld&&) = default; + virtual ~EntityWorld(); + + virtual void Update(Time elapsedTime) = 0; + + EntityWorld& operator=(const EntityWorld&) = default; + EntityWorld& operator=(EntityWorld&&) = default; + }; +} + +#include + +#endif // NAZARA_CORE_ENTITYWORLD_HPP diff --git a/include/Nazara/Core/EntityWorld.inl b/include/Nazara/Core/EntityWorld.inl new file mode 100644 index 000000000..51c0b74cb --- /dev/null +++ b/include/Nazara/Core/EntityWorld.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Core/Systems/SystemGraph.hpp b/include/Nazara/Core/EnttSystemGraph.hpp similarity index 71% rename from include/Nazara/Core/Systems/SystemGraph.hpp rename to include/Nazara/Core/EnttSystemGraph.hpp index 7bba64cd3..a09470615 100644 --- a/include/Nazara/Core/Systems/SystemGraph.hpp +++ b/include/Nazara/Core/EnttSystemGraph.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_CORE_SYSTEMS_SYSTEMGRAPH_HPP -#define NAZARA_CORE_SYSTEMS_SYSTEMGRAPH_HPP +#ifndef NAZARA_CORE_ENTTSYSTEMGRAPH_HPP +#define NAZARA_CORE_ENTTSYSTEMGRAPH_HPP #include #include @@ -18,13 +18,13 @@ namespace Nz { - class NAZARA_CORE_API SystemGraph + class NAZARA_CORE_API EnttSystemGraph { public: - inline SystemGraph(entt::registry& registry); - SystemGraph(const SystemGraph&) = delete; - SystemGraph(SystemGraph&&) = delete; - ~SystemGraph() = default; + inline EnttSystemGraph(entt::registry& registry); + EnttSystemGraph(const EnttSystemGraph&) = delete; + EnttSystemGraph(EnttSystemGraph&&) = delete; + ~EnttSystemGraph() = default; template T& AddSystem(Args&&... args); @@ -33,8 +33,8 @@ namespace Nz void Update(); void Update(Time elapsedTime); - SystemGraph& operator=(const SystemGraph&) = delete; - SystemGraph& operator=(SystemGraph&&) = delete; + EnttSystemGraph& operator=(const EnttSystemGraph&) = delete; + EnttSystemGraph& operator=(EnttSystemGraph&&) = delete; private: struct NAZARA_CORE_API NodeBase @@ -65,6 +65,6 @@ namespace Nz }; } -#include +#include -#endif // NAZARA_CORE_SYSTEMS_SYSTEMGRAPH_HPP +#endif // NAZARA_CORE_ENTTSYSTEMGRAPH_HPP diff --git a/include/Nazara/Core/Systems/SystemGraph.inl b/include/Nazara/Core/EnttSystemGraph.inl similarity index 64% rename from include/Nazara/Core/Systems/SystemGraph.inl rename to include/Nazara/Core/EnttSystemGraph.inl index a884c5333..fd0222aad 100644 --- a/include/Nazara/Core/Systems/SystemGraph.inl +++ b/include/Nazara/Core/EnttSystemGraph.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -12,44 +12,44 @@ namespace Nz namespace Detail { template - struct SystemGraphAllowConcurrent : std::bool_constant {}; + struct EnttSystemGraphAllowConcurrent : std::bool_constant {}; template - struct SystemGraphAllowConcurrent> : std::bool_constant {}; + struct EnttSystemGraphAllowConcurrent> : std::bool_constant {}; template - struct SystemGraphExecutionOrder : std::integral_constant {}; + struct EnttSystemGraphExecutionOrder : std::integral_constant {}; template - struct SystemGraphExecutionOrder> : std::integral_constant {}; + struct EnttSystemGraphExecutionOrder> : std::integral_constant {}; } template template - SystemGraph::Node::Node(Args&&... args) : + EnttSystemGraph::Node::Node(Args&&... args) : system(std::forward(args)...) { } template - void SystemGraph::Node::Update(Time elapsedTime) + void EnttSystemGraph::Node::Update(Time elapsedTime) { system.Update(elapsedTime); } - inline SystemGraph::SystemGraph(entt::registry& registry) : + inline EnttSystemGraph::EnttSystemGraph(entt::registry& registry) : m_registry(registry), m_systemOrderUpdated(true) { } template - T& SystemGraph::AddSystem(Args&&... args) + T& EnttSystemGraph::AddSystem(Args&&... args) { NazaraAssert(m_systemToNodes.find(entt::type_hash()) == m_systemToNodes.end(), "this system already exists"); auto nodePtr = std::make_unique>(m_registry, std::forward(args)...); - nodePtr->executionOrder = Detail::SystemGraphExecutionOrder(); + nodePtr->executionOrder = Detail::EnttSystemGraphExecutionOrder(); T& system = nodePtr->system; @@ -63,7 +63,7 @@ namespace Nz } template - T& SystemGraph::GetSystem() const + T& EnttSystemGraph::GetSystem() const { auto it = m_systemToNodes.find(entt::type_hash()); if (it == m_systemToNodes.end()) diff --git a/include/Nazara/Core/EnttWorld.hpp b/include/Nazara/Core/EnttWorld.hpp new file mode 100644 index 000000000..8c7ecd59e --- /dev/null +++ b/include/Nazara/Core/EnttWorld.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CORE_ENTTWORLD_HPP +#define NAZARA_CORE_ENTTWORLD_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_CORE_API EnttWorld : public EntityWorld + { + public: + EnttWorld(); + EnttWorld(const EnttWorld&) = default; + EnttWorld(EnttWorld&&) = default; + ~EnttWorld() = default; + + template T& AddSystem(Args&&... args); + + entt::handle CreateEntity(); + + entt::registry& GetRegistry(); + const entt::registry& GetRegistry() const; + template T& GetSystem() const; + + void Update(Time elapsedTime) override; + + operator entt::registry&(); + operator const entt::registry&() const; + + EnttWorld& operator=(const EnttWorld&) = delete; + EnttWorld& operator=(EnttWorld&&) = delete; + + private: + entt::registry m_registry; + EnttSystemGraph m_systemGraph; + }; +} + +#include + +#endif // NAZARA_CORE_ENTTWORLD_HPP diff --git a/include/Nazara/Core/EnttWorld.inl b/include/Nazara/Core/EnttWorld.inl new file mode 100644 index 000000000..837c46ba1 --- /dev/null +++ b/include/Nazara/Core/EnttWorld.inl @@ -0,0 +1,53 @@ +// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline EnttWorld::EnttWorld() : + m_systemGraph(m_registry) + { + } + + template + T& EnttWorld::AddSystem(Args&&... args) + { + return m_systemGraph.AddSystem(std::forward(args)...); + } + + inline entt::handle EnttWorld::CreateEntity() + { + return entt::handle(m_registry, m_registry.create()); + } + + inline entt::registry& EnttWorld::GetRegistry() + { + return m_registry; + } + + inline const entt::registry& EnttWorld::GetRegistry() const + { + return m_registry; + } + + template + T& EnttWorld::GetSystem() const + { + return m_systemGraph.GetSystem(); + } + + inline EnttWorld::operator entt::registry&() + { + return m_registry; + } + + inline EnttWorld::operator const entt::registry&() const + { + return m_registry; + } +} + +#include diff --git a/include/Nazara/Core/Systems.hpp b/include/Nazara/Core/Systems.hpp index 6e8908062..01fe876e1 100644 --- a/include/Nazara/Core/Systems.hpp +++ b/include/Nazara/Core/Systems.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Core module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -30,6 +30,5 @@ #define NAZARA_CORE_SYSTEMS_HPP #include -#include #endif // NAZARA_CORE_SYSTEMS_HPP diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 4639112eb..ec4a887f9 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Graphics module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -91,4 +91,11 @@ #include #include +#ifdef NAZARA_ENTT + +#include +#include + +#endif + #endif // NAZARA_GLOBAL_GRAPHICS_HPP diff --git a/include/Nazara/Graphics/Components.hpp b/include/Nazara/Graphics/Components.hpp index f0525b030..c62ebc3ce 100644 --- a/include/Nazara/Graphics/Components.hpp +++ b/include/Nazara/Graphics/Components.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Graphics module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Graphics/Systems.hpp b/include/Nazara/Graphics/Systems.hpp index 0c2402cc1..8443fba70 100644 --- a/include/Nazara/Graphics/Systems.hpp +++ b/include/Nazara/Graphics/Systems.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Graphics module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Math.hpp b/include/Nazara/Math.hpp index 34df866d2..2d471783a 100644 --- a/include/Nazara/Math.hpp +++ b/include/Nazara/Math.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Math module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) Rémi "overdrivr" Bèges (remi.beges@laposte.net) Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/include/Nazara/Network.hpp b/include/Nazara/Network.hpp index a9bf833bb..5af8da000 100644 --- a/include/Nazara/Network.hpp +++ b/include/Nazara/Network.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Network module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer.hpp index 530de613b..ef9d649bb 100644 --- a/include/Nazara/OpenGLRenderer.hpp +++ b/include/Nazara/OpenGLRenderer.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - OpenGL renderer - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/OpenGLRenderer/Wrapper.hpp b/include/Nazara/OpenGLRenderer/Wrapper.hpp index f0424d4f1..5439ffdce 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - OpenGL renderer - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Physics2D.hpp b/include/Nazara/Physics2D.hpp index 43878e2ef..e71661663 100644 --- a/include/Nazara/Physics2D.hpp +++ b/include/Nazara/Physics2D.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Physics2D module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -38,4 +38,11 @@ #include #include +#ifdef NAZARA_ENTT + +#include +#include + +#endif + #endif // NAZARA_GLOBAL_PHYSICS2D_HPP diff --git a/include/Nazara/Physics2D/Components.hpp b/include/Nazara/Physics2D/Components.hpp index d2111705c..961ae131e 100644 --- a/include/Nazara/Physics2D/Components.hpp +++ b/include/Nazara/Physics2D/Components.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Physics2D module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Physics2D/Systems.hpp b/include/Nazara/Physics2D/Systems.hpp index a899e4c0b..06875bbb9 100644 --- a/include/Nazara/Physics2D/Systems.hpp +++ b/include/Nazara/Physics2D/Systems.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Physics2D module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Physics3D.hpp b/include/Nazara/Physics3D.hpp index 2a29a46ff..c726ff5a4 100644 --- a/include/Nazara/Physics3D.hpp +++ b/include/Nazara/Physics3D.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Physics3D module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -36,4 +36,11 @@ #include #include +#ifdef NAZARA_ENTT + +#include +#include + +#endif + #endif // NAZARA_GLOBAL_PHYSICS3D_HPP diff --git a/include/Nazara/Physics3D/Components.hpp b/include/Nazara/Physics3D/Components.hpp index 144565453..5adfe5173 100644 --- a/include/Nazara/Physics3D/Components.hpp +++ b/include/Nazara/Physics3D/Components.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Physics3D module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Physics3D/Systems.hpp b/include/Nazara/Physics3D/Systems.hpp index c901763f7..c98af7926 100644 --- a/include/Nazara/Physics3D/Systems.hpp +++ b/include/Nazara/Physics3D/Systems.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Physics3D module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Platform.hpp b/include/Nazara/Platform.hpp index 7dad894ba..bdb1f9c44 100644 --- a/include/Nazara/Platform.hpp +++ b/include/Nazara/Platform.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Platform module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index ef3ca49a0..1fb258b8f 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Renderer module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp index 54b2fa2b5..4837a6618 100644 --- a/include/Nazara/Utility.hpp +++ b/include/Nazara/Utility.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Utility module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -70,4 +70,11 @@ #include #include +#ifdef NAZARA_ENTT + +#include +#include + +#endif + #endif // NAZARA_GLOBAL_UTILITY_HPP diff --git a/include/Nazara/Utility/Components.hpp b/include/Nazara/Utility/Components.hpp index 497dd73fd..2ea1f4222 100644 --- a/include/Nazara/Utility/Components.hpp +++ b/include/Nazara/Utility/Components.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Utility module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Utility/Systems.hpp b/include/Nazara/Utility/Systems.hpp index 291bff42c..5025b6677 100644 --- a/include/Nazara/Utility/Systems.hpp +++ b/include/Nazara/Utility/Systems.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Utility module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index b19f39d0f..90a8a593b 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Vulkan renderer - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index adad6b9ca..3f1d1d257 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Vulkan renderer - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Widgets.hpp b/include/Nazara/Widgets.hpp index e73711500..63042240b 100644 --- a/include/Nazara/Widgets.hpp +++ b/include/Nazara/Widgets.hpp @@ -3,7 +3,7 @@ /* Nazara Engine - Widgets module - Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com) + Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/src/Nazara/Core/AppEntitySystemComponent.cpp b/src/Nazara/Core/AppEntitySystemComponent.cpp index 63d2ce08e..e8f9fec17 100644 --- a/src/Nazara/Core/AppEntitySystemComponent.cpp +++ b/src/Nazara/Core/AppEntitySystemComponent.cpp @@ -9,6 +9,7 @@ namespace Nz { void AppEntitySystemComponent::Update(Time elapsedTime) { - m_systemGraph.Update(elapsedTime); + for (auto& worldPtr : m_worlds) + worldPtr->Update(elapsedTime); } } diff --git a/src/Nazara/Core/EntityWorld.cpp b/src/Nazara/Core/EntityWorld.cpp new file mode 100644 index 000000000..190e6d67e --- /dev/null +++ b/src/Nazara/Core/EntityWorld.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + EntityWorld::~EntityWorld() = default; +} diff --git a/src/Nazara/Core/Systems/SystemGraph.cpp b/src/Nazara/Core/EnttSystemGraph.cpp similarity index 81% rename from src/Nazara/Core/Systems/SystemGraph.cpp rename to src/Nazara/Core/EnttSystemGraph.cpp index 7440f14f1..4af1f46ae 100644 --- a/src/Nazara/Core/Systems/SystemGraph.cpp +++ b/src/Nazara/Core/EnttSystemGraph.cpp @@ -2,19 +2,19 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - SystemGraph::NodeBase::~NodeBase() = default; + EnttSystemGraph::NodeBase::~NodeBase() = default; - void SystemGraph::Update() + void EnttSystemGraph::Update() { return Update(m_clock.Restart()); } - void SystemGraph::Update(Time elapsedTime) + void EnttSystemGraph::Update(Time elapsedTime) { if (!m_systemOrderUpdated) { diff --git a/src/Nazara/Core/EnttWorld.cpp b/src/Nazara/Core/EnttWorld.cpp new file mode 100644 index 000000000..a0e35ae17 --- /dev/null +++ b/src/Nazara/Core/EnttWorld.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + void EnttWorld::Update(Time elapsedTime) + { + m_systemGraph.Update(elapsedTime); + } +} diff --git a/xmake.lua b/xmake.lua index ff7c47cc8..d57bc5eaf 100644 --- a/xmake.lua +++ b/xmake.lua @@ -170,7 +170,7 @@ option("unitybuild", { description = "Build the engine using unity build", defau set_project("NazaraEngine") set_xmakever("2.7.3") -add_requires("chipmunk2d", "dr_wav", "efsw", "entt 3.10.1", "fmt", "frozen", "kiwisolver", "libflac", "libsdl", "minimp3", "ordered_map", "stb") +add_requires("chipmunk2d", "dr_wav", "efsw", "entt v3.11.1", "fmt", "frozen", "kiwisolver", "libflac", "libsdl", "minimp3", "ordered_map", "stb") add_requires("freetype", { configs = { bzip2 = true, png = true, woff2 = true, zlib = true, debug = is_mode("debug") } }) add_requires("libvorbis", { configs = { with_vorbisenc = false } }) add_requires("openal-soft", { configs = { shared = true }}) diff --git a/xmake/actions/generateheaders.lua b/xmake/actions/generateheaders.lua index 45d1c129c..a48c81f84 100644 --- a/xmake/actions/generateheaders.lua +++ b/xmake/actions/generateheaders.lua @@ -11,11 +11,11 @@ on_run(function () local paths = {} local excludedFiles = { - ["Components.hpp"] = true, + ["Components.hpp"] = { Define = "NAZARA_ENTT" }, ["ConfigCheck.hpp"] = true, ["Debug.hpp"] = true, ["DebugOff.hpp"] = true, - ["Systems.hpp"] = true, + ["Systems.hpp"] = { Define = "NAZARA_ENTT" }, ["ThreadSafety.hpp"] = true, ["ThreadSafetyOff.hpp"] = true } @@ -73,7 +73,9 @@ on_run(function () end paths["Audio"].Excludes["OpenALFunctions.hpp"] = true - paths["Core"].Excludes["AppEntitySystemComponent.hpp"] = true + paths["Core"].Excludes["AppEntitySystemComponent.hpp"] = { Define = "NAZARA_ENTT" } + paths["Core"].Excludes["EnttSystemGraph.hpp"] = { Define = "NAZARA_ENTT" } + paths["Core"].Excludes["EnttWorld.hpp"] = { Define = "NAZARA_ENTT" } paths["OpenGLRenderer"].Excludes["Wrapper.hpp"] = true paths["VulkanRenderer"].Excludes["Wrapper.hpp"] = true @@ -127,6 +129,8 @@ on_run(function () header:write("#ifndef " .. v.HeaderGuard .. "\n") header:write("#define " .. v.HeaderGuard .. "\n\n") + local gatedIncludes = {} + local count = 0 for _, filePath in pairs(files) do local pathParts = path.split(filePath) @@ -136,13 +140,31 @@ on_run(function () local include = table.concat(pathParts, "/") local fileName = path.filename(filePath) - if (not v.Excludes[fileName]) then + + local exclusion = v.Excludes[fileName] + if (not exclusion) then header:write("#include <" .. include .. ">\n") count = count + 1 + elseif (type(exclusion) == "table" and exclusion.Define) then + local gatedFiles = gatedIncludes[exclusion.Define] + if not gatedFiles then + gatedFiles = {} + gatedIncludes[exclusion.Define] = gatedFiles + end + table.insert(gatedFiles, include) end end - - header:write("\n#endif // " .. v.HeaderGuard .. "\n") + header:write("\n") + + for _, gatedDefine in ipairs(table.orderkeys(gatedIncludes)) do + header:write("#ifdef " .. gatedDefine .. "\n\n") + for _, include in ipairs(gatedIncludes[gatedDefine]) do + header:write("#include <" .. include .. ">\n") + end + header:write("\n#endif\n\n") + end + + header:write("#endif // " .. v.HeaderGuard .. "\n") header:close() print(string.format("-#include count: %d", count))