| 1681 | } |
| 1682 | |
| 1683 | void 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 | |
| 1714 | void WorldClient::lightingCalc() { |
| 1715 | MutexLocker prepLocker(m_lightMapPrepMutex); |
nothing calls this directly
no test coverage detected