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

Method lightingTileGather

source/game/StarWorldClient.cpp:1683–1712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1681}
1682
1683void WorldClient::lightingTileGather() {
1684 int64_t start = Time::monotonicMicroseconds();
1685 Vec3F environmentLight = m_sky->environmentLight().toRgbF();
1686 float undergroundLevel = m_worldTemplate->undergroundLevel();
1687 auto liquidsDatabase = Root::singleton().liquidsDatabase();
1688 auto materialDatabase = Root::singleton().materialDatabase();
1689
1690 // Each column in tileEvalColumns is guaranteed to be no larger than the sector size.
1691
1692 m_tileArray->tileEvalColumns(m_lightingCalculator.calculationRegion(), [&](Vec2I const& pos, ClientTile const* column, size_t ySize) {
1693 size_t baseIndex = m_lightingCalculator.baseIndexFor(pos);
1694 for (size_t y = 0; y < ySize; ++y) {
1695 auto& tile = column[y];
1696 Vec3F light;
1697 if (tile.foreground != EmptyMaterialId || tile.foregroundMod != NoModId)
1698 light += materialDatabase->radiantLight(tile.foreground, tile.foregroundMod);
1699
1700 if (tile.liquid.liquid != EmptyLiquidId && tile.liquid.level != 0.0f)
1701 light += liquidsDatabase->radiantLight(tile.liquid);
1702 if (tile.foregroundLightTransparent) {
1703 if (tile.background != EmptyMaterialId || tile.backgroundMod != NoModId)
1704 light += materialDatabase->radiantLight(tile.background, tile.backgroundMod);
1705 if (tile.backgroundLightTransparent && pos[1] + y > undergroundLevel)
1706 light += environmentLight;
1707 }
1708 m_lightingCalculator.setCellIndex(baseIndex + y, light, !tile.foregroundLightTransparent);
1709 }
1710 });
1711 LogMap::set("client_render_world_async_light_gather", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
1712}
1713
1714void WorldClient::lightingCalc() {
1715 MutexLocker prepLocker(m_lightMapPrepMutex);

Callers

nothing calls this directly

Calls 13

singletonClass · 0.85
strfFunction · 0.85
toRgbFMethod · 0.80
environmentLightMethod · 0.80
undergroundLevelMethod · 0.80
liquidsDatabaseMethod · 0.80
materialDatabaseMethod · 0.80
tileEvalColumnsMethod · 0.80
calculationRegionMethod · 0.80
baseIndexForMethod · 0.80
setCellIndexMethod · 0.80
setFunction · 0.50

Tested by

no test coverage detected