optimize performance

This commit is contained in:
CroakFang
2022-11-01 23:43:50 +08:00
parent bdeb68b029
commit 8e4c96dcaf
2 changed files with 6 additions and 20 deletions
@@ -154,7 +154,6 @@ namespace Gallop
{
morph._weight = 0;
}
ChangeMorph();
}
private void ProcessMorph(FacialMorph morph)
@@ -206,15 +205,7 @@ namespace Gallop
morph.Weight = val;
ChangeMorph();
}
public void ChangeMorphWeights(Dictionary<FacialMorph, float> morphs)
{
foreach(var item in morphs)
{
item.Key.Weight = item.Value;
}
ChangeMorph();
}
}
}
@@ -71,25 +71,20 @@ public class FaceEmotionKeyTarget : ScriptableObject
{
if (FaceDrivenKeyTarget == null) return;
FaceDrivenKeyTarget.ClearMorph();
Dictionary<FacialMorph, float> morphs = new Dictionary<FacialMorph, float>();
foreach (var emotion in FaceEmotionKey)
{
if (emotion.emotionKeys != null)
{
foreach (var key in emotion.emotionKeys)
{
if (morphs.ContainsKey(key.morph))
{
morphs[key.morph] = key.morph.Weight + key.weight / 100 * emotion.Weight;
}
else
{
morphs.Add(key.morph, key.morph.Weight + key.weight / 100 * emotion.Weight);
}
key.morph.Weight += key.weight / 100 * emotion.Weight;
}
}
FaceDrivenKeyTarget.ChangeMorphWeights(morphs);
}
FaceDrivenKeyTarget.ChangeMorph();
}
}