wire actor wip

This commit is contained in:
minjaesong
2021-07-30 17:48:25 +09:00
parent 4f52b26590
commit f64574db80
12 changed files with 117 additions and 92 deletions

View File

@@ -44,7 +44,9 @@ Actor range in-depth
|0x1000_0000..0x1FFF_FFFF|Rendered behind (e.g. tapestries)|
|0x2000_0000..0x4FFF_FFFF|Regular actors (e.g. almost all of them)|
|0x5000_0000..0x5FFF_FFFF|Special (e.g. weapon swung, bullets, dropped item, particles)|
|0x6000_0000..0x6FFF_FFFF|Rendered front (e.g. fake tile)|
|0x6000_0000..0x6EFF_FFFF|Rendered front (e.g. fake tile)|
|0x6F00_0000..0x6FFE_FFFF|unassigned|
|0x6FFF_0000..0x6FFF_FFFF|Rendered front--wires|
|0x7000_0000..0x7FFF_FFFF|Rendered as screen overlay, not affected by light nor environment overlays|
Actor IDs are assigned in 256 groups, single actor can have 256 sub-actors

View File

@@ -25,8 +25,8 @@ uniform sampler2D tilesAtlas; // terrain, wire, fluids, etc.
uniform sampler2D tilesBlendAtlas; // alternative terrain for the weather mix (e.g. yellowed grass)
uniform float tilesBlend = 0.0; // percentage of blending [0f..1f]. 0: draws tilesAtlas, 1: draws tilesBlendAtlas
uniform vec2 tilesInAtlas = ivec2(256.0, 256.0);
uniform vec2 atlasTexSize = ivec2(4096.0, 4096.0);
uniform vec2 tilesInAtlas = vec2(256.0, 256.0);
uniform vec2 atlasTexSize = vec2(4096.0, 4096.0);
vec2 tileSizeInPx = atlasTexSize / tilesInAtlas; // should be like ivec2(16.0, 16.0)
uniform vec4 colourFilter = vec4(1, 1, 1, 1); // used by WALL to darken it

View File

