MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ComputeSpatialIndex

Function ComputeSpatialIndex

src/openrct2/entity/EntityRegistry.cpp:47–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 using namespace OpenRCT2::Core;
46
47 static constexpr uint32_t ComputeSpatialIndex(const CoordsXY& loc)
48 {
49 if (loc.IsNull())
50 return kSpatialIndexNullBucket;
51
52 // NOTE: The input coordinate is rotated and can have negative components.
53 const auto tileX = std::abs(loc.x) / kCoordsXYStep;
54 const auto tileY = std::abs(loc.y) / kCoordsXYStep;
55
56 if (tileX >= kMaximumMapSizeTechnical || tileY >= kMaximumMapSizeTechnical)
57 return kSpatialIndexNullBucket;
58
59 return tileX * kMaximumMapSizeTechnical + tileY;
60 }
61
62 static constexpr uint32_t GetSpatialIndex(EntityBase& entity)
63 {

Callers 3

EntityRegistry.cppFile · 0.85
EntitySpatialInsertMethod · 0.85
setLocationMethod · 0.85

Calls 1

IsNullMethod · 0.45

Tested by

no test coverage detected