rendering: improve uvlock behaviour

This commit is contained in:
Lukas 2021-04-15 15:17:04 +02:00
parent e564fa2746
commit c8a56cbb78
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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)
}
}
}