2
0
Эх сурвалжийг харах

Bugfixes for skeletal animation and animation editor

BearishSun 9 жил өмнө
parent
commit
da2ccca154

BIN
Data/Engine/GUISkin.asset


BIN
Data/Engine/ResourceManifest.asset


BIN
Data/Engine/Shaders/Default.bsl.asset


BIN
Data/Engine/Timestamp.asset


BIN
Data/Engine/arial.ttf.asset


+ 31 - 3
Data/Raw/Engine/Shaders/Default.bsl

@@ -1,7 +1,6 @@
 #include "$ENGINE$\DeferredBasePass.bslinc"
 
-Technique 
- : inherits("DeferredBasePass") =
+Technique : base("DiffuseCommon") =
 {
 	Language = "HLSL11";
 	
@@ -28,7 +27,21 @@ Technique
 };
 
 Technique 
- : inherits("DeferredBasePass") =
+ : inherits("DeferredBasePass")
+ : inherits("DiffuseCommon") =
+{
+	Language = "HLSL11";
+};
+
+Technique 
+ : inherits("DeferredBasePassSkinned")
+ : inherits("DiffuseCommon") =
+{
+	Language = "HLSL11";
+	Tags = { "Animated" };
+};
+
+Technique : base("DiffuseCommon") =
 {
 	Language = "GLSL";
 	
@@ -51,4 +64,19 @@ Technique
 			}	
 		};
 	};
+};
+
+Technique 
+ : inherits("DeferredBasePass")
+ : inherits("DiffuseCommon") =
+{
+	Language = "GLSL";
+};
+
+Technique 
+ : inherits("DeferredBasePassSkinned")
+ : inherits("DiffuseCommon") =
+{
+	Language = "GLSL";
+	Tags = { "Animated" };
 };

+ 13 - 0
Source/BansheeCore/Include/BsMaterialParamsRTTI.h

@@ -170,6 +170,17 @@ namespace BansheeEngine
 			obj->mSamplerStateParams = obj->mAlloc.construct<MaterialParamSamplerStateData>(size);
 		}
 
