Ensure the spatial index invalidates when moving the entity position

This commit is contained in:
ζeh Matt committed 2024-10-12 04:57:19 +03:00
1 parent 6a90e91237
commit 698a6491fc
2 files changed
+14 -21

No files matched your search

-12
View File
@@ -20,18 +20,6 @@ template<> bool EntityBase::Is<EntityBase>() const
return true;
}
CoordsXYZ EntityBase::GetLocation() const
{
return { x, y, z };
}
void EntityBase::SetLocation(const CoordsXYZ& newLocation)
{
x = newLocation.x;
y = newLocation.y;
z = newLocation.z;
}
void EntityBase::Invalidate()
{
if (x == kLocationNull)
+14 -9
View File
@@ -464,6 +464,19 @@ void UpdateEntitiesSpatialIndex()
}
}
CoordsXYZ EntityBase::GetLocation() const
{
return { x, y, z };
}
void EntityBase::SetLocation(const CoordsXYZ& newLocation)
{
x = newLocation.x;
y = newLocation.y;
z = newLocation.z;
SpatialIndex |= kSpatialIndexDirtyMask;
}
void EntityBase::MoveTo(const CoordsXYZ& newLocation)
{
if (x != kLocationNull)
@@ -478,17 +491,9 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation)
loc.x = kLocationNull;
}
const auto newSpatialIndex = ComputeSpatialIndex(loc);
if (newSpatialIndex != GetSpatialIndex(this))
{
SpatialIndex |= kSpatialIndexDirtyMask;
}
if (loc.x == kLocationNull)
{
x = loc.x;
y = loc.y;
z = loc.z;
SetLocation(loc);
}
else
{