diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index a35dc53ba..5cd046f55 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -27,6 +27,7 @@ namespace Ndk static SystemIndex systemIndex; private: + void OnEntityRemoved(Entity* entity) override; void OnEntityValidation(Entity* entity, bool justAdded) override; EntityList m_cameras; diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 4c4f3a629..e114499e7 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -16,6 +16,12 @@ namespace Ndk { } + void RenderSystem::OnEntityRemoved(Entity* entity) + { + m_cameras.Remove(entity); + m_drawables.Remove(entity); + } + void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded) { if (entity->HasComponent()) diff --git a/build/scripts/features/core.lua b/build/scripts/features/core.lua index 120917eab..9ce9919ff 100644 --- a/build/scripts/features/core.lua +++ b/build/scripts/features/core.lua @@ -42,8 +42,8 @@ return { { Title = "Stockage et gestion de champs de bits dynamiques (Bitset)", Description = "Classe permettant le stockage et la manipulation optimisée d'un nombre élevé et dynamique de bits (=booléens, opérations de comptage, recherche de bits activés, opérations entre champs de bits, etc.)", - Note = "Il manque des opérateurs de comparaison et une spécialisation de la fonction de hachage", - Progress = 90 + Note = "Il manque une spécialisation de la fonction de hachage", + Progress = 95 } } }, diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index bc1df0e27..389455ba0 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -110,6 +110,18 @@ bool operator==(const NzBitset& lhs, const NzBitset bool operator!=(const NzBitset& lhs, const NzBitset& rhs); +template +bool operator<(const NzBitset& lhs, const NzBitset& rhs); + +template +bool operator<=(const NzBitset& lhs, const NzBitset& rhs); + +template +bool operator>(const NzBitset& lhs, const NzBitset& rhs); + +template +bool operator>=(const NzBitset& lhs, const NzBitset& rhs); + template NzBitset operator&(const NzBitset& lhs, const NzBitset& rhs); diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index a02c16550..c0d365eea 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -555,6 +555,51 @@ bool operator!=(const NzBitset& lhs, const NzBitset +bool operator<(const NzBitset& lhs, const NzBitset& rhs) +{ + const NzBitset& greater = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? lhs : rhs; + const NzBitset& lesser = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? rhs : lhs; + + unsigned int maxBlockCount = greater.GetBlockCount(); + unsigned int minBlockCount = lesser.GetBlockCount(); + + // If the greatest bitset has a single bit active in a block outside the lesser bitset range, then it is greater + for (unsigned int i = maxBlockCount; i > minBlockCount; ++i) + { + if (greater.GetBlock(i)) + return lhs.GetBlockCount() < rhs.GetBlockCount(); + } + + // Compare the common blocks + for (unsigned int i = 0; i < minBlockCount; ++i) + { + unsigned int index = (minBlockCount - i - 1); // Compare from the most significant block to the less significant block + if (lhs.GetBlock(index) < rhs.GetBlock(index)) + return true; + } + + return false; // They are equal +} + +template +bool operator<=(const NzBitset& lhs, const NzBitset& rhs) +{ + return lhs < rhs || lhs == rhs; +} + +template +bool operator>(const NzBitset& lhs, const NzBitset& rhs) +{ + return rhs < lhs; +} + +template +bool operator>=(const NzBitset& lhs, const NzBitset& rhs) +{ + return rhs <= lhs; +} + template NzBitset operator&(const NzBitset& lhs, const NzBitset& rhs) {