diff --git a/ChangeLog.md b/ChangeLog.md index 9eb1627a2..89ad63f04 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -94,6 +94,7 @@ Nazara Development Kit: - Fix TextAreaWidget::Clear crash - Add ConstraintComponent2D class - Fix CollisionComponent3D initialization (teleportation to their real coordinates) which could sometimes mess up the physics scene. +- ⚠️ Renamed World::Update() to World::Refresh() for more clarity and to differentiate it from World::Update(elapsedTime) # 0.4: diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index ee7d4bbb2..694457412 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -64,8 +64,9 @@ namespace Ndk inline void RemoveSystem(SystemIndex index); template void RemoveSystem(); - void Update(); - inline void Update(float elapsedTime); + void Refresh(); + + void Update(float elapsedTime); World& operator=(const World&) = delete; inline World& operator=(World&& world) noexcept; diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index d2be8ac40..4ddc2638f 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -278,21 +278,6 @@ namespace Ndk RemoveSystem(index); } - /*! - * \brief Updates the world - * - * \param elapsedTime Delta time used for the update - */ - - inline void World::Update(float elapsedTime) - { - Update(); //< Update entities - - // And then update systems - for (auto& systemPtr : m_orderedSystems) - systemPtr->Update(elapsedTime); - } - /*! * \brief Moves a world into another world object * \return A reference to the object diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 3a7427ecc..dd99fee54 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -166,12 +166,16 @@ namespace Ndk } /*! - * \brief Updates the world + * \brief Refreshes the world + * + * This function will perform all pending operations in the following order: + * - Reorder systems according to their update order if needed + * - Moving newly created entities (whose which allocate never-used id) data and handles to normal entity list, this will invalidate references to world EntityHandle + * - Destroying dead entities and allowing their ids to be used by newly created entities + * - Update dirty entities, destroying their removed components and filtering them along systems * - * \remark Produces a NazaraAssert if an entity is invalid */ - - void World::Update() + void World::Refresh() { if (!m_orderedSystemsUpdated) ReorderSystems(); @@ -248,6 +252,20 @@ namespace Ndk m_dirtyEntities.Reset(); } + /*! + * \brief Updates the world + * + * \param elapsedTime Delta time used for the update + */ + void World::Update(float elapsedTime) + { + Refresh(); //< Update entities + + // And then update systems + for (auto& systemPtr : m_orderedSystems) + systemPtr->Update(elapsedTime); + } + void World::ReorderSystems() { m_orderedSystems.clear();