bugs on fluid sim, Type is NULL but fill isn't 0/new temporary fluid draw

This commit is contained in:
Minjae Song
2018-12-16 02:10:04 +09:00
parent 191a91cb81
commit 4fa44abd3e
20 changed files with 64 additions and 98 deletions

View File

@@ -1,4 +1,4 @@
"id";"drop";"name" ; "shdr"; "shdg"; "shdb"; "shduv";"strength";"dsty";"mate";"fluid";"solid";"clear";"wall"; "lumr"; "lumg"; "lumb";"lumuv";"fall";"dlfn";"vscs";"fv";"friction"
"id";"drop";"name" ; "shdr"; "shdg"; "shdb"; "shduv";"strength";"dsty";"mate";"fluid";"solid";"clear";"wall"; "lumr"; "lumg"; "lumb"; "lumuv";"fall";"dlfn";"vscs";"fv";"friction"
"0"; "0";"BLOCK_AIR" ;"0.0312";"0.0312";"0.0312";"0.0312"; "1"; "1";"null"; "0"; "0"; "1"; "1";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "N/A"; "0";"4"
"16"; "17";"BLOCK_STONE" ;"0.1252";"0.1252";"0.1252";"0.1252"; "48";"2400";"rock"; "0"; "1"; "0"; "1";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "N/A"; "0";"16"
"17"; "17";"BLOCK_STONE_QUARRIED" ;"0.1252";"0.1252";"0.1252";"0.1252"; "48";"2400";"rock"; "0"; "1"; "0"; "1";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "N/A"; "0";"16"
@@ -97,37 +97,7 @@
"256"; "256";"BLOCK_LANTERN_IRON_REGULAR" ;"0.0312";"0.0312";"0.0312";"0.0312"; "1"; "N/A";"fxtr"; "0"; "0"; "1"; "0";"1.0000";"0.6372";"0.0000";"0.0000"; "0"; "0"; "N/A"; "0";"16"
"257"; "257";"BLOCK_SUNSTONE" ;"0.1252";"0.1252";"0.1252";"0.1252"; "1"; "N/A";"rock"; "0"; "1"; "0"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "2"; "N/A"; "0";"16"
"258"; "258";"BLOCK_DAYLIGHT_CAPACITOR" ;"0.1252";"0.1252";"0.1252";"0.1252"; "1"; "N/A";"glas"; "0"; "1"; "0"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "3"; "N/A"; "0";"16"
"4064"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4065"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4066"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4067"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4068"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4069"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4070"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4071"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4072"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4073"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4074"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4075"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4076"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4077"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4078"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4079"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4080"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4081"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4082"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4083"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4084"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4085"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4086"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4087"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4088"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4089"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4090"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4091"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4092"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4093"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4094"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"4094"; "0";"BLOCK_LAVA" ;"0.9696";"0.9696";"0.9696";"0.9696"; "100";"2600";"rock"; "1"; "0"; "1"; "0";"0.7664";"0.2032";"0.0000";"0.0000"; "0"; "0"; "32"; "0";"16"
"4095"; "0";"BLOCK_WATER" ;"0.1016";"0.0744";"0.0508";"0.0508"; "100";"1000";"watr"; "1"; "0"; "1"; "0";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "16"; "0";"16"
"-1"; "0";"BLOCK_NULL" ;"4.0000";"4.0000";"4.0000";"4.0000"; "-1";"2600";"null"; "0"; "0"; "1"; "1";"0.0000";"0.0000";"0.0000";"0.0000"; "0"; "0"; "N/A"; "0";"16"
@@ -159,9 +129,9 @@
## Illuminators ##
# Illuminator white: Mercury Lamp; CIELAB of (94, -5.131, 10.613), which is made out of CIEXYZ of (0.947638, 1.146481, 0.482263), measured with ColorMunki Spectrometer (If you want high CRI lamp, collect a daylight!)
# Illuminator white: Mercury Lamp; CIELAB of (94, -5.131, 10.613), which is made out of CIEXYZ of (0.947638, 1.146481, 0.482263), measured with ColorMunki Spectrometer (If you don't want green tinge, collect a daylight!)
# Illuminator orange: Sodium Lamp; CIE xy of (0.5375, 0.4153), CIEXYZ of (352.531139, 272.379377, 30.980339), measured with ColorMunki Spectrometer
# Defalut torch : Y 64 x 0.55183 y 0.40966 (Planckian ~1 770 K); real candlelight colour taken from Spyder5 colorimeter (for I couldn't afford i1DisplayPro/Colormunki)
# Defalut torch : Y 64 x 0.55183 y 0.40966 (Planckian ~1 770 K); real candlelight colour taken from Spyder5 colorimeter (for I couldn't afford i1DisplayPro/Colormunki -- at least back then!)
# Sunstone: Artificial sunlight, change colour over time in sync with sunlight. The light is set by game's code.
# Sunlight capacitor: daylight at noon. Set by game's code.
Can't render this file because it contains an unexpected character in line 1 and column 20.

