| 1712 | } |
| 1713 | |
| 1714 | void WorldClient::lightingCalc() { |
| 1715 | MutexLocker prepLocker(m_lightMapPrepMutex); |
| 1716 | if (!m_pendingLightReady.load()) |
| 1717 | return; |
| 1718 | m_pendingLightReady = false; |
| 1719 | RectI lightRange = m_pendingLightRange; |
| 1720 | List<LightSource> lights = std::move(m_pendingLights); |
| 1721 | List<std::pair<Vec2F, Vec3F>> particleLights = std::move(m_pendingParticleLights); |
| 1722 | auto& root = Root::singleton(); |
| 1723 | auto configuration = root.configuration(); |
| 1724 | bool newLighting = configuration->get("newLighting").optBool().value(true); |
| 1725 | bool monochrome = configuration->get("monochromeLighting").toBool(); |
| 1726 | m_lightingCalculator.setParameters(root.assets()->json("/lighting.config:lighting").set("pointAdditive", newLighting)); |
| 1727 | m_lightingCalculator.setMonochrome(monochrome); |
| 1728 | m_lightingCalculator.begin(lightRange); |
| 1729 | lightingTileGather(); |
| 1730 | |
| 1731 | prepLocker.unlock(); |
| 1732 | |
| 1733 | for (auto const& light : lights) { |
| 1734 | Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), light.position); |
| 1735 | if (light.type == LightType::Spread) |
| 1736 | m_lightingCalculator.addSpreadLight(position, light.color); |
| 1737 | else { |
| 1738 | if (light.type == LightType::PointAsSpread) { |
| 1739 | if (!newLighting) |
| 1740 | m_lightingCalculator.addSpreadLight(position, light.color); |
| 1741 | else { // hybrid (used for auto-converted object lights) - 85% spread, 15% point (* .15 is applied in the calculation code) |
| 1742 | m_lightingCalculator.addSpreadLight(position, light.color * 0.85f); |
| 1743 | m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience, true); |
| 1744 | } |
| 1745 | } else { |
| 1746 | m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience); |
| 1747 | } |
| 1748 | } |
| 1749 | } |
| 1750 | |
| 1751 | for (auto const& lightPair : particleLights) { |
| 1752 | Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), lightPair.first); |
| 1753 | m_lightingCalculator.addSpreadLight(position, lightPair.second); |
| 1754 | } |
| 1755 | |
| 1756 | m_lightingCalculator.calculate(m_pendingLightMap); |
| 1757 | { |
| 1758 | MutexLocker mapLocker(m_lightMapMutex); |
| 1759 | m_lightMinPosition = lightRange.min(); |
| 1760 | m_lightMap = std::move(m_pendingLightMap); |
| 1761 | } |
| 1762 | } |
| 1763 | |
| 1764 | void WorldClient::lightingMain() { |
| 1765 | MutexLocker condLocker(m_lightingMutex); |
nothing calls this directly
no test coverage detected