matrix handler: rename upToDate to invalid

This commit is contained in:
Moritz Zwerger 2024-03-01 20:33:11 +01:00
parent 74574b7952
commit 6f562af3bf
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -56,10 +56,10 @@ class MatrixHandler(
var zoom = 0.0f var zoom = 0.0f
set(value) { set(value) {
field = value field = value
upToDate = false invalidate()
} }
private var upToDate = false private var invalid = false
var viewMatrix = Mat4() var viewMatrix = Mat4()
private set private set
@ -105,7 +105,7 @@ class MatrixHandler(
fun init() { fun init() {
connection.events.listen<ResizeWindowEvent> { connection.events.listen<ResizeWindowEvent> {
calculateProjectionMatrix(calculateFOV(), Vec2(it.size)) calculateProjectionMatrix(calculateFOV(), Vec2(it.size))
upToDate = false invalidate()
} }
draw() // set initial values draw() // set initial values
} }
@ -120,7 +120,7 @@ class MatrixHandler(
context.camera.offset.draw() context.camera.offset.draw()
val matrixPosition = Vec3(eyePosition - context.camera.offset.offset) val matrixPosition = Vec3(eyePosition - context.camera.offset.offset)
val front = view.front val front = view.front
if (upToDate && matrixPosition == this.matrixPosition && front == this.front && fov == previousFOV && shaking.isEmpty) { if (!invalid && matrixPosition == this.matrixPosition && front == this.front && fov == previousFOV && shaking.isEmpty) {
return return
} }
this.matrixPosition = matrixPosition this.matrixPosition = matrixPosition
@ -153,7 +153,7 @@ class MatrixHandler(
) )
updateShaders(useMatrixPosition) updateShaders(useMatrixPosition)
upToDate = true invalid = false
} }
private fun updateViewProjectionMatrix() { private fun updateViewProjectionMatrix() {
@ -178,6 +178,6 @@ class MatrixHandler(
} }
fun invalidate() { fun invalidate() {
upToDate = false invalid = true
} }
} }