mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
lightbox fixed once again
This commit is contained in:
@@ -99,9 +99,9 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
* Hitbox(x-offset, y-offset, width, height)
|
* Hitbox(x-offset, y-offset, width, height)
|
||||||
* (Use ArrayList for normal circumstances)
|
* (Use ArrayList for normal circumstances)
|
||||||
*/
|
*/
|
||||||
@Transient override var lightBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
|
@Transient override var lightBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(1.0, 1.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
|
||||||
// the actual values are update on the update()
|
// the actual values are update on the update()
|
||||||
@Transient override var shadeBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
|
@Transient override var shadeBoxList: ArrayList<Lightbox> = arrayListOf(Lightbox(Hitbox(1.0, 1.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
|
||||||
// the actual values are update on the update()
|
// the actual values are update on the update()
|
||||||
|
|
||||||
@Transient val BASE_DENSITY = 980.0
|
@Transient val BASE_DENSITY = 980.0
|
||||||
@@ -801,4 +801,14 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun reload() {
|
||||||
|
super.reload()
|
||||||
|
|
||||||
|
lightBoxList = arrayListOf(Lightbox(Hitbox(1.0, 1.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
|
||||||
|
// the actual values are update on the update()
|
||||||
|
shadeBoxList = arrayListOf(Lightbox(Hitbox(1.0, 1.0, baseHitboxW - 2.0, baseHitboxH - 2.0), Cvec(0)))
|
||||||
|
// the actual values are update on the update()
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import net.torvald.terrarum.gameactors.*
|
|||||||
import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import java.awt.Color
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -368,13 +368,15 @@ object LightmapRenderer {
|
|||||||
val boxW = box.width * scale
|
val boxW = box.width * scale
|
||||||
val boxH = box.height * scale
|
val boxH = box.height * scale
|
||||||
|
|
||||||
val x0 = boxX.div(TILE_SIZE).floorToInt()
|
// println("boxX=$boxX, boxY=$boxY, boxW=$boxW, boxH=$boxH; actor=$it; baseHitboxW=${it.baseHitboxW}; box=$box")
|
||||||
val x1 = (boxX + boxW).div(TILE_SIZE).floorToInt().coerceAtLeast(x0+1)
|
|
||||||
val y0 = boxY.div(TILE_SIZE).floorToInt()
|
|
||||||
val y1 = (boxY + boxH).div(TILE_SIZE).floorToInt().coerceAtLeast(y0+1)
|
|
||||||
|
|
||||||
for (y in y0 until y1) {
|
val x0 = boxX.div(TILE_SIZE).floorToInt()
|
||||||
for (x in x0 until x1) {
|
val x1 = (boxX + boxW - 1).div(TILE_SIZE).floorToInt()
|
||||||
|
val y0 = boxY.div(TILE_SIZE).floorToInt()
|
||||||
|
val y1 = (boxY + boxH - 1).div(TILE_SIZE).floorToInt()
|
||||||
|
|
||||||
|
for (y in y0 .. y1) {
|
||||||
|
for (x in x0 .. x1) {
|
||||||
|
|
||||||
val oldLight = lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: Cvec(0) // if two or more luminous actors share the same block, mix the light
|
val oldLight = lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: Cvec(0) // if two or more luminous actors share the same block, mix the light
|
||||||
val actorLight = colour
|
val actorLight = colour
|
||||||
@@ -392,12 +394,12 @@ object LightmapRenderer {
|
|||||||
val boxH = box.height * scale
|
val boxH = box.height * scale
|
||||||
|
|
||||||
val x0 = boxX.div(TILE_SIZE).floorToInt()
|
val x0 = boxX.div(TILE_SIZE).floorToInt()
|
||||||
val x1 = (boxX + boxW).div(TILE_SIZE).floorToInt().coerceAtLeast(x0+1)
|
val x1 = (boxX + boxW - 1).div(TILE_SIZE).floorToInt()
|
||||||
val y0 = boxY.div(TILE_SIZE).floorToInt()
|
val y0 = boxY.div(TILE_SIZE).floorToInt()
|
||||||
val y1 = (boxY + boxH).div(TILE_SIZE).floorToInt().coerceAtLeast(y0+1)
|
val y1 = (boxY + boxH - 1).div(TILE_SIZE).floorToInt()
|
||||||
|
|
||||||
for (y in y0 until y1) {
|
for (y in y0 .. y1) {
|
||||||
for (x in x0 until x1) {
|
for (x in x0 .. x1) {
|
||||||
|
|
||||||
val oldLight = shadowMap[LandUtil.getBlockAddr(world, x, y)] ?: Cvec(0) // if two or more luminous actors share the same block, mix the light
|
val oldLight = shadowMap[LandUtil.getBlockAddr(world, x, y)] ?: Cvec(0) // if two or more luminous actors share the same block, mix the light
|
||||||
val actorLight = colour
|
val actorLight = colour
|
||||||
|
|||||||
Reference in New Issue
Block a user