I fixed the ingamerender-not-rendering bug??

This commit is contained in:
minjaesong
2024-02-05 01:26:27 +09:00
parent 9ec66109a1
commit cc00e1eff9
6 changed files with 21 additions and 14 deletions

View File

@@ -1246,7 +1246,7 @@ public class App implements ApplicationListener {
printdbg(this, "PostInit done; took "+tms+" seconds");
}
public static void renewAudioProcessor(int bufferSize) {
public static void reloadAudioProcessor(int bufferSize) {
// copy music tracks
var dynaicTracks = audioMixer.getDynamicTracks();
var staticTracks = audioMixer.getTracks();
@@ -1280,6 +1280,7 @@ public class App implements ApplicationListener {
e.printStackTrace();
}
}*/
}

View File

@@ -306,6 +306,8 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
var mousePrimaryJustDown = false; private set
override fun render(updateRate: Float) {
IngameRenderer.setRenderedWorld(gameWorld)
super.render(updateRate)

View File

@@ -180,27 +180,27 @@ object IngameRenderer : Disposable {
* - When the game make transition to the new world (advancing to the next level/entering or exiting the room)
*/
fun setRenderedWorld(world: GameWorld) {
printdbg(this, "Set new RenderedWorld (UUID=${world.worldIndex}) at time ${System.currentTimeMillis()}, called by:")
printStackTrace(this)
// printdbg(this, "Set new RenderedWorld (UUID=${world.worldIndex}) at time ${System.currentTimeMillis()} (disposed: ${world.disposed}), called by:")
// printStackTrace(this)
try {
// change worlds from internal methods
this.world = world
LightmapRenderer.internalSetWorld(world)
BlocksDrawer.world = world
FeaturesDrawer.world = world
if (this.world != world) {
// printdbg(this, "World change detected -- " +
// "old world: ${this.world.hashCode()}, " +
// "new world: ${world.hashCode()}")
// change worlds from internal methods
this.world = world
LightmapRenderer.internalSetWorld(world)
BlocksDrawer.world = world
FeaturesDrawer.world = world
newWorldLoadedLatch = true
}
}
catch (e: UninitializedPropertyAccessException) {
catch (e: Throwable) {
e.printStackTrace()
// new init, do nothing
this.world = world
}
}

View File

@@ -810,6 +810,9 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
gameFullyLoaded = true
}
else {
IngameRenderer.setRenderedWorld(world) // this doesn't slow down the game and prevents world-changing related bugs
}
super.render(updateRate)

View File

@@ -309,6 +309,8 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
private var introUncoverDeltaCounter = 0f
override fun render(updateRate: Float) {
IngameRenderer.setRenderedWorld(demoWorld)
super.render(updateRate)
// async update and render
gameUpdateGovernor.update(Gdx.graphics.deltaTime, App.UPDATE_RATE, updateScreen, renderScreen)

View File

@@ -3,7 +3,6 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.audio.AudioMixer
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.UICanvas
@@ -48,7 +47,7 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
if (it != oldBufferSize) {
oldBufferSize = it
App.renewAudioProcessor(it)
App.reloadAudioProcessor(it)
}
}
}