From d9d9e1390162f9e16f9817d7bd9d24278c3b2daa Mon Sep 17 00:00:00 2001
From: 0b5vr <0b5vr@0b5vr.com>
Date: Fri, 4 Feb 2022 12:33:01 +0900
Subject: [PATCH 1/4] change (1.0, constraint): freezeAxes -> axes
See: https://github.com/vrm-c/vrm-specification/pull/352
---
.../VRM10PostionRotationConstraintEditorBase.cs | 6 +++---
.../VRM10/Runtime/Components/Constraint/ConstraintAxes.cs | 8 ++++----
.../Components/Constraint/VRM10RotationConstraint.cs | 2 +-
.../Constraint/VRM10RotationPositionConstraintBase.cs | 8 ++++----
Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs | 6 +++---
Assets/VRM10/Runtime/Format/Constraints/Format.g.cs | 2 +-
Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs | 8 ++++----
Assets/VRM10/Runtime/IO/Vrm10Exporter.cs | 2 +-
Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 4 ++--
9 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs
index 76a755f18..fcd5e8c6b 100644
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs
+++ b/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs
@@ -96,9 +96,9 @@ namespace UniVRM10
// show dst
{
var sb = new StringBuilder();
- sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.X) ? $"freeze" : $"{delta.x:0.00}");
- sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.Y) ? $"freeze" : $"{delta.y:0.00}");
- sb.Append(m_target.FreezeAxes.HasFlag(AxisMask.Z) ? $"freeze" : $"{delta.z:0.00}");
+ sb.AppendLine(m_target.Axes.HasFlag(AxisMask.X) ? $"{delta.x:0.00}" : "----");
+ sb.AppendLine(m_target.Axes.HasFlag(AxisMask.Y) ? $"{delta.y:0.00}" : "----");
+ sb.Append(m_target.Axes.HasFlag(AxisMask.Z) ? $"{delta.z:0.00}" : "----");
Handles.Label(m_target.GetComponent().transform.position, sb.ToString(), Style);
}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs b/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs
index ab3fd2ce3..1b1e369c9 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs
@@ -4,7 +4,7 @@ using UnityEngine;
namespace UniVRM10
{
///
- /// FreezeAxesで使う。bitマスク
+ /// Axesで使う。bitマスク
///
[Flags]
public enum AxisMask
@@ -25,15 +25,15 @@ namespace UniVRM10
{
public static Vector3 Freeze(this AxisMask mask, Vector3 src)
{
- if (mask.HasFlag(AxisMask.X))
+ if (!mask.HasFlag(AxisMask.X))
{
src.x = 0;
}
- if (mask.HasFlag(AxisMask.Y))
+ if (!mask.HasFlag(AxisMask.Y))
{
src.y = 0;
}
- if (mask.HasFlag(AxisMask.Z))
+ if (!mask.HasFlag(AxisMask.Z))
{
src.z = 0;
}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
index 069a509d8..3301e561f 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
@@ -10,7 +10,7 @@ namespace UniVRM10
[DisallowMultipleComponent]
public class VRM10RotationConstraint : VRM10RotationPositionConstraintBase
{
- public override Vector3 Delta => FreezeAxes.Freeze(Quaternion.Slerp(Quaternion.identity, m_delta.Rotation, Weight).eulerAngles);
+ public override Vector3 Delta => Axes.Freeze(Quaternion.Slerp(Quaternion.identity, m_delta.Rotation, Weight).eulerAngles);
public override TR GetSourceCurrent()
{
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
index af042354f..4483258a9 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
@@ -8,11 +8,11 @@ namespace UniVRM10
{
[SerializeField]
[EnumFlags]
- AxisMask m_freezeAxes = default;
- public AxisMask FreezeAxes
+ AxisMask m_axes = default;
+ public AxisMask Axes
{
- get => m_freezeAxes;
- set => m_freezeAxes = value;
+ get => m_axes;
+ set => m_axes = value;
}
#region Source
diff --git a/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs
index 8f392b14b..0788569ea 100644
--- a/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs
+++ b/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs
@@ -116,8 +116,8 @@ public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode pars
continue;
}
- if(key=="freezeAxes"){
- value.FreezeAxes = __constraint__rotation_Deserialize_FreezeAxes(kv.Value);
+ if(key=="axes"){
+ value.Axes = __constraint__rotation_Deserialize_Axes(kv.Value);
continue;
}
@@ -130,7 +130,7 @@ public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode pars
return value;
}
-public static bool[] __constraint__rotation_Deserialize_FreezeAxes(JsonNode parsed)
+public static bool[] __constraint__rotation_Deserialize_Axes(JsonNode parsed)
{
var value = new bool[parsed.GetArrayCount()];
int i=0;
diff --git a/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs
index 2ba238224..3f54d5ead 100644
--- a/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs
+++ b/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs
@@ -21,7 +21,7 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
public int? Source;
// Axes be constrained by this constraint, in X-Y-Z order.
- public bool[] FreezeAxes;
+ public bool[] Axes;
// The weight of the constraint.
public float? Weight;
diff --git a/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs
index 4f533e337..4a88b27fb 100644
--- a/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs
+++ b/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs
@@ -104,9 +104,9 @@ public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationCons
f.Value(value.Source.GetValueOrDefault());
}
- if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=3){
- f.Key("freezeAxes");
- __constraint__rotation_Serialize_FreezeAxes(f, value.FreezeAxes);
+ if(value.Axes!=null&&value.Axes.Count()>=3){
+ f.Key("axes");
+ __constraint__rotation_Serialize_Axes(f, value.Axes);
}
if(value.Weight.HasValue){
@@ -117,7 +117,7 @@ public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationCons
f.EndMap();
}
-public static void __constraint__rotation_Serialize_FreezeAxes(JsonFormatter f, bool[] value)
+public static void __constraint__rotation_Serialize_Axes(JsonFormatter f, bool[] value)
{
f.BeginList();
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
index b310d15db..de2130b07 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
@@ -425,7 +425,7 @@ namespace UniVRM10
Rotation = new UniGLTF.Extensions.VRMC_node_constraint.RotationConstraint
{
Source = model.Nodes.IndexOf(converter.Nodes[c.Source.gameObject]),
- FreezeAxes = ToArray(c.FreezeAxes),
+ Axes = ToArray(c.Axes),
Weight = c.Weight,
},
},
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
index ddd1649e9..c138e1473 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
@@ -613,7 +613,7 @@ namespace UniVRM10
}
}
- static AxisMask FreezeAxis(bool[] flags)
+ static AxisMask ConstraintAxes(bool[] flags)
{
var mask = default(AxisMask);
if (flags != null && flags.Length == 3)
@@ -651,7 +651,7 @@ namespace UniVRM10
var r = constraint.Rotation;
var rotationConstraint = node.gameObject.AddComponent();
rotationConstraint.Source = Nodes[r.Source.Value];
- rotationConstraint.FreezeAxes = FreezeAxis(r.FreezeAxes);
+ rotationConstraint.Axes = ConstraintAxes(r.Axes);
rotationConstraint.Weight = r.Weight.Value;
rotationConstraint.ModelRoot = Root.transform;
}
From 67d00a496aaaba2a2efb4e948db8ed23cb7174bb Mon Sep 17 00:00:00 2001
From: 0b5vr <0b5vr@0b5vr.com>
Date: Fri, 4 Feb 2022 13:27:21 +0900
Subject: [PATCH 2/4] change (1.0, constraint): default value of axes should
enable all axes
---
.../Constraint/VRM10RotationPositionConstraintBase.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
index 4483258a9..7c4cf74e8 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
@@ -8,7 +8,7 @@ namespace UniVRM10
{
[SerializeField]
[EnumFlags]
- AxisMask m_axes = default;
+ AxisMask m_axes = AxisMask.X | AxisMask.Y | AxisMask.Z;
public AxisMask Axes
{
get => m_axes;
From 90201038283fd0b4bbca16fc7afae52c65c1b86c Mon Sep 17 00:00:00 2001
From: 0b5vr <0b5vr@0b5vr.com>
Date: Fri, 4 Feb 2022 18:48:52 +0900
Subject: [PATCH 3/4] deps: forward vrm-specification to the latest master
---
vrm-specification | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vrm-specification b/vrm-specification
index 4b63473e7..084c4fd3a 160000
--- a/vrm-specification
+++ b/vrm-specification
@@ -1 +1 @@
-Subproject commit 4b63473e79d96ab7e52d071a5b99d643b0d7cf20
+Subproject commit 084c4fd3a19f4a94b854c35661151c23d526d26a
From c5d330626d344e15a9d40d6b86f3c7f913870641 Mon Sep 17 00:00:00 2001
From: 0b5vr <0b5vr@0b5vr.com>
Date: Fri, 4 Feb 2022 18:51:47 +0900
Subject: [PATCH 4/4] refactor (1.0, constraint): rename
AxesMaskExtensions.Freeze -> Mask
---
Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs | 2 +-
.../Runtime/Components/Constraint/VRM10RotationConstraint.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs b/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs
index 1b1e369c9..6fe4e9397 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/ConstraintAxes.cs
@@ -23,7 +23,7 @@ namespace UniVRM10
public static class AxesMaskExtensions
{
- public static Vector3 Freeze(this AxisMask mask, Vector3 src)
+ public static Vector3 Mask(this AxisMask mask, Vector3 src)
{
if (!mask.HasFlag(AxisMask.X))
{
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
index 3301e561f..ba762d967 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
@@ -10,7 +10,7 @@ namespace UniVRM10
[DisallowMultipleComponent]
public class VRM10RotationConstraint : VRM10RotationPositionConstraintBase
{
- public override Vector3 Delta => Axes.Freeze(Quaternion.Slerp(Quaternion.identity, m_delta.Rotation, Weight).eulerAngles);
+ public override Vector3 Delta => Axes.Mask(Quaternion.Slerp(Quaternion.identity, m_delta.Rotation, Weight).eulerAngles);
public override TR GetSourceCurrent()
{