From 0056f92b653a8c2f6aea8b455941d3b323dff629 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 20 Nov 2018 06:08:21 +0900 Subject: [PATCH] physics anomaly at x 0..33? are fixed, other issues (re)introduced See ActorWBMovable@Line1238 --- .../terrarum/gameactors/ActorWBMovable.kt | 38 ++++++++++++++++--- .../terrarum/worlddrawer/BlocksDrawerNew.kt | 2 +- .../worlddrawer/LightmapRendererNew.kt | 3 ++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt b/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt index 84b7adf6a..9276cd00d 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt @@ -1218,19 +1218,47 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean = // // -- Signed, 2017-09-17 + // DEAR PAST ME AT 2017-09-23, + // + // I'm starting to thinking that actually fixing the negative-coord-bug in collision part (you know + // it's caused by wrapping the values to the negative part internally, eh?) ought to be actually faster + // to resolve this year-old issue + // + // Or maybe just allow cameraX (left point) to be negative number and fix the renderer (in which whole + // tiles shifts to left)? + // + // It was interesting; 'fmod' in + // shader.setUniformi("cameraTranslation", WorldCamera.x % TILE_SIZE, WorldCamera.y % TILE_SIZE) // surprisingly, using 'fmod' instead of '%' doesn't work + // broke it, had to use '%'; + // Also, in the lightmap renderer, I had to add this line when updating for_x_start: + // if (for_x_start < 0) for_x_start -= 1 + // Apparently this also fixes notorious jumping issue because hitbox position is changed (wrapped to + // different coord?), which I'm not sure about + // + // Following issues are still remain/reintroduced: + // FIXME while in this "special" zone, leftmost column tiles are duplicated (prob related to < 0 camera) + // FIXME there's large grey box at block coord 0,0 + // + // -- Unsigned, 2018-11-20 + // wrap around for X-axis - val actorMinimumX = Terrarum.HALFW // to make camera's X stay positive - val actorMaximumX = worldsizePxl + actorMinimumX // to make camera's X stay positive + //val actorMinimumX = Terrarum.HALFW // to make camera's X stay positive + //val actorMaximumX = worldsizePxl + actorMinimumX // to make camera's X stay positive hitbox.setPositionFromPointed( - //clampW(hitbox.canonicalX), - if (hitbox.canonicalX < actorMinimumX) + if (hitbox.canonicalX >= worldsizePxl) // just wrap normally and allow camera coord to be negative + hitbox.canonicalX - worldsizePxl + else if (hitbox.canonicalX < 0) + hitbox.canonicalX + worldsizePxl + else + hitbox.canonicalX, // Fixed ROUNDWORLD impl + /*if (hitbox.canonicalX < actorMinimumX) hitbox.canonicalX + worldsizePxl else if (hitbox.canonicalX >= actorMaximumX) hitbox.canonicalX - worldsizePxl else - hitbox.canonicalX, // ROUNDWORLD impl + hitbox.canonicalX, // ROUNDWORLD impl */ clampH(hitbox.canonicalY) ) } diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt index 4893ac97b..a988f4ea0 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt @@ -745,7 +745,7 @@ internal object BlocksDrawer { shader.setUniformi("tilemap", 1) shader.setUniformi("tilemapDimension", tilesBuffer.width, tilesBuffer.height) shader.setUniformf("tilesInAxes", tilesInHorizontal.toFloat(), tilesInVertical.toFloat()) - shader.setUniformi("cameraTranslation", WorldCamera.x fmod TILE_SIZE, WorldCamera.y fmod TILE_SIZE) + shader.setUniformi("cameraTranslation", WorldCamera.x % TILE_SIZE, WorldCamera.y % TILE_SIZE) // surprisingly, using 'fmod' instead of '%' doesn't work /*shader hard-code*/shader.setUniformi("tilesInAtlas", tileAtlas.horizontalCount, tileAtlas.verticalCount) //depends on the tile atlas /*shader hard-code*/shader.setUniformi("atlasTexSize", tileAtlas.texture.width, tileAtlas.texture.height) //depends on the tile atlas tilesQuad.render(shader, GL20.GL_TRIANGLES) diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt index 1b827c47d..b53240e02 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt @@ -178,6 +178,9 @@ object LightmapRenderer { for_x_start = WorldCamera.x / TILE_SIZE // fix for premature lightmap rendering for_y_start = WorldCamera.y / TILE_SIZE // on topmost/leftmost side + if (for_x_start < 0) for_x_start -= 1 // to fix that the light shifts 1 tile to the left when WorldCamera < 0 + //if (for_y_start < 0) for_y_start -= 1 // not needed when we only wrap at x axis + for_x_end = for_x_start + WorldCamera.width / TILE_SIZE + 3 for_y_end = for_y_start + WorldCamera.height / TILE_SIZE + 2 // same fix as above