mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 01:54:04 +09:00
even better fluid tiling
This commit is contained in:
@@ -113,7 +113,7 @@
|
|||||||
<li><index id="emph (tag)"/><code>emph</code> — is a special case of the <code>span</code> tag. The resulting text will be <emph>red</emph></li>
|
<li><index id="emph (tag)"/><code>emph</code> — is a special case of the <code>span</code> tag. The resulting text will be <emph>red</emph></li>
|
||||||
<li><index id="itemname (tag)"/><code>itemname</code> — is a special case of the <code>span</code> tag used to highlight the name of the ingame item. The resulting text will be <itemname>blue</itemname></li>
|
<li><index id="itemname (tag)"/><code>itemname</code> — is a special case of the <code>span</code> tag used to highlight the name of the ingame item. The resulting text will be <itemname>blue</itemname></li>
|
||||||
<li><index id="targetname (tag)"/><code>targetname</code> — is a special case of the <code>span</code> tag used to highlight the name of an arbitrary target or goals. The resulting text will be <targetname>green</targetname></li>
|
<li><index id="targetname (tag)"/><code>targetname</code> — is a special case of the <code>span</code> tag used to highlight the name of an arbitrary target or goals. The resulting text will be <targetname>green</targetname></li>
|
||||||
<li><index id="code (tag)"/><code>code</code> — is a special case of the <code>span</code> tag used to highlight the code element in-line. The resulting text will be <code>maroon and monospaced</code></li>
|
<li><index id="code (tag)"/><code>code</code> — is a special case of the <code>span</code> tag used to highlight the code element in-line. The resulting text will be <code>magenta and monospaced</code></li>
|
||||||
<li><index id="br (tag)"/><code>br</code> — self-closing tag; inserts an anonymous line break</li>
|
<li><index id="br (tag)"/><code>br</code> — self-closing tag; inserts an anonymous line break</li>
|
||||||
<li><index id="newpage (tag)"/><code>newpage</code> — self-closing tag; inserts an anonymous page break</li>
|
<li><index id="newpage (tag)"/><code>newpage</code> — self-closing tag; inserts an anonymous page break</li>
|
||||||
<li><index id="anonbreak (tag)"/><code>anonbreak</code> — self-closing tag; inserts a paragraph break in the text. The break will be in a form of a long straight line on the centre of the text. Useful for typesetting novels</li>
|
<li><index id="anonbreak (tag)"/><code>anonbreak</code> — self-closing tag; inserts a paragraph break in the text. The break will be in a form of a long straight line on the centre of the text. Useful for typesetting novels</li>
|
||||||
|
|||||||
BIN
assets/mods/basegame/fluid/2.tga
LFS
Normal file
BIN
assets/mods/basegame/fluid/2.tga
LFS
Normal file
Binary file not shown.
@@ -2037,8 +2037,8 @@ object BTeXParser {
|
|||||||
private const val HEADING_NUM_TITLE_GAP = 9
|
private const val HEADING_NUM_TITLE_GAP = 9
|
||||||
|
|
||||||
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
||||||
val ccBucks = TerrarumSansBitmap.toColorCode(5,0,0)
|
val ccBucks = TerrarumSansBitmap.toColorCode(10,0,6)
|
||||||
val ccCode = TerrarumSansBitmap.toColorCode(7,0,0)
|
val ccCode = TerrarumSansBitmap.toColorCode(12,0,7)
|
||||||
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
||||||
val ccEmph = TerrarumSansBitmap.toColorCode(0xfc11)
|
val ccEmph = TerrarumSansBitmap.toColorCode(0xfc11)
|
||||||
val ccItemName = TerrarumSansBitmap.toColorCode(0xf03b)
|
val ccItemName = TerrarumSansBitmap.toColorCode(0xf03b)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameitems
|
package net.torvald.terrarum.modulebasegame.gameitems
|
||||||
|
|
||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
|
import net.torvald.terrarum.BlockCodex
|
||||||
import net.torvald.terrarum.INGAME
|
import net.torvald.terrarum.INGAME
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.Fluid
|
import net.torvald.terrarum.blockproperties.Fluid
|
||||||
@@ -29,7 +30,12 @@ class ItemBottomlessWaterBucket(originalID: ItemID) : GameItem(originalID) {
|
|||||||
|
|
||||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
|
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
|
||||||
val mx = Terrarum.mouseTileX; val my =Terrarum.mouseTileY
|
val mx = Terrarum.mouseTileX; val my =Terrarum.mouseTileY
|
||||||
INGAME.world.setFluid(mx, my, Fluid.WATER, 1f)
|
if (!BlockCodex[INGAME.world.getTileFromTerrain(mx, my)].isSolid) {
|
||||||
return 0L
|
INGAME.world.setFluid(mx, my, Fluid.WATER, 1f)
|
||||||
|
return 0L
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return -1L
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,13 +33,13 @@ import kotlin.system.measureTimeMillis
|
|||||||
*/
|
*/
|
||||||
class BTeXTest : ApplicationAdapter() {
|
class BTeXTest : ApplicationAdapter() {
|
||||||
|
|
||||||
// val filePath = "btex.btxbook"
|
val filePath = "btex.xml"
|
||||||
// val filePath = "btex_ko.xml"
|
// val filePath = "btex_ko.xml"
|
||||||
// val filePath = "test.xml"
|
// val filePath = "test.xml"
|
||||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||||
// val filePath = "literature/koKR/yisang_nalgae.xml"
|
// val filePath = "literature/koKR/yisang_nalgae.xml"
|
||||||
val filePath = "literature/koKR/yisang_geonchukmuhanyukmyeongakche.xml"
|
// val filePath = "literature/koKR/yisang_geonchukmuhanyukmyeongakche.xml"
|
||||||
|
|
||||||
private var serialise = true
|
private var serialise = true
|
||||||
|
|
||||||
|
|||||||
@@ -377,10 +377,7 @@ internal object BlocksDrawer {
|
|||||||
val solids = getNearbyTilesInfoTileCnx(x, y)
|
val solids = getNearbyTilesInfoTileCnx(x, y)
|
||||||
val notSolid = 15 - solids
|
val notSolid = 15 - solids
|
||||||
val fluids = getNearbyFluidsInfo(x, y)
|
val fluids = getNearbyFluidsInfo(x, y)
|
||||||
val fmask = getFluidMaskStatus(fluids)
|
val fluidU = fluids[3].amount
|
||||||
|
|
||||||
val tileToUse = fluidCornerLut[notSolid and fmask] and fluidCornerLut[solids]
|
|
||||||
|
|
||||||
|
|
||||||
val nearbyFluidType = fluids.asSequence().filter { it.amount >= 0.5f / 16f }.map { it.type }.filter { it.startsWith("fluid@") }.sorted().firstOrNull()
|
val nearbyFluidType = fluids.asSequence().filter { it.amount >= 0.5f / 16f }.map { it.type }.filter { it.startsWith("fluid@") }.sorted().firstOrNull()
|
||||||
|
|
||||||
@@ -390,23 +387,48 @@ internal object BlocksDrawer {
|
|||||||
val tile = world.getTileFromTerrain(wx, wy)
|
val tile = world.getTileFromTerrain(wx, wy)
|
||||||
|
|
||||||
if (BlockCodex[tile].isSolidForTileCnx && nearbyFluidType != null) {
|
if (BlockCodex[tile].isSolidForTileCnx && nearbyFluidType != null) {
|
||||||
|
val fmask = getFluidMaskStatus(fluids)
|
||||||
|
var tileToUse = fluidCornerLut[notSolid and fmask] and fluidCornerLut[solids]
|
||||||
|
|
||||||
rawTileNum = world.tileNameToNumberMap[nearbyFluidType]!!
|
rawTileNum = world.tileNameToNumberMap[nearbyFluidType]!!
|
||||||
|
|
||||||
|
// upper points and lower points use different maths
|
||||||
|
// in either case, LR fluids are to be checked
|
||||||
|
|
||||||
|
val fluidR = fluids[0].amount
|
||||||
|
val fluidL = fluids[2].amount
|
||||||
|
|
||||||
|
// check LR for down points
|
||||||
|
if (tileToUse and 0b0110 != 0) {
|
||||||
|
if (fluidR < 0.5f / 16f)
|
||||||
|
tileToUse = tileToUse and 0b1101
|
||||||
|
if (fluidL < 0.5f / 16f)
|
||||||
|
tileToUse = tileToUse and 0b1011
|
||||||
|
}
|
||||||
|
// check R
|
||||||
|
else if (tileToUse and 0b0010 != 0) {
|
||||||
|
if (fluidR < 0.5f / 16f )
|
||||||
|
tileToUse = 0
|
||||||
|
}
|
||||||
|
// check L
|
||||||
|
else if (tileToUse and 0b0100 != 0) {
|
||||||
|
if (fluidL < 0.5f / 16f)
|
||||||
|
tileToUse = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
18 + tileToUse
|
18 + tileToUse
|
||||||
}
|
}
|
||||||
else if (rawTileNum == 0)
|
else if (rawTileNum == 0)
|
||||||
0
|
0
|
||||||
else if (fluids[3].amount >= 1.5f / 16f)
|
else if (bufferY > 0 && tempRenderTypeBuffer[bufferY - 1, bufferX].let {
|
||||||
|
it.ushr(16) == rawTileNum && it.and(255) == 0
|
||||||
|
})
|
||||||
|
16
|
||||||
|
else if (bufferY > 0 && tempRenderTypeBuffer[bufferY - 1, bufferX].let {
|
||||||
|
it.ushr(16) == rawTileNum && it.and(255) < 18
|
||||||
|
})
|
||||||
17
|
17
|
||||||
else if (fluids[3].amount >= 0.5f / 16f) {
|
|
||||||
//if tile above is fluid tile which use 16, use 17
|
|
||||||
if (bufferY > 0 && tempRenderTypeBuffer[bufferY - 1, bufferX].let {
|
|
||||||
(it.ushr(16) == rawTileNum && it.and(255) >= 16) ||
|
|
||||||
(it.ushr(16) == rawTileNum && it.and(255) == 1)
|
|
||||||
})
|
|
||||||
17
|
|
||||||
// else, use 16
|
|
||||||
else 16
|
|
||||||
}
|
|
||||||
else if (fillThis < 0.5f / 16f)
|
else if (fillThis < 0.5f / 16f)
|
||||||
0
|
0
|
||||||
else if (fillThis >= 15.5f / 16f) {
|
else if (fillThis >= 15.5f / 16f) {
|
||||||
@@ -433,7 +455,7 @@ internal object BlocksDrawer {
|
|||||||
15
|
15
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
(fillThis * 16f - 0.5f).roundToInt().coerceIn(0, 15)
|
(fillThis * 16f - 0.5f).floorToInt().coerceIn(0, 15)
|
||||||
}
|
}
|
||||||
else if (treeLeavesTiles.binarySearch(rawTileNum) >= 0) {
|
else if (treeLeavesTiles.binarySearch(rawTileNum) >= 0) {
|
||||||
getNearbyTilesInfoTrees(x, y, mode).swizzle8(rawTileNum, hash)
|
getNearbyTilesInfoTrees(x, y, mode).swizzle8(rawTileNum, hash)
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ object LightmapRenderer {
|
|||||||
private var _mapThisTileOpacity = UnsafeCvecArray(LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT)
|
private var _mapThisTileOpacity = UnsafeCvecArray(LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT)
|
||||||
private var _mapThisTileOpacity2 = UnsafeCvecArray(LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT)
|
private var _mapThisTileOpacity2 = UnsafeCvecArray(LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT)
|
||||||
|
|
||||||
private const val AIR = Block.AIR
|
|
||||||
|
|
||||||
const val DRAW_TILE_SIZE: Float = TILE_SIZE / IngameRenderer.lightmapDownsample
|
const val DRAW_TILE_SIZE: Float = TILE_SIZE / IngameRenderer.lightmapDownsample
|
||||||
|
|
||||||
internal var for_x_start = 0
|
internal var for_x_start = 0
|
||||||
@@ -540,7 +538,9 @@ object LightmapRenderer {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (_thisFluid.type != Fluid.NULL) {
|
if (_thisFluid.type != Fluid.NULL) {
|
||||||
_fluidAmountToCol.set(_thisFluid.amount, _thisFluid.amount, _thisFluid.amount, _thisFluid.amount)
|
_thisFluid.amount.coerceAtMost(1f).let {
|
||||||
|
_fluidAmountToCol.set(it, it, it, it)
|
||||||
|
}
|
||||||
|
|
||||||
_thisTileLuminosity.set(_thisTerrainProp.getLumCol(worldX, worldY))
|
_thisTileLuminosity.set(_thisTerrainProp.getLumCol(worldX, worldY))
|
||||||
_thisTileLuminosity.maxAndAssign(_thisFluidProp.lumCol.mul(_fluidAmountToCol))
|
_thisTileLuminosity.maxAndAssign(_thisFluidProp.lumCol.mul(_fluidAmountToCol))
|
||||||
@@ -649,36 +649,6 @@ object LightmapRenderer {
|
|||||||
return if (BlockCodex[world.getTileFromTerrain(x, y)].isSolid) 1.2f else 1f
|
return if (BlockCodex[world.getTileFromTerrain(x, y)].isSolid) 1.2f else 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ivec4 {
|
|
||||||
|
|
||||||
var r = 0
|
|
||||||
var g = 0
|
|
||||||
var b = 0
|
|
||||||
var a = 0
|
|
||||||
|
|
||||||
fun broadcast(scalar: Int) {
|
|
||||||
r=scalar
|
|
||||||
g=scalar
|
|
||||||
b=scalar
|
|
||||||
a=scalar
|
|
||||||
}
|
|
||||||
fun add(scalar: Int) {
|
|
||||||
r+=scalar
|
|
||||||
g+=scalar
|
|
||||||
b+=scalar
|
|
||||||
a+=scalar
|
|
||||||
}
|
|
||||||
|
|
||||||
fun lane(index: Int) = when(index) {
|
|
||||||
0 -> r
|
|
||||||
1 -> g
|
|
||||||
2 -> b
|
|
||||||
3 -> a
|
|
||||||
else -> throw IndexOutOfBoundsException("Invalid index $index")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var lightBuffer: Pixmap = Pixmap(64, 64, Pixmap.Format.RGBA8888) // must not be too small
|
var lightBuffer: Pixmap = Pixmap(64, 64, Pixmap.Format.RGBA8888) // must not be too small
|
||||||
|
|
||||||
private val colourNull = Cvec(0)
|
private val colourNull = Cvec(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user