mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 10:09:16 +00:00
UnitMotion: Compute pushing-grid index once in Move()
pos.X/pos.Y divided by PUSHING_GRID_SIZE twice each (ENSURE, then m_MovingUnits.get()) instead of once.
This commit is contained in:
1 parent
43d8446854
commit
862bdd5349
1 file changed
+4
-6
@@ -456,12 +456,10 @@ void CCmpUnitMotionManager::Move(EntityMap<MotionState>& ents, fixed dt)
|
||||
it->second.pos = it->second.initialPos;
|
||||
it->second.speed = it->second.cmpUnitMotion->GetCurrentSpeed();
|
||||
it->second.angle = it->second.initialAngle;
|
||||
ENSURE(it->second.pos.X.ToInt_RoundToZero() / PUSHING_GRID_SIZE < m_MovingUnits.width() &&
|
||||
it->second.pos.Y.ToInt_RoundToZero() / PUSHING_GRID_SIZE < m_MovingUnits.height());
|
||||
std::vector<EntityMap<MotionState>::iterator>& subdiv = m_MovingUnits.get(
|
||||
it->second.pos.X.ToInt_RoundToZero() / PUSHING_GRID_SIZE,
|
||||
it->second.pos.Y.ToInt_RoundToZero() / PUSHING_GRID_SIZE
|
||||
);
|
||||
const int gridX{it->second.pos.X.ToInt_RoundToZero() / PUSHING_GRID_SIZE};
|
||||
const int gridY{it->second.pos.Y.ToInt_RoundToZero() / PUSHING_GRID_SIZE};
|
||||
ENSURE(gridX < m_MovingUnits.width() && gridY < m_MovingUnits.height());
|
||||
std::vector<EntityMap<MotionState>::iterator>& subdiv = m_MovingUnits.get(gridX, gridY);
|
||||
subdiv.emplace_back(it);
|
||||
assigned.emplace(&subdiv);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user