randomised torch flicker

This commit is contained in:
minjaesong
2020-02-24 01:00:11 +09:00
parent 6c7fe9cf2b
commit 73c827b77f
10 changed files with 153 additions and 85 deletions

View File

@@ -6,6 +6,7 @@
|8448..0x0F_FFFF|Items (static) (1M possible)| |8448..0x0F_FFFF|Items (static) (1M possible)|
|0x10_0000..0x0FFF_FFFF|Items (dynamic\*) (267M possible)| |0x10_0000..0x0FFF_FFFF|Items (dynamic\*) (267M possible)|
|0x1000_0000..0x7FFF_FFFF|Actors (1879M possible)| |0x1000_0000..0x7FFF_FFFF|Actors (1879M possible)|
|-1..-65536|Virtual Tiles|
|-2147483648..-1 (all negative numbers)|Faction (2147M possible)| |-2147483648..-1 (all negative numbers)|Faction (2147M possible)|
* dynamic items have own properties that will persist through savegame. * dynamic items have own properties that will persist through savegame.

View File

@@ -0,0 +1,24 @@
package net.torvald.terrarum
/**
* See REFERENCING.md
*/
object ReferencingRanges {
val TILES = 0..4095
val WALLS = 4096..8191
val WIRES = 8192..8447
val ITEMS_STATIC = 8448..0x0F_FFFF
val ITEMS_DYNAMIC = 0x10_0000..0x0FFF_FFFF
val ACTORS = 0x1000_0000..0x7FFF_FFFF
val ACTORS_BEHIND = 0x1000_0000..0x1FFF_FFFF // Rendered behind (e.g. tapestries)
val ACTORS_MIDDLE = 0x2000_0000..0x4FFF_FFFF // Regular actors (e.g. almost all of them)
val ACTORS_MIDTOP = 0x5000_0000..0x5FFF_FFFF // Special (e.g. weapon swung, bullets, dropped item, particles)
val ACTORS_FRONT = 0x6000_0000..0x6FFF_FFFF // Rendered front (e.g. fake tile)
val ACTORS_OVERLAY = 0x7000_0000..0x7FFF_FFFF // Rendered as screen overlay, not affected by light nor environment overlays
val VIRTUAL_TILES = -1 downTo -65536
}

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.blockproperties
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.AppLoader.printmsg import net.torvald.terrarum.AppLoader.printmsg
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.gameworld.FluidType import net.torvald.terrarum.gameworld.FluidType
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.utils.CSVFetcher
@@ -18,16 +19,25 @@ object BlockCodex {
private var blockProps = HashMap<Int, BlockProp>() private var blockProps = HashMap<Int, BlockProp>()
val dynamicLights = SortedArrayList<Int>() val dynamicLights = SortedArrayList<Int>() // does not include virtual ones
/** 4096 */ /** 4096 */
const val MAX_TERRAIN_TILES = GameWorld.TILES_SUPPORTED val MAX_TERRAIN_TILES = GameWorld.TILES_SUPPORTED
private val nullProp = BlockProp() private val nullProp = BlockProp()
var highestNumber = -1 var highestNumber = -1 // does not include virtual ones
private set private set
// fake props for "randomised" dynamic lights
const val DYNAMIC_RANDOM_CASES = 64
var virtualPropsCount = 0
private set
/** always points to the HIGHEST prop ID. <Original ID, Virtual ID> */
val dynamicToVirtualPropMapping = ArrayList<Pair<Int, Int>>()
/** for random access dont iterate over this */
val dynamicToVirtualMap = hashMapOf<Int, Int>()
/** /**
* Later entry (possible from other modules) will replace older ones * Later entry (possible from other modules) will replace older ones
*/ */
@@ -48,8 +58,18 @@ object BlockCodex {
val id = intVal(it, "id") val id = intVal(it, "id")
setProp(id, it) setProp(id, it)
// register tiles with dynamic light
if ((blockProps[id]?.dynamicLuminosityFunction ?: 0) != 0) { if ((blockProps[id]?.dynamicLuminosityFunction ?: 0) != 0) {
dynamicLights.add(id) dynamicLights.add(id)
// add virtual props for dynamic lights
val virtualIDMax = ReferencingRanges.VIRTUAL_TILES.first - virtualPropsCount
dynamicToVirtualPropMapping.add(id to virtualIDMax)
dynamicToVirtualMap[id] = virtualIDMax
repeat(DYNAMIC_RANDOM_CASES) { i ->
setProp(virtualIDMax - i, it)
virtualPropsCount += 1
}
} }
if (id > highestNumber) if (id > highestNumber)

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.blockproperties package net.torvald.terrarum.blockproperties
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.gameworld.fmod
/** /**
* Created by minjaesong on 2016-02-16. * Created by minjaesong on 2016-02-16.
@@ -49,11 +50,17 @@ class BlockProp {
internal var baseLumColB = 0f // base value used to calculate dynamic luminosity internal var baseLumColB = 0f // base value used to calculate dynamic luminosity
internal var baseLumColA = 0f // base value used to calculate dynamic luminosity internal var baseLumColA = 0f // base value used to calculate dynamic luminosity
internal val baseLumCol = Cvec(0) internal val baseLumCol = Cvec(0)
var lumColR = 0f // memoised value of dynamic luminosity //var lumColR = 0f // memoised value of dynamic luminosity
var lumColG = 0f // memoised value of dynamic luminosity //var lumColG = 0f // memoised value of dynamic luminosity
var lumColB = 0f // memoised value of dynamic luminosity //var lumColB = 0f // memoised value of dynamic luminosity
var lumColA = 0f // memoised value of dynamic luminosity //var lumColA = 0f // memoised value of dynamic luminosity
var lumCol = Cvec(0) internal val _lumCol = Cvec(0)
fun getLumCol(x: Int, y: Int) = if (dynamicLuminosityFunction == 0) {
baseLumCol
} else {
val offset = (x * 214013 + 2531011).ushr(16).fmod(BlockCodex.DYNAMIC_RANDOM_CASES)
BlockCodex[BlockCodex.dynamicToVirtualMap[id]!! - offset]._lumCol
}
/** /**
* @param luminosity * @param luminosity
@@ -61,7 +68,7 @@ class BlockProp {
//inline val luminosity: Cvec //inline val luminosity: Cvec
// get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction) // get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction)
fun getLum(channel: Int) = lumCol.getElem(channel) //fun getLum(channel: Int) = lumCol.getElem(channel)
var drop: Int = 0 var drop: Int = 0
@@ -72,4 +79,8 @@ class BlockProp {
var dynamicLuminosityFunction: Int = 0 var dynamicLuminosityFunction: Int = 0
var material: String = "" var material: String = ""
var rngBase0 = Math.random().toFloat() // initial cycle phase (xxxxFuncX)
var rngBase1 = Math.random().toFloat() // flicker P0, etc
var rngBase2 = Math.random().toFloat() // flicker P1, etc
} }

View File

@@ -14,81 +14,50 @@ import net.torvald.terrarum.worlddrawer.LightmapRenderer
* Created by minjaesong on 2016-06-16. * Created by minjaesong on 2016-06-16.
*/ */
object BlockPropUtil { object BlockPropUtil {
var flickerFuncX: Second = 0f // saves current status (time) of func //var flickerFuncX: Second = 0f // saves current status (time) of func
val flickerFuncDomain: Second = 0.08f // time between two noise sample val flickerFuncDomain: Second = 0.08f // time between two noise sample
val flickerFuncRange = 0.012f // intensity [0, 1] val flickerFuncRange = 0.012f // intensity [0, 1]
var breathFuncX = 0f //var breathFuncX = 0f
val breathRange = 0.02f val breathRange = 0.02f
val breathCycleDuration: Second = 2f val breathCycleDuration: Second = 2f
var pulsateFuncX = 0f //var pulsateFuncX = 0f
val pulsateRange = 0.034f val pulsateRange = 0.034f
val pulsateCycleDuration: Second = 0.5f val pulsateCycleDuration: Second = 0.5f
val random = HQRNG() val random = HQRNG()
var flickerP0 = getNewRandom() //var flickerP0 = getNewRandom()
var flickerP1 = getNewRandom() //var flickerP1 = getNewRandom()
init { init {
} }
private fun getTorchFlicker(baseLum: Cvec): Cvec { private fun getTorchFlicker(prop: BlockProp): Cvec {
val funcY = FastMath.interpolateLinear(flickerFuncX / flickerFuncDomain, flickerP0, flickerP1) val funcY = FastMath.interpolateLinear(prop.rngBase0 / flickerFuncDomain, prop.rngBase1, prop.rngBase2)
return alterBrightnessUniform(baseLum, funcY) return alterBrightnessUniform(prop.baseLumCol, funcY)
} }
private fun getTorchFlicker(baseLum: Float): Float { private fun getSlowBreath(prop: BlockProp): Cvec {
return baseLum + FastMath.interpolateLinear(flickerFuncX / flickerFuncDomain, flickerP0, flickerP1) val funcY = FastMath.sin(FastMath.PI * prop.rngBase0 / breathCycleDuration) * breathRange
return alterBrightnessUniform(prop.baseLumCol, funcY)
} }
private fun getSlowBreath(baseLum: Cvec): Cvec { private fun getPulsate(prop: BlockProp): Cvec {
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange val funcY = FastMath.sin(FastMath.PI * prop.rngBase0 / pulsateCycleDuration) * pulsateRange
return alterBrightnessUniform(baseLum, funcY) return alterBrightnessUniform(prop.baseLumCol, funcY)
} }
private fun getSlowBreath(baseLum: Float): Float {
return baseLum + FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
}
private fun getPulsate(baseLum: Cvec): Cvec {
val funcY = FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
return alterBrightnessUniform(baseLum, funcY)
}
private fun getPulsate(baseLum: Float): Float {
return baseLum + FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
}
/** /**
* Using our own timer so that they flickers for same duration regardless of game's FPS * Using our own timer so that they flickers for same duration regardless of game's FPS
*/ */
internal fun dynamicLumFuncTickClock() { internal fun dynamicLumFuncTickClock() {
// FPS-time compensation
if (Gdx.graphics.framesPerSecond > 0) {
flickerFuncX += Gdx.graphics.rawDeltaTime
breathFuncX += Gdx.graphics.rawDeltaTime
pulsateFuncX += Gdx.graphics.rawDeltaTime
}
// flicker-related vars
if (flickerFuncX > flickerFuncDomain) {
flickerFuncX -= flickerFuncDomain
flickerP0 = flickerP1
flickerP1 = getNewRandom()
}
// breath-related vars
if (breathFuncX > breathCycleDuration) breathFuncX -= breathCycleDuration
// pulsate-related vars
if (pulsateFuncX > pulsateCycleDuration) pulsateFuncX -= pulsateCycleDuration
// update the memoised values in props // update the memoised values in props
for (key in BlockCodex.dynamicLights) { /*for (key in BlockCodex.dynamicLights) {
try { try {
val prop = BlockCodex[key] val prop = BlockCodex[key]
if (prop.dynamicLuminosityFunction != 0) { if (prop.dynamicLuminosityFunction != 0) {
@@ -100,6 +69,38 @@ object BlockPropUtil {
} }
} }
catch (skip: NullPointerException) {} catch (skip: NullPointerException) {}
}*/
// update randomised virtual props instead
for (keyMax in BlockCodex.dynamicToVirtualPropMapping) {
repeat(BlockCodex.DYNAMIC_RANDOM_CASES) {
val prop = BlockCodex[keyMax.second - it]
val domain = when (prop.dynamicLuminosityFunction) {
1 -> flickerFuncDomain
4 -> breathCycleDuration
5 -> pulsateCycleDuration
else -> 0f
}
// FPS-time compensation
if (Gdx.graphics.framesPerSecond > 0) {
prop.rngBase0 += Gdx.graphics.rawDeltaTime
}
// reset timer
if (prop.rngBase0 > domain) {
prop.rngBase0 -= domain
// flicker related
prop.rngBase1 = prop.rngBase2
prop.rngBase2 = getNewRandom()
}
prop._lumCol.set(getDynamicLumFunc(prop))
//prop.lumColR = prop.lumCol.r
//prop.lumColG = prop.lumCol.g
//prop.lumColB = prop.lumCol.b
//prop.lumColA = prop.lumCol.a
}
} }
} }
@@ -107,21 +108,21 @@ object BlockPropUtil {
private fun linearInterpolation1D(a: Float, b: Float, x: Float) = a * (1 - x) + b * x private fun linearInterpolation1D(a: Float, b: Float, x: Float) = a * (1 - x) + b * x
private fun getDynamicLumFunc(baseLum: Cvec, type: Int): Cvec { private fun getDynamicLumFunc(prop: BlockProp): Cvec {
return when (type) { return when (prop.dynamicLuminosityFunction) {
1 -> getTorchFlicker(baseLum) 1 -> getTorchFlicker(prop)
2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT) // current global light 2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT) // current global light
3 -> WeatherMixer.getGlobalLightOfTime(Terrarum.ingame!!.world, WorldTime.DAY_LENGTH / 2).cpy().mul(LightmapRenderer.DIV_FLOAT) // daylight at noon 3 -> WeatherMixer.getGlobalLightOfTime(Terrarum.ingame!!.world, WorldTime.DAY_LENGTH / 2).cpy().mul(LightmapRenderer.DIV_FLOAT) // daylight at noon
4 -> getSlowBreath(baseLum) 4 -> getSlowBreath(prop)
5 -> getPulsate(baseLum) 5 -> getPulsate(prop)
else -> baseLum else -> prop.baseLumCol
} }
} }
/** /**
* @param chan 0 for R, 1 for G, 2 for B, 3 for A * @param chan 0 for R, 1 for G, 2 for B, 3 for A
*/ */
private fun getDynamicLumFuncByChan(baseLum: Float, type: Int, chan: Int): Float { /*private fun getDynamicLumFuncByChan(baseLum: Float, type: Int, chan: Int): Float {
return when (type) { return when (type) {
1 -> getTorchFlicker(baseLum) 1 -> getTorchFlicker(baseLum)
2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT).getElem(chan) // current global light 2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT).getElem(chan) // current global light
@@ -130,7 +131,7 @@ object BlockPropUtil {
5 -> getPulsate(baseLum) 5 -> getPulsate(baseLum)
else -> baseLum else -> baseLum
} }
} }*/
/** /**
* Darken or brighten colour by 'brighten' argument * Darken or brighten colour by 'brighten' argument

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.gameactors package net.torvald.terrarum.gameactors
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN
@@ -22,11 +23,11 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
} }
companion object { companion object {
val RANGE_BEHIND = ACTORID_MIN..0x1FFF_FFFF // 1 val RANGE_BEHIND = ReferencingRanges.ACTORS_BEHIND // 1
val RANGE_MIDDLE = 0x2000_0000..0x4FFF_FFFF // 3 val RANGE_MIDDLE = ReferencingRanges.ACTORS_MIDDLE // 3
val RANGE_MIDTOP = 0x5000_0000..0x5FFF_FFFF // 1 val RANGE_MIDTOP = ReferencingRanges.ACTORS_MIDTOP // 1
val RANGE_FRONT = 0x6000_0000..0x6FFF_FFFF // 1 val RANGE_FRONT = ReferencingRanges.ACTORS_FRONT // 1
val RANDE_OVERLAY= 0x7000_0000..0x7FFF_FFFF // 1 val RANDE_OVERLAY= ReferencingRanges.ACTORS_OVERLAY // 1
} }
abstract fun update(delta: Float) abstract fun update(delta: Float)

View File

@@ -4,6 +4,7 @@ package net.torvald.terrarum.gameworld
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.blockproperties.BlockCodex
@@ -478,7 +479,7 @@ open class GameWorld : Disposable {
@Transient const val TERRAIN = 1 @Transient const val TERRAIN = 1
@Transient const val WIRE = 2 @Transient const val WIRE = 2
@Transient const val TILES_SUPPORTED = 4096 @Transient val TILES_SUPPORTED = ReferencingRanges.TILES.last + 1
//@Transient val SIZEOF: Byte = 2 //@Transient val SIZEOF: Byte = 2
@Transient const val LAYERS: Byte = 4 // terrain, wall (layerTerrainLowBits + layerWallLowBits), wire @Transient const val LAYERS: Byte = 4 // terrain, wall (layerTerrainLowBits + layerWallLowBits), wire

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.Fluid import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
@@ -27,12 +28,12 @@ object ItemCodex {
val dynamicItemDescription = HashMap<ItemID, GameItem>() val dynamicItemDescription = HashMap<ItemID, GameItem>()
val dynamicToStaticTable = HashMap<ItemID, ItemID>() val dynamicToStaticTable = HashMap<ItemID, ItemID>()
val ITEM_TILES = 0..GameWorld.TILES_SUPPORTED - 1 val ITEM_TILES = ReferencingRanges.TILES
val ITEM_WALLS = GameWorld.TILES_SUPPORTED..GameWorld.TILES_SUPPORTED * 2 - 1 val ITEM_WALLS = ReferencingRanges.WALLS
val ITEM_WIRES = GameWorld.TILES_SUPPORTED * 2..GameWorld.TILES_SUPPORTED * 2 + 255 val ITEM_WIRES = ReferencingRanges.WIRES
val ITEM_STATIC = ITEM_WIRES.endInclusive + 1..0x0F_FFFF val ITEM_STATIC = ReferencingRanges.ITEMS_STATIC
val ITEM_DYNAMIC = 0x10_0000..0x0FFF_FFFF val ITEM_DYNAMIC = ReferencingRanges.ITEMS_DYNAMIC
val ACTORID_MIN = ITEM_DYNAMIC.endInclusive + 1 val ACTORID_MIN = ReferencingRanges.ACTORS.first
private val itemImagePlaceholder: TextureRegion private val itemImagePlaceholder: TextureRegion
get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_24") // copper pickaxe get() = CommonResourcePool.getAsTextureRegion("itemplaceholder_24") // copper pickaxe

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.random.HQRNG
import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.blockproperties.BlockCodex
@@ -15,8 +16,11 @@ import java.util.*
*/ */
internal class FixtureTikiTorch : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 2)), Luminous { internal class FixtureTikiTorch : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 2)), Luminous {
private val rndHash1: Int
private val rndHash2: Int
override var color: Cvec override var color: Cvec
get() = BlockCodex[Block.TORCH].lumCol get() = BlockCodex[Block.TORCH].getLumCol(rndHash1, rndHash2)
set(value) { set(value) {
throw UnsupportedOperationException() throw UnsupportedOperationException()
} }
@@ -35,6 +39,10 @@ internal class FixtureTikiTorch : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1,
sprite!!.setRowsAndFrames(1, 1) sprite!!.setRowsAndFrames(1, 1)
actorValue[AVKey.BASEMASS] = MASS actorValue[AVKey.BASEMASS] = MASS
val rng = HQRNG()
rndHash1 = rng.nextInt()
rndHash2 = rng.nextInt()
} }
companion object { companion object {

View File

@@ -239,7 +239,7 @@ object LightmapRenderer {
// pre-seed the lightmap with known value // pre-seed the lightmap with known value
for (x in for_x_start - overscan_open..for_x_end + overscan_open) { /*for (x in for_x_start - overscan_open..for_x_end + overscan_open) {
for (y in for_y_start - overscan_open..for_y_end + overscan_open) { for (y in for_y_start - overscan_open..for_y_end + overscan_open) {
val tile = world.getTileFromTerrain(x, y) val tile = world.getTileFromTerrain(x, y)
val wall = world.getTileFromWall(x, y) val wall = world.getTileFromWall(x, y)
@@ -264,7 +264,7 @@ object LightmapRenderer {
//lightmap.setB(lx, ly, lightlevel.b) //lightmap.setB(lx, ly, lightlevel.b)
//lightmap.setA(lx, ly, lightlevel.a) //lightmap.setA(lx, ly, lightlevel.a)
} }
} }*/
} }
// O((5*9)n) == O(n) where n is a size of the map. // O((5*9)n) == O(n) where n is a size of the map.
@@ -681,7 +681,7 @@ object LightmapRenderer {
// regarding the issue #26 // regarding the issue #26
try { try {
val fuck = BlockCodex[thisTerrain].lumCol val fuck = BlockCodex[thisTerrain].getLumCol(x, y)
} }
catch (e: NullPointerException) { catch (e: NullPointerException) {
System.err.println("## NPE -- x: $x, y: $y, value: $thisTerrain") System.err.println("## NPE -- x: $x, y: $y, value: $thisTerrain")
@@ -704,13 +704,13 @@ object LightmapRenderer {
if (thisFluid.type != Fluid.NULL) { if (thisFluid.type != Fluid.NULL) {
fluidAmountToCol.set(thisFluid.amount, thisFluid.amount, thisFluid.amount, thisFluid.amount) fluidAmountToCol.set(thisFluid.amount, thisFluid.amount, thisFluid.amount, thisFluid.amount)
thisTileLuminosity.set(BlockCodex[thisTerrain].lumCol) thisTileLuminosity.set(BlockCodex[thisTerrain].getLumCol(x, y))
thisTileLuminosity.maxAndAssign(BlockCodex[thisFluid.type].lumCol.mul(fluidAmountToCol)) // already been div by four thisTileLuminosity.maxAndAssign(BlockCodex[thisFluid.type].getLumCol(x, y).mul(fluidAmountToCol)) // already been div by four
thisTileOpacity.set(BlockCodex[thisTerrain].opacity) thisTileOpacity.set(BlockCodex[thisTerrain].opacity)
thisTileOpacity.maxAndAssign(BlockCodex[thisFluid.type].opacity.mul(fluidAmountToCol)) // already been div by four thisTileOpacity.maxAndAssign(BlockCodex[thisFluid.type].opacity.mul(fluidAmountToCol)) // already been div by four
} }
else { else {
thisTileLuminosity.set(BlockCodex[thisTerrain].lumCol) thisTileLuminosity.set(BlockCodex[thisTerrain].getLumCol(x, y))
thisTileOpacity.set(BlockCodex[thisTerrain].opacity) thisTileOpacity.set(BlockCodex[thisTerrain].opacity)
} }
@@ -727,7 +727,7 @@ object LightmapRenderer {
lightLevelThis.maxAndAssign(thisTileLuminosity).maxAndAssign(lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: colourNull) lightLevelThis.maxAndAssign(thisTileLuminosity).maxAndAssign(lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: colourNull)
} }
private fun getLightsAndShadesCh(x: Int, y: Int, channel: Int) { /*private fun getLightsAndShadesCh(x: Int, y: Int, channel: Int) {
lightLevelThisCh = 0f lightLevelThisCh = 0f
thisTerrain = world.getTileFromTerrain(x, y) ?: Block.STONE thisTerrain = world.getTileFromTerrain(x, y) ?: Block.STONE
thisFluid = world.getFluid(x, y) thisFluid = world.getFluid(x, y)
@@ -735,7 +735,7 @@ object LightmapRenderer {
// regarding the issue #26 // regarding the issue #26
try { try {
val fuck = BlockCodex[thisTerrain].lumCol val fuck = BlockCodex[thisTerrain].getLumCol(x, y)
} }
catch (e: NullPointerException) { catch (e: NullPointerException) {
System.err.println("## NPE -- x: $x, y: $y, value: $thisTerrain") System.err.println("## NPE -- x: $x, y: $y, value: $thisTerrain")
@@ -780,7 +780,7 @@ object LightmapRenderer {
// blend lantern // blend lantern
lightLevelThisCh = maxOf(thisTileLuminosityCh, lightLevelThisCh) lightLevelThisCh = maxOf(thisTileLuminosityCh, lightLevelThisCh)
lightLevelThisCh = maxOf(lanternMap[LandUtil.getBlockAddr(world, x, y)]?.getElem(channel) ?: 0f, lightLevelThisCh) lightLevelThisCh = maxOf(lanternMap[LandUtil.getBlockAddr(world, x, y)]?.getElem(channel) ?: 0f, lightLevelThisCh)
} }*/
private val inNoopMaskp = Point2i(0,0) private val inNoopMaskp = Point2i(0,0)