instead of dealing with delta, we'll just update multiple times, THIS TIME IN CORRECT WAY

(because it really works :p)
This commit is contained in:
minjaesong
2019-01-22 02:44:05 +09:00
parent afba402c6c
commit ded9cb1a10
12 changed files with 111 additions and 153 deletions

View File

@@ -82,7 +82,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
fun getCanonicalTitle() = AppLoader.GAME_NAME +
" — F: ${Gdx.graphics.framesPerSecond}" +
if (AppLoader.IS_DEVELOPMENT_BUILD)
"t${Terrarum.updateRateStr} / RT${Terrarum.renderRateStr})" +
"F${Terrarum.updateRateStr})" +
" — M: J${Terrarum.memJavaHeap}M / N${Terrarum.memNativeHeap}M / X${Terrarum.memXmx}M"
else
""
@@ -379,6 +379,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
LightmapRenderer.fireRecalculateEvent()
AppLoader.debugTimers["Ingame.updateCounter"] = 0
@@ -408,8 +409,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
itemOnGrip?.endSecondaryUse(delta)
}
protected val renderRate = Terrarum.renderRate
private var firstTimeRun = true
///////////////
@@ -422,6 +421,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
}
private var countdownToDeltaReset = 15 // number of frames
private var updateAkku = 0.0
override fun render(delta: Float) {
// Q&D solution for LoadScreen and Ingame, where while LoadScreen is working, Ingame now no longer has GL Context
@@ -443,7 +443,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
}
if (countdownToDeltaReset >= 0) {3
if (countdownToDeltaReset >= 0) {
if (countdownToDeltaReset == 0) {
AppLoader.resetDeltaSmoothingHistory()
}
@@ -456,20 +456,15 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
/** UPDATE CODE GOES HERE */
updateAkku += AppLoader.getSmoothDelta()
if (false && AppLoader.getConfigBoolean("multithread")) { // NO MULTITHREADING: camera don't like concurrent modification (jittery actor movements)
if (firstTimeRun || updateThreadWrapper.state == Thread.State.TERMINATED) {
updateThreadWrapper = Thread(ingameUpdateThread, "Terrarum UpdateThread")
updateThreadWrapper.start()
if (firstTimeRun) firstTimeRun = false
}
// else, NOP;
}
else {
var i = 0L
while (updateAkku >= delta) {
AppLoader.debugTimers["Ingame.update"] = measureNanoTime { updateGame(delta) }
updateAkku -= delta
i += 1
}
AppLoader.debugTimers["Ingame.updateCounter"] = i
/** RENDER CODE GOES HERE */
@@ -543,6 +538,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
private fun renderGame() {
Gdx.graphics.setTitle(getCanonicalTitle())
IngameRenderer.invoke(
world as GameWorldExtension,
actorsRenderBehind,