MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / freshenCollision

Method freshenCollision

source/game/StarWorldClient.cpp:2072–2101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2070}
2071
2072void WorldClient::freshenCollision(RectI const& region) {
2073 if (!inWorld())
2074 return;
2075
2076 RectI freshenRegion = RectI::null();
2077 for (int x = region.xMin(); x < region.xMax(); ++x) {
2078 for (int y = region.yMin(); y < region.yMax(); ++y) {
2079 if (auto tile = m_tileArray->modifyTile({x, y})) {
2080 if (tile->collisionCacheDirty)
2081 freshenRegion.combine(RectI(x, y, x + 1, y + 1));
2082 }
2083 }
2084 }
2085
2086 if (!freshenRegion.isNull()) {
2087 for (int x = freshenRegion.xMin(); x < freshenRegion.xMax(); ++x) {
2088 for (int y = freshenRegion.yMin(); y < freshenRegion.yMax(); ++y) {
2089 if (auto tile = m_tileArray->modifyTile({x, y})) {
2090 tile->collisionCacheDirty = false;
2091 tile->collisionCache.clear();
2092 }
2093 }
2094 }
2095
2096 for (auto& collisionBlock : m_collisionGenerator.getBlocks(freshenRegion)) {
2097 if (auto tile = m_tileArray->modifyTile(collisionBlock.space))
2098 tile->collisionCache.append(std::move(collisionBlock));
2099 }
2100 }
2101}
2102
2103float WorldClient::lightLevel(Vec2F const& pos) const {
2104 if (!inWorld())

Callers 1

forEachCollisionBlockMethod · 0.45

Calls 10

xMinMethod · 0.80
xMaxMethod · 0.80
yMinMethod · 0.80
yMaxMethod · 0.80
getBlocksMethod · 0.80
modifyTileMethod · 0.45
combineMethod · 0.45
isNullMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected