mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
more cleanup regarding fireRecalculateEvent
This commit is contained in:
@@ -74,4 +74,5 @@ class UnsafePtr(val ptr: Long, val allocSize: Long) {
|
||||
}
|
||||
|
||||
override fun toString() = "0x${ptr.toString(16)} with size $allocSize"
|
||||
override fun equals(other: Any?) = this.ptr == (other as UnsafePtr).ptr
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.AppLoader.printdbgerr
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
@@ -29,7 +30,6 @@ import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
|
||||
/**
|
||||
@@ -226,10 +226,6 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
|
||||
// update UIs //
|
||||
uiContainer.forEach { it.update(delta) }
|
||||
|
||||
|
||||
|
||||
LightmapRenderer.fireRecalculateEvent() // don't half-frame update; it will jitter!
|
||||
}
|
||||
|
||||
fun renderScreen() {
|
||||
@@ -242,11 +238,11 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
gdxClearAndSetBlend(.64f, .754f, .84f, 1f)
|
||||
|
||||
|
||||
if (!demoWorld.disposed) { // FIXME q&d hack to circumvent the dangling pointer issue #26
|
||||
if (!demoWorld.layerTerrain.ptr.destroyed) { // FIXME q&d hack to circumvent the dangling pointer issue #26
|
||||
IngameRenderer.invoke(gamePaused = false, uisToDraw = uiContainer)
|
||||
}
|
||||
else {
|
||||
System.err.println("[TitleScreen] demoworld is already destroyed")
|
||||
printdbgerr(this, "Demoworld is already been destroyed")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.gameworld
|
||||
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.UnsafeHelper
|
||||
import net.torvald.UnsafePtr
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
|
||||
/**
|
||||
@@ -13,7 +14,7 @@ import net.torvald.terrarum.AppLoader.printdbg
|
||||
open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||
|
||||
// using unsafe pointer gets you 100 fps, whereas using directbytebuffer gets you 90
|
||||
private val ptr = UnsafeHelper.allocate(width * height * BYTES_PER_BLOCK)
|
||||
internal val ptr: UnsafePtr = UnsafeHelper.allocate(width * height * BYTES_PER_BLOCK)
|
||||
|
||||
//private val directByteBuffer: ByteBuffer
|
||||
|
||||
@@ -142,8 +143,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||
printdbg(this, "BlockLayer successfully freed")
|
||||
}
|
||||
|
||||
internal fun getPtr() = ptr
|
||||
|
||||
companion object {
|
||||
@Transient val BYTES_PER_BLOCK = 2L
|
||||
}
|
||||
|
||||
@@ -472,6 +472,8 @@ open class GameWorld : Disposable {
|
||||
disposed = true
|
||||
}
|
||||
|
||||
override fun equals(other: Any?) = layerTerrain.ptr == (other as GameWorld).layerTerrain.ptr
|
||||
|
||||
companion object {
|
||||
@Transient const val WALL = 0
|
||||
@Transient const val TERRAIN = 1
|
||||
|
||||
@@ -28,7 +28,6 @@ import net.torvald.terrarum.serialise.toULittle48
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UINSMenu
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
@@ -309,7 +308,6 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
IngameRenderer.setWorld(gameWorld)
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
|
||||
@@ -32,7 +32,6 @@ import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.util.CircularArray
|
||||
import java.util.*
|
||||
@@ -377,14 +376,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
// these need to appear on top of any others
|
||||
uiContainer.add(notifier)
|
||||
|
||||
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
|
||||
|
||||
AppLoader.setDebugTime("Ingame.updateCounter", 0)
|
||||
|
||||
|
||||
|
||||
// some sketchy test code here
|
||||
|
||||
|
||||
@@ -963,7 +956,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
if (gameInitialised) {
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
//LightmapRenderer.fireRecalculateEvent()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@ object LightmapRenderer {
|
||||
}
|
||||
finally {
|
||||
this.world = world
|
||||
|
||||
// fireRecalculateEvent()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +216,7 @@ object LightmapRenderer {
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
System.err.println("[LightmapRendererNew.fireRecalculateEvent] Attempted to refer destroyed unsafe array " +
|
||||
"(${world.layerTerrain.getPtr()})")
|
||||
"(${world.layerTerrain.ptr})")
|
||||
e.printStackTrace()
|
||||
return // something's wrong but we'll ignore it like a trustful AK
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user