Marko Pintera 11 лет назад
Родитель
Сommit
cb54b1bd67

+ 1 - 1
CamelotCore/Source/CmCommandQueue.cpp

@@ -113,7 +113,7 @@ namespace CamelotFramework
 				{
 					LOGDBG("Async operation return value wasn't resolved properly. Resolving automatically to nullptr. " \
 						"Make sure to complete the operation before returning from the command callback method.");
-					command.asyncOp->completeOperation(nullptr);
+					command.asyncOp->_completeOperation(nullptr);
 				}
 			}
 			else

+ 2 - 2
CamelotCore/Source/CmRenderSystem.cpp

@@ -298,7 +298,7 @@ namespace CamelotFramework {
 		gProfiler().beginSample("writeSubresourceB");
 
 		data->unlock();
-		asyncOp.completeOperation();
+		asyncOp._completeOperation();
 
 		gProfiler().endSample("writeSubresourceB");
 	}
@@ -311,7 +311,7 @@ namespace CamelotFramework {
 
 		resource->readSubresource(subresourceIdx, *data);
 		data->unlock();
-		asyncOp.completeOperation();
+		asyncOp._completeOperation();
 
 		gProfiler().endSample("readSubresource");
 	}

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -136,7 +136,7 @@ namespace CamelotFramework
 
 		RenderSystem::initialize_internal(asyncOp);
 
-		asyncOp.completeOperation(primaryWindow);
+		asyncOp._completeOperation(primaryWindow);
 	}
 
     void D3D11RenderSystem::destroy_internal()

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -181,7 +181,7 @@ namespace CamelotFramework
 		// call superclass method
 		RenderSystem::initialize_internal(asyncOp);
 
-		asyncOp.completeOperation(primaryWindow);
+		asyncOp._completeOperation(primaryWindow);
 	}
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::destroy_internal()

+ 1 - 1
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -180,7 +180,7 @@ namespace CamelotFramework
 
 		RenderSystem::initialize_internal(asyncOp);
 
-		asyncOp.completeOperation(primaryWindow);
+		asyncOp._completeOperation(primaryWindow);
 	}
 
 	void GLRenderSystem::destroy_internal()

+ 11 - 3
CamelotUtility/Include/CmAsyncOp.h

@@ -11,6 +11,10 @@ namespace CamelotFramework
 	 *			Contains uninitialized data until "hasCompleted" returns true. 
 	 * 			
 	 * @note	You are allowed (and meant to) to copy this by value.
