From bb954440675c2a23d91b5e2484f9b487afe41133 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 20 Aug 2021 23:28:59 +0900 Subject: [PATCH] reducing number of warnings on the codebase --- src/net/torvald/gdx/graphics/Cvec.kt | 8 +- .../torvald/gdx/lwjgl/LwjglGraphics.java.txt | 2 +- src/net/torvald/terrarum/AppLoader.java | 7 +- src/net/torvald/terrarum/ColorLimiterTest.kt | 3 +- src/net/torvald/terrarum/GlslTilingTest.kt | 3 +- src/net/torvald/terrarum/PostProcessor.kt | 5 +- src/net/torvald/terrarum/SanicLoadScreen.kt | 2 +- src/net/torvald/terrarum/Terrarum.kt | 2 +- src/net/torvald/terrarum/TitleScreen.kt | 12 +-- .../terrarum/blockproperties/BlockPropUtil.kt | 2 +- .../terrarum/gameactors/ActorWithBody.kt | 99 +++---------------- .../terrarum/modulebasegame/BuildingMaker.kt | 2 +- .../terrarum/modulebasegame/IngameRenderer.kt | 9 +- .../terrarum/modulebasegame/TerrarumIngame.kt | 18 +--- .../gameactors/ActorHumanoid.kt | 2 +- .../modulebasegame/ui/UIInventoryMinimap.kt | 2 +- .../ui/UIItemInventoryItemGrid.kt | 2 +- .../modulebasegame/ui/UIVitalMetre.kt | 6 +- .../terrarum/serialise/SavegameWriter.kt | 4 +- src/net/torvald/terrarum/tests/UIElemTest.kt | 2 +- .../torvald/terrarum/ui/UIItemIntSlider.kt | 22 ++--- .../terrarum/ui/UIItemTransitionContainer.kt | 2 +- .../torvald/terrarum/weather/WeatherMixer.kt | 3 +- .../terrarum/worlddrawer/BlocksDrawer.kt | 3 +- 24 files changed, 58 insertions(+), 164 deletions(-) diff --git a/src/net/torvald/gdx/graphics/Cvec.kt b/src/net/torvald/gdx/graphics/Cvec.kt index 6c552a334..8f5fb8efe 100644 --- a/src/net/torvald/gdx/graphics/Cvec.kt +++ b/src/net/torvald/gdx/graphics/Cvec.kt @@ -273,10 +273,10 @@ class Cvec { return this } - override fun equals(o: Any?): Boolean { - if (this === o) return true - if (o == null || javaClass != o.javaClass) return false - val color = o as Cvec? + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + val color = other as Cvec? return toIntBits() == color!!.toIntBits() } diff --git a/src/net/torvald/gdx/lwjgl/LwjglGraphics.java.txt b/src/net/torvald/gdx/lwjgl/LwjglGraphics.java.txt index e969660c8..8624d56fd 100644 --- a/src/net/torvald/gdx/lwjgl/LwjglGraphics.java.txt +++ b/src/net/torvald/gdx/lwjgl/LwjglGraphics.java.txt @@ -173,7 +173,7 @@ public class LwjglGraphics implements Graphics { } } - public float getRawDeltaTime () { + public float getDeltaTime () { return deltaTime; } diff --git a/src/net/torvald/terrarum/AppLoader.java b/src/net/torvald/terrarum/AppLoader.java index fb500c82f..efa46714b 100644 --- a/src/net/torvald/terrarum/AppLoader.java +++ b/src/net/torvald/terrarum/AppLoader.java @@ -487,7 +487,7 @@ public class AppLoader implements ApplicationListener { postInit(); } - AppLoader.setDebugTime("GDX.rawDelta", (long) (Gdx.graphics.getRawDeltaTime() * 1000_000_000f)); + AppLoader.setDebugTime("GDX.rawDelta", (long) (Gdx.graphics.getDeltaTime() * 1000_000_000f)); FrameBufferManager.begin(renderFBO); @@ -500,7 +500,7 @@ public class AppLoader implements ApplicationListener { if (currenScreen == null) { drawSplash(); - loadTimer += Gdx.graphics.getRawDeltaTime(); + loadTimer += Gdx.graphics.getDeltaTime(); if (loadTimer >= showupTime) { // hand over the scene control to this single class; Terrarum must call @@ -556,13 +556,12 @@ public class AppLoader implements ApplicationListener { } private void drawSplash() { - shaderBayerSkyboxFill.begin(); + shaderBayerSkyboxFill.bind(); shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined); shaderBayerSkyboxFill.setUniformf("parallax_size", 0f); shaderBayerSkyboxFill.setUniformf("topColor", gradWhiteTop.r, gradWhiteTop.g, gradWhiteTop.b); shaderBayerSkyboxFill.setUniformf("bottomColor", gradWhiteBottom.r, gradWhiteBottom.g, gradWhiteBottom.b); fullscreenQuad.render(shaderBayerSkyboxFill, GL20.GL_TRIANGLES); - shaderBayerSkyboxFill.end(); setCameraPosition(0f, 0f); diff --git a/src/net/torvald/terrarum/ColorLimiterTest.kt b/src/net/torvald/terrarum/ColorLimiterTest.kt index b225f28d9..f4de0bf1e 100644 --- a/src/net/torvald/terrarum/ColorLimiterTest.kt +++ b/src/net/torvald/terrarum/ColorLimiterTest.kt @@ -39,11 +39,10 @@ object ColorLimiterTest : ApplicationAdapter() { ShaderProgram.pedantic = false shader4096 = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/4096_bayer.frag")) - shader4096.begin() + shader4096.bind() shader4096.setUniformf("rcount", 4f) shader4096.setUniformf("gcount", 4f) shader4096.setUniformf("bcount", 4f) - shader4096.end() //img = Texture("assets/test_gradient.tga") img = Texture("assets/test_texture.tga") diff --git a/src/net/torvald/terrarum/GlslTilingTest.kt b/src/net/torvald/terrarum/GlslTilingTest.kt index 816862aeb..2652ad345 100644 --- a/src/net/torvald/terrarum/GlslTilingTest.kt +++ b/src/net/torvald/terrarum/GlslTilingTest.kt @@ -139,7 +139,7 @@ object GlslTilingTest : ApplicationAdapter() { tilesBufferAsTex.bind(2) tileAtlas.bind(1) // for some fuck reason, it must be bound as last - shader.begin() + shader.bind() shader.setUniformMatrix("u_projTrans", batch.projectionMatrix)//camera.combined) //shader.setUniformf("colourFilter", Color.RED) shader.setUniformf("screenDimension", Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat()) @@ -152,7 +152,6 @@ object GlslTilingTest : ApplicationAdapter() { shader.setUniformf("tilesInAtlas", 256f, 256f) //depends on the tile atlas shader.setUniformf("atlasTexSize", 4096f, 4096f) //depends on the tile atlas tilesQuad.render(shader, GL20.GL_TRIANGLES) - shader.end() tilesBufferAsTex.dispose() diff --git a/src/net/torvald/terrarum/PostProcessor.kt b/src/net/torvald/terrarum/PostProcessor.kt index 67e701f52..62260acfb 100644 --- a/src/net/torvald/terrarum/PostProcessor.kt +++ b/src/net/torvald/terrarum/PostProcessor.kt @@ -75,7 +75,7 @@ object PostProcessor : Disposable { } - debugUI.update(Gdx.graphics.rawDeltaTime) + debugUI.update(Gdx.graphics.deltaTime) AppLoader.measureDebugTime("Renderer.PostProcessor") { @@ -135,11 +135,10 @@ object PostProcessor : Disposable { fbo.colorBufferTexture.bind(0) - shader?.begin() + shader?.bind() shader?.setUniformMatrix("u_projTrans", projMat) shader?.setUniformi("u_texture", 0) AppLoader.fullscreenQuad.render(shader, GL20.GL_TRIANGLES) - shader?.end() Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it diff --git a/src/net/torvald/terrarum/SanicLoadScreen.kt b/src/net/torvald/terrarum/SanicLoadScreen.kt index 30df1a4dd..866bff2a1 100644 --- a/src/net/torvald/terrarum/SanicLoadScreen.kt +++ b/src/net/torvald/terrarum/SanicLoadScreen.kt @@ -70,7 +70,7 @@ object SanicLoadScreen : LoadScreenBase() { override fun render(delta: Float) { Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle()) - val delta = Gdx.graphics.rawDeltaTime + val delta = Gdx.graphics.deltaTime glideDispY = AppLoader.screenSize.screenH - 100f - AppLoader.fontGame.lineHeight arrowObjGlideSize = arrowObjTex.width + 2f * AppLoader.screenSize.screenW diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index fe209f006..abf11c10f 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -266,7 +266,7 @@ object Terrarum : Disposable { get() = Gdx.input.deltaY /** Delta converted as it it was a FPS */ inline val updateRate: Double - get() = 1.0 / Gdx.graphics.rawDeltaTime + get() = 1.0 / Gdx.graphics.deltaTime /** * Usage: diff --git a/src/net/torvald/terrarum/TitleScreen.kt b/src/net/torvald/terrarum/TitleScreen.kt index 23d9ad21b..473c51057 100644 --- a/src/net/torvald/terrarum/TitleScreen.kt +++ b/src/net/torvald/terrarum/TitleScreen.kt @@ -194,7 +194,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) { // async update and render - val dt = Gdx.graphics.rawDeltaTime + val dt = Gdx.graphics.deltaTime updateAkku += dt var i = 0L @@ -208,16 +208,6 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) { // render? just do it anyway AppLoader.measureDebugTime("Ingame.Render") { renderScreen() } - AppLoader.setDebugTime("Ingame.Render - (Light + Tiling)", - ((AppLoader.debugTimers["Ingame.Render"] as? Long) ?: 0) - - ( - ((AppLoader.debugTimers["Renderer.Lanterns"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.LightPrecalc"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.LightRuns"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.LightToScreen"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.Tiling"] as? Long) ?: 0) - ) - ) } fun updateScreen(delta: Float) { diff --git a/src/net/torvald/terrarum/blockproperties/BlockPropUtil.kt b/src/net/torvald/terrarum/blockproperties/BlockPropUtil.kt index 7dcb70808..84a743479 100644 --- a/src/net/torvald/terrarum/blockproperties/BlockPropUtil.kt +++ b/src/net/torvald/terrarum/blockproperties/BlockPropUtil.kt @@ -81,7 +81,7 @@ object BlockPropUtil { // FPS-time compensation if (Gdx.graphics.framesPerSecond > 0) { - prop.rngBase0 += Gdx.graphics.rawDeltaTime + prop.rngBase0 += Gdx.graphics.deltaTime } // reset timer diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 8b46c8dc7..9a06dd348 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -18,14 +18,12 @@ import net.torvald.terrarum.gameworld.BlockAddress import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.realestate.LandUtil -import net.torvald.terrarum.worlddrawer.CreateTileAtlas import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import org.dyn4j.geometry.Vector2 import java.util.* import kotlin.math.absoluteValue import kotlin.math.roundToInt -import kotlin.math.sign /** @@ -33,8 +31,8 @@ import kotlin.math.sign * Also has all the usePhysics * * @param renderOrder Rendering order (BEHIND, MIDDLE, MIDTOP, FRONT) - * @param immobileBody use realistic air friction (1/1000 of "unrealistic" canonical setup) - * @param usePhysics use usePhysics simulation + * @param physProp physics properties + * @param id use custom ActorID * * Created by minjaesong on 2016-01-13. */ @@ -328,8 +326,6 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, * @param h * @param tx positive: translate sprite to LEFT. * @param ty positive: translate sprite to DOWN. - * @see ActorWBMovable.drawBody - * @see ActorWBMovable.drawGlow */ fun setHitboxDimension(w: Int, h: Int, tx: Int, ty: Int) { baseHitboxH = h @@ -423,7 +419,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, // Actors are subject to the gravity and the buoyancy if they are not levitating if (!isNoSubjectToGrav) { - applyGravitation(delta) + applyGravitation() } //applyBuoyancy() @@ -463,9 +459,9 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, // TODO less friction for non-animating objects (make items glide far more on ice) // FIXME asymmetry on friction - setHorizontalFriction(delta) // friction SHOULD use and alter externalV + setHorizontalFriction() // friction SHOULD use and alter externalV //if (isNoClip) { // TODO also hanging on the rope, etc. - setVerticalFriction(delta) + setVerticalFriction() //} @@ -514,54 +510,12 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, isStationary = (hitbox - oldHitbox).magnitudeSquared < PHYS_EPSILON_VELO } - /** - * Similar to applyForce but deals with walking. Read below: - * - * how speedcap is achieved with moveDelta: - * moveDelta is (velo + walk), but this added value is reset every update. - * if it wasn't, it will go like this: - * F 0 velo + walk - * F 1 velo + walk + velo + walk - * as a result, the speed will keep increase without it - */ - /*private fun combineVeloToMoveDelta() { - if (this is Controllable) { - // decide whether to ignore walkX - if (!(isWalled(hitbox, COLLIDING_LEFT) && walkX < 0) - || !(isWalled(hitbox, COLLIDING_RIGHT) && walkX > 0) - ) { - moveDelta.x = externalV.x + walkX - } - - // decide whether to ignore walkY - if (!(isWalled(hitbox, COLLIDING_TOP) && walkY < 0) - || !(isWalled(hitbox, COLLIDING_BOTTOM) && walkY > 0) - ) { - moveDelta.y = externalV.y + walkY - } - } - else { - if (!isWalled(hitbox, COLLIDING_LEFT) - || !isWalled(hitbox, COLLIDING_RIGHT) - ) { - moveDelta.x = externalV.x - } - - // decide whether to ignore walkY - if (!isWalled(hitbox, COLLIDING_TOP) - || !isWalled(hitbox, COLLIDING_BOTTOM) - ) { - moveDelta.y = externalV.y - } - } - }*/ - - fun getDrag(delta: Float, externalForce: Vector2): Vector2 { + fun getDrag(externalForce: Vector2): Vector2 { /** * weight; gravitational force in action * W = mass * G (9.8 [m/s^2]) */ - val W: Vector2 = gravitation * Terrarum.PHYS_TIME_FRAME.toDouble() + val W: Vector2 = gravitation * Terrarum.PHYS_TIME_FRAME /** * Area */ @@ -595,42 +549,15 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, * * Apply only if not grounded; normal force is precessed separately. */ - private fun applyGravitation(delta: Float) { + private fun applyGravitation() { if (!isNoSubjectToGrav && !(gravitation.y > 0 && walledBottom || gravitation.y < 0 && walledTop)) { //if (!isWalled(hitbox, COLLIDING_BOTTOM)) { - applyForce(getDrag(delta, externalV)) + applyForce(getDrag(externalV)) //} } } - /** - * nextHitbox must NOT be altered before this method is called! - */ - /*@Deprecated("It's stupid anyway.") private fun displaceByCCD() { - if (!isNoCollideWorld) { - if (!isColliding(hitbox)) - return - - // do some CCD between hitbox and nextHitbox - val ccdDelta = (hitbox.toVector() - hitbox.toVector()) - if (ccdDelta.x != 0.0 || ccdDelta.y != 0.0) { - //ccdDelta.set(ccdDelta.setMagnitude(CCD_TICK)) // fixed tick - val displacement = Math.min(1.0.div(moveDelta.magnitude * 2), 0.5) // adaptive tick - ccdDelta.set(ccdDelta.setMagnitude(displacement)) - } - - //println("deltaMax: $deltaMax") - //println("ccdDelta: $ccdDelta") - - while (!ccdDelta.isZero && isColliding(hitbox)) { - hitbox.translate(-ccdDelta) - } - - //println("ccdCollided: $ccdCollided") - } - }*/ - private fun displaceHitbox() { // // HOW IT SHOULD WORK // // // //////////////////////// @@ -1002,7 +929,6 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, val intpStep = 64.0 // make interpolation even if the "next" position is clear of collision - var clearOfCollision = true val testHitbox = hitbox.clone() // divide the vectors by the constant @@ -1020,13 +946,11 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, if (isWalled2(testHitbox, COLLIDING_UD)) { externalV.y *= elasticity // TODO also multiply the friction value controllerV?.let { controllerV!!.y *= elasticity } // TODO also multiply the friction value - clearOfCollision = false } // horizontal collision if (isWalled2(testHitbox, COLLIDING_LR)) { externalV.x *= elasticity // TODO also multiply the friction value controllerV?.let { controllerV!!.x *= elasticity } // TODO also multiply the friction value - clearOfCollision = false } } @@ -1241,7 +1165,6 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, val ys = if (gravitation.y >= 0) pyEnd downTo pyStart else pyStart..pyEnd val yheight = (ys.last - ys.first).absoluteValue var stairHeight = 0 - var countUpForStairHeight = true var hitFloor = false for (y in ys) { @@ -1370,7 +1293,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, /** about stopping * for about get moving, see updateMovementControl */ - private fun setHorizontalFriction(delta: Float) { + private fun setHorizontalFriction() { val friction = if (isNoClip) BASE_FRICTION * (actorValue.getAsDouble(AVKey.FRICTIONMULT) ?: 1.0) * BlockCodex[Block.STONE].friction.frictionToMult() else { @@ -1399,7 +1322,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, } } - private fun setVerticalFriction(delta: Float) { + private fun setVerticalFriction() { val friction = if (isNoClip) BASE_FRICTION * (actorValue.getAsDouble(AVKey.FRICTIONMULT) ?: 1.0) * BlockCodex[Block.STONE].friction.frictionToMult() else diff --git a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt index 992208919..9429bbf88 100644 --- a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt +++ b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt @@ -314,7 +314,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) { // ASYNCHRONOUS UPDATE AND RENDER // - val dt = Gdx.graphics.rawDeltaTime + val dt = Gdx.graphics.deltaTime updateAkku += dt var i = 0L diff --git a/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt b/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt index 7ab98de43..693e81c46 100644 --- a/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt +++ b/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt @@ -93,11 +93,10 @@ object IngameRenderer : Disposable { if (AppLoader.getConfigBoolean("fxdither")) { shaderBayer = AppLoader.loadShaderFromFile("assets/4096.vert", "assets/4096_bayer.frag") - shaderBayer.begin() + shaderBayer.bind() shaderBayer.setUniformf("rcount", 64f) shaderBayer.setUniformf("gcount", 64f) shaderBayer.setUniformf("bcount", 64f) - shaderBayer.end() } else { shaderBayer = AppLoader.loadShaderFromFile("assets/4096.vert", "assets/passthrurgb.frag") @@ -626,11 +625,10 @@ object IngameRenderer : Disposable { val texture = LightmapRenderer.draw() texture.bind(0) - shaderPassthru.begin() + shaderPassthru.bind() shaderPassthru.setUniformMatrix("u_projTrans", camera.combined) shaderPassthru.setUniformi("u_texture", 0) blurWriteQuad.render(shaderPassthru, GL20.GL_TRIANGLES) - shaderPassthru.end() } // do blurring @@ -641,7 +639,7 @@ object IngameRenderer : Disposable { blurTex.texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) blurTex.texture.bind(0) - shaderBlur.begin() + shaderBlur.bind() shaderBlur.setUniformMatrix("u_projTrans", camera.combined) shaderBlur.setUniformi("u_texture", 0) shaderBlur.setUniformf("iResolution", @@ -652,7 +650,6 @@ object IngameRenderer : Disposable { else shaderBlur.setUniformf("direction", 0f, blurRadius) blurWriteQuad.render(shaderBlur, GL20.GL_TRIANGLES) - shaderBlur.end() // swap diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index ed48f6a81..add870cd7 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -534,7 +534,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { // ASYNCHRONOUS UPDATE AND RENDER // /** UPDATE CODE GOES HERE */ - val dt = Gdx.graphics.rawDeltaTime + val dt = Gdx.graphics.deltaTime updateAkku += dt var i = 0L @@ -549,16 +549,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { /** RENDER CODE GOES HERE */ AppLoader.measureDebugTime("Ingame.Render") { renderGame() } - AppLoader.setDebugTime("Ingame.Render - (Light + Tiling)", - ((AppLoader.debugTimers["Ingame.Render"] as? Long) ?: 0) - - ( - ((AppLoader.debugTimers["Renderer.Lanterns"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.LightPrecalc"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.LightRuns"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.LightToScreen"] as? Long) ?: 0) + - ((AppLoader.debugTimers["Renderer.Tiling"] as? Long) ?: 0) - ) - ) } @@ -660,11 +650,11 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { uiContainer.forEach { when (it) { - is UICanvas -> it.update(Gdx.graphics.rawDeltaTime) - is Id_UICanvasNullable -> it.get()?.update(Gdx.graphics.rawDeltaTime) + is UICanvas -> it.update(Gdx.graphics.deltaTime) + is Id_UICanvasNullable -> it.get()?.update(Gdx.graphics.deltaTime) } } - //uiFixture?.update(Gdx.graphics.rawDeltaTime) + //uiFixture?.update(Gdx.graphics.deltaTime) // deal with the uiFixture being closed if (uiFixture?.isClosed == true) { uiFixture = null } diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt index 8c61e6737..9876d5f04 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt @@ -567,7 +567,7 @@ open class ActorHumanoid( val timedJumpCharge = jumpFunc(MAX_JUMP_LENGTH, jmpCtr) forceVec.y -= getJumpAcc(jumpPower, timedJumpCharge) - forceVec.y += getDrag(AppLoader.UPDATE_RATE, forceVec).y + forceVec.y += getDrag(forceVec).y simYPos += forceVec.y // ignoring all the fluid drag OTHER THAN THE AIR diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt index dd40de7ad..a30e5d6fb 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt @@ -36,7 +36,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() { override fun updateUI(delta: Float) { MinimapComposer.setWorld(Terrarum.ingame!!.world) MinimapComposer.update() - minimapRerenderTimer += Gdx.graphics.rawDeltaTime + minimapRerenderTimer += Gdx.graphics.deltaTime } override fun renderUI(batch: SpriteBatch, camera: Camera) { diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt index 688359a77..422a07457 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt @@ -144,7 +144,7 @@ class UIItemInventoryItemGrid( // equip da shit val itemEquipSlot = item.equipPosition if (itemEquipSlot == GameItem.EquipPosition.NULL) { - TODO("Equip position is NULL, does this mean it's single-consume items like a potion? (from item: \"$item\" with itemID: ${item?.originalID}/${item?.dynamicID})") + TODO("Equip position is NULL, does this mean it's single-consume items like a potion? (from item: \"$item\" with itemID: ${item.originalID}/${item.dynamicID})") } val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying if (player != null) { diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIVitalMetre.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIVitalMetre.kt index 589365bc4..95743e9c3 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIVitalMetre.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIVitalMetre.kt @@ -30,13 +30,13 @@ class UIVitalMetre( private val gap = 4f override var width: Int = 80 + 2 * margin; set(value) { throw Error("operation not permitted") } - override var height: Int; get() = player.baseHitboxH ?: 0 * 3 + margin; set(value) { throw Error("operation not permitted") } + override var height: Int; get() = player.baseHitboxH; set(value) { throw Error("operation not permitted") } override var openCloseTime: Second = 0.05f //private val relativePX = width / 2f - private val offsetY: Float; get() = (player.baseHitboxH ?: 0) * 1.5f - private val circleRadius: Float; get() = (player.baseHitboxH ?: 0) * 3f + private val offsetY: Float; get() = player.baseHitboxH * 1.5f + private val circleRadius: Float; get() = player.baseHitboxH * 3f private val theta = 33f private val halfTheta = theta / 2f diff --git a/src/net/torvald/terrarum/serialise/SavegameWriter.kt b/src/net/torvald/terrarum/serialise/SavegameWriter.kt index 50c3aa53d..58776daf4 100644 --- a/src/net/torvald/terrarum/serialise/SavegameWriter.kt +++ b/src/net/torvald/terrarum/serialise/SavegameWriter.kt @@ -49,7 +49,7 @@ object SavegameWriter { private lateinit var playerName: String operator fun invoke(pnameOverride: String? = null): Boolean { - playerName = pnameOverride ?: "${Terrarum.ingame!!.actorGamer!!.actorValue[AVKey.NAME]}" + playerName = pnameOverride ?: "${Terrarum.ingame!!.actorGamer.actorValue[AVKey.NAME]}" if (playerName.isEmpty()) playerName = "Test subject ${Math.random().times(0x7FFFFFFF).roundToInt()}" try { @@ -71,7 +71,7 @@ object SavegameWriter { val creationDate = System.currentTimeMillis() / 1000L val ingame = Terrarum.ingame!! val gameworld = ingame.world - val player = ingame.actorGamer!! + val player = ingame.actorGamer val disk = VDUtil.createNewDisk(0x7FFFFFFFFFFFFFFFL, "Tesv-$playerName", charset) val ROOT = disk.root.entryID diff --git a/src/net/torvald/terrarum/tests/UIElemTest.kt b/src/net/torvald/terrarum/tests/UIElemTest.kt index cc72c118f..cb845e0e3 100644 --- a/src/net/torvald/terrarum/tests/UIElemTest.kt +++ b/src/net/torvald/terrarum/tests/UIElemTest.kt @@ -39,7 +39,7 @@ class UIElemTest : ApplicationAdapter() { override fun render() { - ui.update(Gdx.graphics.rawDeltaTime) + ui.update(Gdx.graphics.deltaTime) ui.render(batch, camera) } diff --git a/src/net/torvald/terrarum/ui/UIItemIntSlider.kt b/src/net/torvald/terrarum/ui/UIItemIntSlider.kt index c199f9cb7..d35948f06 100644 --- a/src/net/torvald/terrarum/ui/UIItemIntSlider.kt +++ b/src/net/torvald/terrarum/ui/UIItemIntSlider.kt @@ -96,37 +96,37 @@ class UIItemIntSlider( get() = super.mouseOverCall override var updateListener: ((Float) -> Unit)? get() = super.updateListener - set(value) {} + set(_) {} override var keyDownListener: ((Int) -> Unit)? get() = super.keyDownListener - set(value) {} + set(_) {} override var keyUpListener: ((Int) -> Unit)? get() = super.keyUpListener - set(value) {} + set(_) {} override var mouseMovedListener: ((Int, Int) -> Unit)? get() = super.mouseMovedListener - set(value) {} + set(_) {} override var touchDraggedListener: ((Int, Int, Int) -> Unit)? get() = super.touchDraggedListener - set(value) {} + set(_) {} override var touchDownListener: ((Int, Int, Int, Int) -> Unit)? get() = super.touchDownListener - set(value) {} + set(_) {} override var touchUpListener: ((Int, Int, Int, Int) -> Unit)? get() = super.touchUpListener - set(value) {} + set(_) {} override var scrolledListener: ((Float, Float) -> Unit)? get() = super.scrolledListener - set(value) {} + set(_) {} override var clickOnceListener: ((Int, Int, Int) -> Unit)? get() = super.clickOnceListener - set(value) {} + set(_) {} override var clickOnceListenerFired: Boolean get() = super.clickOnceListenerFired - set(value) {} + set(_) {} override var controllerInFocus: Boolean get() = super.controllerInFocus - set(value) {} + set(_) {} override fun dispose() { TODO("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/src/net/torvald/terrarum/ui/UIItemTransitionContainer.kt b/src/net/torvald/terrarum/ui/UIItemTransitionContainer.kt index 696495656..c7a47d494 100644 --- a/src/net/torvald/terrarum/ui/UIItemTransitionContainer.kt +++ b/src/net/torvald/terrarum/ui/UIItemTransitionContainer.kt @@ -54,7 +54,7 @@ open class UIItemTransitionContainer( } if (transitionOngoing) { - transitionTimer += Gdx.graphics.rawDeltaTime + transitionTimer += Gdx.graphics.deltaTime currentPosition = UIUtils.moveLinear(transitionReqSource, transitionReqTarget, transitionTimer, transitionLength) diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index df34414d3..416bd4970 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -193,7 +193,7 @@ internal object WeatherMixer : RNGConsumer { // don't use shader to just fill the whole screen... frag shader will be called a million times and it's best to not burden it /* - IngameRenderer.shaderSkyboxFill.begin() + IngameRenderer.shaderSkyboxFill.bind() IngameRenderer.shaderSkyboxFill.setUniformMatrix("u_projTrans", camera.combined) IngameRenderer.shaderSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b) IngameRenderer.shaderSkyboxFill.setUniformf("bottomColor", bottomCol.r, bottomCol.g, bottomCol.b) @@ -201,7 +201,6 @@ internal object WeatherMixer : RNGConsumer { IngameRenderer.shaderSkyboxFill.setUniformf("parallax_size", 1f/3f) IngameRenderer.shaderSkyboxFill.setUniformf("zoomInv", 1f / (Terrarum.ingame?.screenZoom ?: 1f)) AppLoader.fullscreenQuad.render(IngameRenderer.shaderSkyboxFill, GL20.GL_TRIANGLES) - IngameRenderer.shaderSkyboxFill.end() */ diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt index 4bce6fec9..41b7162ea 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt @@ -605,7 +605,7 @@ internal object BlocksDrawer { tileAtlas.texture.bind(0) // for some fuck reason, it must be bound as last } - shader.begin() + shader.bind() 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) @@ -628,7 +628,6 @@ internal object BlocksDrawer { shader.setUniformf("mulBlendIntensity", if (mode == OCCLUSION) occlusionIntensity else 1f) //shader.setUniformf("drawBreakage", if (mode == WIRE) 0f else 1f) tilesQuad.render(shader, GL20.GL_TRIANGLES) - shader.end() //tilesBufferAsTex.dispose() }