UpdateDelta

This commit is contained in:
ousttrue 2021-05-17 17:47:59 +09:00
parent cc3568da14
commit da4ae3f0e5
3 changed files with 19 additions and 35 deletions

View File

@ -13,27 +13,6 @@ namespace UniVRM10
Vector3 m_delta;
public override Vector3 Delta => m_delta;
protected override void UpdateDelta()
{
if (Source == null)
{
enabled = false;
return;
}
if (m_src == null)
{
m_src = new ConstraintSource(Source, ModelRoot);
}
if (m_dst == null)
{
m_dst = new ConstraintDestination(transform, ModelRoot);
}
m_delta = FreezeAxes.Freeze(m_src.TranslationDelta(SourceCoordinate));
m_dst.ApplyTranslation(Delta, Weight, DestinationCoordinate, ModelRoot);
}
public override TR GetSourceCurrent()
{
var coords = GetSourceCoords();
@ -55,5 +34,11 @@ namespace UniVRM10
return new TR(Delta) * coords;
}
protected override void UpdateDelta()
{
m_delta = FreezeAxes.Freeze(m_src.TranslationDelta(SourceCoordinate));
m_dst.ApplyTranslation(Delta, Weight, DestinationCoordinate, ModelRoot);
}
}
}

View File

@ -13,11 +13,6 @@ namespace UniVRM10
public override Vector3 Delta => m_delta.eulerAngles;
protected override void UpdateDelta()
{
m_delta = m_src.RotationDelta(SourceCoordinate, SourceOffset);
}
public override TR GetSourceCurrent()
{
var coords = GetSourceCoords();
@ -39,5 +34,18 @@ namespace UniVRM10
return coords * new TR(m_delta);
}
protected override void UpdateDelta()
{
m_delta = m_src.RotationDelta(SourceCoordinate, SourceOffset);
// 軸制限
var fleezed = FreezeAxes.Freeze(Delta);
var rotation = Quaternion.Euler(fleezed);
// Debug.Log($"{delta} => {rotation}");
// オイラー角を再度Quaternionへ。weight を加味してSlerpする
m_dst.ApplyRotation(DestinationOffset * rotation, Weight, DestinationCoordinate, ModelRoot);
}
}
}

View File

@ -204,15 +204,6 @@ namespace UniVRM10
// 回転差分
UpdateDelta();
// 軸制限
var fleezed = FreezeAxes.Freeze(Delta);
var rotation = Quaternion.Euler(fleezed);
// Debug.Log($"{delta} => {rotation}");
// オイラー角を再度Quaternionへ。weight を加味してSlerpする
m_dst.ApplyRotation(DestinationOffset * rotation, Weight, DestinationCoordinate, ModelRoot);
}
}
}