entity rotation: use normalizeAssign over normalize

This safes a few bytes of memory allocation each call
This commit is contained in:
Moritz Zwerger 2024-03-01 15:43:43 +01:00
parent 41880b0ada
commit a3f09071d6
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 5 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
* Copyright (C) 2020-2024 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -33,7 +33,7 @@ data class EntityRotation(
yawRad.sin * pitchCos,
-pitchRad.sin,
yawRad.cos * pitchCos
).normalize()
).normalizeAssign()
}
override fun toString(): String {

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
* Copyright (C) 2020-2024 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -21,5 +21,4 @@ object CameraDefinition {
const val NEAR_PLANE = 0.01f
const val FAR_PLANE = World.MAX_RENDER_DISTANCE * ProtocolDefinition.SECTION_LENGTH.toFloat()
val CAMERA_UP_VEC3 = Vec3(0.0f, 1.0f, 0.0f)
}

View File

@ -165,8 +165,8 @@ class MatrixHandler(
private fun updateFront(front: Vec3) {
this.front = front
this.right = (front cross CAMERA_UP_VEC3).normalize()
this.up = (this.right cross front).normalize()
this.right = (front cross CAMERA_UP_VEC3).normalizeAssign()
this.up = (this.right cross front).normalizeAssign()
}
private fun updateShaders(cameraPosition: Vec3) {