Browse Source

Fix face shapekeys in ShapeAnimator breaking face

Closes #33
habeebweeb 3 years ago
parent
commit
5b6b7148f1

+ 1 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/FaceWindowPanes/MaidFaceSliderPane.cs

@@ -10,7 +10,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     using static Meido;
     public class MaidFaceSliderPane : BasePane
     {
-        // TODO: Consider placing in external file to be user editable
         private static readonly Dictionary<string, float> SliderLimits = new Dictionary<string, float>()
         {
             // Eye Shut
@@ -208,9 +207,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         private void SetFaceValue(string key, bool value)
         {
-            float max = (key == "hoho" || key == "hoho2") ? 0.5f : 1f;
             if (key == "toothoff") value = !value;
-            SetFaceValue(key, value ? max : 0f);
+            SetFaceValue(key, value ? 1f : 0f);
         }
     }
 }

+ 27 - 7
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/Meido.cs

@@ -562,21 +562,41 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 BackupBlendSetValues();
 
                 Maid.FaceAnime(blendSet, 0f);
+
+                var morph = Body.Face.morph;
+
+                foreach (var faceKey in faceKeys)
+                {
+                    var hash = Utility.GP01FbFaceHash(morph, faceKey);
+                    if (!morph.Contains(hash)) continue;
+
+                    var blendIndex = (int) morph.hash[hash];
+                    var value = faceKey == "nosefook"
+                        ? Maid.boNoseFook || morph.boNoseFook ? 1f : 0f
+                        : morph.dicBlendSet[CurrentFaceBlendSet][blendIndex];
+
+                    morph.SetBlendValues(blendIndex, value);
+                }
+
+                morph.FixBlendValues();
             }
 
             StopBlink();
             OnUpdateMeido();
         }
 
-        public void SetFaceBlendValue(string hash, float value)
+        public void SetFaceBlendValue(string faceKey, float value)
         {
             TMorph morph = Body.Face.morph;
-            hash = Utility.GP01FbFaceHash(morph, hash);
-            if (morph.Contains(hash))
-            {
-                if (hash == "nosefook") Maid.boNoseFook = morph.boNoseFook = value > 0f;
-                else morph.dicBlendSet[CurrentFaceBlendSet][(int)morph.hash[hash]] = value;
-            }
+            var hash = Utility.GP01FbFaceHash(morph, faceKey);
+            if (!morph.Contains(hash)) return;
+
+            var blendIndex = (int) morph.hash[hash];
+            if (faceKey == "nosefook") Maid.boNoseFook = morph.boNoseFook = value > 0f;
+            else morph.dicBlendSet[CurrentFaceBlendSet][blendIndex] = value;
+
+            morph.SetBlendValues(blendIndex, value);
+            morph.FixBlendValues();
         }
 
         public float GetFaceBlendValue(string hash)