Skip to content

Commit bd04f2e

Browse files
committed
Interactivity: fixed quat math nodes (wrong return value type, deg/rad conversion)
1 parent 60e0e88 commit bd04f2e

6 files changed

Lines changed: 47 additions & 6 deletions

File tree

Editor/Scripts/Interactivity/VisualScriptingExport/UnitExporters/Math/GenericMathInvokeUnitExports.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public static void Register()
6767
InvokeUnitExport.RegisterInvokeExporter(typeof(Matrix4x4), nameof(Matrix4x4.Inverse), new GenericInvokeMathInvokeUnitExporters<Math_InverseNode>());
6868

6969
InvokeUnitExport.RegisterInvokeExporter(typeof(Quaternion), nameof(Quaternion.Inverse), new GenericInvokeMathInvokeUnitExporters<Math_QuatConjugateNode>());
70-
InvokeUnitExport.RegisterInvokeExporter(typeof(Quaternion), nameof(Quaternion.Angle), new GenericInvokeMathInvokeUnitExporters<Math_QuatAngleBetweenNode>());
7170
}
7271
}
7372
public class GenericInvokeMathInvokeUnitExporters<TSchema> : GenericInvokeUnitExport<TSchema> where TSchema : GltfInteractivityNodeSchema, new()

Editor/Scripts/Interactivity/VisualScriptingExport/UnitExporters/Math/QuaternionAngleAxisUnitExporter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ public bool InitializeInteractivityNodes(UnitExporter unitExporter)
2121
var unit = unitExporter.unit as InvokeMember;
2222

2323
var node = unitExporter.CreateNode<Math_QuatFromAxisAngleNode>();
24-
node.ValueIn(Math_QuatFromAxisAngleNode.IdAngle).MapToInputPort(unit.valueInputs[0]);
2524
node.ValueIn(Math_QuatFromAxisAngleNode.IdAxis).MapToInputPort(unit.valueInputs[1]);
2625
node.ValueOut(Math_QuatFromAxisAngleNode.IdOutValue).MapToPort(unit.result);
27-
26+
27+
var degToRadNode = unitExporter.CreateNode<Math_RadNode>();
28+
degToRadNode.ValueIn(Math_RadNode.IdInputA).MapToInputPort(unit.valueInputs[0]);
29+
node.ValueIn(Math_QuatFromAxisAngleNode.IdAngle).ConnectToSource(degToRadNode.FirstValueOut());
30+
2831
return true;
2932
}
3033
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using Unity.VisualScripting;
3+
using UnityEditor;
4+
using UnityEngine;
5+
using UnityGLTF.Interactivity.Schema;
6+
7+
namespace UnityGLTF.Interactivity.VisualScripting.Export
8+
{
9+
public class QuaternionAngleUnitExporter : IUnitExporter
10+
{
11+
public Type unitType { get; }
12+
13+
[InitializeOnLoadMethod]
14+
private static void Register()
15+
{
16+
InvokeUnitExport.RegisterInvokeExporter(typeof(Quaternion), nameof(Quaternion.Angle), new QuaternionToAxisAngleUnitExporter());
17+
}
18+
19+
public bool InitializeInteractivityNodes(UnitExporter unitExporter)
20+
{
21+
var unit = unitExporter.unit as InvokeMember;
22+
23+
var node = unitExporter.CreateNode<Math_QuatAngleBetweenNode>();
24+
node.ValueIn(Math_QuatToAxisAngleNode.IdValueA).MapToInputPort(unit.valueInputs[0]);
25+
node.ValueIn(Math_QuatToAxisAngleNode.IdValueA).MapToInputPort(unit.valueInputs[1]);
26+
27+
var degToRadNode = unitExporter.CreateNode<Math_RadNode>();
28+
degToRadNode.ValueIn(Math_RadNode.IdInputA).ConnectToSource(node.FirstValueOut());
29+
degToRadNode.FirstValueOut().MapToPort(unit.result);
30+
31+
return true;
32+
}
33+
}
34+
}

Editor/Scripts/Interactivity/VisualScriptingExport/UnitExporters/Math/QuaternionAngleUnitExporter.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Scripts/Interactivity/VisualScriptingExport/UnitExporters/Math/QuaternionToAxisAngleUnitExporter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ public bool InitializeInteractivityNodes(UnitExporter unitExporter)
2222

2323
var node = unitExporter.CreateNode<Math_QuatToAxisAngleNode>();
2424
node.ValueIn(Math_QuatToAxisAngleNode.IdValueA).MapToInputPort(unit.valueInputs[0]);
25-
2625
node.ValueOut(Math_QuatToAxisAngleNode.IdOutAxis).MapToPort(unit.valueOutputs["&axis"]);
27-
node.ValueOut(Math_QuatToAxisAngleNode.IdOutAngle).MapToPort(unit.valueOutputs["&angle"]);
26+
27+
var degToRadNode = unitExporter.CreateNode<Math_RadNode>();
28+
degToRadNode.ValueIn(Math_RadNode.IdInputA).ConnectToSource(node.ValueOut(Math_QuatToAxisAngleNode.IdOutAngle));
29+
degToRadNode.FirstValueOut().MapToPort(unit.valueOutputs["&angle"]);
2830

2931
return true;
3032
}

Runtime/Scripts/Interactivity/Schema/Nodes/Math/MathNodes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ public class Math_QuatFromAxisAngleNode : GltfInteractivityNodeSchema
10571057
[InputSocketDescription(GltfTypes.Float3)]
10581058
public const string IdAxis = "axis";
10591059

1060-
[OutputSocketDescription(GltfTypes.Float)]
1060+
[OutputSocketDescription(GltfTypes.Float4)]
10611061
public const string IdOutValue = "value";
10621062
}
10631063

0 commit comments

Comments
 (0)