Binary file not shown.

View File

@@ -108,7 +108,7 @@ object BlockCodex {
prop.friction = intVal(record, "friction")
prop.viscosity = intVal(record, "vscs")
prop.isFluid = Fluid.isThisTileFluid(prop.id)//boolVal(record, "fluid")
prop.isFluid = boolVal(record, "fluid")
prop.isSolid = boolVal(record, "solid")
prop.isClear = boolVal(record, "clear")
prop.isWallable = boolVal(record, "wall")

View File

@@ -359,6 +359,11 @@ open class GameWorld {
}*/
if (fluidType == Fluid.NULL && fill != 0f) {
throw Error("Illegal fluid at ($x,$y): ${FluidInfo(fluidType, fill)}")
}
val addr = LandUtil.getBlockAddr(this, x, y)
// fluid completely drained
if (fill <= WorldSimulator.FLUID_MIN_MASS) {
@@ -396,7 +401,9 @@ open class GameWorld {
return if (type == null) FluidInfo(Fluid.NULL, 0f) else FluidInfo(type, fill!!)
}
data class FluidInfo(val type: FluidType, val amount: Float)
data class FluidInfo(val type: FluidType, val amount: Float) {
override fun toString() = "Fluid type: ${type.value}, amount: $amount"
}
fun getTemperature(worldTileX: Int, worldTileY: Int): Float? {

View File

@@ -76,8 +76,8 @@ object WorldSimulator {
fun moveFluids(delta: Float) {
makeFluidMapFromWorld()
simCompression()
/*for (y in 1 until fluidMap.size - 1) {
//simCompression()
for (y in 1 until fluidMap.size - 1) {
for (x in 1 until fluidMap[0].size - 1) {
val worldX = x + updateXFrom
val worldY = y + updateYFrom
@@ -98,7 +98,7 @@ object WorldSimulator {
fluidNewMap[y + 1][x] += remainingMass
}
}
}*/
}
fluidmapToWorld()
}
@@ -299,9 +299,9 @@ object WorldSimulator {
fluidNewMap[y][x] = fluidData.amount
fluidNewTypeMap[y][x] = fluidData.type
if (x + updateXFrom == 60 && y + updateYFrom == 256) {
/*if (x + updateXFrom == 60 && y + updateYFrom == 256) {
printdbg(this, "making array amount ${fluidData.amount} for (60,256)")
}
}*/
}
}
}

View File

@@ -10,14 +10,18 @@ import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.ceilInt
import net.torvald.terrarum.gameworld.MapLayer
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_TILES
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.util.zip.GZIPInputStream
import kotlin.math.roundToInt
/**
@@ -311,39 +315,9 @@ internal object BlocksDrawer {
* will blend colour using colour multiplication
* i.e. red hues get lost if you dive into the water
*/
private val TILES_BLEND_MUL = hashSetOf(-1
/*Block.WATER,
Block.WATER_1,
Block.WATER_2,
Block.WATER_3,
Block.WATER_4,
Block.WATER_5,
Block.WATER_6,
Block.WATER_7,
Block.WATER_8,
Block.WATER_9,
Block.WATER_10,
Block.WATER_11,
Block.WATER_12,
Block.WATER_13,
Block.WATER_14,
Block.WATER_15,
Block.LAVA,
Block.LAVA_1,
Block.LAVA_2,
Block.LAVA_3,
Block.LAVA_4,
Block.LAVA_5,
Block.LAVA_6,
Block.LAVA_7,
Block.LAVA_8,
Block.LAVA_9,
Block.LAVA_10,
Block.LAVA_11,
Block.LAVA_12,
Block.LAVA_13,
Block.LAVA_14,
Block.LAVA_15*/
private val TILES_BLEND_MUL = hashSetOf(
Block.WATER,
Block.LAVA
)
/**
@@ -387,6 +361,7 @@ internal object BlocksDrawer {
drawTiles(TERRAIN, true) // blendmul tiles
renderUsingBuffer(TERRAIN, projectionMatrix)
renderFluids(projectionMatrix)
@@ -454,6 +429,9 @@ internal object BlocksDrawer {
for (y in for_y_start..for_y_end) {
for (x in for_x_start..for_x_end) {
val bufferX = x - for_x_start
val bufferY = y - for_y_start
val thisTile: Int?
if (mode % 3 == WALL)
thisTile = world.getTileFromWall(x, y)
@@ -516,29 +494,39 @@ internal object BlocksDrawer {
// so obviously when we caught not eligible tile, we need to skip that by marking as Tile No. zero
if (isBlendMul(thisTile)) {
writeToBuffer(mode, x - for_x_start, y - for_y_start, thisTileX, thisTileY, breakingStage)
if (BlockCodex[thisTile].isFluid) {
val fluid = world.getFluid(x, y)
if (fluid.type == Fluid.NULL && fluid.amount != 0f) {
throw Error("Illegal fluid at ($x,$y): $fluid")
}
if (fluid.amount >= WorldSimulator.FLUID_MIN_MASS) {
val fluidLevel = fluid.amount.coerceIn(0f,1f).times(PairedMapLayer.RANGE - 1).roundToInt()
val baseTileID = (GameWorld.TILES_SUPPORTED) - fluid.type.abs()
val tileX = fluidLevel + (baseTileID % 16) * PairedMapLayer.RANGE
val tileY = baseTileID / 16
printdbg(this, "$fluid")
printdbg(this, "$fluidLevel, $baseTileID, $tileX, $tileY")
writeToBuffer(mode, bufferX, bufferY, tileX, tileY, 0)
}
}
else {
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, breakingStage)
}
}
else {
writeToBuffer(mode, x - for_x_start, y - for_y_start, 0, 0, 0)
writeToBuffer(mode, bufferX, bufferY, 0, 0, 0)
}
}
else {
// do NOT add "if (!isBlendMul(thisTile))"!
// or else they will not look like they should be when backed with wall
writeToBuffer(mode, x - for_x_start, y - for_y_start, thisTileX, thisTileY, breakingStage)
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, breakingStage)
}
// draw a breakage
/*if (mode == TERRAIN || mode == WALL) {
val breakage = if (mode == TERRAIN) world.getTerrainDamage(x, y) else world.getWallDamage(x, y)
val maxHealth = BlockCodex[world.getTileFromTerrain(x, y)].strength
val stage = (breakage / maxHealth).times(breakAnimSteps).roundInt()
// actual drawing
if (stage > 0) {
writeToBuffer(mode, x - for_x_start, y - for_y_start, 5 + stage, 0)
}
}*/
//} // end if (is illuminated)
//} // end if (not an air)
@@ -762,6 +750,10 @@ internal object BlocksDrawer {
//tilesBufferAsTex.dispose()
}
private fun renderFluids(projectionMatrix: Matrix4) {
}
private var oldScreenW = 0
private var oldScreenH = 0

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File