Преглед изворни кода

Morph shape curves are no longer displayed as normal property curves

BearishSun пре 9 година
родитељ
комит
829132c60f

+ 25 - 0
Source/MBansheeEditor/Windows/Animation/EditorAnimInfo.cs

@@ -19,6 +19,7 @@ namespace BansheeEditor
     {
         public SerializableProperty.FieldType type;
         public CurveDrawInfo[] curveInfos;
+        public bool isPropertyCurve;
     }
 
     /// <summary>
@@ -142,6 +143,7 @@ namespace BansheeEditor
                         FieldAnimCurves fieldCurves = new FieldAnimCurves();
                         fieldCurves.type = SerializableProperty.FieldType.Vector3;
                         fieldCurves.curveInfos = new CurveDrawInfo[3];
+                        fieldCurves.isPropertyCurve = !clipInfo.isImported;
 
                         fieldCurves.curveInfos[0] = new CurveDrawInfo();
                         fieldCurves.curveInfos[0].curve = new EdAnimationCurve(curveEntry.X, tangentsX);
@@ -250,6 +252,7 @@ namespace BansheeEditor
                 }
 
                 fieldCurves.curveInfos = new CurveDrawInfo[numCurves];
+                fieldCurves.isPropertyCurve = !clipInfo.isImported && !IsMorphShapeCurve(KVP.Key);
 
                 for (int i = 0; i < numCurves; i++)
                 {
@@ -286,6 +289,28 @@ namespace BansheeEditor
             return ProjectLibrary.IsSubresource(resourcePath);
         }
 
+        /// <summary>
+        /// Checks does a curve with the specified path represent a curve affecting a morph shape.
+        /// </summary>
+        /// <param name="path">Path of the curve to check.</param>
+        /// <returns>True if morph shape frame or weight animation, false otherwise.</returns>
+        public static bool IsMorphShapeCurve(string path)
+        {
+            if (string.IsNullOrEmpty(path))
+                return false;
+
+            string trimmedPath = path.Trim('/');
+            string[] entries = trimmedPath.Split('/');
+
+            if (entries.Length < 3)
+                return true;
+
+            if (entries[entries.Length - 2] != "MorphShapes")
+                return false;
+
+            return entries[entries.Length - 1] == "Frames" || entries[entries.Length - 1] == "Weight";
+        }
+
         /// <summary>
         /// Applies any changes made to the animation curves or events to the actual animation clip. Only works for
         /// non-imported animation clips.

+ 4 - 6
Source/MBansheeEditor/Windows/Animation/GUIAnimFieldDisplay.cs

@@ -195,7 +195,7 @@ namespace BansheeEditor
                     continue;
 
                 bool entryIsMissing;
