mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
fix: some NaNs that can be caused by scroll bars
This commit is contained in:
@@ -88,7 +88,7 @@ internal object ExportMap2 : ConsoleCommand {
|
||||
}
|
||||
|
||||
private fun Iterable<Float>.normaliseNaN(default: Float = 0f): FloatArray {
|
||||
return this.map { if (it.isNaN()) default else it }.toFloatArray()
|
||||
return this.map { it.ifNaN(default) }.toFloatArray()
|
||||
}
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
@@ -340,11 +340,11 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
|
||||
private fun ActorWithBody.movingTowardsRight(): Boolean {
|
||||
// return ((this.controllerV ?: Vector2()) + this.externalV).x >= PHYS_EPSILON_VELO
|
||||
return (((this.controllerV?.x ?: 0.0) / this.externalV.x).let { if (it.isNaN()) 0.0 else it } - 1) >= PHYS_EPSILON_DIST
|
||||
return (((this.controllerV?.x ?: 0.0) / this.externalV.x).ifNaN(0.0) - 1) >= PHYS_EPSILON_DIST
|
||||
}
|
||||
private fun ActorWithBody.movingTowardsLeft(): Boolean {
|
||||
// return ((this.controllerV ?: Vector2()) + this.externalV).x <= -PHYS_EPSILON_VELO
|
||||
return (((this.controllerV?.x ?: 0.0) / this.externalV.x).let { if (it.isNaN()) 0.0 else it } - 1) <= PHYS_EPSILON_DIST
|
||||
return (((this.controllerV?.x ?: 0.0) / this.externalV.x).ifNaN(0.0) - 1) <= PHYS_EPSILON_DIST
|
||||
}
|
||||
private fun ActorWithBody.notMoving(): Boolean {
|
||||
// return ((this.controllerV ?: Vector2()) + this.externalV).x.absoluteValue < PHYS_EPSILON_VELO
|
||||
|
||||
@@ -249,7 +249,7 @@ class UIDebugInventron : UICanvas(
|
||||
}
|
||||
|
||||
private fun drawAnalysis(batch: SpriteBatch) {
|
||||
val scroll = (analyserScroll.value * analysisTextBuffer.size.times(TEXT_LINE_HEIGHT).minus(analyserHeight - 3)).roundToInt().coerceAtLeast(0)
|
||||
val scroll = (analyserScroll.value * analysisTextBuffer.size.times(TEXT_LINE_HEIGHT).minus(analyserHeight - 3)).ifNaN(0.0).roundToInt().coerceAtLeast(0)
|
||||
analysisTextBuffer.forEachIndexed { index, s ->
|
||||
App.fontGame.draw(batch, s, analyserPosX + 6, analyserPosY2 + 3 + index * TEXT_LINE_HEIGHT - scroll)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user