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
|
package de.bixilon.minosoft.data
|
||||||
|
|
||||||
import glm_.vec3.Vec3
|
import glm_.vec3.Vec3
|
||||||
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
enum class Axes {
|
enum class Axes {
|
||||||
X,
|
X,
|
||||||
@ -32,6 +33,10 @@ enum class Axes {
|
|||||||
return choose(axis, vec3.x, vec3.y, vec3.z)
|
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 {
|
private fun choose(axis: Axes, x: Float, y: Float, z: Float): Float {
|
||||||
return when (axis) {
|
return when (axis) {
|
||||||
X -> x
|
X -> x
|
||||||
|
@ -58,12 +58,9 @@ class ElementRenderer(
|
|||||||
}
|
}
|
||||||
if (uvLock) {
|
if (uvLock) {
|
||||||
for (direction in Directions.DIRECTIONS) {
|
for (direction in Directions.DIRECTIONS) {
|
||||||
val angle = when (Axes.byDirection(direction)) {
|
val axis = Axes.byDirection(direction)
|
||||||
Axes.X -> rotation.x
|
val angle = Axes.choose(axis, rotation) * Axes.choose(axis, direction.directionVector)
|
||||||
Axes.Y -> rotation.y
|
faces[direction]?.rotate(-angle)
|
||||||
Axes.Z -> rotation.z
|
|
||||||
}
|
|
||||||
faces[direction]?.rotate(angle)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user