+	 * 			
+	 *			You'll notice mIsCompleted isn't locked. This is safe on x86 architectures because all stores
+	 *			are executed in order. Loads may be executed out of order from stores but worst case scenario is that
+	 *			mIsCompleted reports false a few cycles too late, which is not relevant for practical use.
 	 */
 	class CM_UTILITY_EXPORT AsyncOp
 	{
@@ -28,7 +32,11 @@ namespace CamelotFramework
 	public:
 		AsyncOp()
 			:mData(cm_shared_ptr<AsyncOpData, ScratchAlloc>())
-		{}
+		{
+#if CM_ARCH_TYPE != CM_ARCHITECTURE_x86_32 && CM_ARCH_TYPE != CM_ARCHITECTURE_x86_64
+			static_assert(false, "You will likely need to add locks for mIsCompleted on architectures other than x86.");
+#endif
+		}
 
 		/**
 		 * @brief	True if the async operation has completed.
@@ -38,12 +46,12 @@ namespace CamelotFramework
 		/**
 		 * @brief	Internal method. Mark the async operation as completed.
 		 */
-		void completeOperation(boost::any returnValue);
+		void _completeOperation(boost::any returnValue);
 
 		/**
 		 * @brief	Internal method. Mark the async operation as completed, without setting a return value.
 		 */
-		void completeOperation();
+		void _completeOperation();
 
 		/**
 		 * @brief	Retrieves the value returned by the async operation. Only valid

+ 5 - 5
CamelotUtility/Include/CmPlatformDefines.h

@@ -10,8 +10,8 @@
 #define CM_COMPILER_INTEL 3
 #define CM_COMPILER_CLANG 4
 
-#define CM_ARCHITECTURE_32 1
-#define CM_ARCHITECTURE_64 2
+#define CM_ARCHITECTURE_x86_32 1
+#define CM_ARCHITECTURE_x86_64 2
 
 #define CM_ENDIAN_LITTLE 1
 #define CM_ENDIAN_BIG 2
@@ -65,10 +65,10 @@
 #endif
 
 // Find the architecture type
-#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
-#   define CM_ARCH_TYPE CM_ARCHITECTURE_64
+#if defined(__x86_64__) || defined(_M_X64)
+#   define CM_ARCH_TYPE CM_ARCHITECTURE_x86_64
 #else
-#   define CM_ARCH_TYPE CM_ARCHITECTURE_32
+#   define CM_ARCH_TYPE CM_ARCHITECTURE_x86_32
 #endif
 
 // Windows Settings

+ 2 - 2
CamelotUtility/Source/CmAsyncOp.cpp

@@ -2,13 +2,13 @@
 
 namespace CamelotFramework
 {
-	void AsyncOp::completeOperation(boost::any returnValue) 
+	void AsyncOp::_completeOperation(boost::any returnValue) 
 	{ 
 		mData->mReturnValue = returnValue; 
 		mData->mIsCompleted = true; 
 	}
 
-	void AsyncOp::completeOperation() 
+	void AsyncOp::_completeOperation() 
 	{ 
 		mData->mIsCompleted = true; 
 	}

+ 1 - 1
CamelotUtility/Source/CmRay.cpp

@@ -57,7 +57,7 @@ namespace CamelotFramework
 		}
 
 		// Calculate the largest area projection plane in X, Y or Z.
-		size_t i0, i1;
+		UINT32 i0, i1;
 		{
 			float n0 = Math::abs(normal[0]);
 			float n1 = Math::abs(normal[1]);

+ 19 - 0
MBansheeEditor/DbgCustomInspector.cs

@@ -0,0 +1,19 @@
+using System;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    [CustomInspector(typeof(DbgComponent))]
+    public class DbgCustomInspector : Inspector
+    {
+        internal override void Refresh()
+        {
+            throw new NotImplementedException();
+        }
+
+        internal override int GetOptimalHeight()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 14 - 0
MBansheeEditor/EditorWindow.cs

@@ -6,6 +6,9 @@ namespace BansheeEditor
 {
     public class EditorWindow : ScriptObject
     {
+        internal int width { get { return Internal_GetWidth(); } }
+        internal int height { get { return Internal_GetHeight(); } }
+
         protected EditorGUI GUI;
 
         public static EditorWindow OpenWindow<T>() where T : EditorWindow
@@ -18,7 +21,18 @@ namespace BansheeEditor
             GUI = new EditorGUI(this);
         }
 
+        protected virtual void WindowResized(int width, int height)
+        {
+            
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetWidth();
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetHeight();
     }
 }

+ 15 - 0
MBansheeEditor/Inspector/CustomInspector.cs

@@ -0,0 +1,15 @@
+using System;
+
+namespace BansheeEditor
+{
+    [AttributeUsage(AttributeTargets.Class)]
+    public sealed class CustomInspector : Attribute
+    {
+        private Type type;
+
+        public CustomInspector(Type type)
+        {
+            this.type = type;
+        }
+    }
+}

+ 11 - 11
MBansheeEngine/Inspector/EditorField.cs → MBansheeEditor/Inspector/EditorField.cs

@@ -1,11 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public class EditorField
-    {
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BansheeEditor
+{
+    public class EditorField
+    {
+    }
+}

+ 21 - 0
MBansheeEditor/Inspector/GenericInspector.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BansheeEditor
+{
+    internal sealed class GenericInspector : Inspector
+    {
+        internal override void Refresh()
+        {
+            throw new NotImplementedException();
+        }
+
+        internal override int GetOptimalHeight()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 15 - 15
MBansheeEngine/Inspector/InspectableArray.cs → MBansheeEditor/Inspector/InspectableArray.cs

@@ -1,15 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public class InspectableArray : InspectableObjectBase
-    {
-        public InspectableArray(Array array)
-        {
-            // TODO - Populate "fields" array
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BansheeEditor
+{
+    public class InspectableArray : InspectableObjectBase
+    {
+        public InspectableArray(Array array)
+        {
+            // TODO - Populate "fields" array
+        }
+    }
+}

+ 65 - 65
MBansheeEngine/Inspector/InspectableField.cs → MBansheeEditor/Inspector/InspectableField.cs

@@ -1,65 +1,65 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public class InspectableField
-    {
-        public enum Type
-        {
-            Int,
-            Float,
-            Bool,
-            String,
-            Color,
-            Vector2,
-            Vector3,
-            Vector4,
-            GameObjectRef,
-            ResourceRef,
-            Object,
-            Array,
-            List,
-            Dictionary
-        }
-
-        private EditorField guiField; // TODO - This will likely be a specific EditorField type, not a generic base one
-        private InspectableObjectBase parent;
-        private Type type;
-
-        // TODO - Add getters/setters for all fields
-        
-        // TODO - Make sure "guiField" is created properly
-
-        public void Refresh()
-        {
-            // TODO - Update "guiField" from the field value by calling "Internal_Get*" method
-        }
-
-        public void Destroy()
-        {
-            // TODO - Called by the parent
-            //  Release "guiField"
-        }
-
-        private void OnValueChangedInt32(Int32 newValue)
-        {
-            // TODO - Callback from "guiField"
-            //  Need separate methods for all types
-            //  Call "Internal_Set*" method to update the actual field
-            //  Register an "Undo" action
-        }
-
-        // TODO - I need a set of these methods for all possible "Type"s
-        //  Internally they should use SerializableField methods for setting/getting values
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetInt32(IntPtr nativeInstance, Int32 value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Int32 Internal_GetInt32(IntPtr nativeInstance);
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+
+namespace BansheeEditor
+{
+    public class InspectableField
+    {
+        public enum Type
+        {
+            Int,
+            Float,
+            Bool,
+            String,
+            Color,
+            Vector2,
+            Vector3,
+            Vector4,
+            GameObjectRef,
+            ResourceRef,
+            Object,
+            Array,
+            List,
+            Dictionary
+        }
+
+        private EditorField guiField; // TODO - This will likely be a specific EditorField type, not a generic base one
+        private InspectableObjectBase parent;
+        private Type type;
+
+        // TODO - Add getters/setters for all fields
+        
+        // TODO - Make sure "guiField" is created properly
+
+        public void Refresh()
+        {
+            // TODO - Update "guiField" from the field value by calling "Internal_Get*" method
+        }
+
+        public void Destroy()
+        {
+            // TODO - Called by the parent
+            //  Release "guiField"
+        }
+
+        private void OnValueChangedInt32(Int32 newValue)
+        {
+            // TODO - Callback from "guiField"
+            //  Need separate methods for all types
+            //  Call "Internal_Set*" method to update the actual field
+            //  Register an "Undo" action
+        }
+
+        // TODO - I need a set of these methods for all possible "Type"s
+        //  Internally they should use SerializableField methods for setting/getting values
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetInt32(IntPtr nativeInstance, Int32 value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Int32 Internal_GetInt32(IntPtr nativeInstance);
+    }
+}

+ 15 - 15
MBansheeEngine/Inspector/InspectableObject.cs → MBansheeEditor/Inspector/InspectableObject.cs

@@ -1,15 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public class InspectableObject : InspectableObjectBase
-    {
-        public InspectableObject(object obj)
-        {
-            // TODO - Populate "fields" array
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BansheeEditor
+{
+    public class InspectableObject : InspectableObjectBase
+    {
+        public InspectableObject(object obj)
+        {
+            // TODO - Populate "fields" array
+        }
+    }
+}

+ 44 - 44
MBansheeEngine/Inspector/InspectableObjectBase.cs → MBansheeEditor/Inspector/InspectableObjectBase.cs

@@ -1,44 +1,44 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public abstract class InspectableObjectBase
-    {
-        private bool _isExpanded = false;
-        private InspectableField[] _fields;
-
-        public bool isExpanded { get { return _isExpanded; } }
-        public InspectableField[] fields { get { return _fields; } }
-
-        public void Expand()
-        {
-            // TODO - Show all child "fields"
-            //  Reposition all visual child elements
-            //  Re-do tab indexes
-            _isExpanded = true;
-        }
-
-        public void Collapse()
-        {
-            // TODO - Hide all child "fields"
-            //  Reposition all visual child elements
-            //  Re-do tab indexes
-            _isExpanded = false;
-        }
-
-        public void Refresh()
-        {
-            for (int i = 0; i < fields.Length; i++)
-                fields[i].Refresh();
-        }
-
-        public void Destroy()
-        {
-            for (int i = 0; i < fields.Length; i++)
-                fields[i].Destroy();
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BansheeEditor
+{
+    public abstract class InspectableObjectBase
+    {
+        private bool _isExpanded = false;
+        private InspectableField[] _fields;
+
+        public bool isExpanded { get { return _isExpanded; } }
+        public InspectableField[] fields { get { return _fields; } }
+
+        public void Expand()
+        {
+            // TODO - Show all child "fields"
+            //  Reposition all visual child elements
+            //  Re-do tab indexes
+            _isExpanded = true;
+        }
+
+        public void Collapse()
+        {
+            // TODO - Hide all child "fields"
+            //  Reposition all visual child elements
+            //  Re-do tab indexes
+            _isExpanded = false;
+        }
+
+        public void Refresh()
+        {
+            for (int i = 0; i < fields.Length; i++)
+                fields[i].Refresh();
+        }
+
+        public void Destroy()
+        {
+            for (int i = 0; i < fields.Length; i++)
+                fields[i].Destroy();
+        }
+    }
+}

+ 76 - 0
MBansheeEditor/Inspector/InspectorArea.cs

@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    public class InspectorArea
+    {
+        private GUIArea guiArea;
+        private Inspector owner;
+
+        private int parentX, parentY, parentWidth, parentHeight;
+        private int x, y, width, height;
+        private short depth;
+
+        public GUILayout layout
+        {
+            get { return guiArea.layout; }
+        }
+
+        internal InspectorArea(Inspector owner, EditorGUI parentGUI)
+        {
+            this.owner = owner;
+            guiArea = parentGUI.AddArea(0, 0, 0, 0);
+        }
+
+        public void Destroy()
+        {
+            owner.Remove(this);
+
+            guiArea.Destroy();
+        }
+
+        public void SetArea(int x, int y, int width, int height, short depth)
+        {
+            this.x = x;
+            this.y = y;
+            this.width = width;
+            this.height = height;
+            this.depth = depth;
+
+            UpdateGUIArea();
+        }
+
+        internal void SetParentArea(int x, int y, int width, int height)
+        {
+            parentX = x;
+            parentY = y;
+            parentWidth = width;
+            parentHeight = height;
+
+            UpdateGUIArea();
+        }
+
+        private void UpdateGUIArea()
+        {
+            int guiX = parentX + x;
+            int guiY = parentY + y;
+
+            int guiRight = guiX + width;
+            guiRight = MathEx.Min(guiRight, parentX + parentWidth);
+
+            int guiWidth = MathEx.Max(0, guiRight - guiX);
+
+            int guiBottom = guiY + height;
+            guiBottom = MathEx.Min(guiBottom, parentY + parentHeight);
+
+            int guiHeight = MathEx.Max(0, guiBottom - guiY);
+
+            guiArea.SetArea(guiX, guiY, guiWidth, guiHeight, depth);
+        }
+    }
+}

+ 11 - 0
MBansheeEditor/MBansheeEditor.csproj

@@ -39,10 +39,21 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="DbgCustomInspector.cs" />
     <Compile Include="DbgEditorWindow.cs" />
     <Compile Include="EditorApplication.cs" />
     <Compile Include="EditorGUI.cs" />
     <Compile Include="EditorWindow.cs" />
+    <Compile Include="Inspector\CustomInspector.cs" />
+    <Compile Include="Inspector\EditorField.cs" />
+    <Compile Include="Inspector\GenericInspector.cs" />
+    <Compile Include="Inspector\InspectableArray.cs" />
+    <Compile Include="Inspector\InspectableField.cs" />
+    <Compile Include="Inspector\InspectableObject.cs" />
+    <Compile Include="Inspector\InspectableObjectBase.cs" />
+    <Compile Include="Inspector\Inspector.cs" />
+    <Compile Include="Inspector\InspectorArea.cs" />
+    <Compile Include="Inspector\InspectorWindow.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>

+ 5 - 0
MBansheeEngine/GUI/GUIArea.cs

@@ -63,6 +63,11 @@ namespace BansheeEngine
             return newArea;
         }
 
+        public void SetArea(int x, int y, int width, int height, short depth = 0)
+        {
+            // TODO
+        }
+
         public void SetVisible(bool visible)
         {
             Internal_SetVisible(mCachedPtr, visible);

+ 1 - 1
MBansheeEngine/GUI/GUIBase.cs

@@ -36,7 +36,7 @@ namespace BansheeEngine
             _mainLayout = mainArea.layout;
         }
 
-        public GUIArea AddArea(int x, int y, int width = 0, int height = 0, short depth = 0)
+        public GUIArea AddArea(int x, int y, int width, int height, short depth = 0)
         {
             GUIArea area = GUIArea.Create(this, x, y, width, height, depth);
             area.SetParent(this);

+ 0 - 14
MBansheeEngine/Inspector/CustomInspector.cs

@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public abstract class CustomInspector
-    {
-        public abstract void Refresh();
-
-        public abstract void Destroy();
-    }
-}

+ 0 - 76
MBansheeEngine/Inspector/Inspector.cs

@@ -1,76 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BansheeEngine
-{
-    public class Inspector
-    {
-        private GUIElement[] guiElements;
-        private InspectableObject[] childObjects;
-        private CustomInspector[] customInspectors;
-
-        public Inspector(SceneObject so, GUILayout layout)
-        {
-            // TODO - Create SceneObject gui elements (name + transform)
-            
-            List<CustomInspector> customInspectors = new List<CustomInspector>();
-            List<InspectableObject> childObjects = new List<InspectableObject>();
-
-            Component[] allComponents = so.GetComponents();
-            for (int i = 0; i < allComponents.Length; i++)
-            {
-                // TODO
-                //  - Create component foldout
-                //  - Hook up the foldout so when clicked it will expand/collapse the custom inspector or child object
-
-                if (HasCustomInspector(allComponents[i].GetType()))
-                {
-                    customInspectors.Add(CreateCustomInspector(allComponents[i]));
-                }
-                else
-                {
-                    childObjects.Add(new InspectableObject(allComponents[i]));
-                }
-            }
-
-            this.customInspectors = customInspectors.ToArray();
-            this.childObjects = childObjects.ToArray();
-        }
-
-        public void Refresh()
-        {
-            for (int i = 0; i < childObjects.Length; i++)
-                childObjects[i].Refresh();
-
-            for (int i = 0; i < customInspectors.Length; i++)
-                customInspectors[i].Refresh();
-        }
-
-        public void Destroy()
-        {
-            // TODO - Destroy SceneObject GUI elements
-
-            for (int i = 0; i < childObjects.Length; i++)
-                childObjects[i].Destroy();
-
-            for (int i = 0; i < customInspectors.Length; i++)
-                customInspectors[i].Destroy();
-        }
-
-        private bool HasCustomInspector(Type type)
-        {
-            // TODO - Check if Component (or some other type) has a custom inspector
-            return false;
-        }
-
-        private CustomInspector CreateCustomInspector(Component component)
-        {
-            // Find and create a custom inspector
-            return null;
-        }
-
-        // TODO - Ensure all GUI elements are properly cleaned up when this is destroyed
-    }
-}

+ 0 - 7
MBansheeEngine/MBansheeEngine.csproj

@@ -75,13 +75,6 @@
     <Compile Include="GUI\GUIToggle.cs" />
     <Compile Include="GUI\GUIToggleGroup.cs" />
     <Compile Include="HideInInspector.cs" />
-    <Compile Include="Inspector\CustomInspector.cs" />
-    <Compile Include="Inspector\EditorField.cs" />
-    <Compile Include="Inspector\InspectableArray.cs" />
-    <Compile Include="Inspector\InspectableField.cs" />
-    <Compile Include="Inspector\InspectableObject.cs" />
-    <Compile Include="Inspector\InspectableObjectBase.cs" />
-    <Compile Include="Inspector\Inspector.cs" />
     <Compile Include="LocString.cs" />
     <Compile Include="Math\MathEx.cs" />
     <Compile Include="Math\Matrix3.cs" />