downsampling sorta works, ONLY WHEN (width or height % 4) is 0 or 1

This commit is contained in:
minjaesong
2017-07-05 16:03:50 +09:00
parent e54822a7e4
commit 2d5761d66c
16 changed files with 114 additions and 95 deletions

View File

@@ -47,7 +47,7 @@ object FeaturesDrawer {
* usually targeted for the environmental temperature (desert/winterland), hence the name.
*/
fun drawEnvOverlay(batch: SpriteBatch) {
val onscreen_tiles_max = FastMath.ceil(Gdx.graphics.height * Gdx.graphics.width / FastMath.sqr (TILE_SIZE.toFloat())) * 2
val onscreen_tiles_max = FastMath.ceil(TerrarumGDX.HEIGHT * TerrarumGDX.WIDTH / FastMath.sqr (TILE_SIZE.toFloat())) * 2
val onscreen_tiles_cap = onscreen_tiles_max / 4f
val onscreen_cold_tiles = BlockStats.getCount(*TILES_COLD).toFloat()
val onscreen_warm_tiles = BlockStats.getCount(*TILES_WARM).toFloat()
@@ -62,8 +62,8 @@ object FeaturesDrawer {
batch.color = ColourTemp(colTemp)
batch.fillRect(WorldCamera.x * zoom,
WorldCamera.y * zoom,
Gdx.graphics.width * if (zoom < 1) 1f / zoom else zoom,
Gdx.graphics.height * if (zoom < 1) 1f / zoom else zoom
TerrarumGDX.WIDTH * if (zoom < 1) 1f / zoom else zoom,
TerrarumGDX.HEIGHT * if (zoom < 1) 1f / zoom else zoom
)
}

View File

@@ -34,9 +34,9 @@ object LightmapRenderer {
// TODO resize(int, int) -aware
val LIGHTMAP_WIDTH = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(Gdx.graphics.width)
val LIGHTMAP_WIDTH = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(TerrarumGDX.WIDTH)
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
val LIGHTMAP_HEIGHT = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(Gdx.graphics.height)
val LIGHTMAP_HEIGHT = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(TerrarumGDX.HEIGHT)
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
/**
@@ -351,7 +351,7 @@ object LightmapRenderer {
(x * DRAW_TILE_SIZE).round().toFloat(),
(y * DRAW_TILE_SIZE).round().toFloat(),
(DRAW_TILE_SIZE.ceil() * sameLevelCounter).toFloat(),
DRAW_TILE_SIZE.ceil().toFloat()
DRAW_TILE_SIZE.ceil().toFloat() + 1f
)
x += sameLevelCounter - 1

View File

@@ -3,7 +3,12 @@ package net.torvald.terrarum.worlddrawer
import com.badlogic.gdx.Gdx
import com.jme3.math.FastMath
import net.torvald.terrarum.TerrarumGDX
import net.torvald.terrarum.gameactors.ceilInt
import net.torvald.terrarum.gameactors.floor
import net.torvald.terrarum.gameactors.floorInt
import net.torvald.terrarum.gameactors.roundInt
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.round
/**
* Created by minjaesong on 2016-12-30.
@@ -34,26 +39,21 @@ object WorldCamera {
val player = TerrarumGDX.ingame!!.player
width = FastMath.ceil(Gdx.graphics.width / TerrarumGDX.ingame!!.screenZoom) // div, not mul
height = FastMath.ceil(Gdx.graphics.height / TerrarumGDX.ingame!!.screenZoom)
width = FastMath.ceil(TerrarumGDX.WIDTH / TerrarumGDX.ingame!!.screenZoom) // div, not mul
height = FastMath.ceil(TerrarumGDX.HEIGHT / TerrarumGDX.ingame!!.screenZoom)
// position - (WH / 2)
x = Math.round(// X only: ROUNDWORLD implementation
(player?.hitbox?.centeredX?.toFloat() ?: 0f) - width / 2)
y = Math.round(FastMath.clamp(
x = (// X only: ROUNDWORLD implementation
(player?.hitbox?.centeredX?.toFloat() ?: 0f) - width / 2).roundInt()
y = (FastMath.clamp(
(player?.hitbox?.centeredY?.toFloat() ?: 0f) - height / 2,
TILE_SIZE.toFloat(),
world!!.height * TILE_SIZE - height - TILE_SIZE.toFloat()
))
)).roundInt()
gdxCamX = Math.round(// X only: ROUNDWORLD implementation
(player?.hitbox?.centeredX?.toFloat() ?: 0f)).toFloat()
gdxCamY = Math.round(FastMath.clamp(
(player?.hitbox?.centeredY?.toFloat() ?: 0f),
TILE_SIZE.toFloat(),
world!!.height * TILE_SIZE - height - TILE_SIZE.toFloat()
)).toFloat()
gdxCamX = x + (width / 2f).round()
gdxCamY = y + (height / 2f).round()
}
}
}