From f466a7494b83a584efe31fe45911bb441372d6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 8 Feb 2022 20:05:14 +0100 Subject: [PATCH] Update for EnTT 3.9 --- examples/PhysicsDemo/main.cpp | 3 +- examples/WidgetDemo/main.cpp | 3 +- include/Nazara/Core/ECS.hpp | 48 ------------------- include/Nazara/Core/ECS.inl | 42 ---------------- .../Graphics/Components/GraphicsComponent.hpp | 2 +- .../Graphics/Components/LightComponent.hpp | 2 +- .../Nazara/Graphics/Systems/RenderSystem.hpp | 2 +- .../Physics3D/Systems/Physics3DSystem.hpp | 2 +- .../Utility/Components/NodeComponent.hpp | 2 +- include/Nazara/Widgets/Widgets.hpp | 4 +- src/Nazara/Core/ECS.cpp | 11 ----- src/Nazara/Graphics/Graphics.cpp | 3 -- src/Nazara/Physics3D/Physics3D.cpp | 2 - src/Nazara/Utility/Utility.cpp | 3 -- src/Nazara/Widgets/Widgets.cpp | 4 +- xmake.lua | 2 +- 16 files changed, 11 insertions(+), 124 deletions(-) delete mode 100644 include/Nazara/Core/ECS.hpp delete mode 100644 include/Nazara/Core/ECS.inl delete mode 100644 src/Nazara/Core/ECS.cpp diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index 2cd8c9216..d8f123bc3 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -38,7 +37,7 @@ int main() std::cin.ignore(std::numeric_limits::max(), '\n'); - Nz::Modules nazara(rendererConfig); + Nz::Modules nazara(rendererConfig); Nz::RenderWindow window; diff --git a/examples/WidgetDemo/main.cpp b/examples/WidgetDemo/main.cpp index 9f86592a8..a8d930cc4 100644 --- a/examples/WidgetDemo/main.cpp +++ b/examples/WidgetDemo/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -38,7 +37,7 @@ int main() std::cin.ignore(std::numeric_limits::max(), '\n'); - Nz::Modules nazara(rendererConfig); + Nz::Modules nazara(rendererConfig); Nz::RenderWindow window; diff --git a/include/Nazara/Core/ECS.hpp b/include/Nazara/Core/ECS.hpp deleted file mode 100644 index 965a47d8c..000000000 --- a/include/Nazara/Core/ECS.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2022 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_ECS_HPP -#define NAZARA_CORE_ECS_HPP - -#include -#include -#include - -namespace Nz -{ - class CameraComponent; - class GraphicsComponent; - class NodeComponent; - class RigidBody3DComponent; - - class ECS : public ModuleBase - { - friend ModuleBase; - friend class Audio; - friend class Graphics; - friend class Physics2D; - friend class Physics3D; - friend class Utility; - friend class Widgets; - - public: - using Dependencies = TypeList; - - struct Config {}; - - inline ECS(Config /*config*/); - ~ECS() = default; - - private: - static inline void RegisterComponents(); - - NAZARA_CORE_API static ECS* s_instance; - }; -} - -#include - -#endif // NAZARA_CORE_ECS_HPP diff --git a/include/Nazara/Core/ECS.inl b/include/Nazara/Core/ECS.inl deleted file mode 100644 index 94db626e1..000000000 --- a/include/Nazara/Core/ECS.inl +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2022 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 -#include - -namespace Nz -{ - namespace Detail - { - template - struct RegisterComponent - { - void operator()(entt::id_type& expectedId) - { - if (entt::type_seq() != expectedId++) - throw std::runtime_error(std::string(entt::type_name::value()) + " has wrong index, please initialize Nazara ECS before instancing your own components"); - } - }; - } - - /*! - * \ingroup core - * \class Nz::ECS - * \brief Core class that represents the ECS module - */ - inline ECS::ECS(Config /*config*/) : - ModuleBase("ECS", this) - { - RegisterComponents(); - } - - inline void ECS::RegisterComponents() - { - entt::id_type expectedId = 0; - TypeListApply, Detail::RegisterComponent>(expectedId); - } -} - -#include diff --git a/include/Nazara/Graphics/Components/GraphicsComponent.hpp b/include/Nazara/Graphics/Components/GraphicsComponent.hpp index 37c463f35..8002b7ae9 100644 --- a/include/Nazara/Graphics/Components/GraphicsComponent.hpp +++ b/include/Nazara/Graphics/Components/GraphicsComponent.hpp @@ -8,9 +8,9 @@ #define NAZARA_GRAPHICS_COMPONENTS_GRAPHICSCOMPONENT_HPP #include -#include #include #include +#include #include #include diff --git a/include/Nazara/Graphics/Components/LightComponent.hpp b/include/Nazara/Graphics/Components/LightComponent.hpp index 5101d746a..7e9aba747 100644 --- a/include/Nazara/Graphics/Components/LightComponent.hpp +++ b/include/Nazara/Graphics/Components/LightComponent.hpp @@ -8,9 +8,9 @@ #define NAZARA_GRAPHICS_COMPONENTS_LIGHTCOMPONENT_HPP #include -#include #include #include +#include #include #include diff --git a/include/Nazara/Graphics/Systems/RenderSystem.hpp b/include/Nazara/Graphics/Systems/RenderSystem.hpp index d90ae1cd4..00312edce 100644 --- a/include/Nazara/Graphics/Systems/RenderSystem.hpp +++ b/include/Nazara/Graphics/Systems/RenderSystem.hpp @@ -8,11 +8,11 @@ #define NAZARA_GRAPHICS_SYSTEMS_RENDERSYSTEM_HPP #include -#include #include #include #include #include +#include #include #include #include diff --git a/include/Nazara/Physics3D/Systems/Physics3DSystem.hpp b/include/Nazara/Physics3D/Systems/Physics3DSystem.hpp index 2e646af55..3777688b4 100644 --- a/include/Nazara/Physics3D/Systems/Physics3DSystem.hpp +++ b/include/Nazara/Physics3D/Systems/Physics3DSystem.hpp @@ -8,9 +8,9 @@ #define NAZARA_PHYSICS3D_SYSTEMS_PHYSICS3DSYSTEM_HPP #include -#include #include #include +#include namespace Nz { diff --git a/include/Nazara/Utility/Components/NodeComponent.hpp b/include/Nazara/Utility/Components/NodeComponent.hpp index 92e11865b..2311702b1 100644 --- a/include/Nazara/Utility/Components/NodeComponent.hpp +++ b/include/Nazara/Utility/Components/NodeComponent.hpp @@ -8,8 +8,8 @@ #define NAZARA_UTILITY_COMPONENTS_NODECOMPONENT_HPP #include -#include #include +#include namespace Nz { diff --git a/include/Nazara/Widgets/Widgets.hpp b/include/Nazara/Widgets/Widgets.hpp index 44617244f..81a2a3feb 100644 --- a/include/Nazara/Widgets/Widgets.hpp +++ b/include/Nazara/Widgets/Widgets.hpp @@ -8,10 +8,10 @@ #define NAZARA_WIDGETS_HPP #include -#include #include #include #include +#include namespace Nz { @@ -23,7 +23,7 @@ namespace Nz friend ModuleBase; public: - using Dependencies = TypeList; + using Dependencies = TypeList; struct Config; diff --git a/src/Nazara/Core/ECS.cpp b/src/Nazara/Core/ECS.cpp deleted file mode 100644 index ba935b290..000000000 --- a/src/Nazara/Core/ECS.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2022 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 -{ - NAZARA_CORE_API ECS* ECS::s_instance = nullptr; -} diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index f0ffa120c..4c4dac94b 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include @@ -29,8 +28,6 @@ namespace Nz ModuleBase("Graphics", this), m_preferredDepthStencilFormat(PixelFormat::Undefined) { - ECS::RegisterComponents(); - Renderer* renderer = Renderer::Instance(); const std::vector& renderDeviceInfo = renderer->QueryRenderDevices(); diff --git a/src/Nazara/Physics3D/Physics3D.cpp b/src/Nazara/Physics3D/Physics3D.cpp index 7dbfbd21b..09b2f94fa 100644 --- a/src/Nazara/Physics3D/Physics3D.cpp +++ b/src/Nazara/Physics3D/Physics3D.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -17,7 +16,6 @@ namespace Nz Physics3D::Physics3D(Config /*config*/) : ModuleBase("Physics3D", this) { - ECS::RegisterComponents(); } unsigned int Physics3D::GetMemoryUsed() diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 53008a748..c996d55a2 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -40,8 +39,6 @@ namespace Nz Utility::Utility(Config /*config*/) : ModuleBase("Utility", this) { - ECS::RegisterComponents(); - if (!Font::Initialize()) throw std::runtime_error("failed to initialize fonts"); diff --git a/src/Nazara/Widgets/Widgets.cpp b/src/Nazara/Widgets/Widgets.cpp index 8f3563d71..b5d3c9221 100644 --- a/src/Nazara/Widgets/Widgets.cpp +++ b/src/Nazara/Widgets/Widgets.cpp @@ -15,11 +15,9 @@ namespace Nz * \class Nz::Widgets * \brief Widgets class that represents the module initializer of Widgets */ - Widgets::Widgets(Config config) : + Widgets::Widgets(Config /*config*/) : ModuleBase("Widgets", this) { - ECS::RegisterComponents(); - CreateDefaultMaterials(); } diff --git a/xmake.lua b/xmake.lua index e1d6c8e08..077341768 100644 --- a/xmake.lua +++ b/xmake.lua @@ -109,7 +109,7 @@ set_xmakever("2.6.3") add_repositories("local-repo xmake-repo") -add_requires("chipmunk2d", "dr_wav", "entt", "kiwisolver", "libflac", "libsdl", "minimp3", "stb") +add_requires("chipmunk2d", "dr_wav", "entt >=3.9", "kiwisolver", "libflac", "libsdl", "minimp3", "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 }})