(EntityHandle) Fixed hashs

Former-commit-id: f5d23d81a5b46dfbf90d2004dfeb9595f30c2df2
This commit is contained in:
Lynix 2015-03-31 02:20:30 +02:00
parent c25f824f65
commit 28b0e26a88
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp // For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <functional> #include <functional>
#include <limits>
namespace Ndk namespace Ndk
{ {
@ -242,7 +243,11 @@ namespace std
{ {
size_t operator()(const Ndk::EntityHandle& handle) const size_t operator()(const Ndk::EntityHandle& handle) const
{ {
return hash<Ndk::Entity*>()(handle.GetEntity()); // Hasher le pointeur fonctionnerait jusqu'à ce que l'entité soit mise à jour et déplacée
// pour cette raison, nous devons hasher l'ID de l'entité (qui reste constante)
Ndk::EntityId id = (handle.IsValid()) ? handle->GetId() : std::numeric_limits<Ndk::EntityId>::max();
return hash<Ndk::EntityId>()(id);
} }
}; };