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 * 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. * 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, yawRad.sin * pitchCos,
-pitchRad.sin, -pitchRad.sin,
yawRad.cos * pitchCos yawRad.cos * pitchCos
).normalize() ).normalizeAssign()
} }
override fun toString(): String { override fun toString(): String {

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * 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. * 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 NEAR_PLANE = 0.01f
const val FAR_PLANE = World.MAX_RENDER_DISTANCE * ProtocolDefinition.SECTION_LENGTH.toFloat() const val FAR_PLANE = World.MAX_RENDER_DISTANCE * ProtocolDefinition.SECTION_LENGTH.toFloat()
val CAMERA_UP_VEC3 = Vec3(0.0f, 1.0f, 0.0f) val CAMERA_UP_VEC3 = Vec3(0.0f, 1.0f, 0.0f)
} }

View File

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