mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
rendering: improve uvlock behaviour
This commit is contained in:
parent
e564fa2746
commit
c8a56cbb78
@ -13,6 +13,7 @@
|
||||
package de.bixilon.minosoft.data
|
||||
|
||||
import glm_.vec3.Vec3
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
enum class Axes {
|
||||
X,
|
||||
@ -32,6 +33,10 @@ enum class Axes {
|
||||
return choose(axis, vec3.x, vec3.y, vec3.z)
|
||||
}
|
||||
|
||||
fun choose(axis: Axes, vec3i: Vec3i): Int {
|
||||
return choose(axis, Vec3(vec3i)).toInt()
|
||||
}
|
||||
|
||||
private fun choose(axis: Axes, x: Float, y: Float, z: Float): Float {
|
||||
return when (axis) {
|
||||
X -> x
|
||||
|
@ -58,12 +58,9 @@ class ElementRenderer(
|
||||
}
|
||||
if (uvLock) {
|
||||
for (direction in Directions.DIRECTIONS) {
|
||||
val angle = when (Axes.byDirection(direction)) {
|
||||
Axes.X -> rotation.x
|
||||
Axes.Y -> rotation.y
|
||||
Axes.Z -> rotation.z
|
||||
}
|
||||
faces[direction]?.rotate(angle)
|
||||
val axis = Axes.byDirection(direction)
|
||||
val angle = Axes.choose(axis, rotation) * Axes.choose(axis, direction.directionVector)
|
||||
faces[direction]?.rotate(-angle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user