Bladeren bron

Properly map user-made morph curves to internal morph curve names
Properly map imported morph curve names to morph curve paths

BearishSun 9 jaren geleden
bovenliggende
commit
6bd998abef

+ 4 - 4
Source/BansheeCore/Source/BsAnimationManager.cpp

@@ -310,7 +310,7 @@ namespace BansheeEngine
 							if (diff > 0.0f)
 							if (diff > 0.0f)
 							{
 							{
 								float t = -relative / diff;
 								float t = -relative / diff;
-								shapeInfo.finalWeight = std::min(t, 1.0f);
+								shapeInfo.finalWeight = 1.0f - std::min(t, 1.0f);
 							}
 							}
 							else
 							else
 								shapeInfo.finalWeight = 1.0f;
 								shapeInfo.finalWeight = 1.0f;
@@ -338,7 +338,7 @@ namespace BansheeEngine
 								if (diff > 0.0f)
 								if (diff > 0.0f)
 								{
 								{
 									float t = -relative / diff;
 									float t = -relative / diff;
-									shapeInfo.finalWeight = std::min(t, 1.0f);
+									shapeInfo.finalWeight = 1.0f - std::min(t, 1.0f);
 								}
 								}
 								else
 								else
 									shapeInfo.finalWeight = 1.0f;
 									shapeInfo.finalWeight = 1.0f;
@@ -349,7 +349,7 @@ namespace BansheeEngine
 								if (diff > 0.0f)
 								if (diff > 0.0f)
 								{
 								{
 									float t = relative / diff;
 									float t = relative / diff;
-									shapeInfo.finalWeight = 1.0f - std::min(t, 1.0f);
+									shapeInfo.finalWeight = std::min(t, 1.0f);
 								}
 								}
 								else
 								else
 									shapeInfo.finalWeight = 0.0f;
 									shapeInfo.finalWeight = 0.0f;
@@ -369,7 +369,7 @@ namespace BansheeEngine
 								if (diff > 0.0f)
 								if (diff > 0.0f)
 								{
 								{
 									float t = -relative / diff;
 									float t = -relative / diff;
-									shapeInfo.finalWeight = std::min(t, 1.0f);
+									shapeInfo.finalWeight = 1.0f - std::min(t, 1.0f);
 								}
 								}
 								else
 								else
 									shapeInfo.finalWeight = 1.0f;
 									shapeInfo.finalWeight = 1.0f;

+ 58 - 24
Source/MBansheeEditor/Windows/Animation/EditorAnimInfo.cs

@@ -251,9 +251,10 @@ namespace BansheeEditor
                         fieldCurves.type = SerializableProperty.FieldType.Color;
                         fieldCurves.type = SerializableProperty.FieldType.Color;
                 }
                 }
 
 
-                fieldCurves.curveInfos = new CurveDrawInfo[numCurves];
-                fieldCurves.isPropertyCurve = !clipInfo.isImported && !IsMorphShapeCurve(KVP.Key);
+                bool isMorphCurve = false;
+                string curvePath = KVP.Key;
 
 
+                fieldCurves.curveInfos = new CurveDrawInfo[numCurves];
                 for (int i = 0; i < numCurves; i++)
                 for (int i = 0; i < numCurves; i++)
                 {
                 {
                     int curveIdx = KVP.Value[i].Item1;
                     int curveIdx = KVP.Value[i].Item1;
@@ -266,9 +267,21 @@ namespace BansheeEditor
                     fieldCurves.curveInfos[i] = new CurveDrawInfo();
                     fieldCurves.curveInfos[i] = new CurveDrawInfo();
                     fieldCurves.curveInfos[i].curve = new EdAnimationCurve(clipCurves.FloatCurves[curveIdx].Curve, tangents);
                     fieldCurves.curveInfos[i].curve = new EdAnimationCurve(clipCurves.FloatCurves[curveIdx].Curve, tangents);
                     fieldCurves.curveInfos[i].color = GUICurveDrawing.GetUniqueColor(globalCurveIdx++);
                     fieldCurves.curveInfos[i].color = GUICurveDrawing.GetUniqueColor(globalCurveIdx++);
+
+                    if (clipCurves.FloatCurves[curveIdx].Flags.HasFlag(AnimationCurveFlags.MorphFrame))
+                    {
+                        curvePath = "MorphShapes/Frames/" + KVP.Key;
+                        isMorphCurve = true;
+                    }
+                    else if (clipCurves.FloatCurves[curveIdx].Flags.HasFlag(AnimationCurveFlags.MorphWeight))
+                    {
+                        curvePath = "MorphShapes/Weight/" + KVP.Key;
+                        isMorphCurve = true;
+                    }
                 }
                 }
 
 
-                string curvePath = KVP.Key;
+                fieldCurves.isPropertyCurve = !clipInfo.isImported && !isMorphCurve;
+
                 clipInfo.curves[curvePath] = fieldCurves;
                 clipInfo.curves[curvePath] = fieldCurves;
             }
             }
 
 
