mirror of
https://github.com/Bixilon/Minosoft.git
synced 2026-12-05 15:58:25 +00:00
fix frustum, fix skeletal rendering
This commit is contained in:
4 files changed
+16
-8
No files matched your search
+3
-3
@@ -52,7 +52,7 @@ class FrustumTest {
|
||||
}
|
||||
|
||||
fun `aabb without world offset`() {
|
||||
val frustum = create(Mat4f(-0.86422914f, -0.09317832f, -0.24142957f, -0.24142484f, 0.0f, 1.3786901f, -0.26089254f, -0.26088744f, -0.2232244f, 0.36074647f, 0.9347118f, 0.9346935f, -240.01099f, -351.1156f, -635.5928f, -635.5603f))
|
||||
val frustum = create(Mat4f(-0.86422914f, -0.09317832f, -0.24142957f, -0.24142484f, 0.0f, 1.3786901f, -0.26089254f, -0.26088744f, -0.2232244f, 0.36074647f, 0.9347118f, 0.9346935f, -240.01099f, -351.1156f, -635.5928f, -635.5603f).transpose())
|
||||
|
||||
assertTrue(AABB(-430.56384174919845, 70.0, 590.7873477416574, -430.31384174919845, 70.25, 591.0373477416574) in frustum)
|
||||
assertTrue(AABB(-427.9736901136882, 70.0, 591.3889686121771, -427.7236901136882, 70.25, 591.6389686121771) in frustum)
|
||||
@@ -66,7 +66,7 @@ class FrustumTest {
|
||||
}
|
||||
|
||||
fun `aabb without world offset 2`() {
|
||||
val frustum = create(Mat4f(0.031299774f, 1.4272678f, 0.0017395335f, 0.0017394995f, 0.0f, 0.0024857917f, -1.0000181f, -0.99999857f, 0.89204353f, -0.050079573f, -6.103626E-5f, -6.103507E-5f, -533.13086f, 625.4982f, 80.68989f, 80.708305f))
|
||||
val frustum = create(Mat4f(0.031299774f, 1.4272678f, 0.0017395335f, 0.0017394995f, 0.0f, 0.0024857917f, -1.0000181f, -0.99999857f, 0.89204353f, -0.050079573f, -6.103626E-5f, -6.103507E-5f, -533.13086f, 625.4982f, 80.68989f, 80.708305f).transpose())
|
||||
|
||||
assertTrue(AABB(-412.8941188408839, 71.0, 602.2574852969693, -412.6441188408839, 71.25, 602.5074852969693) in frustum)
|
||||
assertTrue(AABB(-410.98738348932096, 71.0, 607.7848105520435, -410.73738348932096, 71.25, 608.0348105520435) in frustum)
|
||||
@@ -80,7 +80,7 @@ class FrustumTest {
|
||||
}
|
||||
|
||||
fun `aabb with world offset`() {
|
||||
val frustum = create(Mat4f(-0.50417376f, 1.1785046f, 0.0014267226f, 0.0014266947f, 0.0f, 0.0024691392f, -1.0000181f, -0.99999857f, 0.7365663f, 0.80667686f, 9.765802E-4f, 9.765611E-4f, 482.31094f, 369.0533f, 91.83938f, 91.85758f), BlockPosition(12288, 0, -1837056))
|
||||
val frustum = create(Mat4f(-0.50417376f, 1.1785046f, 0.0014267226f, 0.0014266947f, 0.0f, 0.0024691392f, -1.0000181f, -0.99999857f, 0.7365663f, 0.80667686f, 9.765802E-4f, 9.765611E-4f, 482.31094f, 369.0533f, 91.83938f, 91.85758f).transpose(), BlockPosition(12288, 0, -1837056))
|
||||
|
||||
assertTrue(AABB(12381.468664298143, 75.0, -1837647.3519469386, 12381.718664298143, 75.25, -1837647.1019469386) in frustum)
|
||||
assertTrue(AABB(12392.072452953968, 77.0, -1837649.209980461, 12392.322452953968, 77.25, -1837648.959980461) in frustum)
|
||||
|
||||
@@ -64,6 +64,10 @@ value class MMat3f(val _0: UnsafeMat3f) : _Mat3f {
|
||||
_0[row, column] = value
|
||||
}
|
||||
|
||||
inline fun set(other: Mat3f) {
|
||||
other._0.array.copyInto(_0.array)
|
||||
}
|
||||
|
||||
inline operator fun plus(number: Number) = MMat3f().apply { Mat3Operations.plus(this@MMat3f.unsafe, number.f, this) }
|
||||
inline operator fun plus(other: Mat3f) = MMat3f().apply { Mat3Operations.plus(this@MMat3f.unsafe, other, this) }
|
||||
inline operator fun plus(other: MMat3f) = MMat3f().apply { Mat3Operations.plus(this@MMat3f.unsafe, other.unsafe, this) }
|
||||
@@ -98,7 +102,7 @@ value class MMat3f(val _0: UnsafeMat3f) : _Mat3f {
|
||||
)
|
||||
|
||||
inline fun clearAssign() {
|
||||
_0.array.fill(0.0f)
|
||||
set(Mat3f.EMPTY)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -77,6 +77,10 @@ value class MMat4f(val _0: UnsafeMat4f) : _Mat4f {
|
||||
_0[row, column] = value
|
||||
}
|
||||
|
||||
inline fun set(other: Mat4f) {
|
||||
other._0.array.copyInto(_0.array)
|
||||
}
|
||||
|
||||
inline operator fun plus(number: Number) = MMat4f().apply { Mat4Operations.plus(this@MMat4f.unsafe, number.f, this) }
|
||||
inline operator fun plus(other: Mat4f) = MMat4f().apply { Mat4Operations.plus(this@MMat4f.unsafe, other, this) }
|
||||
inline operator fun plus(other: MMat4f) = MMat4f().apply { Mat4Operations.plus(this@MMat4f.unsafe, other.unsafe, this) }
|
||||
@@ -118,7 +122,7 @@ value class MMat4f(val _0: UnsafeMat4f) : _Mat4f {
|
||||
|
||||
|
||||
inline fun clearAssign() {
|
||||
_0.array.fill(0.0f)
|
||||
set(Mat4f.EMPTY)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
package de.bixilon.minosoft.gui.rendering.camera.frustum
|
||||
|
||||
|
||||
import de.bixilon.kmath.mat.mat3.f.Mat3f
|
||||
import de.bixilon.kmath.mat.mat4.f.Mat4f
|
||||
import de.bixilon.kmath.vec.vec3.f.Vec3f
|
||||
import de.bixilon.kmath.vec.vec4.f.Vec4f
|
||||
import de.bixilon.kutil.collections.CollectionUtil.get
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
@@ -28,12 +30,9 @@ import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.data.world.positions.ChunkPosition
|
||||
import de.bixilon.minosoft.data.world.positions.InSectionPosition
|
||||
import de.bixilon.minosoft.data.world.positions.SectionPosition
|
||||
import de.bixilon.kmath.mat.mat3.f.Mat3f
|
||||
import de.bixilon.kmath.vec.vec4.f.Vec4f
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
import de.bixilon.minosoft.gui.rendering.camera.Camera
|
||||
import de.bixilon.minosoft.gui.rendering.camera.MatrixHandler
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec4.Vec4fUtil.dot
|
||||
|
||||
// Big thanks to: https://gist.github.com/podgorskiy/e698d18879588ada9014768e3e82a644
|
||||
class Frustum(
|
||||
@@ -46,6 +45,7 @@ class Frustum(
|
||||
private set
|
||||
|
||||
private fun recalculate(matrix: Mat4f) {
|
||||
val matrix = matrix.transpose()
|
||||
val planes = arrayOf(
|
||||
matrix[3] + matrix[0],
|
||||
matrix[3] - matrix[0],
|
||||
|
||||
Reference in new issue
Block a user