physics anomaly at x 0..33? are fixed, other issues (re)introduced

See ActorWBMovable@Line1238
This commit is contained in:
minjaesong
2018-11-20 06:08:21 +09:00
parent 795ba4a511
commit eb9b7fba8a
3 changed files with 37 additions and 6 deletions

View File

@@ -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)
)
}

View File

@@ -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)

View File

@@ -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