Add body tracking and dragging, optimize performance

This commit is contained in:
CroakFang
2023-06-29 22:39:46 +08:00
parent 1bec75c2bd
commit f60dd424f4
13 changed files with 395 additions and 314 deletions
@@ -361,6 +361,16 @@ namespace Gallop
ApplyRotation();
}
public void ChangeMorphEye()
{
FacialResetEye();
ProcessMorph(LeftEyeXrange);
ProcessMorph(LeftEyeYrange);
ProcessMorph(RightEyeXrange);
ProcessMorph(RightEyeYrange);
ApplyRotationEye();
}
public void ClearMorph()
{
EarMorphs.ForEach(morph => morph.weight = 0);
@@ -453,7 +463,7 @@ namespace Gallop
public void FacialResetAll()
{
if (Container.FaceOverrideData&& Container.FaceOverrideData.Enable)
if (Container.FaceOverrideData && Container.FaceOverrideData.Enable)
{
OverrideFace(Container.FaceOverrideData);
}
@@ -467,6 +477,17 @@ namespace Gallop
ApplyRotation();
}
public void FacialResetEye()
{
if (Container.FaceOverrideData && Container.FaceOverrideData.Enable)
{
OverrideFace(Container.FaceOverrideData);
}
FacialReset(BaseLEyeMorph.trsArray);
FacialReset(BaseREyeMorph.trsArray);
ApplyRotationEye();
}
public void FacialReset(List<TrsArray> trsArrays)
{
foreach (TrsArray trs in trsArrays)
@@ -500,6 +521,20 @@ namespace Gallop
}
}
public void ApplyRotationEye()
{
Action<List<TrsArray>> applyRotation = delegate (List<TrsArray> trsArray)
{
foreach (TrsArray trs in trsArray)
{
if(trs.transform)
trs.transform.localRotation = RotationConvert.fromMaya(RotationRecorder[trs.transform]);
}
};
applyRotation.Invoke(BaseLEyeMorph.trsArray);
applyRotation.Invoke(BaseREyeMorph.trsArray);
}
public void ChangeMorphWeight(FacialMorph morph, float val)
{
Container.isAnimatorControl = false;
@@ -520,7 +555,14 @@ namespace Gallop
LeftEyeYrange.weight = ly;
RightEyeXrange.weight = rx;
RightEyeYrange.weight = ry;
ChangeMorph();
if (Container.FaceOverrideData && Container.FaceOverrideData.Enable)
{
ChangeMorph();
}
else
{
ChangeMorphEye();
}
}
public void ProcessLocator()
@@ -618,9 +660,9 @@ namespace Gallop
changed = true;
}
if (new List<FaceOverrideElement>(arr.DstArray).Find(f=>f.Index == src) == null)
{
srcmorph.weight = 0;
if (new List<FaceOverrideElement>(arr.DstArray).Find(f => f.Index == src) == null)
{
srcmorph.weight = 0;
}
}
targetMorph.ForEach(a => a.Invoke());