more constants, improve code a bit

This commit is contained in:
Bixilon 2022-01-18 19:32:23 +01:00
parent 8f7c8efd88
commit 7b0148c50f
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 14 additions and 6 deletions

View File

@ -90,7 +90,7 @@ class MatrixHandler(
}
private fun calculateProjectionMatrix(screenDimensions: Vec2 = renderWindow.window.sizef) {
projectionMatrix = glm.perspective(fov.rad.toFloat(), screenDimensions.x / screenDimensions.y, 0.01f, minOf(fogEnd + 2.0f, 10000.0f))
projectionMatrix = glm.perspective(fov.rad.toFloat(), screenDimensions.x / screenDimensions.y, NEAR_PLANE, minOf(fogEnd + 2.0f, FAR_PLANE))
}
fun init() {
@ -166,6 +166,8 @@ class MatrixHandler(
}
companion object {
const val NEAR_PLANE = 0.01f
const val FAR_PLANE = 10000.0f
val CAMERA_UP_VEC3 = Vec3(0.0, 1.0, 0.0)
}
}

View File

@ -28,33 +28,39 @@ import kotlin.reflect.KProperty0
object JavaFXDelegate {
private fun checkErosState() {
if (RunConfiguration.DISABLE_EROS) {
throw IllegalStateException("Eros is disabled!")
}
}
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<V>.observeFX(owner: Any, observer: (V) -> Unit) {
check(!RunConfiguration.DISABLE_EROS)
checkErosState()
this.observe(owner) { JavaFXUtil.runLater { observer(it) } }
}
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<Set<V>>.observeSetFX(owner: Any, observer: (SetChange<V>) -> Unit) {
check(!RunConfiguration.DISABLE_EROS)
checkErosState()
this.observeSet(owner) { JavaFXUtil.runLater { observer(it) } }
}
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<List<V>>.observeListFX(owner: Any, observer: (ListChange<V>) -> Unit) {
check(!RunConfiguration.DISABLE_EROS)
checkErosState()
this.observeList(owner) { JavaFXUtil.runLater { observer(it) } }
}
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <K, V> KProperty0<Map<K, V>>.observeMapFX(owner: Any, observer: (MapChange<K, V>) -> Unit) {
check(!RunConfiguration.DISABLE_EROS)
checkErosState()
this.observeMap(owner) { JavaFXUtil.runLater { observer(it) } }
}
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <K, V> KProperty0<AbstractBiMap<K, V>>.observeBiMapFX(owner: Any, observer: (MapChange<K, V>) -> Unit) {
check(!RunConfiguration.DISABLE_EROS)
checkErosState()
this.observeBiMap(owner) { JavaFXUtil.runLater { observer(it) } }
}
}