From fe5a4bcfb06374f62bbde54576ae0a6d07a49144 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 28 Jan 2022 11:31:34 +0900 Subject: [PATCH] lanternmap will blend when multiple blocks occupy the same block --- src/net/torvald/terrarum/serialise/WriteSavegame.kt | 4 ++-- src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/net/torvald/terrarum/serialise/WriteSavegame.kt b/src/net/torvald/terrarum/serialise/WriteSavegame.kt index a8de24cf7..fc78760ab 100644 --- a/src/net/torvald/terrarum/serialise/WriteSavegame.kt +++ b/src/net/torvald/terrarum/serialise/WriteSavegame.kt @@ -53,8 +53,8 @@ object WriteSavegame { val w = 960 val h = 640 - val cx = WorldCamera.x % 2 - val cy = WorldCamera.y % 2 + val cx = (1 - WorldCamera.x % 2) + val cy = (1 - WorldCamera.y % 2) val x = (fb.width - w) - cx // force the even-numbered position val y = (fb.height - h) - cy // force the even-numbered position diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt index d81163045..9a03b628a 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt @@ -341,9 +341,10 @@ object LightmapRenderer { for (x in lightBoxX.div(TILE_SIZE).floorInt() ..lightBoxX.plus(lightBoxW).div(TILE_SIZE).floorInt()) { - val normalisedCvec = it.color//.cpy().mul(DIV_FLOAT) + val oldLight = lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: Cvec(0) // if two or more luminous actors share the same block, mix the light + val actorLight = it.color - lanternMap[LandUtil.getBlockAddr(world, x, y)] = normalisedCvec + lanternMap[LandUtil.getBlockAddr(world, x, y)] = oldLight.maxAndAssign(actorLight) } } }