@@ -176,9 +176,9 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
if (actorContainerActive.size == 0 && actorContainerInactive.size == 0)
throw IllegalArgumentException("Actor with ID $ID does not exist.")
var actor = actorContainerActive.searchFor(ID) { it.referenceID!! }
var actor = actorContainerActive.searchFor(ID) { it.referenceID }
if (actor == null) {
actor = actorContainerInactive.searchFor(ID) { it.referenceID!! }
actor = actorContainerInactive.searchFor(ID) { it.referenceID }
if (actor == null) {
/*JOptionPane.showMessageDialog(

View File

@@ -104,7 +104,7 @@ object PostProcessor : Disposable {
if (KeyToggler.isOn(Input.Keys.F10)) {
batch.color = Color.WHITE
batch.inUse {
AppLoader.fontSmallNumbers.draw(it, "Wire draw class: ${BlocksDrawer.selectedWireRenderClass}", 2f, 2f)
AppLoader.fontSmallNumbers.draw(it, "Wire draw class: ${(Terrarum.ingame as? net.torvald.terrarum.modulebasegame.TerrarumIngame)?.selectedWireRenderClass}", 2f, 2f)
}
}

View File

@@ -8,7 +8,6 @@ object ReferencingRanges {
val TILES = 0..65535 // 65 536 blocks
val WALLS = 65536..131071 // 65 536 walls
val WIRES = 131072..135167 // 4 096 wires
val ITEMS_STATIC = 135168..0x0F_FFFF // 913 408 items
val ITEMS_DYNAMIC = 0x10_0000..0x0FFF_FFFF // 267 386 880 pseudo-items
val ACTORS = 0x1000_0000..0x7FFF_FFFF // too much actors
@@ -17,7 +16,8 @@ object ReferencingRanges {
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_FRONT = 0x6000_0000..0x6EFF_FFFF // Rendered front (e.g. fake tile)
val ACTORS_WIRES = 0x6FFF_0000..0x6FFF_FFFF // Rendered front--weres
val ACTORS_OVERLAY = 0x7000_0000..0x7FFF_FFFF // Rendered as screen overlay, not affected by light nor environment overlays
val VIRTUAL_TILES = -2 downTo -1048576 // index of -1 breaks things for some reason :(

View File

@@ -19,7 +19,6 @@ import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.ActorID
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -279,6 +278,9 @@ object Terrarum : Disposable {
/** Delta converted as it it was a FPS */
inline val updateRate: Double
get() = 1.0 / Gdx.graphics.rawDeltaTime
private val noSubActorClass = hashSetOf(Actor.RenderOrder.WIRES)
/**
* Usage:
*
@@ -294,7 +296,8 @@ object Terrarum : Disposable {
Actor.RenderOrder.MIDDLE -> Actor.RANGE_MIDDLE
Actor.RenderOrder.MIDTOP -> Actor.RANGE_MIDTOP
Actor.RenderOrder.FRONT -> Actor.RANGE_FRONT
Actor.RenderOrder.OVERLAY-> Actor.RANDE_OVERLAY
Actor.RenderOrder.OVERLAY-> Actor.RANGE_OVERLAY
Actor.RenderOrder.WIRES -> Actor.RANGE_WIRES
}
}
catch (gameNotInitialisedException: KotlinNullPointerException) {
@@ -303,7 +306,7 @@ object Terrarum : Disposable {
var ret: Int
do {
ret = HQRNG().nextInt().and(0x7FFFFF00) // set new ID
ret = HQRNG().nextInt().and(if (noSubActorClass.contains(renderOrder)) 0x7FFFFFFF else 0x7FFFFF00) // set new ID
} while (hasCollision(ret)) // check for collision
return ret
}

View File

@@ -19,7 +19,8 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
MIDDLE, // actors
MIDTOP, // bullets, thrown items
FRONT, // fake tiles
OVERLAY // screen overlay, not affected by lightmap
OVERLAY, // screen overlay, not affected by lightmap
WIRES
}
companion object {
@@ -27,7 +28,8 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
val RANGE_MIDDLE = ReferencingRanges.ACTORS_MIDDLE // 3
val RANGE_MIDTOP = ReferencingRanges.ACTORS_MIDTOP // 1
val RANGE_FRONT = ReferencingRanges.ACTORS_FRONT // 1
val RANDE_OVERLAY= ReferencingRanges.ACTORS_OVERLAY // 1
val RANGE_OVERLAY= ReferencingRanges.ACTORS_OVERLAY // 0.9375
val RANGE_WIRES = ReferencingRanges.ACTORS_WIRES // 0.0002
}
abstract fun update(delta: Float)
@@ -45,13 +47,13 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
return referenceID == (other as Actor).referenceID
}
override fun hashCode() = referenceID!!
override fun hashCode() = referenceID
override fun toString() =
if (actorValue.getAsString("name").isNullOrEmpty())
"${hashCode()}"
else
"${hashCode()} (${actorValue.getAsString("name")})"
override fun compareTo(other: Actor): Int = (this.referenceID!! - other.referenceID!!).sign()
override fun compareTo(other: Actor): Int = (this.referenceID - other.referenceID).sign()
fun Int.sign(): Int = if (this > 0) 1 else if (this < 0) -1 else 0

View File

@@ -0,0 +1,10 @@
package net.torvald.terrarum.gameactors
/**
* Created by minjaesong on 2021-07-30.
*/
class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.IMMOBILE) {
init {
this.referenceID = id
}
}

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.blockproperties.BlockPropUtil
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.blockstats.BlockStats
import net.torvald.terrarum.blockstats.MinimapComposer
import net.torvald.terrarum.concurrent.ThreadExecutor
@@ -22,6 +23,7 @@ import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.console.AVTracker
import net.torvald.terrarum.console.ActorsList
import net.torvald.terrarum.gameactors.WireActor
import net.torvald.terrarum.modulebasegame.gameactors.*
import net.torvald.terrarum.modulebasegame.gameactors.physicssolver.CollisionSolver
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
@@ -32,6 +34,7 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
import net.torvald.terrarum.modulebasegame.worldgenerator.Worldgen
import net.torvald.terrarum.modulebasegame.worldgenerator.WorldgenParams
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.worlddrawer.BlocksDrawer
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.util.CircularArray
@@ -150,6 +153,14 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
var particlesActive = 0
private set
var selectedWireRenderClass = ""
/**
* unlike faketiles which gets placed onto the world just like ordinary fixtures, wires are dynamically
* "rendered" into wire-actors, and we need to keep track of them in some way (and definitely NOT create
* 65536 actors all at once)
*/
private var allocatedWireActorsCount = 0
private lateinit var ingameUpdateThread: ThreadIngameUpdate
@@ -626,6 +637,9 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// deal with the uiFixture being closed
if (uiFixture?.isClosed == true) { uiFixture = null }
// fill up visibleActorsRenderFront for wires
fillUpWiresBuffer()
IngameRenderer.invoke(
paused,
visibleActorsRenderBehind,
@@ -639,6 +653,45 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
)
}
private fun fillUpWiresBuffer() {
fun getOrMakeWireActor(num: Int): ActorWithBody {
return try {
getActorByID(ReferencingRanges.ACTORS_WIRES.first + num) as ActorWithBody
}
catch (_: IllegalArgumentException) {
val actor = WireActor(ReferencingRanges.ACTORS_WIRES.first + num)
addNewActor(actor)
actor
}
}
if (selectedWireRenderClass.isNotBlank()) {
val for_y_start = (WorldCamera.y.toFloat() / TILE_SIZE).floorInt()
val for_y_end = for_y_start + BlocksDrawer.tilesInVertical - 1
val for_x_start = (WorldCamera.x.toFloat() / TILE_SIZE).floorInt()
val for_x_end = for_x_start + BlocksDrawer.tilesInHorizontal - 1
var wiringCounter = 0
for (y in for_y_start..for_y_end) {
for (x in for_x_start..for_x_end) {
val wires = world.getAllWiresFrom(x, y)
wires?.forEach {
if (WireCodex[it].renderClass == selectedWireRenderClass) {
val wireActor = getOrMakeWireActor(wiringCounter)
// TODO setup the wire actor
wiringCounter += 1
}
}
}
}
}
}
private fun filterVisibleActors() {
visibleActorsRenderBehind = actorsRenderBehind.filter { it.inScreen() }
visibleActorsRenderMiddle = actorsRenderMiddle.filter { it.inScreen() }
@@ -928,7 +981,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
Actor.RenderOrder.MIDTOP -> {
actorsRenderMidTop.add(actor); insertionSortLastElemAV(actorsRenderMidTop)
}
Actor.RenderOrder.FRONT -> {
Actor.RenderOrder.FRONT, Actor.RenderOrder.WIRES -> {
actorsRenderFront.add(actor); insertionSortLastElemAV(actorsRenderFront)
}
Actor.RenderOrder.OVERLAY-> {

View File

@@ -3,17 +3,11 @@ package net.torvald.terrarum.modulebasegame.gameitems
import net.torvald.terrarum.Point2d
import net.torvald.terrarum.Point2i
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.worlddrawer.BlocksDrawer
/**
* Created by minjaesong on 2019-05-02.
@@ -77,7 +71,7 @@ object BlockBase {
}
fun blockEffectWhenEquipped(delta: Float) {
BlocksDrawer.selectedWireRenderClass = ""
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
}
fun wireStartPrimaryUse(gameItem: GameItem, delta: Float): Boolean {
@@ -102,11 +96,11 @@ object BlockBase {
fun wireEffectWhenEquipped(gameItem: GameItem, delta: Float) {
val itemID = gameItem.originalID
BlocksDrawer.selectedWireRenderClass = WireCodex[itemID].renderClass
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = WireCodex[itemID].renderClass
}
fun wireEffectWhenUnequipped(gameItem: GameItem, delta: Float) {
BlocksDrawer.selectedWireRenderClass = ""
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
}
}

View File

@@ -46,7 +46,7 @@ internal object BlocksDrawer {
val weatherTerrains: Array<TextureRegionPack>
lateinit var tilesTerrain: TextureRegionPack; private set
lateinit var tilesTerrainBlend: TextureRegionPack; private set
val tilesWire: TextureRegionPack
//val tilesWire: TextureRegionPack
val tileItemTerrain: TextureRegionPack
val tileItemWall: TextureRegionPack
val tilesFluid: TextureRegionPack
@@ -58,7 +58,7 @@ internal object BlocksDrawer {
val WALL = GameWorld.WALL
val TERRAIN = GameWorld.TERRAIN
val WIRE = GameWorld.WIRE
//val WIRE = GameWorld.WIRE
val FLUID = -2
val OCCLUSION = 31337
@@ -80,7 +80,7 @@ internal object BlocksDrawer {
private lateinit var terrainTilesBuffer: Array<IntArray>
private lateinit var wallTilesBuffer: Array<IntArray>
private lateinit var wireTilesBuffer: Array<IntArray>
//private lateinit var wireTilesBuffer: Array<IntArray>
private lateinit var fluidTilesBuffer: Array<IntArray>
private lateinit var occlusionBuffer: Array<IntArray>
private var tilesBuffer: Pixmap = Pixmap(1, 1, Pixmap.Format.RGBA8888)
@@ -107,8 +107,7 @@ internal object BlocksDrawer {
TextureRegionPack(Texture(AppLoader.tileMaker.atlasWinter), TILE_SIZE, TILE_SIZE)
)
//TODO make wire work with the TileAtlas system
tilesWire = TextureRegionPack(ModMgr.getGdxFile("basegame", "wires/wire.tga"), TILE_SIZE, TILE_SIZE)
//tilesWire = TextureRegionPack(ModMgr.getGdxFile("basegame", "wires/wire.tga"), TILE_SIZE, TILE_SIZE)
tilesFluid = TextureRegionPack(Texture(AppLoader.tileMaker.atlasFluid), TILE_SIZE, TILE_SIZE)
tilesGlow = TextureRegionPack(Texture(AppLoader.tileMaker.atlasGlow), TILE_SIZE, TILE_SIZE)
@@ -178,7 +177,7 @@ internal object BlocksDrawer {
/**
* Which wires should be drawn. Normally this value is set by the wiring item (e.g. wire pieces, wirecutters)
*/
var selectedWireRenderClass = ""
// var selectedWireRenderClass = ""
internal fun renderData() {
@@ -226,10 +225,10 @@ internal object BlocksDrawer {
gdxSetBlendNormal()
if (selectedWireRenderClass.isNotBlank()) {
/*if (selectedWireRenderClass.isNotBlank()) {
//println("Wires! draw: $drawWires") // use F10 instead
renderUsingBuffer(WIRE, projectionMatrix, false)
}
}*/
}
/**
@@ -299,7 +298,6 @@ internal object BlocksDrawer {
val thisTile: ItemID = when (mode) {
WALL -> world.getTileFromWall(x, y)
TERRAIN -> world.getTileFromTerrain(x, y)
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()
OCCLUSION -> "placeholder_occlusion"
else -> throw IllegalArgumentException()
@@ -313,9 +311,6 @@ internal object BlocksDrawer {
else if (mode == FLUID) {
getNearbyTilesInfoFluids(x, y)
}
else if (mode == WIRE) {
getNearbyWiringInfo(x, y, thisTile)
}
else if (isPlatform(thisTile)) {
getNearbyTilesInfoPlatform(x, y)
}
@@ -338,15 +333,11 @@ internal object BlocksDrawer {
OCCLUSION_TILE_NUM_BASE
else if (mode == FLUID)
AppLoader.tileMaker.fluidToTileNumber(world.getFluid(x, y))
else if (mode == WIRE)
0 // TODO need new wire storing format
else
renderTag.tileNumber
val tileNumber = if (mode != WIRE && thisTile == Block.AIR) 0
val tileNumber = if (thisTile == Block.AIR) 0
// special case: fluids
else if (mode == FLUID) tileNumberBase + connectLut47[nearbyTilesInfo]
// special case: wires
else if (mode == WIRE) tileNumberBase + connectLut16[nearbyTilesInfo]
// special case: occlusion
else if (mode == OCCLUSION)
tileNumberBase + connectLut47[nearbyTilesInfo]
@@ -366,25 +357,12 @@ internal object BlocksDrawer {
//println("tileNumberBase = $tileNumberBase, tileNumber = $tileNumber, fluid = ${world.getFluid(x, y)}")
}
val breakage = if (mode == TERRAIN) world.getTerrainDamage(x, y) else world.getWallDamage(x, y)
val maxHealth = BlockCodex[world.getTileFromTerrain(x, y)].strength
val breakingStage = (breakage / maxHealth).times(BREAKAGE_STEPS).roundToInt()
val breakage = if (mode == TERRAIN) world.getTerrainDamage(x, y) else if (mode == WALL) world.getWallDamage(x, y) else 0f
val maxHealth = if (mode == TERRAIN || mode == WALL) BlockCodex[world.getTileFromTerrain(x, y)].strength else 1
val breakingStage = if (mode == TERRAIN || mode == WALL) (breakage / maxHealth).times(BREAKAGE_STEPS).roundToInt() else 0
// draw a tile
if (mode == WIRE) {
// no wire here, draw block id 255 (bottom right)
writeToBuffer(mode, bufferX, bufferY, 15, 15, 0)
}
else if (mode == OCCLUSION || mode == FLUID) {
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, 0)
}
else {
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, breakingStage)
}
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, breakingStage)
}
}
}
@@ -403,7 +381,7 @@ internal object BlocksDrawer {
}
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 }
val nearbyTiles = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) }
var ret = 0
for (i in nearbyTiles.indices) {
@@ -433,28 +411,8 @@ internal object BlocksDrawer {
return ret
}
/**
* @param wire -1 for none, 0 for signal red, 1 for untility prototype, 2 for low power, 3 for high power;
* log of bits defined in [net.torvald.terrarum.blockproperties.Wire]
*
* @return offset from the spritesheet's "base" tile number, 0..15.
*/
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) {
if (nearbyTiles[i] == wire) {
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
}
}
return ret*/
}
private fun getNearbyTilesInfoConMutual(x: Int, y: Int, mode: Int): Int {
val nearbyTiles: List<ItemID> = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y)!! }
val nearbyTiles: List<ItemID> = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) }
var ret = 0
for (i in nearbyTiles.indices) {
@@ -520,7 +478,7 @@ internal object BlocksDrawer {
private fun getNearbyTilesInfoPlatform(x: Int, y: Int): Int {
val nearbyTiles = arrayOf(Block.NULL, Block.NULL, Block.NULL, Block.NULL)
val NEARBY_TILE_KEY_BACK = NEARBY_TILE_KEY_UP
//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)
@@ -578,7 +536,7 @@ internal object BlocksDrawer {
val sourceBuffer = when(mode) {
TERRAIN -> terrainTilesBuffer
WALL -> wallTilesBuffer
WIRE -> wireTilesBuffer
//WIRE -> wireTilesBuffer
FLUID -> fluidTilesBuffer
OCCLUSION -> occlusionBuffer
else -> throw IllegalArgumentException()
@@ -602,20 +560,20 @@ internal object BlocksDrawer {
val tileAtlas = when (mode) {
TERRAIN, WALL, OCCLUSION -> tilesTerrain
WIRE -> tilesWire
//WIRE -> tilesWire
FLUID -> tilesFluid
else -> throw IllegalArgumentException()
}
val sourceBuffer = when(mode) {
TERRAIN -> terrainTilesBuffer
WALL -> wallTilesBuffer
WIRE -> wireTilesBuffer
//WIRE -> wireTilesBuffer
FLUID -> fluidTilesBuffer
OCCLUSION -> occlusionBuffer
else -> throw IllegalArgumentException()
}
val vertexColour = when (mode) {
TERRAIN, WIRE, FLUID, OCCLUSION -> Color.WHITE
TERRAIN, /*WIRE,*/ FLUID, OCCLUSION -> Color.WHITE
WALL -> AppLoader.tileMaker.wallOverlayColour
else -> throw IllegalArgumentException()
}
@@ -649,6 +607,8 @@ internal object BlocksDrawer {
shader.begin()
shader.setUniformMatrix("u_projTrans", projectionMatrix)//camera.combined)
shader.setUniform2fv("tilesInAtlas", AppLoader.tileMaker.SHADER_SIZE_KEYS, 2, 2)
shader.setUniform2fv("atlasTexSize", AppLoader.tileMaker.SHADER_SIZE_KEYS, 0, 2)
shader.setUniformf("colourFilter", vertexColour)
shader.setUniformf("screenDimension", Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
shader.setUniformi("tilesAtlas", 0)
@@ -688,11 +648,10 @@ internal object BlocksDrawer {
// only update if it's really necessary
if (oldTH != tilesInHorizontal || oldTV != tilesInVertical) {
terrainTilesBuffer = Array<IntArray>(tilesInVertical, { kotlin.IntArray(tilesInHorizontal) })
wallTilesBuffer = Array<IntArray>(tilesInVertical, { kotlin.IntArray(tilesInHorizontal) })
wireTilesBuffer = Array<IntArray>(tilesInVertical, { kotlin.IntArray(tilesInHorizontal) })
fluidTilesBuffer = Array<IntArray>(tilesInVertical, { kotlin.IntArray(tilesInHorizontal) })
occlusionBuffer = Array<IntArray>(tilesInVertical, { kotlin.IntArray(tilesInHorizontal) })
terrainTilesBuffer = Array(tilesInVertical) { IntArray(tilesInHorizontal) }
wallTilesBuffer = Array(tilesInVertical) { IntArray(tilesInHorizontal) }
fluidTilesBuffer = Array(tilesInVertical) { IntArray(tilesInHorizontal) }
occlusionBuffer = Array(tilesInVertical) { IntArray(tilesInHorizontal) }
tilesBuffer.dispose()
tilesBuffer = Pixmap(tilesInHorizontal, tilesInVertical, Pixmap.Format.RGBA8888)
@@ -759,7 +718,7 @@ internal object BlocksDrawer {
weatherTerrains.forEach { it.dispose() }
tilesGlow.dispose()
tilesWire.dispose()
//tilesWire.dispose()
tileItemTerrain.dispose()
tileItemWall.dispose()
tilesFluid.dispose()

View File

@@ -34,6 +34,8 @@ class CreateTileAtlas {
val MAX_TEX_SIZE = AppLoader.getConfigInt("atlastexsize").coerceIn(1024, AppLoader.glInfo.GL_MAX_TEXTURE_SIZE)
val TILES_IN_X = MAX_TEX_SIZE / TILE_SIZE
val SHADER_SIZE_KEYS = floatArrayOf(MAX_TEX_SIZE.toFloat(), MAX_TEX_SIZE.toFloat(), TILES_IN_X.toFloat(), TILES_IN_X.toFloat())
val ITEM_ATLAS_TILES_X = 16
private val TOTAL_TILES = TILES_IN_X * TILES_IN_X