Fix output axes calculations. Another interesting effect

This commit is contained in:
2026-03-12 14:32:25 +08:00
parent cf63c5d062
commit 7c540bb6ad
7 changed files with 11769 additions and 2432 deletions
@@ -1,15 +1,10 @@
// Convert scaling vector to 4x4 transformation matrix // Convert scaling vector to 4x4 transformation matrix
// Scaling values are applied to X, Y, Z axes (sxyz.x, sxyz.y, sxyz.z) // Scaling values are applied to X, Y, Z axes (sxyz.x, sxyz.y, sxyz.z)
float4x4 ScaleToMatrix(float3 s) { float CrossProduct(float2 u, float2 v) {
// Create diagonal scaling matrix // Create diagonal scaling matrix
// s.x applied to X-axis // s.x applied to X-axis
// s.y applied to Y-axis // s.y applied to Y-axis
// s.z applied to Z-axis // s.z applied to Z-axis
return float4x4( return u.x * v.y - u.y * v.x;
s.x, 0.0, 0.0, 0.0,
0.0, s.y, 0.0, 0.0,
0.0, 0.0, s.z, 0.0,
0.0, 0.0, 0.0, 1.0
);
} }
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 8b5037aa7089c944a9d657d0c98e831c guid: f8f4610af7293684491e647c5387e5e4
ShaderIncludeImporter: ShaderIncludeImporter:
externalObjects: {} externalObjects: {}
userData: userData:
+6 -6
View File
@@ -270,11 +270,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Value propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[0].m_Value
value: 1 value: 179.5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[1].m_Value propertyPath: m_PropertySheet.m_Float.m_Array.Array.data[1].m_Value
value: 1 value: -130.2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -973084862543737302, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_PropertySheet.m_Vector3f.m_Array.Array.data[0].m_Name propertyPath: m_PropertySheet.m_Vector3f.m_Array.Array.data[0].m_Name
@@ -310,7 +310,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -774367247743995920, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -774367247743995920, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_Enabled propertyPath: m_Enabled
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: -364223573239433514, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_LocalScale.y propertyPath: m_LocalScale.y
@@ -362,7 +362,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8980549144392899874, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3} - target: {fileID: 8980549144392899874, guid: 25c54d8c074f08447ab1c822a6a052fa, type: 3}
propertyPath: m_IsActive propertyPath: m_IsActive
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
@@ -384,7 +384,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!4 &262750851 --- !u!4 &262750851
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -488,7 +488,7 @@ Transform:
m_GameObject: {fileID: 1826889287} m_GameObject: {fileID: 1826889287}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10} m_LocalPosition: {x: 0, y: 0, z: -5}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
-14
View File
@@ -1,14 +0,0 @@
// Extract coordinate axes from transformation matrix
// Returns the rotation part (3x3 upper-left submatrix)
float3x3 MatrixToAxes(float4x4 t) {
// Extract the 3x3 rotation submatrix from the 4x4 transformation matrix
// Row 0 = X-axis direction (t[0].xyz)
// Row 1 = Y-axis direction (t[1].xyz)
// Row 2 = Z-axis direction (t[2].xyz)
return float3x3(
t[0].xyz, // X-axis
t[1].xyz, // Y-axis
t[2].xyz // Z-axis
);
}
@@ -0,0 +1,39 @@
float cross2(float2 u, float2 v)
{
return u.x * v.y - u.y * v.x;
}
float4x4 SelectGreaterAxes(
float4x4 axes,
float2 ss_x,
float2 ss_y,
float2 ss_z)
{
float3 axis_x = axes[0].xyz;
float3 axis_y = axes[1].xyz;
float3 axis_z = axes[2].xyz;
float4x4 result = (float4x4)0;
float area_xy = abs(cross2(ss_x, ss_y));
float area_xz = abs(cross2(ss_x, ss_z));
float area_yz = abs(cross2(ss_y, ss_z));
if (area_xy > area_xz && area_xy > area_yz)
{
result[0].xyz = axis_x;
result[1].xyz = axis_y;
}
else if (area_xz > area_xy && area_xz > area_yz)
{
result[0].xyz = axis_x;
result[1].xyz = axis_z;
}
else
{
result[0].xyz = axis_y;
result[1].xyz = axis_z;
}
return result;
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 2e2b8d8010fe4a34e879d0b679e1bf37 guid: 4e07830e6ff48d44b80448b30e80f9ed
ShaderIncludeImporter: ShaderIncludeImporter:
externalObjects: {} externalObjects: {}
userData: userData:
File diff suppressed because it is too large Load Diff