fixed a bug where world thumbnail is not centered to the player

This commit is contained in:
minjaesong
2022-02-25 15:35:17 +09:00
parent dc86de139c
commit 95476359fe
2 changed files with 15 additions and 14 deletions

View File

@@ -53,11 +53,11 @@ object WriteSavegame {
val w = 960
val h = 640
val cx = (1 - WorldCamera.x % 2)
val cy = (1 - 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
val x = (fb.width - w) / 2 - cx // force the even-numbered position
val y = (fb.height - h) / 2 - cy // force the even-numbered position
val p = Pixmap.createFromFrameBuffer(x, y, w, h)
IngameRenderer.fboRGBexport = p

View File

@@ -178,7 +178,7 @@ object LightmapRenderer {
//println("$for_x_start..$for_x_end, $for_x\t$for_y_start..$for_y_end, $for_y")
App.measureDebugTime("Renderer.Lanterns") {
buildLanternmap(actorContainer)
buildLanternAndShadowMap(actorContainer)
} // usually takes 3000 ns
// copy current world's globalLight into this
@@ -338,20 +338,21 @@ object LightmapRenderer {
}
}
private fun buildLanternmap(actorContainer: List<ActorWithBody>) {
private fun buildLanternAndShadowMap(actorContainer: List<ActorWithBody>) {
lanternMap.clear()
shadowMap.clear()
actorContainer.forEach {
if (it is Luminous) {
val lightBoxCopy = it.lightBoxList.subList(0, it.lightBoxList.size) // make copy to prevent ConcurrentModificationException
val shadeBoxCopy = it.shadeBoxList.subList(0, it.shadeBoxList.size) // make copy to prevent ConcurrentModificationException
val scale = it.scale
// put lanterns to the area the luminantBox is occupying
lightBoxCopy.forEach { (lightBox, colour) ->
val lightBoxX = it.hitbox.startX + (lightBox.startX * it.scale)
val lightBoxY = it.hitbox.startY + (lightBox.startY * it.scale)
val lightBoxW = lightBox.width * it.scale
val lightBoxH = lightBox.height * it.scale
val lightBoxX = it.hitbox.startX + (lightBox.startX * scale)
val lightBoxY = it.hitbox.startY + (lightBox.startY * scale)
val lightBoxW = lightBox.width * scale
val lightBoxH = lightBox.height * scale
for (y in lightBoxY.div(TILE_SIZE).floorInt()
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
for (x in lightBoxX.div(TILE_SIZE).floorInt()
@@ -367,10 +368,10 @@ object LightmapRenderer {
// put shades to the area the luminantBox is occupying
shadeBoxCopy.forEach { (shadeBox, colour) ->
val lightBoxX = it.hitbox.startX + (shadeBox.startX * it.scale)
val lightBoxY = it.hitbox.startY + (shadeBox.startY * it.scale)
val lightBoxW = shadeBox.width * it.scale
val lightBoxH = shadeBox.height * it.scale
val lightBoxX = it.hitbox.startX + (shadeBox.startX * scale)
val lightBoxY = it.hitbox.startY + (shadeBox.startY * scale)
val lightBoxW = shadeBox.width * scale
val lightBoxH = shadeBox.height * scale
for (y in lightBoxY.div(TILE_SIZE).floorInt()
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
for (x in lightBoxX.div(TILE_SIZE).floorInt()