fix: some NaNs that can be caused by scroll bars

This commit is contained in:
minjaesong
2025-02-01 20:51:40 +09:00
parent a2006b0354
commit 69ebdbc542
13 changed files with 19 additions and 18 deletions

View File

@@ -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