From 559a3b8b39b35a7f6542d0b567dc4559b421edbd Mon Sep 17 00:00:00 2001 From: Onek8 Date: Sun, 6 Apr 2025 14:30:52 +0000 Subject: [PATCH 1/4] Update leenkx/Sources/iron/math/Quat.hx --- leenkx/Sources/iron/math/Quat.hx | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/leenkx/Sources/iron/math/Quat.hx b/leenkx/Sources/iron/math/Quat.hx index e0d744f..3c23b89 100644 --- a/leenkx/Sources/iron/math/Quat.hx +++ b/leenkx/Sources/iron/math/Quat.hx @@ -66,12 +66,32 @@ class Quat { } public inline function fromAxisAngle(axis: Vec4, angle: FastFloat): Quat { - var s: FastFloat = Math.sin(angle * 0.5); - x = axis.x * s; - y = axis.y * s; - z = axis.z * s; - w = Math.cos(angle * 0.5); - return normalize(); + //var s: FastFloat = Math.sin(angle * 0.5); + //x = axis.x * s; + //y = axis.y * s; + //z = axis.z * s; + //w = Math.cos(angle * 0.5); + //return normalize(); + // Normalize the axis vector first + var axisLen = Math.sqrt(axis.x * axis.x + axis.y * axis.y + axis.z * axis.z); + if (axisLen > 0.00001) { + var aL = 1.0 / axisLen; + var nX = axis.x * aL; + var nY = axis.y * aL; + var nZ = axis.z * aL; + var halfAngle = angle * 0.5; + var s: FastFloat = Math.sin(halfAngle); + x = nX * s; + y = nY * s; + z = nZ * s; + w = Math.cos(halfAngle); + } else { + x = 0.0; + y = 0.0; + z = 0.0; + w = 1.0; + } + return this; } public inline function toAxisAngle(axis: Vec4): FastFloat { From c6139282edff94bcb869322b587f34669958d461 Mon Sep 17 00:00:00 2001 From: Onek8 Date: Sun, 6 Apr 2025 14:34:19 +0000 Subject: [PATCH 2/4] Update leenkx/blender/lnx/logicnode/lnx_sockets.py --- leenkx/blender/lnx/logicnode/lnx_sockets.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/leenkx/blender/lnx/logicnode/lnx_sockets.py b/leenkx/blender/lnx/logicnode/lnx_sockets.py index 585a3b0..3ceab3e 100644 --- a/leenkx/blender/lnx/logicnode/lnx_sockets.py +++ b/leenkx/blender/lnx/logicnode/lnx_sockets.py @@ -201,20 +201,11 @@ class LnxRotationSocket(LnxCustomSocket): x *= pi/180 y *= pi/180 z *= pi/180 - cx, sx = cos(x/2), sin(x/2) - cy, sy = cos(y/2), sin(y/2) - cz, sz = cos(z/2), sin(z/2) - - qw, qx, qy, qz = 1.0,0.0,0.0,0.0 - for direction in param3[::-1]: - qwi, qxi,qyi,qzi = {'X': (cx,sx,0,0), 'Y': (cy,0,sy,0), 'Z': (cz,0,0,sz)}[direction] - - qw = qw*qwi -qx*qxi -qy*qyi -qz*qzi - qx = qx*qwi +qw*qxi +qy*qzi -qz*qyi - qy = qy*qwi +qw*qyi +qz*qxi -qx*qzi - qz = qz*qwi +qw*qzi +qx*qyi -qy*qxi - return mathutils.Vector((qx,qy,qz,qw)) - + + euler = mathutils.Euler((x, y, z), param3) + quat = euler.to_quaternion() + return mathutils.Vector((quat.x, quat.y, quat.z, quat.w)) + def do_update_raw(self, context): part1 = mathutils.Vector(( From ee8d3314b528342b1241445be187679f4f08064e Mon Sep 17 00:00:00 2001 From: Onek8 Date: Sun, 6 Apr 2025 15:25:39 +0000 Subject: [PATCH 3/4] Update leenkx/Sources/leenkx/logicnode/TransformNode.hx --- leenkx/Sources/leenkx/logicnode/TransformNode.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leenkx/Sources/leenkx/logicnode/TransformNode.hx b/leenkx/Sources/leenkx/logicnode/TransformNode.hx index 7f51eff..81ffa1f 100644 --- a/leenkx/Sources/leenkx/logicnode/TransformNode.hx +++ b/leenkx/Sources/leenkx/logicnode/TransformNode.hx @@ -18,7 +18,7 @@ class TransformNode extends LogicNode { override function get(from: Int): Dynamic { var loc: Vec4 = inputs[0].get(); var rot: Quat = new Quat().setFrom(inputs[1].get()); - rot.normalize(); + //rot.normalize(); var scale: Vec4 = inputs[2].get(); if (loc == null && rot == null && scale == null) return this.value; if (loc == null || rot == null || scale == null) return null; From d1edb1464e8077042dd9f4da8c8892c68c25b984 Mon Sep 17 00:00:00 2001 From: Onek8 Date: Sun, 6 Apr 2025 15:27:05 +0000 Subject: [PATCH 4/4] Update leenkx/Sources/iron/math/Quat.hx --- leenkx/Sources/iron/math/Quat.hx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/leenkx/Sources/iron/math/Quat.hx b/leenkx/Sources/iron/math/Quat.hx index 3c23b89..6a8cce9 100644 --- a/leenkx/Sources/iron/math/Quat.hx +++ b/leenkx/Sources/iron/math/Quat.hx @@ -429,6 +429,12 @@ class Quat { else this.mult(qz); + // TO DO quick fix doesnt make sense. + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + return this; }