mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +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 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 com.jme3.math.FastMath
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbgerr
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
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.modulebasegame.weather.WeatherMixer
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,10 +226,6 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
// update UIs //
|
// update UIs //
|
||||||
uiContainer.forEach { it.update(delta) }
|
uiContainer.forEach { it.update(delta) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LightmapRenderer.fireRecalculateEvent() // don't half-frame update; it will jitter!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun renderScreen() {
|
fun renderScreen() {
|
||||||
@@ -242,11 +238,11 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
gdxClearAndSetBlend(.64f, .754f, .84f, 1f)
|
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)
|
IngameRenderer.invoke(gamePaused = false, uisToDraw = uiContainer)
|
||||||
}
|
}
|
||||||
else {
|
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 com.badlogic.gdx.utils.Disposable
|
||||||
import net.torvald.UnsafeHelper
|
import net.torvald.UnsafeHelper
|
||||||
|
import net.torvald.UnsafePtr
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
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 {
|
open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||||
|
|
||||||
// using unsafe pointer gets you 100 fps, whereas using directbytebuffer gets you 90
|
// 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
|
//private val directByteBuffer: ByteBuffer
|
||||||
|
|
||||||
@@ -142,8 +143,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
printdbg(this, "BlockLayer successfully freed")
|
printdbg(this, "BlockLayer successfully freed")
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun getPtr() = ptr
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Transient val BYTES_PER_BLOCK = 2L
|
@Transient val BYTES_PER_BLOCK = 2L
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,6 +472,8 @@ open class GameWorld : Disposable {
|
|||||||
disposed = true
|
disposed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?) = layerTerrain.ptr == (other as GameWorld).layerTerrain.ptr
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Transient const val WALL = 0
|
@Transient const val WALL = 0
|
||||||
@Transient const val TERRAIN = 1
|
@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.UICanvas
|
||||||
import net.torvald.terrarum.ui.UINSMenu
|
import net.torvald.terrarum.ui.UINSMenu
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
@@ -309,7 +308,6 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
|
|
||||||
IngameRenderer.setWorld(gameWorld)
|
IngameRenderer.setWorld(gameWorld)
|
||||||
LightmapRenderer.fireRecalculateEvent()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun show() {
|
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
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import net.torvald.util.CircularArray
|
import net.torvald.util.CircularArray
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -377,14 +376,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
// these need to appear on top of any others
|
// these need to appear on top of any others
|
||||||
uiContainer.add(notifier)
|
uiContainer.add(notifier)
|
||||||
|
|
||||||
|
|
||||||
LightmapRenderer.fireRecalculateEvent()
|
|
||||||
|
|
||||||
|
|
||||||
AppLoader.setDebugTime("Ingame.updateCounter", 0)
|
AppLoader.setDebugTime("Ingame.updateCounter", 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// some sketchy test code here
|
// some sketchy test code here
|
||||||
|
|
||||||
|
|
||||||
@@ -963,7 +956,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
|
|
||||||
if (gameInitialised) {
|
if (gameInitialised) {
|
||||||
LightmapRenderer.fireRecalculateEvent()
|
//LightmapRenderer.fireRecalculateEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ object LightmapRenderer {
|
|||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
this.world = world
|
this.world = world
|
||||||
|
|
||||||
|
// fireRecalculateEvent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +216,7 @@ object LightmapRenderer {
|
|||||||
}
|
}
|
||||||
catch (e: NullPointerException) {
|
catch (e: NullPointerException) {
|
||||||
System.err.println("[LightmapRendererNew.fireRecalculateEvent] Attempted to refer destroyed unsafe array " +
|
System.err.println("[LightmapRendererNew.fireRecalculateEvent] Attempted to refer destroyed unsafe array " +
|
||||||
"(${world.layerTerrain.getPtr()})")
|
"(${world.layerTerrain.ptr})")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
return // something's wrong but we'll ignore it like a trustful AK
|
return // something's wrong but we'll ignore it like a trustful AK
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user