+		UINT32& getNumBufferParams(MaterialParams* obj)
+		{
+			return obj->mNumBufferParams;
+		}
+
+		void setNumBufferParams(MaterialParams* obj, UINT32& value)
+		{
+			obj->mNumBufferParams = value;
+			obj->mBufferParams = obj->mAlloc.construct<MaterialParamBufferData>(value);
+		}
+
 		MaterialParamsRTTI()
 		{
 			addPlainArrayField("paramData", 0, &MaterialParamsRTTI::getParamData, &MaterialParamsRTTI::getParamDataArraySize, 
@@ -185,6 +196,8 @@ namespace BansheeEngine
 
 			addReflectablePtrArrayField("samplerStateParams", 4, &MaterialParamsRTTI::getSamplerStateParam,
 				&MaterialParamsRTTI::getSamplerStateArraySize, &MaterialParamsRTTI::setSamplerStateParam, &MaterialParamsRTTI::setSamplerStateArraySize);
+
+			addPlainField("numBufferParams", 5, &MaterialParamsRTTI::getNumBufferParams, &MaterialParamsRTTI::setNumBufferParams);
 		}
 
 		void onSerializationStarted(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override

+ 1 - 1
Source/BansheeCore/Source/BsAnimation.cpp

@@ -1105,7 +1105,7 @@ namespace BansheeEngine
 
 		// Must ensure that clip in the proxy and current primary clip are the same
 		mGenericCurveValuesValid = false;
-		if(mAnimProxy->numLayers > 0 || mAnimProxy->layers[0].numStates > 0)
+		if(mAnimProxy->numLayers > 0 && mAnimProxy->layers[0].numStates > 0)
 		{
 			const AnimationState& state = mAnimProxy->layers[0].states[0];
 

+ 17 - 17
Source/BansheeUtility/Include/BsRTTIPrerequisites.h

@@ -189,7 +189,7 @@ namespace BansheeEngine
 
 			for(auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				UINT32 elementSize = RTTIPlainType<T>::getDynamicSize(*iter);
+				UINT32 elementSize = rttiGetElemSize(*iter);
 				RTTIPlainType<T>::toMemory(*iter, memory);
 
 				memory += elementSize;
@@ -227,8 +227,8 @@ namespace BansheeEngine
 		{ 
 			UINT64 dataSize = sizeof(UINT32) * 2;
 
-			for(auto iter = data.begin(); iter != data.end(); ++iter)
-				dataSize += RTTIPlainType<T>::getDynamicSize(*iter);		
+			for (auto iter = data.begin(); iter != data.end(); ++iter)
+				dataSize += rttiGetElemSize(*iter);
 
 			assert(dataSize <= std::numeric_limits<UINT32>::max());
 
@@ -259,7 +259,7 @@ namespace BansheeEngine
 
 			for(auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				UINT32 elementSize = RTTIPlainType<T>::getDynamicSize(*iter);
+				UINT32 elementSize = rttiGetElemSize(*iter);
 				RTTIPlainType<T>::toMemory(*iter, memory);
 
 				memory += elementSize;
@@ -298,7 +298,7 @@ namespace BansheeEngine
 			UINT64 dataSize = sizeof(UINT32) * 2;
 
 			for(auto iter = data.begin(); iter != data.end(); ++iter)
-				dataSize += RTTIPlainType<T>::getDynamicSize(*iter);		
+				dataSize += rttiGetElemSize(*iter);
 
 			assert(dataSize <= std::numeric_limits<UINT32>::max());
 
@@ -329,13 +329,13 @@ namespace BansheeEngine
 
 			for(auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				UINT32 keySize = RTTIPlainType<Key>::getDynamicSize(iter->first);
+				UINT32 keySize = rttiGetElemSize(iter->first);
 				RTTIPlainType<Key>::toMemory(iter->first, memory);
 
 				memory += keySize;
 				size += keySize;
 
-				UINT32 valueSize = RTTIPlainType<Value>::getDynamicSize(iter->second);
+				UINT32 valueSize = rttiGetElemSize(iter->second);
 				RTTIPlainType<Value>::toMemory(iter->second, memory);
 
 				memory += valueSize;
@@ -379,8 +379,8 @@ namespace BansheeEngine
 
 			for(auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				dataSize += RTTIPlainType<Key>::getDynamicSize(iter->first);		
-				dataSize += RTTIPlainType<Value>::getDynamicSize(iter->second);
+				dataSize += rttiGetElemSize(iter->first);
+				dataSize += rttiGetElemSize(iter->second);
 			}
 
 			assert(dataSize <= std::numeric_limits<UINT32>::max());
@@ -415,13 +415,13 @@ namespace BansheeEngine
 
 			for (auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				UINT32 keySize = RTTIPlainType<Key>::getDynamicSize(iter->first);
+				UINT32 keySize = rttiGetElemSize(iter->first);
 				RTTIPlainType<Key>::toMemory(iter->first, memory);
 
 				memory += keySize;
 				size += keySize;
 
-				UINT32 valueSize = RTTIPlainType<Value>::getDynamicSize(iter->second);
+				UINT32 valueSize = rttiGetElemSize(iter->second);
 				RTTIPlainType<Value>::toMemory(iter->second, memory);
 
 				memory += valueSize;
@@ -501,7 +501,7 @@ namespace BansheeEngine
 
 			for (auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				UINT32 keySize = RTTIPlainType<Key>::getDynamicSize(*iter);
+				UINT32 keySize = rttiGetElemSize(*iter);
 				RTTIPlainType<Key>::toMemory(*iter, memory);
 
 				memory += keySize;
@@ -541,7 +541,7 @@ namespace BansheeEngine
 
 			for (auto iter = data.begin(); iter != data.end(); ++iter)
 			{
-				dataSize += RTTIPlainType<Key>::getDynamicSize(*iter);
+				dataSize += rttiGetElemSize(*iter);
 			}
 
 			assert(dataSize <= std::numeric_limits<UINT32>::max());
@@ -566,13 +566,13 @@ namespace BansheeEngine
 			char* memoryStart = memory;
 			memory += sizeof(UINT32);
 
-			UINT32 firstSize = RTTIPlainType<A>::getDynamicSize(data.first);
+			UINT32 firstSize = rttiGetElemSize(data.first);
 			RTTIPlainType<A>::toMemory(data.first, memory);
 
 			memory += firstSize;
 			size += firstSize;
 
-			UINT32 secondSize = RTTIPlainType<B>::getDynamicSize(data.second);
+			UINT32 secondSize = rttiGetElemSize(data.second);
 			RTTIPlainType<B>::toMemory(data.second, memory);
 
 			memory += secondSize;
@@ -601,8 +601,8 @@ namespace BansheeEngine
 		static UINT32 getDynamicSize(const std::pair<A, B>& data)	
 		{ 
 			UINT64 dataSize = sizeof(UINT32);
-			dataSize += RTTIPlainType<A>::getDynamicSize(data.first);		
-			dataSize += RTTIPlainType<B>::getDynamicSize(data.second);
+			dataSize += rttiGetElemSize(data.first);
+			dataSize += rttiGetElemSize(data.second);
 
 			assert(dataSize <= std::numeric_limits<UINT32>::max());
 

+ 0 - 2
Source/MBansheeEditor/Inspectors/MaterialInspector.cs

@@ -40,7 +40,6 @@ namespace BansheeEditor
                 RebuildParamGUI(material);
 
                 bool newIsCustom = newBuiltinType == BuiltinShader.Custom;
-                builtinShaderField.Active = !newIsCustom;
                 shaderField.Active = newIsCustom;
             };
 
@@ -56,7 +55,6 @@ namespace BansheeEditor
             };
 
             bool isCustom = builtinType == BuiltinShader.Custom;
-            builtinShaderField.Active = !isCustom;
             shaderField.Active = isCustom;
 
             Layout.AddElement(builtinShaderField);

+ 17 - 1
Source/MBansheeEditor/Window/MenuItems.cs

@@ -411,7 +411,7 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Adds an ANimation component to the currently selected scene object.
+        /// Adds an Animation component to the currently selected scene object.
         /// </summary>
         [MenuItem("Components/Animation", 7029)]
         private static void AddAnimation()
@@ -425,6 +425,22 @@ namespace BansheeEditor
             EditorApplication.SetSceneDirty();
         }
 
+
+        /// <summary>
+        /// Adds a Bone component to the currently selected scene object.
+        /// </summary>
+        [MenuItem("Components/Bone", 7028)]
+        private static void AddBone()
+        {
+            SceneObject so = Selection.SceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, false, "Added an Bone component");
+            so.AddComponent<Bone>();
+            EditorApplication.SetSceneDirty();
+        }
+
         /// <summary>
         /// Creates a new empty scene object.
         /// </summary>

+ 10 - 6
Source/MBansheeEditor/Windows/Animation/EditorAnimInfo.cs

@@ -111,14 +111,18 @@ namespace BansheeEditor
                         TangentMode[] tangentsX = null;
                         TangentMode[] tangentsY = null;
                         TangentMode[] tangentsZ = null;
-                        foreach (var tangentEntry in tangents)
+
+                        if (tangents != null)
                         {
-                            if (tangentEntry.name == curveEntry.Name)
+                            foreach (var tangentEntry in tangents)
                             {
-                                tangentsX = tangentEntry.tangentsX;
-                                tangentsY = tangentEntry.tangentsY;
-                                tangentsZ = tangentEntry.tangentsZ;
-                                break;
+                                if (tangentEntry.name == curveEntry.Name)
+                                {
+                                    tangentsX = tangentEntry.tangentsX;
+                                    tangentsY = tangentEntry.tangentsY;
+                                    tangentsZ = tangentEntry.tangentsZ;
+                                    break;
+                                }
                             }
                         }
 

+ 7 - 15
Source/MBansheeEditor/Windows/Animation/GUIGraphValues.cs

@@ -79,23 +79,16 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Draws text displaying the time at the provided position.
+        /// Draws text displaying the value at the provided position.
         /// </summary>
         /// <param name="yPos">Position to draw the text at.</param>
-        /// <param name="seconds">Time to display, in seconds.</param>
-        /// <param name="minutes">If true the time will be displayed in minutes, otherwise in seconds.</param>
+        /// <param name="value">Value to display.</param>
         /// <param name="above">If true the text will be displayed above the provided position, otherwise below.</param>
-        private void DrawTime(int yPos, float seconds, bool minutes, bool above)
+        private void DrawValue(int yPos, float value,  bool above)
         {
-            TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
+            string valueString = value.ToString();
 
-            string timeString;
-            if (minutes)
-                timeString = timeSpan.TotalMinutes.ToString("#0") + ":" + timeSpan.Seconds.ToString("D2");
-            else
-                timeString = timeSpan.TotalSeconds.ToString("#0.00");
-
-            Vector2I textBounds = GUIUtility.CalculateTextBounds(timeString, EditorBuiltin.DefaultFont,
+            Vector2I textBounds = GUIUtility.CalculateTextBounds(valueString, EditorBuiltin.DefaultFont,
                 EditorStyles.DefaultFontSize);
 
             Vector2I textPosition = new Vector2I();
@@ -108,7 +101,7 @@ namespace BansheeEditor
                 const int PADDING = 3; // So the text doesn't touch the tick
                 textPosition.y = yPos + PADDING;
             }
-            canvas.DrawText(timeString, textPosition, EditorBuiltin.DefaultFont, COLOR_TRANSPARENT_LIGHT_GRAY,
+            canvas.DrawText(valueString, textPosition, EditorBuiltin.DefaultFont, COLOR_TRANSPARENT_LIGHT_GRAY,
                 EditorStyles.DefaultFontSize);
         }
 
@@ -138,7 +131,6 @@ namespace BansheeEditor
                 if (ticks.Length > 0)
                 {
                     float valuePerTick = (rangeEnd - rangeStart)/ticks.Length;
-                    bool displayAsMinutes = TimeSpan.FromSeconds(valuePerTick).Minutes > 0;
 
                     for (int j = 0; j < ticks.Length; j++)
                     {
@@ -155,7 +147,7 @@ namespace BansheeEditor
 
                         // Draw text for the highest level ticks
                         if (i == 0)
-                            DrawTime(yPos, ticks[j], displayAsMinutes, ticks[j] <= 0.0f);
+                            DrawValue(yPos, ticks[j], ticks[j] <= 0.0f);
                     }
                 }
             }

+ 15 - 10
Source/MBansheeEditor/Windows/AnimationWindow.cs

@@ -362,7 +362,6 @@ namespace BansheeEditor
             horzScrollBar.SetWidth(curveEditorSize.x);
             vertScrollBar.SetHeight(curveEditorSize.y);
 
-            SetCurrentFrame(currentFrameIdx);
             UpdateScrollBarSize();
         }
 
@@ -562,6 +561,8 @@ namespace BansheeEditor
 
             guiCurveEditor.Events = clipInfo.events;
             guiCurveEditor.DisableCurveEdit = clipIsImported;
+
+            SetCurrentFrame(0);
         }
 
         private static bool IsClipImported(AnimationClip clip)
@@ -594,10 +595,10 @@ namespace BansheeEditor
                 selectedSO = so;
                 selectedFields.Clear();
 
-                RebuildGUI();
-
                 clipInfo = null;
 
+                RebuildGUI();
+
                 // Load existing clip if one exists
                 if (selectedSO != null)
                 {
@@ -730,7 +731,7 @@ namespace BansheeEditor
             return new Vector2(xRange, yRange);
         }
 
-        private void UpdateDisplayedCurves()
+        private void UpdateDisplayedCurves(bool allowReduce = false)
         {
             List<EdAnimationCurve> curvesToDisplay = new List<EdAnimationCurve>();
             for (int i = 0; i < selectedFields.Count; i++)
@@ -743,10 +744,12 @@ namespace BansheeEditor
             guiCurveEditor.SetCurves(curvesToDisplay.ToArray());
 
             Vector2 newRange = GetOptimalRange();
-
-            // Don't reduce visible range
-            newRange.x = Math.Max(newRange.x, guiCurveEditor.Range.x);
-            newRange.y = Math.Max(newRange.y, guiCurveEditor.Range.y);
+            if (!allowReduce)
+            {
+                // Don't reduce visible range
+                newRange.x = Math.Max(newRange.x, guiCurveEditor.Range.x);
+                newRange.y = Math.Max(newRange.y, guiCurveEditor.Range.y);
+            }
 
             guiCurveEditor.Range = newRange;
             UpdateScrollBarSize();
@@ -758,6 +761,7 @@ namespace BansheeEditor
 
         private void AddNewField(string path, SerializableProperty.FieldType type)
         {
+            bool noSelection = selectedFields.Count == 0;
             guiFieldDisplay.AddField(path);
 
             switch (type)
@@ -845,7 +849,7 @@ namespace BansheeEditor
             }
 
             EditorApplication.SetProjectDirty();
-            UpdateDisplayedCurves();
+            UpdateDisplayedCurves(noSelection);
         }
 
         private void SelectField(string path, bool additive)
@@ -853,6 +857,7 @@ namespace BansheeEditor
             if (!additive)
                 selectedFields.Clear();
 
+            bool noSelection = selectedFields.Count == 0;
             if (!string.IsNullOrEmpty(path))
             {
                 selectedFields.RemoveAll(x => { return x == path || IsPathParent(x, path); });
@@ -861,7 +866,7 @@ namespace BansheeEditor
 
             guiFieldDisplay.SetSelection(selectedFields.ToArray());
 
-            UpdateDisplayedCurves();
+            UpdateDisplayedCurves(noSelection);
         }
 
         private void RemoveSelectedFields()

+ 1 - 1
Source/MBansheeEngine/Animation/Interop/NativeAnimation.cs

@@ -118,7 +118,7 @@ namespace BansheeEngine
 
         public void MapCurveToSceneObject(string curve, SceneObject sceneObject)
         {
-            if (string.IsNullOrEmpty(curve) || sceneObject == null)
+            if (curve == null || sceneObject == null)
                 return;
 
             Internal_MapCurveToSceneObject(mCachedPtr, curve, sceneObject.GetCachedPtr());

+ 4 - 4
Source/RenderBeast/Source/BsRenderBeast.cpp

@@ -200,11 +200,11 @@ namespace BansheeEngine
 				else
 				{
 					RendererMaterial& matInfo = any_cast_ref<RendererMaterial>(materialInfo);
-					if(matInfo.matVersion != renElement.material->getVersion())
-					{
-						if (matInfo.params.size() <= techniqueIdx)
-							matInfo.params.resize(techniqueIdx + 1);
+					if (matInfo.params.size() <= techniqueIdx)
+						matInfo.params.resize(techniqueIdx + 1);
 
+					if(matInfo.params[techniqueIdx] == nullptr || matInfo.matVersion != renElement.material->getVersion())
+					{
 						matInfo.params[techniqueIdx] = renElement.material->createParamsSet(techniqueIdx);
 						matInfo.matVersion = renElement.material->getVersion();
 

+ 1 - 1
Source/SBansheeEditor/Source/BsScriptImportOptions.cpp

@@ -672,7 +672,7 @@ namespace BansheeEngine
 		bool isAdditive = splitInfo.isAdditive;
 
 		void* params[4] = { monoString, &startFrame, &endFrame, &isAdditive };
-		return metaData.scriptClass->createInstance("string, int, int, bool", params);
+		return metaData.scriptClass->createInstance("string,int,int,bool", params);
 	}
 
 	MonoField* ScriptImportedAnimationEvents::nameField = nullptr;

+ 1 - 1
Source/SBansheeEngine/Source/BsScriptAnimationClip.cpp

@@ -122,6 +122,6 @@ namespace BansheeEngine
 		float time = event.time;
 
 		void* params[2] = { monoString, &time };
-		return metaData.scriptClass->createInstance("string, float", params);
+		return metaData.scriptClass->createInstance("string,float", params);
 	}
 }

+ 2 - 2
Source/SBansheeEngine/Source/BsScriptAnimationCurves.cpp

@@ -287,7 +287,7 @@ namespace BansheeEngine
 		UINT32 flags = curve.flags;
 
 		void* params[5] = { monoString, &flags, monoXCurve, monoYCurve, monoZCurve };
-		return metaData.scriptClass->createInstance("string, int, AnimationCurve, AnimationCurve, AnimationCurve", params);
+		return metaData.scriptClass->createInstance("string,int,AnimationCurve,AnimationCurve,AnimationCurve", params);
 	}
 
 	MonoField* ScriptNamedFloatCurve::sNameField = nullptr;
@@ -337,6 +337,6 @@ namespace BansheeEngine
 
 		UINT32 flags = curve.flags;
 		void* params[3] = { monoString, &flags, monoCurve };
-		return metaData.scriptClass->createInstance("string, int, AnimationCurve", params);
+		return metaData.scriptClass->createInstance("string,int,AnimationCurve", params);
 	}
 }