-                if (fieldInfos[i].isUserCurve)
+                if (fieldInfos[i].curveGroup.isPropertyCurve)
                 {
                     string pathSuffix;
                     SerializableProperty property = Animation.FindProperty(root, fieldInfos[i].path, out pathSuffix);
@@ -299,7 +299,7 @@ namespace BansheeEditor
     /// </summary>
     internal abstract class GUIAnimFieldEntry
     {
-        private const int MAX_PATH_LENGTH = 30;
+        private const int MAX_PATH_LENGTH = 20;
         protected const int INDENT_AMOUNT = 10;
 
         protected string path;
@@ -781,7 +781,7 @@ namespace BansheeEditor
         public GUIAnimMissingEntry(GUIAnimFieldLayouts layouts, string path)
             : base(layouts, path, false, 15)
         {
-            missingLabel = new GUILabel("Missing property!", GUIOption.FixedHeight(GetEntryHeight()));
+            missingLabel = new GUILabel("Missing!", GUIOption.FixedHeight(GetEntryHeight()));
             underlayLayout = layouts.underlay.AddLayoutX();
             underlayLayout.AddFlexibleSpace();
             underlayLayout.AddElement(missingLabel);
@@ -806,16 +806,14 @@ namespace BansheeEditor
     /// </summary>
     internal struct AnimFieldInfo
     {
-        public AnimFieldInfo(string path, FieldAnimCurves curveGroup, bool isUserCurve)
+        public AnimFieldInfo(string path, FieldAnimCurves curveGroup)
         {
             this.path = path;
             this.curveGroup = curveGroup;
-            this.isUserCurve = isUserCurve;
         }
 
         public string path;
         public FieldAnimCurves curveGroup;
-        public bool isUserCurve;
     }
 
     /** @} */

+ 0 - 3
Source/MBansheeEditor/Windows/Animation/GUIFieldSelector.cs

@@ -248,14 +248,11 @@ namespace BansheeEditor
             }
 
             // Handle special fields
-            Debug.Log("Type: " + serializableObject.Type);
             if (serializableObject.Type == typeof(Animation))
             {
                 Animation anim = serializableObject.Object as Animation;
-                Debug.Log("Anim: " + (anim != null));
                 MorphShapes morphShapes = anim?.SceneObject.GetComponent<Renderable>()?.Mesh?.MorphShapes;
 
-                Debug.Log("Shapes: " + (morphShapes != null));
                 if (morphShapes != null)
                 {
                     string propertyPath = parent.path + "/MorphShapes";

+ 9 - 3
Source/MBansheeEditor/Windows/AnimationWindow.cs

@@ -710,7 +710,7 @@ namespace BansheeEditor
             persistentData.dirtyAnimClips[clip.UUID] = clipInfo;
 
             foreach (var curve in clipInfo.curves)
-                guiFieldDisplay.AddField(new AnimFieldInfo(curve.Key, curve.Value, !clipInfo.isImported));
+                guiFieldDisplay.AddField(new AnimFieldInfo(curve.Key, curve.Value));
 
             guiCurveEditor.Events = clipInfo.events;
             guiCurveEditor.DisableCurveEdit = clipInfo.isImported;
@@ -1346,13 +1346,15 @@ namespace BansheeEditor
         private void AddNewField(string path, SerializableProperty.FieldType type)
         {
             bool noSelection = selectedFields.Count == 0;
-            
+            bool isPropertyCurve = !clipInfo.isImported && !EditorAnimClipInfo.IsMorphShapeCurve(path);
+
             switch (type)
             {
                 case SerializableProperty.FieldType.Vector4:
                     {
                         FieldAnimCurves fieldCurves = new FieldAnimCurves();
                         fieldCurves.type = type;
+                        fieldCurves.isPropertyCurve = isPropertyCurve;
                         fieldCurves.curveInfos = new CurveDrawInfo[4];
 
                         string[] subPaths = { ".x", ".y", ".z", ".w" };
@@ -1370,6 +1372,7 @@ namespace BansheeEditor
                     {
                         FieldAnimCurves fieldCurves = new FieldAnimCurves();
                         fieldCurves.type = type;
+                        fieldCurves.isPropertyCurve = isPropertyCurve;
                         fieldCurves.curveInfos = new CurveDrawInfo[3];
 
                         string[] subPaths = { ".x", ".y", ".z" };
@@ -1387,6 +1390,7 @@ namespace BansheeEditor
                     {
                         FieldAnimCurves fieldCurves = new FieldAnimCurves();
                         fieldCurves.type = type;
+                        fieldCurves.isPropertyCurve = isPropertyCurve;
                         fieldCurves.curveInfos = new CurveDrawInfo[2];
 
                         string[] subPaths = { ".x", ".y" };
@@ -1404,6 +1408,7 @@ namespace BansheeEditor
                     {
                         FieldAnimCurves fieldCurves = new FieldAnimCurves();
                         fieldCurves.type = type;
+                        fieldCurves.isPropertyCurve = isPropertyCurve;
                         fieldCurves.curveInfos = new CurveDrawInfo[4];
 
                         string[] subPaths = { ".r", ".g", ".b", ".a" };
@@ -1421,6 +1426,7 @@ namespace BansheeEditor
                     {
                         FieldAnimCurves fieldCurves = new FieldAnimCurves();
                         fieldCurves.type = type;
+                        fieldCurves.isPropertyCurve = isPropertyCurve;
                         fieldCurves.curveInfos = new CurveDrawInfo[1];
 
                         fieldCurves.curveInfos[0].curve = new EdAnimationCurve();
@@ -1484,7 +1490,7 @@ namespace BansheeEditor
         {
             List<AnimFieldInfo> existingFields = new List<AnimFieldInfo>();
             foreach (var KVP in clipInfo.curves)
-                existingFields.Add(new AnimFieldInfo(KVP.Key, KVP.Value, !clipInfo.isImported));
+                existingFields.Add(new AnimFieldInfo(KVP.Key, KVP.Value));
 
             guiFieldDisplay.SetFields(existingFields.ToArray());
         }