diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs index e2beac9ca..08d430ba5 100644 --- a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs +++ b/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs @@ -17,7 +17,7 @@ namespace UniVRM10 } #region SRC - void SrcDrawCurrent() + void DrawSourceCurrent() { var s = m_target.transform.lossyScale.x; @@ -28,25 +28,15 @@ namespace UniVRM10 Handles.DrawWireCube(Vector3.zero, new Vector3(size, size, size)); } - void SrcDrawModelCoords() + void DrawSourceCoords() { var s = m_target.transform.lossyScale.x; - - // init - m_target.GetSourceModelCoords().Draw(0.2f / s); - } - - void SrcDrawLocalCoords() - { - var s = m_target.transform.lossyScale.x; - - // init - m_target.GetSourceLocalCoords().Draw(0.2f / s); + m_target.GetSourceCoords().Draw(0.2f / s); } #endregion #region Dst - void DstDrawCurrent() + void DrawDstCurrent() { var s = m_target.transform.lossyScale.x; @@ -57,20 +47,10 @@ namespace UniVRM10 Handles.DrawWireCube(Vector3.zero, new Vector3(size, size, size)); } - void DstDrawModelCoords() + void DrawDstCoords() { var s = m_target.transform.lossyScale.x; - - // init - m_target.GetDstModelCoords().Draw(0.2f / s); - } - - void DstDrawLocalCoords() - { - var s = m_target.transform.lossyScale.x; - - // init - m_target.GetDstLocalCoords().Draw(0.2f / s); + m_target.GetDstCoords().Draw(0.2f / s); } #endregion @@ -134,35 +114,10 @@ namespace UniVRM10 Handles.Label(m_target.transform.position, sb.ToString(), s_style); } - switch (m_target.SourceCoordinate) - { - case ObjectSpace.model: - SrcDrawModelCoords(); - break; - - case ObjectSpace.local: - SrcDrawLocalCoords(); - break; - - default: - throw new NotImplementedException(); - } - SrcDrawCurrent(); - - switch (m_target.DestinationCoordinate) - { - case ObjectSpace.model: - DstDrawModelCoords(); - break; - - case ObjectSpace.local: - DstDrawLocalCoords(); - break; - - default: - throw new NotImplementedException(); - } - DstDrawCurrent(); + DrawSourceCoords(); + DrawSourceCurrent(); + DrawDstCoords(); + DrawDstCurrent(); } } } diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs index 115c563b7..14ab8a139 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs @@ -1,4 +1,5 @@ -using UniGLTF.Extensions.VRMC_node_constraint; +using System; +using UniGLTF.Extensions.VRMC_node_constraint; using UnityEngine; @@ -36,54 +37,59 @@ namespace UniVRM10 ConstraintSource m_src; /// - /// Model の座標系 + /// Source の座標系 /// /// - public TR GetSourceModelCoords() + public TR GetSourceCoords() { - var r = Quaternion.identity; - if (Source != null) + switch (SourceCoordinate) { - if (ModelRoot != null) - { - r = ModelRoot.rotation; - } - } - - var t = Vector3.zero; - if (Source != null) - { - t = Source.position; - } - - return new TR(r, t); - } - - /// - /// Local の座標系。つまり親座標系 - /// - /// - public TR GetSourceLocalCoords() - { - if (Source != null) - { - if (m_src != null) - { - // runtime - var parent = TR.Identity; - if (Source.parent != null) + case ObjectSpace.model: { - parent = TR.FromWorld(Source.parent); + + var r = Quaternion.identity; + if (Source != null) + { + if (ModelRoot != null) + { + r = ModelRoot.rotation; + } + } + + var t = Vector3.zero; + if (Source != null) + { + t = Source.position; + } + + return new TR(r, t); + } + + case ObjectSpace.local: + { + if (Source != null) + { + if (m_src != null) + { + // runtime + var parent = TR.Identity; + if (Source.parent != null) + { + parent = TR.FromWorld(Source.parent); + } + return parent * m_src.LocalInitial; + } + else + { + return TR.FromWorld(Source); + } + } + + return TR.Identity; } - return parent * m_src.LocalInitial; - } - else - { - return TR.FromWorld(Source); - } } - return TR.Identity; + throw new NotImplementedException(); } public Quaternion Delta @@ -93,31 +99,40 @@ namespace UniVRM10 } ConstraintDestination m_dst; - public TR GetDstModelCoords() + public TR GetDstCoords() { - var r = Quaternion.identity; - if (ModelRoot != null) + switch (DestinationCoordinate) { - r = ModelRoot.rotation; - } - return new TR(r, transform.position); - } - public TR GetDstLocalCoords() - { - if (m_src != null) - { - // runtime - var parent = TR.Identity; - if (transform.parent != null) - { - parent = TR.FromWorld(transform.parent); - } - return parent * m_dst.LocalInitial; - } - else - { - return TR.FromWorld(transform); + case ObjectSpace.model: + { + var r = Quaternion.identity; + if (ModelRoot != null) + { + r = ModelRoot.rotation; + } + return new TR(r, transform.position); + } + + case ObjectSpace.local: + { + if (m_src != null) + { + // runtime + var parent = TR.Identity; + if (transform.parent != null) + { + parent = TR.FromWorld(transform.parent); + } + return parent * m_dst.LocalInitial; + } + else + { + return TR.FromWorld(transform); + } + } } + + throw new NotImplementedException(); } ///