mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-09 04:19:42 -05:00
fix operator*
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using UniGLTF.Extensions.VRMC_node_constraint;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -36,12 +35,9 @@ namespace UniVRM10
|
||||
void DrawDstCurrent()
|
||||
{
|
||||
var s = m_target.transform.lossyScale.x;
|
||||
|
||||
// current
|
||||
Handles.matrix = m_target.transform.localToWorldMatrix;
|
||||
Handles.matrix = m_target.GetDstCurrent().TRS(0.05f * s);
|
||||
Handles.color = Color.yellow;
|
||||
var size = 0.05f / s;
|
||||
Handles.DrawWireCube(Vector3.zero, new Vector3(size, size, size));
|
||||
Handles.DrawWireCube(Vector3.zero, Vector3.one);
|
||||
}
|
||||
|
||||
void DrawDstCoords()
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace UniVRM10
|
||||
var toRelative = from.worldToLocalMatrix;
|
||||
return new TR(toRelative.rotation * t.rotation, toRelative.MultiplyPoint(t.position));
|
||||
}
|
||||
|
||||
|
||||
public TR(Quaternion r, Vector3 t)
|
||||
{
|
||||
Rotation = r;
|
||||
@@ -31,6 +31,6 @@ namespace UniVRM10
|
||||
|
||||
public Matrix4x4 TRS(float s) => Matrix4x4.TRS(Translation, Rotation, new Vector3(s, s, s));
|
||||
|
||||
public static TR operator *(TR a, TR b) => new TR(a.Rotation * b.Rotation, b.Rotation * a.Translation + b.Translation);
|
||||
public static TR operator *(TR a, TR b) => new TR(a.Rotation * b.Rotation, a.Rotation * b.Translation + a.Translation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,59 +94,15 @@ namespace UniVRM10
|
||||
|
||||
public TR GetSourceCurrent()
|
||||
{
|
||||
switch (SourceCoordinate)
|
||||
var coords = GetSourceCoords();
|
||||
if (m_src != null)
|
||||
{
|
||||
case ObjectSpace.model:
|
||||
{
|
||||
var r = Quaternion.identity;
|
||||
if (Source != null)
|
||||
{
|
||||
if (ModelRoot != null)
|
||||
{
|
||||
r = ModelRoot.rotation;
|
||||
if (m_src != null)
|
||||
{
|
||||
r *= m_src.RotationDelta(ObjectSpace.model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 = Quaternion.identity;
|
||||
if (Source.parent != null)
|
||||
{
|
||||
parent = Source.parent.rotation;
|
||||
}
|
||||
var delta = m_src.RotationDelta(ObjectSpace.local);
|
||||
|
||||
return new TR(parent * m_src.LocalInitial.Rotation * delta, Source.position);
|
||||
}
|
||||
else
|
||||
{
|
||||
return TR.FromWorld(Source);
|
||||
}
|
||||
}
|
||||
|
||||
return TR.Identity;
|
||||
}
|
||||
return coords * new TR(m_src.RotationDelta(SourceCoordinate));
|
||||
}
|
||||
else
|
||||
{
|
||||
return coords;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Quaternion Delta
|
||||
@@ -180,7 +136,7 @@ namespace UniVRM10
|
||||
{
|
||||
parent = TR.FromWorld(transform.parent);
|
||||
}
|
||||
return m_dst.LocalInitial * parent;
|
||||
return parent * m_dst.LocalInitial;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -192,6 +148,51 @@ namespace UniVRM10
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public TR GetDstCurrent()
|
||||
{
|
||||
var coords = GetDstCoords();
|
||||
if (m_src != null)
|
||||
{
|
||||
return coords * new TR(m_src.RotationDelta(SourceCoordinate));
|
||||
}
|
||||
else
|
||||
{
|
||||
return coords;
|
||||
}
|
||||
// switch (DestinationCoordinate)
|
||||
// {
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Editorで設定値の変更を反映するために、クリアする
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user