forked from LeenkxTeam/LNXSDK
Cleanup
This commit is contained in:
@ -66,32 +66,12 @@ class Quat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public inline function fromAxisAngle(axis: Vec4, angle: FastFloat): Quat {
|
public inline function fromAxisAngle(axis: Vec4, angle: FastFloat): Quat {
|
||||||
//var s: FastFloat = Math.sin(angle * 0.5);
|
var s: FastFloat = Math.sin(angle * 0.5);
|
||||||
//x = axis.x * s;
|
x = axis.x * s;
|
||||||
//y = axis.y * s;
|
y = axis.y * s;
|
||||||
//z = axis.z * s;
|
z = axis.z * s;
|
||||||
//w = Math.cos(angle * 0.5);
|
w = Math.cos(angle * 0.5);
|
||||||
//return normalize();
|
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 {
|
public inline function toAxisAngle(axis: Vec4): FastFloat {
|
||||||
@ -399,33 +379,17 @@ class Quat {
|
|||||||
@return This quaternion.
|
@return This quaternion.
|
||||||
**/
|
**/
|
||||||
public inline function fromEulerOrdered(e: Vec4, order: String): Quat {
|
public inline function fromEulerOrdered(e: Vec4, order: String): Quat {
|
||||||
|
var c1 = Math.cos(e.x / 2);
|
||||||
var mappedAngles = new Vec4();
|
var c2 = Math.cos(e.y / 2);
|
||||||
switch (order) {
|
var c3 = Math.cos(e.z / 2);
|
||||||
case "XYZ":
|
var s1 = Math.sin(e.x / 2);
|
||||||
mappedAngles.set(e.x, e.y, e.z);
|
var s2 = Math.sin(e.y / 2);
|
||||||
case "XZY":
|
var s3 = Math.sin(e.z / 2);
|
||||||
mappedAngles.set(e.x, e.z, e.y);
|
|
||||||
case "YXZ":
|
|
||||||
mappedAngles.set(e.y, e.x, e.z);
|
|
||||||
case "YZX":
|
|
||||||
mappedAngles.set(e.y, e.z, e.x);
|
|
||||||
case "ZXY":
|
|
||||||
mappedAngles.set(e.z, e.x, e.y);
|
|
||||||
case "ZYX":
|
|
||||||
mappedAngles.set(e.z, e.y, e.x);
|
|
||||||
}
|
|
||||||
var c1 = Math.cos(mappedAngles.x / 2);
|
|
||||||
var c2 = Math.cos(mappedAngles.y / 2);
|
|
||||||
var c3 = Math.cos(mappedAngles.z / 2);
|
|
||||||
var s1 = Math.sin(mappedAngles.x / 2);
|
|
||||||
var s2 = Math.sin(mappedAngles.y / 2);
|
|
||||||
var s3 = Math.sin(mappedAngles.z / 2);
|
|
||||||
var qx = new Quat(s1, 0, 0, c1);
|
var qx = new Quat(s1, 0, 0, c1);
|
||||||
var qy = new Quat(0, s2, 0, c2);
|
var qy = new Quat(0, s2, 0, c2);
|
||||||
var qz = new Quat(0, 0, s3, c3);
|
var qz = new Quat(0, 0, s3, c3);
|
||||||
|
|
||||||
// Original multiplication sequence (implements reverse of 'order')
|
|
||||||
if (order.charAt(2) == 'X')
|
if (order.charAt(2) == 'X')
|
||||||
this.setFrom(qx);
|
this.setFrom(qx);
|
||||||
else if (order.charAt(2) == 'Y')
|
else if (order.charAt(2) == 'Y')
|
||||||
@ -445,12 +409,6 @@ class Quat {
|
|||||||
else
|
else
|
||||||
this.mult(qz);
|
this.mult(qz);
|
||||||
|
|
||||||
// TO DO quick fix somethings wrong..
|
|
||||||
this.x = -this.x;
|
|
||||||
this.y = -this.y;
|
|
||||||
this.z = -this.z;
|
|
||||||
this.w = -this.w;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,15 +132,11 @@ class Transform {
|
|||||||
|
|
||||||
function composeDelta() {
|
function composeDelta() {
|
||||||
// Delta transform
|
// Delta transform
|
||||||
var dl = new Vec4().addvecs(loc, dloc);
|
dloc.addvecs(loc, dloc);
|
||||||
var ds = new Vec4().setFrom(scale);
|
dscale.addvecs(dscale, scale);
|
||||||
ds.x *= dscale.x;
|
drot.fromEuler(_deulerX, _deulerY, _deulerZ);
|
||||||
ds.y *= dscale.y;
|
drot.multquats(rot, drot);
|
||||||
ds.z *= dscale.z;
|
local.compose(dloc, drot, dscale);
|
||||||
var dr = new Quat().fromEuler(_deulerX, _deulerY, _deulerZ);
|
|
||||||
dr.multquats(dr, rot);
|
|
||||||
dr.multquats(drot, dr);
|
|
||||||
local.compose(dl, dr, ds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -131,15 +131,8 @@ class MouseLookNode extends LogicNode {
|
|||||||
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
||||||
verticalAxis.set(0, 1, 0); // Y-axis for vertical rotation
|
verticalAxis.set(0, 1, 0); // Y-axis for vertical rotation
|
||||||
case "Y": // Y-axis forward (most common for 3D games)
|
case "Y": // Y-axis forward (most common for 3D games)
|
||||||
#if lnx_yaxisup
|
|
||||||
// Y-up coordinate system (Blender default)
|
|
||||||
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
||||||
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
||||||
#else
|
|
||||||
// Z-up coordinate system
|
|
||||||
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
|
||||||
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
|
||||||
#end
|
|
||||||
case "Z": // Z-axis forward (top-down or specific orientations)
|
case "Z": // Z-axis forward (top-down or specific orientations)
|
||||||
horizontalAxis.set(0, 1, 0); // Y-axis for horizontal rotation
|
horizontalAxis.set(0, 1, 0); // Y-axis for horizontal rotation
|
||||||
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
||||||
|
|||||||
@ -75,8 +75,8 @@ def resize_texture_if_needed(image: bpy.types.Image, filepath: str, max_size: in
|
|||||||
texture_quality = wrd.lnx_texture_quality
|
texture_quality = wrd.lnx_texture_quality
|
||||||
|
|
||||||
cache_key = (filepath, max_size, texture_quality, os.path.getmtime(filepath) if os.path.exists(filepath) else 0)
|
cache_key = (filepath, max_size, texture_quality, os.path.getmtime(filepath) if os.path.exists(filepath) else 0)
|
||||||
if cache_key in _texture_resize_cache:
|
if cache_key in texture_resize_cache:
|
||||||
cached_path = _texture_resize_cache[cache_key]
|
cached_path = texture_resize_cache[cache_key]
|
||||||
if os.path.exists(cached_path):
|
if os.path.exists(cached_path):
|
||||||
return cached_path
|
return cached_path
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ def resize_texture_if_needed(image: bpy.types.Image, filepath: str, max_size: in
|
|||||||
src_mtime = os.path.getmtime(filepath)
|
src_mtime = os.path.getmtime(filepath)
|
||||||
dst_mtime = os.path.getmtime(resized_path)
|
dst_mtime = os.path.getmtime(resized_path)
|
||||||
if dst_mtime >= src_mtime:
|
if dst_mtime >= src_mtime:
|
||||||
_texture_resize_cache[cache_key] = resized_path
|
texture_resize_cache[cache_key] = resized_path
|
||||||
return resized_path
|
return resized_path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -146,7 +146,7 @@ def resize_texture_if_needed(image: bpy.types.Image, filepath: str, max_size: in
|
|||||||
|
|
||||||
if result.returncode == 0 and os.path.exists(resized_path):
|
if result.returncode == 0 and os.path.exists(resized_path):
|
||||||
print(f"[Texture Optimizer] Resized: {basename} {width}x{height} -> {new_width}x{new_height}")
|
print(f"[Texture Optimizer] Resized: {basename} {width}x{height} -> {new_width}x{new_height}")
|
||||||
_texture_resize_cache[cache_key] = resized_path
|
texture_resize_cache[cache_key] = resized_path
|
||||||
return resized_path
|
return resized_path
|
||||||
else:
|
else:
|
||||||
error_msg = result.stderr.decode('utf-8', errors='ignore') if result.stderr else 'Unknown error'
|
error_msg = result.stderr.decode('utf-8', errors='ignore') if result.stderr else 'Unknown error'
|
||||||
|
|||||||
Reference in New Issue
Block a user