diff --git a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt index 5989f33ea..595282e8a 100644 --- a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt +++ b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt @@ -359,9 +359,6 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) { mouseOnUI = (overwriteMouseOnUI || uiPenMenu.isVisible /*|| uiPalette.isVisible*/ || uiGetPoiName.isVisible) - WorldCamera.update(world, actorNowPlaying) - - // make pen work HERE // when LEFT mouse is down if (!tappedOnUI && Terrarum.mouseDown && !mouseOnUI) { @@ -457,6 +454,8 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) { private val renderGame = { delta: Float -> _testMarkerDrawCalls = 0L + WorldCamera.update(world, actorNowPlaying) + IngameRenderer.invoke(delta, false, screenZoom, listOf(), diff --git a/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt b/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt index 08bd33464..feefbf17d 100644 --- a/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt +++ b/src/net/torvald/terrarum/modulebasegame/TitleScreen.kt @@ -328,9 +328,6 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) { WeatherMixer.update(delta, cameraPlayer, demoWorld) cameraPlayer.update(delta) - // worldcamera update AFTER cameraplayer in this case; the other way is just an exception for actual ingame SFX - WorldCamera.update(demoWorld, cameraPlayer) - // update UIs // uiContainer.forEach { it?.update(delta) } @@ -369,6 +366,8 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) { if (!demoWorld.layerTerrain.ptr.destroyed) { // FIXME q&d hack to circumvent the dangling pointer issue #26 + WorldCamera.update(demoWorld, cameraPlayer) + IngameRenderer.invoke( delta, false, diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt index 90bbea698..0371fa381 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt @@ -1176,7 +1176,11 @@ internal object BlocksDrawer { private val occlusionIntensity = 0.25f // too low value and dark-coloured walls won't darken enough private val doTilemapUpdate: Boolean - get() = (!world.layerTerrain.ptrDestroyed && App.GLOBAL_RENDER_TIMER % 3 == 0L) + get() { + // TODO adaptive rate control via cam delta + val rate = 4 + return (!world.layerTerrain.ptrDestroyed && App.GLOBAL_RENDER_TIMER % rate == 0L) + } private var camTransX = 0 private var camTransY = 0 diff --git a/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt b/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt index 034c38fc4..fe501f2dd 100644 --- a/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt +++ b/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt @@ -79,6 +79,9 @@ object WorldCamera { inline val camVector: com.badlogic.gdx.math.Vector2 get() = com.badlogic.gdx.math.Vector2(gdxCamX, gdxCamY) + /** + * Must be called on RENDER, not UPDATE, before the IngameRenderer invocation. + */ fun update(world: GameWorld, player: ActorWithBody?) { if (player == null) return