@@ -303,12 +316,12 @@ namespace BansheeEditor
             string[] entries = trimmedPath.Split('/');
             string[] entries = trimmedPath.Split('/');
 
 
             if (entries.Length < 3)
             if (entries.Length < 3)
-                return true;
+                return false;
 
 
             if (entries[entries.Length - 3] != "MorphShapes")
             if (entries[entries.Length - 3] != "MorphShapes")
                 return false;
                 return false;
 
 
-            return entries[entries.Length - 2] == "Frames" || entries[entries.Length - 2] == "Weight";
+            return entries[entries.Length - 2] == "Weight" || entries[entries.Length - 2] == "Frames";
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -382,15 +395,16 @@ namespace BansheeEditor
                 }
                 }
                 else
                 else
                 {
                 {
-                    Action<int, string> addCurve = (idx, subPath) =>
+                    Action<int, string, string, AnimationCurveFlags> addCurve = (idx, path, subPath, flags) =>
                     {
                     {
-                        string path = kvp.Key + subPath;
+                        string fullPath = path + subPath;
 
 
-                        NamedFloatCurve curve = new NamedFloatCurve(path,
-                        new AnimationCurve(kvp.Value.curveInfos[idx].curve.KeyFrames));
+                        NamedFloatCurve curve = new NamedFloatCurve(fullPath,
+                            new AnimationCurve(kvp.Value.curveInfos[idx].curve.KeyFrames));
+                        curve.Flags = flags;
 
 
                         EditorFloatCurveTangents curveTangents = new EditorFloatCurveTangents();
                         EditorFloatCurveTangents curveTangents = new EditorFloatCurveTangents();
-                        curveTangents.name = path;
+                        curveTangents.name = fullPath;
                         curveTangents.tangents = kvp.Value.curveInfos[idx].curve.TangentModes;
                         curveTangents.tangents = kvp.Value.curveInfos[idx].curve.TangentModes;
 
 
                         floatCurves.Add(curve);
                         floatCurves.Add(curve);
@@ -400,30 +414,50 @@ namespace BansheeEditor
                     switch (kvp.Value.type)
                     switch (kvp.Value.type)
                     {
                     {
                         case SerializableProperty.FieldType.Vector2:
                         case SerializableProperty.FieldType.Vector2:
-                            addCurve(0, ".x");
-                            addCurve(1, ".y");
+                            addCurve(0, kvp.Key, ".x", 0);
+                            addCurve(1, kvp.Key, ".y", 0);
                             break;
                             break;
                         case SerializableProperty.FieldType.Vector3:
                         case SerializableProperty.FieldType.Vector3:
-                            addCurve(0, ".x");
-                            addCurve(1, ".y");
-                            addCurve(2, ".z");
+                            addCurve(0, kvp.Key, ".x", 0);
+                            addCurve(1, kvp.Key, ".y", 0);
+                            addCurve(2, kvp.Key, ".z", 0);
                             break;
                             break;
                         case SerializableProperty.FieldType.Vector4:
                         case SerializableProperty.FieldType.Vector4:
-                            addCurve(0, ".x");
-                            addCurve(1, ".y");
-                            addCurve(2, ".z");
-                            addCurve(3, ".w");
+                            addCurve(0, kvp.Key, ".x", 0);
+                            addCurve(1, kvp.Key, ".y", 0);
+                            addCurve(2, kvp.Key, ".z", 0);
+                            addCurve(3, kvp.Key, ".w", 0);
                             break;
                             break;
                         case SerializableProperty.FieldType.Color:
                         case SerializableProperty.FieldType.Color:
-                            addCurve(0, ".r");
-                            addCurve(1, ".g");
-                            addCurve(2, ".b");
-                            addCurve(3, ".a");
+                            addCurve(0, kvp.Key, ".r", 0);
+                            addCurve(1, kvp.Key, ".g", 0);
+                            addCurve(2, kvp.Key, ".b", 0);
+                            addCurve(3, kvp.Key, ".a", 0);
                             break;
                             break;
                         case SerializableProperty.FieldType.Bool:
                         case SerializableProperty.FieldType.Bool:
                         case SerializableProperty.FieldType.Int:
                         case SerializableProperty.FieldType.Int:
                         case SerializableProperty.FieldType.Float:
                         case SerializableProperty.FieldType.Float:
-                            addCurve(0, "");
+                        {
+                            AnimationCurveFlags flags = 0;
+                            string path = kvp.Key;
+
+                            if (IsMorphShapeCurve(kvp.Key))
+                            {
+                                string trimmedPath = path.Trim('/');
+                                string[] entries = trimmedPath.Split('/');
+
+                                bool isWeight = entries[entries.Length - 2] == "Weight";
+
+                                if (isWeight)
+                                    flags = AnimationCurveFlags.MorphWeight;
+                                else
+                                    flags = AnimationCurveFlags.MorphFrame;
+
+                                path = entries[entries.Length - 1];
+                            }
+
+                            addCurve(0, path, "", flags);
+                        }
                             break;
                             break;
                     }
                     }
                 }
                 }