MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / getSpatialIndexOffset

Function getSpatialIndexOffset

src/OpenLoco/src/Entities/EntityManager.cpp:132–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130 }
131
132 constexpr size_t getSpatialIndexOffset(const World::Pos2& loc)
133 {
134 if (loc.x == Location::null)
135 {
136 return kEntitySpatialIndexNull;
137 }
138
139 const auto tileX = std::abs(loc.x) / World::kTileSize;
140 const auto tileY = std::abs(loc.y) / World::kTileSize;
141
142 if (tileX >= World::kMapPitch || tileY >= World::kMapPitch)
143 {
144 return kEntitySpatialIndexNull;
145 }
146
147 return (World::kMapPitch * tileX) + tileY;
148 }
149
150 EntityId firstQuadrantId(const World::Pos2& loc)
151 {

Callers 4

firstQuadrantIdFunction · 0.85
insertToSpatialIndexFunction · 0.85
removeFromSpatialIndexFunction · 0.85
moveSpatialEntryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected