the-flattening wip

This commit is contained in:
minjaesong
2021-02-10 17:48:01 +09:00
parent 73acaea025
commit 8fdc11288c
21 changed files with 513 additions and 503 deletions

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
@@ -179,7 +180,7 @@ internal object BlocksDrawer {
/**
* To interact with external modules
*/
@JvmStatic fun addBlendMul(blockID: Int): Boolean {
@JvmStatic fun addBlendMul(blockID: ItemID): Boolean {
return TILES_BLEND_MUL.add(blockID)
}
@@ -307,11 +308,11 @@ internal object BlocksDrawer {
val bufferX = x - for_x_start
val bufferY = y - for_y_start
val thisTile = when (mode) {
val thisTile: ItemID = when (mode) {
WALL -> world.getTileFromWall(x, y)
TERRAIN -> world.getTileFromTerrain(x, y)
WIRE -> world.getWiringBlocks(x, y).and(drawWires).toBitOrd() * 16
FLUID -> world.getFluid(x, y).type.abs()
WIRE -> "basegame:-1" // TODO need new wire storing format //world.getWiringBlocks(x, y).and(drawWires).toBitOrd() * 16
FLUID -> "basegame:-1" // TODO need new wire storing format //world.getFluid(x, y).type.abs()
else -> throw IllegalArgumentException()
}
@@ -344,10 +345,10 @@ internal object BlocksDrawer {
if (mode == FLUID)
CreateTileAtlas.fluidToTileNumber(world.getFluid(x, y))
else if (mode == WIRE)
thisTile
0 // TODO need new wire storing format
else
renderTag.tileNumber
val tileNumber = if (mode != WIRE && thisTile == 0) 0
val tileNumber = if (mode != WIRE && thisTile == Block.AIR) 0
// special case: fluids
else if (mode == FLUID) tileNumberBase + connectLut47[nearbyTilesInfo]
// special case: wires
@@ -376,11 +377,11 @@ internal object BlocksDrawer {
// draw a tile
if (mode == WIRE && thisTile < 0) {
if (mode == WIRE) {
// no wire here, draw block id 255 (bottom right)
writeToBuffer(mode, bufferX, bufferY, 15, 15, 0)
}
else if (mode == FLUID || mode == WIRE) {
else if (mode == FLUID) {
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, 0)
}
else {
@@ -404,7 +405,7 @@ internal object BlocksDrawer {
)
}
private fun getNearbyTilesInfoConSelf(x: Int, y: Int, mode: Int, mark: Int?): Int {
private fun getNearbyTilesInfoConSelf(x: Int, y: Int, mode: Int, mark: ItemID?): Int {
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) ?: Block.NULL }
var ret = 0
@@ -423,8 +424,9 @@ internal object BlocksDrawer {
*
* @return offset from the spritesheet's "base" tile number, 0..15.
*/
private fun getNearbyWiringInfo(x: Int, y: Int, wire: Int): Int {
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getWiringBlocks(it.x, it.y).and(drawWires).toBitOrd() * 16 }
private fun getNearbyWiringInfo(x: Int, y: Int, wire: ItemID): Int {
return 0 // TODO need new wire storing format
/*val nearbyTiles = getNearbyTilesPos(x, y).map { world.getWiringBlocks(it.x, it.y).and(drawWires).toBitOrd() * 16 }
var ret = 0
for (i in nearbyTiles.indices) {
@@ -433,11 +435,11 @@ internal object BlocksDrawer {
}
}
return ret
return ret*/
}
private fun getNearbyTilesInfoConMutual(x: Int, y: Int, mode: Int): Int {
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) ?: Block.NULL }
val nearbyTiles: List<ItemID> = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y)!! }
var ret = 0
for (i in nearbyTiles.indices) {
@@ -454,7 +456,7 @@ internal object BlocksDrawer {
*/
private fun getNearbyTilesInfoFluids(x: Int, y: Int): Int {
val nearbyPos = getNearbyTilesPos(x, y)
val nearbyTiles = nearbyPos.map { world.getTileFromTerrain(it.x, it.y) ?: Block.NULL }
val nearbyTiles: List<ItemID> = nearbyPos.map { world.getTileFromTerrain(it.x, it.y) }
var ret = 0
for (i in nearbyTiles.indices) {
@@ -468,12 +470,12 @@ internal object BlocksDrawer {
}
private fun getNearbyTilesInfoWallSticker(x: Int, y: Int): Int {
val nearbyTiles = IntArray(4)
val nearbyTiles = arrayOf(Block.NULL, Block.NULL, Block.NULL, Block.NULL)
val NEARBY_TILE_KEY_BACK = NEARBY_TILE_KEY_UP
nearbyTiles[NEARBY_TILE_KEY_LEFT] = world.getTileFrom(TERRAIN, x - 1, y) ?: Block.NULL
nearbyTiles[NEARBY_TILE_KEY_RIGHT] = world.getTileFrom(TERRAIN, x + 1, y) ?: Block.NULL
nearbyTiles[NEARBY_TILE_KEY_DOWN] = world.getTileFrom(TERRAIN, x , y + 1) ?: Block.NULL
nearbyTiles[NEARBY_TILE_KEY_BACK] = world.getTileFrom(WALL, x , y) ?: Block.NULL
nearbyTiles[NEARBY_TILE_KEY_LEFT] = world.getTileFrom(TERRAIN, x - 1, y)
nearbyTiles[NEARBY_TILE_KEY_RIGHT] = world.getTileFrom(TERRAIN, x + 1, y)
nearbyTiles[NEARBY_TILE_KEY_DOWN] = world.getTileFrom(TERRAIN, x , y + 1)
nearbyTiles[NEARBY_TILE_KEY_BACK] = world.getTileFrom(WALL, x , y)
try {
if (BlockCodex[nearbyTiles[NEARBY_TILE_KEY_DOWN]].isSolid)
@@ -502,9 +504,11 @@ internal object BlocksDrawer {
}
private fun getNearbyTilesInfoPlatform(x: Int, y: Int): Int {
val nearbyTiles = IntArray(4)
nearbyTiles[NEARBY_TILE_KEY_LEFT] = world.getTileFrom(TERRAIN, x - 1, y) ?: Block.NULL
nearbyTiles[NEARBY_TILE_KEY_RIGHT] = world.getTileFrom(TERRAIN, x + 1, y) ?: Block.NULL
val nearbyTiles = arrayOf(Block.NULL, Block.NULL, Block.NULL, Block.NULL)
val NEARBY_TILE_KEY_BACK = NEARBY_TILE_KEY_UP
nearbyTiles[NEARBY_TILE_KEY_LEFT] = world.getTileFrom(TERRAIN, x - 1, y)
nearbyTiles[NEARBY_TILE_KEY_LEFT] = world.getTileFrom(TERRAIN, x - 1, y)
nearbyTiles[NEARBY_TILE_KEY_RIGHT] = world.getTileFrom(TERRAIN, x + 1, y)
if ((BlockCodex[nearbyTiles[NEARBY_TILE_KEY_LEFT]].isSolid &&
BlockCodex[nearbyTiles[NEARBY_TILE_KEY_RIGHT]].isSolid) ||
@@ -753,10 +757,10 @@ internal object BlocksDrawer {
fun getRenderEndX(): Int = clampWTile(getRenderStartX() + (WorldCamera.width / TILE_SIZE) + 2)
fun getRenderEndY(): Int = clampHTile(getRenderStartY() + (WorldCamera.height / TILE_SIZE) + 2)
fun isConnectSelf(b: Int): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_SELF
fun isConnectMutual(b: Int): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_MUTUAL
fun isWallSticker(b: Int): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER
fun isPlatform(b: Int): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
fun isConnectSelf(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_SELF
fun isConnectMutual(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_MUTUAL
fun isWallSticker(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER
fun isPlatform(b: ItemID): Boolean = CreateTileAtlas.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
//fun isBlendMul(b: Int): Boolean = TILES_BLEND_MUL.contains(b)
fun tileInCamera(x: Int, y: Int) =

View File

@@ -6,9 +6,12 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.*
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld
import kotlin.math.roundToInt
@@ -28,6 +31,8 @@ object CreateTileAtlas {
const val TILE_SIZE = TerrarumAppConfiguration.TILE_SIZE
const val TILES_IN_X = MAX_TEX_SIZE / TILE_SIZE
const val ITEM_ATLAS_TILES_X = 16
private val TOTAL_TILES = TILES_IN_X * TILES_IN_X
lateinit var atlas: Pixmap
@@ -38,8 +43,10 @@ object CreateTileAtlas {
lateinit var atlasGlow: Pixmap // glowing won't be affected by the season... for now
lateinit var itemTerrainTexture: Texture
lateinit var itemWallTexture: Texture
lateinit var terrainTileColourMap: GdxColorMap
internal lateinit var tags: HashMap<Int, RenderTag>
lateinit var terrainTileColourMap: HashMap<ItemID, Cvec>
lateinit var tags: HashMap<ItemID, RenderTag> // TileID, RenderTag
private set
lateinit var itemSheetNumbers: HashMap<ItemID, Int> // TileID, Int
private set
private val defaultRenderTag = RenderTag(3, RenderTag.CONNECT_SELF, RenderTag.MASK_NA) // 'update' block
var initialised = false
@@ -56,14 +63,16 @@ object CreateTileAtlas {
private var atlasCursor = 0
private var atlasCursorGlow = 0
private val atlasInit = "./assets/graphics/blocks/init.tga"
private var itemSheetCursor = 16
/**
* Must be called AFTER mods' loading so that all the block props are loaded
*/
operator fun invoke(updateExisting: Boolean = false) { if (updateExisting || !initialised) {
tags = HashMap<Int, RenderTag>()
tags[0] = RenderTag(0, RenderTag.CONNECT_SELF, RenderTag.MASK_NA)
tags = HashMap<ItemID, RenderTag>()
itemSheetNumbers = HashMap<ItemID, Int>()
tags[Block.AIR] = RenderTag(0, RenderTag.CONNECT_SELF, RenderTag.MASK_NA)
atlas = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
atlasAutumn = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
@@ -86,27 +95,27 @@ object CreateTileAtlas {
// get all the files applicable
// first, get all the '/blocks' directory, and add all the files, regardless of their extension, to the list
val tgaList = ArrayList<FileHandle>()
ModMgr.getGdxFilesFromEveryMod("blocks").forEach {
if (!it.isDirectory) {
throw Error("Path '${it.path()}' is not a directory")
val tgaList = ArrayList<Pair<String, FileHandle>>() //Pair of <modname, filehandle>
ModMgr.getGdxFilesFromEveryMod("blocks").forEach { (modname, filehandle) ->
if (!filehandle.isDirectory) {
throw Error("Path '${filehandle.path()}' is not a directory")
}
it.list().forEach { tgaFile ->
filehandle.list().forEach { tgaFile ->
if (!tgaFile.isDirectory && (tgaFile.name().matches(tileNameRegex))) {
tgaList.add(tgaFile)
tgaList.add(modname to tgaFile)
}
}
}
// Sift through the file list for blocks, but TGA format first
tgaList.forEach {
tgaList.forEach { (modname, filehandle) ->
try {
val glowFile = Gdx.files.internal(it.path().dropLast(4) + "_glow.tga") // assuming strict ".tga" file
fileToAtlantes(it, if (glowFile.exists()) glowFile else null)
val glowFile = Gdx.files.internal(filehandle.path().dropLast(4) + "_glow.tga") // assuming strict ".tga" file
fileToAtlantes(modname, filehandle, if (glowFile.exists()) glowFile else null)
}
catch (e: GdxRuntimeException) {
System.err.println("Couldn't load file $it, skipping...")
System.err.println("Couldn't load file $filehandle from $modname, skipping...")
}
}
@@ -127,73 +136,6 @@ object CreateTileAtlas {
}
}*/
// Sift through the file list for fluids, but TGA format first
val fluidMasterPixmap = Pixmap(TILE_SIZE * 47, TILE_SIZE * 8, Pixmap.Format.RGBA8888)
tgaList.filter { it.name().matches(validFluidTilesFilename) && it.extension().toUpperCase() == "TGA" }.forEachIndexed { fluidLevel, it ->
val pixmap = Pixmap(it)
// dirty manual copy
repeat(5) {
fluidMasterPixmap.drawPixmap(pixmap,
it * TILE_SIZE * 7, fluidLevel * TILE_SIZE,
0, TILE_SIZE * it,
TILE_SIZE * 7, TILE_SIZE
)
}
repeat(2) {
fluidMasterPixmap.drawPixmap(pixmap,
(35 + it * 6) * TILE_SIZE, fluidLevel * TILE_SIZE,
0, TILE_SIZE * (5 + it),
TILE_SIZE * 6, TILE_SIZE
)
}
pixmap.dispose()
}
// test print
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/fluidpixmapmaster.tga"), fluidMasterPixmap, false)
// occupy the fluid pixmap with software rendering
for (i in BlockCodex.MAX_TERRAIN_TILES..BlockCodex.highestNumber) {
val fluid = Color(BlockCodex[i].colour)
// pixmap <- (color SCREEN fluidMasterPixmap)
// then occupy the atlasFluid
val pixmap = Pixmap(fluidMasterPixmap.width, fluidMasterPixmap.height, Pixmap.Format.RGBA8888)
pixmap.blending = Pixmap.Blending.None
for (y in 0 until pixmap.height) {
for (x in 0 until pixmap.width) {
val inColour = Color(fluidMasterPixmap.getPixel(x, y))
// SCREEN for RGB, MUL for A.
inColour.r = 1f - (1f - fluid.r) * (1f - inColour.r)
inColour.g = 1f - (1f - fluid.g) * (1f - inColour.g)
inColour.b = 1f - (1f - fluid.b) * (1f - inColour.b)
inColour.a = fluid.a * inColour.a
pixmap.drawPixel(x, y, inColour.toRGBA())
}
}
// test print
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/$i.tga"), pixmap, false)
// to the atlas
val atlasTargetPos = 16 + 47 * 8 * (i - BlockCodex.MAX_TERRAIN_TILES)
for (k in 0 until 47 * 8) {
val srcX = (k % 47) * TILE_SIZE
val srcY = (k / 47) * TILE_SIZE
val destX = ((atlasTargetPos + k) % TILES_IN_X) * TILE_SIZE
val destY = ((atlasTargetPos + k) / TILES_IN_X) * TILE_SIZE
atlasFluid.drawPixmap(pixmap, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
}
pixmap.dispose()
}
fluidMasterPixmap.dispose()
// create item_wall images
fun maskTypetoTileIDForItemImage(maskType: Int) = when(maskType) {
@@ -204,14 +146,14 @@ object CreateTileAtlas {
val itemTerrainPixmap = Pixmap(16 * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
val itemWallPixmap = Pixmap(16 * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888)
val terrainColormapPixmap = Pixmap(16, TILES_IN_X, Pixmap.Format.RGBA8888)
CreateTileAtlas.tags.toMap().forEach { t, u ->
val tilePosFromAtlas = u.tileNumber + maskTypetoTileIDForItemImage(u.maskType)
CreateTileAtlas.tags.toMap().forEach { id, tag ->
val tilePosFromAtlas = tag.tileNumber + maskTypetoTileIDForItemImage(tag.maskType)
val srcX = (tilePosFromAtlas % TILES_IN_X) * TILE_SIZE
val srcY = (tilePosFromAtlas / TILES_IN_X) * TILE_SIZE
val destX = (t % 16) * TILE_SIZE
val destY = (t / 16) * TILE_SIZE
val t = tileIDtoItemSheetNumber(id)
val destX = (t % ITEM_ATLAS_TILES_X) * TILE_SIZE
val destY = (t / ITEM_ATLAS_TILES_X) * TILE_SIZE
itemTerrainPixmap.drawPixmap(CreateTileAtlas.atlas, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
itemWallPixmap.drawPixmap(CreateTileAtlas.atlas, srcX, srcY, TILE_SIZE, TILE_SIZE, destX, destY, TILE_SIZE, TILE_SIZE)
}
@@ -222,35 +164,35 @@ object CreateTileAtlas {
itemWallPixmap.drawPixel(x, y, c)
}
}
// create terrain colourmap
terrainTileColourMap = HashMap<ItemID, Cvec>()
val pxCount = TILE_SIZE * TILE_SIZE
for (id in 0 until BlockCodex.MAX_TERRAIN_TILES) {
val tx = (id % 16) * TILE_SIZE
val ty = (id / 16) * TILE_SIZE
var r = 0; var g = 0; var b = 0; var a = 0
for (id in itemSheetNumbers) {
val tilenum = id.value
val tx = (tilenum % ITEM_ATLAS_TILES_X) * TILE_SIZE
val ty = (tilenum / ITEM_ATLAS_TILES_X) * TILE_SIZE
var r = 0f; var g = 0f; var b = 0f; var a = 0f
// average out the whole block
for (y in ty until ty + TILE_SIZE) {
for (x in tx until tx + TILE_SIZE) {
val data = itemTerrainPixmap.getPixel(x, y)
r += (data ushr 24) and 255
g += (data ushr 16) and 255
b += (data ushr 8) and 255
a += data and 255
r += ((data ushr 24) and 255).div(255f)
g += ((data ushr 16) and 255).div(255f)
b += ((data ushr 8) and 255).div(255f)
a += (data and 255).div(255f)
}
}
terrainColormapPixmap.drawPixel(tx / TILE_SIZE, ty / TILE_SIZE,
(r / pxCount).shl(24) or
(g / pxCount).shl(16) or
(b / pxCount).shl(8) or
(a / pxCount)
terrainTileColourMap[id.key] = Cvec(
(r / pxCount),
(g / pxCount),
(b / pxCount),
(a / pxCount)
)
}
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/terrain_colormap.tga"), terrainColormapPixmap, false)
//PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/terrainitem.tga"), itemTerrainPixmap, false)
terrainTileColourMap = GdxColorMap(terrainColormapPixmap)
itemTerrainTexture = Texture(itemTerrainPixmap)
itemWallTexture = Texture(itemWallPixmap)
itemTerrainPixmap.dispose()
@@ -259,7 +201,7 @@ object CreateTileAtlas {
initialised = true
} }
fun getRenderTag(blockID: Int): RenderTag {
fun getRenderTag(blockID: ItemID): RenderTag {
return tags.getOrDefault(blockID, defaultRenderTag)
}
@@ -273,10 +215,11 @@ object CreateTileAtlas {
private val nullTile = Pixmap(TILE_SIZE * 16, TILE_SIZE * 16, Pixmap.Format.RGBA8888)
private fun fileToAtlantes(matte: FileHandle, glow: FileHandle?) {
private fun fileToAtlantes(modname: String, matte: FileHandle, glow: FileHandle?) {
val tilesPixmap = Pixmap(matte)
val tilesGlowPixmap = if (glow != null) Pixmap(glow) else nullTile
val blockID = matte.nameWithoutExtension().toInt()
val blockName = matte.nameWithoutExtension().toInt() // basically a filename
val blockID = "$modname:$blockName"
// determine the type of the block (populate tags list)
// predefined by the image dimension: 16x16 for (1,0)
@@ -317,14 +260,20 @@ object CreateTileAtlas {
drawToAtlantes(tilesPixmap, tilesGlowPixmap, tileCount)
}
itemSheetNumbers[blockID] = itemSheetCursor
itemSheetCursor += 1
tilesPixmap.dispose()
}
fun tileIDtoAtlasNumber(tileID: ItemID) = tags[tileID]!!.tileNumber
fun tileIDtoItemSheetNumber(tileID: ItemID) = itemSheetNumbers[tileID]!!
/**
* This function must precede the drawToAtlantes() function, as the marking requires the variable
* 'atlasCursor' and the draw function modifies it!
*/
private fun addTag(id: Int, connectionType: Int, maskType: Int) {
private fun addTag(id: ItemID, connectionType: Int, maskType: Int) {
if (tags.containsKey(id)) {
throw Error("Block $id already exists")
}
@@ -391,6 +340,9 @@ object CreateTileAtlas {
}
}
/**
* @param tileNumber ordinal number of a tile in the texture atlas
*/
data class RenderTag(val tileNumber: Int, val connectionType: Int, val maskType: Int) {
companion object {
const val CONNECT_MUTUAL = 0

View File

@@ -487,14 +487,14 @@ object LightmapRenderer {
if (_thisFluid.type != Fluid.NULL) {
_fluidAmountToCol.set(_thisFluid.amount, _thisFluid.amount, _thisFluid.amount, _thisFluid.amount)
_thisTileLuminosity.set(BlockCodex[_thisTerrain].getLumCol(worldX, worldY))
_thisTileLuminosity.set(BlockCodex[world.tileNumberToNameMap[_thisTerrain]].getLumCol(worldX, worldY))
_thisTileLuminosity.maxAndAssign(BlockCodex[_thisFluid.type].getLumCol(worldX, worldY).mul(_fluidAmountToCol)) // already been div by four
_mapThisTileOpacity.setVec(lx, ly, BlockCodex[_thisTerrain].opacity)
_mapThisTileOpacity.setVec(lx, ly, BlockCodex[world.tileNumberToNameMap[_thisTerrain]].opacity)
_mapThisTileOpacity.max(lx, ly, BlockCodex[_thisFluid.type].opacity.mul(_fluidAmountToCol))// already been div by four
}
else {
_thisTileLuminosity.set(BlockCodex[_thisTerrain].getLumCol(worldX, worldY))
_mapThisTileOpacity.setVec(lx, ly, BlockCodex[_thisTerrain].opacity)
_thisTileLuminosity.set(BlockCodex[world.tileNumberToNameMap[_thisTerrain]].getLumCol(worldX, worldY))
_mapThisTileOpacity.setVec(lx, ly, BlockCodex[world.tileNumberToNameMap[_thisTerrain]].opacity)
}
_mapThisTileOpacity2.setR(lx, ly, _mapThisTileOpacity.getR(lx, ly) * 1.41421356f)
@@ -504,7 +504,8 @@ object LightmapRenderer {
// open air || luminous tile backed by sunlight
if ((_thisTerrain == AIR && _thisWall == AIR) || (_thisTileLuminosity.nonZero() && _thisWall == AIR)) {
if ((world.tileNumberToNameMap[_thisTerrain] == AIR && world.tileNumberToNameMap[_thisWall] == AIR) ||
(_thisTileLuminosity.nonZero() && world.tileNumberToNameMap[_thisWall] == AIR)) {
_mapLightLevelThis.setVec(lx, ly, sunLight)
}