mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
fixed a bug where world thumbnail is not centered to the player
This commit is contained in:
@@ -53,11 +53,11 @@ object WriteSavegame {
|
|||||||
val w = 960
|
val w = 960
|
||||||
val h = 640
|
val h = 640
|
||||||
|
|
||||||
val cx = (1 - WorldCamera.x % 2)
|
val cx = /*1-*/(WorldCamera.x % 2)
|
||||||
val cy = (1 - WorldCamera.y % 2)
|
val cy = /*1-*/(WorldCamera.y % 2)
|
||||||
|
|
||||||
val x = (fb.width - w) - cx // force the even-numbered position
|
val x = (fb.width - w) / 2 - cx // force the even-numbered position
|
||||||
val y = (fb.height - h) - cy // 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)
|
val p = Pixmap.createFromFrameBuffer(x, y, w, h)
|
||||||
IngameRenderer.fboRGBexport = p
|
IngameRenderer.fboRGBexport = p
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ object LightmapRenderer {
|
|||||||
//println("$for_x_start..$for_x_end, $for_x\t$for_y_start..$for_y_end, $for_y")
|
//println("$for_x_start..$for_x_end, $for_x\t$for_y_start..$for_y_end, $for_y")
|
||||||
|
|
||||||
App.measureDebugTime("Renderer.Lanterns") {
|
App.measureDebugTime("Renderer.Lanterns") {
|
||||||
buildLanternmap(actorContainer)
|
buildLanternAndShadowMap(actorContainer)
|
||||||
} // usually takes 3000 ns
|
} // usually takes 3000 ns
|
||||||
|
|
||||||
// copy current world's globalLight into this
|
// 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()
|
lanternMap.clear()
|
||||||
shadowMap.clear()
|
shadowMap.clear()
|
||||||
actorContainer.forEach {
|
actorContainer.forEach {
|
||||||
if (it is Luminous) {
|
if (it is Luminous) {
|
||||||
val lightBoxCopy = it.lightBoxList.subList(0, it.lightBoxList.size) // make copy to prevent ConcurrentModificationException
|
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 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
|
// put lanterns to the area the luminantBox is occupying
|
||||||
lightBoxCopy.forEach { (lightBox, colour) ->
|
lightBoxCopy.forEach { (lightBox, colour) ->
|
||||||
val lightBoxX = it.hitbox.startX + (lightBox.startX * it.scale)
|
val lightBoxX = it.hitbox.startX + (lightBox.startX * scale)
|
||||||
val lightBoxY = it.hitbox.startY + (lightBox.startY * it.scale)
|
val lightBoxY = it.hitbox.startY + (lightBox.startY * scale)
|
||||||
val lightBoxW = lightBox.width * it.scale
|
val lightBoxW = lightBox.width * scale
|
||||||
val lightBoxH = lightBox.height * it.scale
|
val lightBoxH = lightBox.height * scale
|
||||||
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
||||||
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
||||||
for (x in lightBoxX.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
|
// put shades to the area the luminantBox is occupying
|
||||||
shadeBoxCopy.forEach { (shadeBox, colour) ->
|
shadeBoxCopy.forEach { (shadeBox, colour) ->
|
||||||
val lightBoxX = it.hitbox.startX + (shadeBox.startX * it.scale)
|
val lightBoxX = it.hitbox.startX + (shadeBox.startX * scale)
|
||||||
val lightBoxY = it.hitbox.startY + (shadeBox.startY * it.scale)
|
val lightBoxY = it.hitbox.startY + (shadeBox.startY * scale)
|
||||||
val lightBoxW = shadeBox.width * it.scale
|
val lightBoxW = shadeBox.width * scale
|
||||||
val lightBoxH = shadeBox.height * it.scale
|
val lightBoxH = shadeBox.height * scale
|
||||||
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
||||||
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
||||||
for (x in lightBoxX.div(TILE_SIZE).floorInt()
|
for (x in lightBoxX.div(TILE_SIZE).floorInt()
|
||||||
|
|||||||
Reference in New Issue
Block a user