(World) Optimized entities handling a lot
Former-commit-id: f05f3bb7bf321d30fd51f504ace95aa0ea9f7f8d
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
#ifndef NDK_WORLD_HPP
|
||||
#define NDK_WORLD_HPP
|
||||
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/EntityHandle.hpp>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
@@ -27,21 +29,32 @@ namespace Ndk
|
||||
|
||||
void Clear();
|
||||
|
||||
EntityHandle GetEntity(Entity::Id id);
|
||||
|
||||
void KillEntity(const EntityHandle& entity);
|
||||
void KillEntities(const EntityList& list);
|
||||
|
||||
EntityHandle GetEntity(Entity::Id id);
|
||||
|
||||
bool IsEntityValid(const EntityHandle& entity) const;
|
||||
bool IsEntityIdValid(Entity::Id id) const;
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
struct EntityBlock
|
||||
{
|
||||
EntityBlock(Entity&& e) :
|
||||
entity(std::move(e))
|
||||
{
|
||||
}
|
||||
|
||||
Entity entity;
|
||||
unsigned int aliveIndex;
|
||||
};
|
||||
|
||||
std::vector<Entity::Id> m_freeIdList;
|
||||
std::vector<Entity> m_entities;
|
||||
std::vector<EntityBlock> m_entities;
|
||||
EntityList m_aliveEntities;
|
||||
EntityList m_killedEntities;
|
||||
NzBitset<nzUInt64> m_killedEntities;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user