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; morph._weight = 0;
} }
ChangeMorph();
} }
private void ProcessMorph(FacialMorph morph) private void ProcessMorph(FacialMorph morph)
@@ -207,14 +206,6 @@ namespace Gallop
ChangeMorph(); 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; if (FaceDrivenKeyTarget == null) return;
FaceDrivenKeyTarget.ClearMorph(); FaceDrivenKeyTarget.ClearMorph();
Dictionary<FacialMorph, float> morphs = new Dictionary<FacialMorph, float>();
foreach (var emotion in FaceEmotionKey) foreach (var emotion in FaceEmotionKey)
{ {
if (emotion.emotionKeys != null) if (emotion.emotionKeys != null)
{ {
foreach (var key in emotion.emotionKeys) foreach (var key in emotion.emotionKeys)
{ {
if (morphs.ContainsKey(key.morph)) key.morph.Weight += key.weight / 100 * emotion.Weight;
{
morphs[key.morph] = key.morph.Weight + key.weight / 100 * emotion.Weight;
}
else
{
morphs.Add(key.morph, key.morph.Weight + key.weight / 100 * emotion.Weight);
}
} }
} }
FaceDrivenKeyTarget.ChangeMorphWeights(morphs);
} }
FaceDrivenKeyTarget.ChangeMorph();
} }
} }