mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 01:16:46 -04:00
fix some skeletal transformation bugs
This commit is contained in:
parent
a23ec4c1c3
commit
ecba02d533
@ -172,8 +172,8 @@ object BlockProperties {
|
||||
return Pair(property, property.parse(value)!!)
|
||||
}
|
||||
|
||||
@Deprecated("not block specific")
|
||||
private fun parseProperty(group: String, value: Any): Pair<BlockProperty<*>, Any> {
|
||||
// TODO: block.properties
|
||||
val properties = PROPERTIES[group] ?: throw IllegalArgumentException("Can not find group: $group, expected value $value")
|
||||
|
||||
var property: BlockProperty<*>? = null
|
||||
|
@ -48,7 +48,7 @@ class SkeletalManager(
|
||||
prepareDraw()
|
||||
shader.light = light
|
||||
|
||||
instance.transform.pack(uniformBuffer.buffer)
|
||||
instance.transform.pack(uniformBuffer.buffer, instance.position)
|
||||
uniformBuffer.upload(0 until instance.model.transformCount * Mat4.length)
|
||||
|
||||
instance.model.mesh.draw()
|
||||
|
@ -29,6 +29,7 @@ class SkeletalInstance(
|
||||
val transform: TransformInstance,
|
||||
) {
|
||||
val animation = AnimationManager(this)
|
||||
var position = Mat4()
|
||||
var light = 0xFF
|
||||
|
||||
|
||||
@ -47,11 +48,9 @@ class SkeletalInstance(
|
||||
}
|
||||
|
||||
fun update(position: Vec3, rotation: Vec3) {
|
||||
val matrix = Mat4()
|
||||
this.position = Mat4()
|
||||
.translateAssign(position)
|
||||
.rotateRadAssign(rotation)
|
||||
|
||||
transform.value(matrix)
|
||||
}
|
||||
|
||||
fun update(position: Vec3d, rotation: Vec3) {
|
||||
|
@ -25,9 +25,6 @@ class TransformInstance(
|
||||
) {
|
||||
val value = Mat4()
|
||||
|
||||
fun pack(buffer: FloatBuffer) {
|
||||
pack(buffer, Mat4())
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
this.value(Mat4.EMPTY_INSTANCE)
|
||||
@ -37,8 +34,8 @@ class TransformInstance(
|
||||
}
|
||||
}
|
||||
|
||||
private fun pack(buffer: FloatBuffer, parent: Mat4) {
|
||||
val value = value * parent
|
||||
fun pack(buffer: FloatBuffer, parent: Mat4) {
|
||||
val value = parent * value
|
||||
val offset = this.id * Mat4.length
|
||||
for (index in 0 until Mat4.length) {
|
||||
buffer.put(offset + index, value.array[index])
|
||||
|
@ -59,7 +59,7 @@ object Vec3Util {
|
||||
get() = this.floor
|
||||
|
||||
val Vec3.Companion.X: Vec3 get() = Vec3Util.X
|
||||
val Vec3.Companion.Y: Vec3 get() = Vec3Util.X
|
||||
val Vec3.Companion.Y: Vec3 get() = Vec3Util.Y
|
||||
val Vec3.Companion.Z: Vec3 get() = Vec3Util.Z
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user