Browse Source

Various fixes in order to get handles operational
Refactored how is HWND retrieved in order to fix 32-bit build
Added debug console to more easily track issues with Mono runtime

Marko Pintera 11 years ago
parent
commit
24f99ac96e

+ 16 - 16
BansheeCore/Source/Win32/BsPlatformImpl.cpp

@@ -92,19 +92,19 @@ namespace BansheeEngine
 	void Platform::captureMouse(const RenderWindow& window)
 	{
 		RenderWindowPtr primaryWindow = gCoreApplication().getPrimaryWindow();
-		HWND hwnd;
+		UINT64 hwnd;
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 		
-		PostMessage(hwnd, WM_BS_SETCAPTURE, WPARAM(hwnd), 0);
+		PostMessage((HWND)hwnd, WM_BS_SETCAPTURE, WPARAM((HWND)hwnd), 0);
 	}
 
 	void Platform::releaseMouseCapture()
 	{
 		RenderWindowPtr primaryWindow = gCoreApplication().getPrimaryWindow();
-		HWND hwnd;
+		UINT64 hwnd;
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 
-		PostMessage(hwnd, WM_BS_RELEASECAPTURE, WPARAM(hwnd), 0);
+		PostMessage((HWND)hwnd, WM_BS_RELEASECAPTURE, WPARAM((HWND)hwnd), 0);
 	}
 
 	bool Platform::isPointOverWindow(const RenderWindow& window, const Vector2I& screenPos)
@@ -115,11 +115,11 @@ namespace BansheeEngine
 		point.x = screenPos.x;
 		point.y = screenPos.y;
 
-		HWND hwndToCheck;
+		UINT64 hwndToCheck;
 		window.getCustomAttribute("WINDOW", &hwndToCheck);
 
 		HWND hwndUnderPos = WindowFromPoint(point);
-		return hwndUnderPos == hwndToCheck;
+		return hwndUnderPos == (HWND)hwndToCheck;
 	}
 
 	void Platform::hideCursor()
@@ -130,10 +130,10 @@ namespace BansheeEngine
 		// WM_SETCURSOR in message loop to hide the cursor is smarter solution anyway.
 
 		RenderWindowPtr primaryWindow = gCoreApplication().getPrimaryWindow();
-		HWND hwnd;
+		UINT64 hwnd;
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 
-		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
+		PostMessage((HWND)hwnd, WM_SETCURSOR, WPARAM((HWND)hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
 	void Platform::showCursor()
@@ -144,20 +144,20 @@ namespace BansheeEngine
 		// WM_SETCURSOR in message loop to hide the cursor is smarter solution anyway.
 
 		RenderWindowPtr primaryWindow = gCoreApplication().getPrimaryWindow();
-		HWND hwnd;
+		UINT64 hwnd;
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 
-		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
+		PostMessage((HWND)hwnd, WM_SETCURSOR, WPARAM((HWND)hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
 	void Platform::clipCursorToWindow(const RenderWindow& window)
 	{
-		HWND hwnd;
+		UINT64 hwnd;
 		window.getCustomAttribute("WINDOW", &hwnd);
 
 		// Clip cursor to the window
 		RECT clipWindowRect;
-		if(GetWindowRect(hwnd, &clipWindowRect))
+		if(GetWindowRect((HWND)hwnd, &clipWindowRect))
 		{
 			ClipCursor(&clipWindowRect);
 		}
@@ -251,10 +251,10 @@ namespace BansheeEngine
 
 		// Make sure we notify the message loop to perform the actual cursor update
 		RenderWindowPtr primaryWindow = gCoreApplication().getPrimaryWindow();
-		HWND hwnd;
+		UINT64 hwnd;
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 
-		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
+		PostMessage((HWND)hwnd, WM_SETCURSOR, WPARAM((HWND)hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
 	void Platform::setCaptionNonClientAreas(const RenderWindowCore& window, const Vector<Rect2I>& nonClientAreas)
@@ -386,10 +386,10 @@ namespace BansheeEngine
 		auto iterFind = mDropTargets.data->dropTargetsPerWindow.find(window);
 		if(iterFind == mDropTargets.data->dropTargetsPerWindow.end())
 		{
-			HWND hwnd;
+			UINT64 hwnd;
 			window->getCustomAttribute("WINDOW", &hwnd);
 
-			win32DropTarget = bs_new<Win32DropTarget>(hwnd);
+			win32DropTarget = bs_new<Win32DropTarget>((HWND)hwnd);
 			mDropTargets.data->dropTargetsPerWindow[window] = win32DropTarget;
 
 			{

+ 6 - 6
BansheeCore/Source/Win32/BsPlatformWndProc.cpp

@@ -23,9 +23,9 @@ namespace BansheeEngine
 				{
 					RenderWindowCore* curModalWindow = mModalWindowStack.top();
 
-					HWND curHwnd;
+					UINT64 curHwnd;
 					curModalWindow->getCustomAttribute("WINDOW", &curHwnd);
-					EnableWindow(curHwnd, FALSE);
+					EnableWindow((HWND)curHwnd, FALSE);
 				}
 				else
 				{
@@ -35,9 +35,9 @@ namespace BansheeEngine
 						if(renderWindow == newWindow)
 							continue;
 
-						HWND curHwnd;
+						UINT64 curHwnd;
 						renderWindow->getCustomAttribute("WINDOW", &curHwnd);
-						EnableWindow(curHwnd, FALSE);
+						EnableWindow((HWND)curHwnd, FALSE);
 					}
 				}
 
@@ -94,9 +94,9 @@ namespace BansheeEngine
 					{
 						RenderWindowCore* curModalWindow = mModalWindowStack.top();
 
-						HWND curHwnd;
+						UINT64 curHwnd;
 						curModalWindow->getCustomAttribute("WINDOW", &curHwnd);
-						EnableWindow(curHwnd, TRUE);
+						EnableWindow((HWND)curHwnd, TRUE);
 					}
 					else
 						reenableWindows = true; // No more modal windows, re-enable any remaining window

+ 4 - 4
BansheeD3D11RenderSystem/Source/BsD3D11RenderWindow.cpp

@@ -471,8 +471,8 @@ namespace BansheeEngine
 	{
 		if(name == "WINDOW")
 		{
-			HWND *pWnd = (HWND*)pData;
-			*pWnd = mHWnd;
+			UINT64 *pWnd = (UINT64*)pData;
+			*pWnd = (UINT64)mHWnd;
 			return;
 		}
 
@@ -747,8 +747,8 @@ namespace BansheeEngine
 	{
 		if (name == "WINDOW")
 		{
-			HWND *pHwnd = (HWND*)pData;
-			*pHwnd = getHWnd();
+			UINT64 *pHwnd = (UINT64*)pData;
+			*pHwnd = (UINT64)getHWnd();
 			return;
 		}
 	}

+ 2 - 2
BansheeD3D11RenderSystem/Source/BsD3D11RenderWindowManager.cpp

@@ -18,9 +18,9 @@ namespace BansheeEngine
 
 		if(parentWindow != nullptr)
 		{
-			HWND hWnd;
+			UINT64 hWnd;
 			parentWindow->getCustomAttribute("WINDOW", &hWnd);
-			desc.platformSpecific["parentWindowHandle"] = toString((UINT64)hWnd);
+			desc.platformSpecific["parentWindowHandle"] = toString(hWnd);
 		}
 
 		// Create the window

+ 4 - 4
BansheeD3D9RenderSystem/Source/BsD3D9RenderWindow.cpp

@@ -395,8 +395,8 @@ namespace BansheeEngine
 		}		
 		else if( name == "WINDOW" )
 		{
-			HWND *pHwnd = (HWND*)pData;
-			*pHwnd = _getWindowHandle();
+			UINT64 *pHwnd = (UINT64*)pData;
+			*pHwnd = (UINT64)_getWindowHandle();
 			return;
 		}
 		else if( name == "isTexture" )
@@ -682,8 +682,8 @@ namespace BansheeEngine
 	{
 		if (name == "WINDOW")
 		{
-			HWND *pHwnd = (HWND*)pData;
-			*pHwnd = getHWnd();
+			UINT64 *pHwnd = (UINT64*)pData;
+			*pHwnd = (UINT64)getHWnd();
 			return;
 		}
 	}

+ 2 - 2
BansheeD3D9RenderSystem/Source/BsD3D9RenderWindowManager.cpp

@@ -15,9 +15,9 @@ namespace BansheeEngine
 	{
 		if(parentWindow != nullptr)
 		{
-			HWND hWnd;
+			UINT64 hWnd;
 			parentWindow->getCustomAttribute("WINDOW", &hWnd);
-			desc.platformSpecific["parentWindowHandle"] = toString((UINT64)hWnd);
+			desc.platformSpecific["parentWindowHandle"] = toString(hWnd);
 		}
 
 		D3D9RenderWindow* window = new (bs_alloc<D3D9RenderWindow, PoolAlloc>()) D3D9RenderWindow(desc, mRenderSystem->getInstanceHandle());

+ 1 - 1
BansheeEditor/Include/BsEditorSettings.h

@@ -56,7 +56,7 @@ namespace BansheeEngine
 		UINT32 mGridMajorAxisSpacing = 10;
 		UINT32 mGridAxisMarkerSpacing = 25;
 
-		float mHandleSize = 20.0f;
+		float mHandleSize = 0.25f;
 
 		mutable UINT32 mHash = 0;
 	};

+ 10 - 3
BansheeEditor/Source/BsHandleManager.cpp

@@ -8,7 +8,7 @@
 namespace BansheeEngine
 {
 	HandleManager::HandleManager()
-		:mSliderManager(nullptr), mDrawManager(nullptr)
+		:mSliderManager(nullptr), mDrawManager(nullptr), mSettingsHash(0xFFFFFFFF)
 	{
 		mSliderManager = bs_new<HandleSliderManager>();
 		mDrawManager = bs_new<HandleDrawManager>();
@@ -38,6 +38,13 @@ namespace BansheeEngine
 		mDrawManager->draw(camera);
 	}
 
+	void HandleManager::setSettings(const EditorSettingsPtr& settings)
+	{
+		mSettings = settings;
+
+		updateFromProjectSettings();
+	}
+
 	void HandleManager::updateFromProjectSettings()
 	{
 		setDefaultHandleSize(mSettings->getHandleSize());
@@ -60,8 +67,8 @@ namespace BansheeEngine
 		Vector3 cameraPos = camera->getPosition();
 
 		Vector3 diff = handlePos - cameraPos;
-		float distAlongViewDir = diff.dot(camera->getRotation().zAxis());
+		float distAlongViewDir = Math::abs(diff.dot(camera->getRotation().zAxis()));
 
-		return mDefaultHandleSize / std::max(distAlongViewDir, 0.0001f);
+		return distAlongViewDir * mDefaultHandleSize;
 	}
 }

+ 3 - 0
BansheeEditor/Source/BsHandleSliderManager.cpp

@@ -123,5 +123,8 @@ namespace BansheeEngine
 
 		if (mActiveSlider == slider)
 			mActiveSlider = nullptr;
+
+		if (mHoverSlider == slider)
+			mHoverSlider = nullptr;
 	}
 }

+ 1 - 0
BansheeEditor/Source/BsSceneViewHandler.cpp

@@ -23,6 +23,7 @@ namespace BansheeEngine
 		mRenderCallback = RendererManager::instance().getActive()->onRenderViewport.connect(std::bind(&SceneViewHandler::render, this, _1, _2));
 		mSceneGrid = bs_new<SceneGrid>();
 		mSceneGrid->setSettings(gEditorApplication().getEditorSettings());
+		HandleManager::instance().setSettings(gEditorApplication().getEditorSettings());
 	}
 
 	SceneViewHandler::~SceneViewHandler()

+ 58 - 0
BansheeEditorExec/BsEditorExec.cpp

@@ -1,9 +1,59 @@
 #include <windows.h>
+#include <iostream>
+#include <stdio.h>
+#include <fcntl.h>
+#include <io.h>
 
 #include "BsEditorApplication.h"
 
 using namespace BansheeEngine;
 
+#if BS_DEBUG_MODE
+void InitializeDebugConsole()
+{
+	//Create a console for this application
+	AllocConsole();
+	//Redirect unbuffered STDOUT to the console
+	HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+	int SystemOutput = _open_osfhandle(intptr_t(ConsoleOutput), _O_TEXT);
+	FILE *COutputHandle = _fdopen(SystemOutput, "w");
+	*stdout = *COutputHandle;
+	setvbuf(stdout, NULL, _IONBF, 0);
+
+	//Redirect unbuffered STDERR to the console
+	HANDLE ConsoleError = GetStdHandle(STD_ERROR_HANDLE);
+	int SystemError = _open_osfhandle(intptr_t(ConsoleError), _O_TEXT);
+	FILE *CErrorHandle = _fdopen(SystemError, "w");
+	*stderr = *CErrorHandle;
+	setvbuf(stderr, NULL, _IONBF, 0);
+
+	//Redirect unbuffered STDIN to the console
+	HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
+	int SystemInput = _open_osfhandle(intptr_t(ConsoleInput), _O_TEXT);
+	FILE *CInputHandle = _fdopen(SystemInput, "r");
+	*stdin = *CInputHandle;
+	setvbuf(stdin, NULL, _IONBF, 0);
+
+	//make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
+	std::ios::sync_with_stdio(true);
+}
+
+void ShutdownDebugConsole()
+{
+	//Write "Press any key to exit"
+	HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+	DWORD CharsWritten;
+	WriteConsole(ConsoleOutput, "\nPress any key to exit", 22, &CharsWritten, 0);
+	//Disable line-based input mode so we can get a single character
+	HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
+	SetConsoleMode(ConsoleInput, 0);
+	//Read a single character
+	TCHAR InputBuffer;
+	DWORD CharsRead;
+	ReadConsole(ConsoleInput, &InputBuffer, 1, &CharsRead, 0);
+}
+#endif
+
 int CALLBACK WinMain(
 	_In_  HINSTANCE hInstance,
 	_In_  HINSTANCE hPrevInstance,
@@ -11,9 +61,17 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	)
 {
+#if BS_DEBUG_MODE
+	InitializeDebugConsole();
+#endif
+
 	EditorApplication::startUp(RenderSystemPlugin::OpenGL);
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();
 
+#if BS_DEBUG_MODE
+	ShutdownDebugConsole();
+#endif
+
 	return 0;
 }

+ 1 - 0
BansheeEngine.sln

@@ -167,6 +167,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Guides", "Guides", "{425968
 		Dependencies.txt = Dependencies.txt
 		Mono-3.2.3-IntegrationGuide.txt = Mono-3.2.3-IntegrationGuide.txt
 		Mono-3.4.0-IntegrationGuide.txt = Mono-3.4.0-IntegrationGuide.txt
+		Mono-3.8.0-IntegrationGuide.txt = Mono-3.8.0-IntegrationGuide.txt
 		NVTTCompilationGuide.txt = NVTTCompilationGuide.txt
 	EndProjectSection
 EndProject

+ 8 - 8
BansheeEngine/Include/BsGUILayoutUtility.h

@@ -7,21 +7,21 @@
 namespace BansheeEngine
 {
 	/**
-	* Helper class that performs various operations related to
-	* GUILayout and GUI element sizing/placement.
-	*/
+	 * Helper class that performs various operations related to
+	 * GUILayout and GUI element sizing/placement.
+	 */
 	class BS_EXPORT GUILayoutUtility
 	{
 	public:
 		/**
-		* Calculates optimal size of a GUI element.
-		*/
+		 * Calculates optimal size of a GUI element.
+		 */
 		static Vector2I calcOptimalSize(const GUIElementBase* elem);
 
 		/**
-		* Calculates position and size of a GUI element in its current layout.
-		* Returned position is relative to layout origin.
-		*/
+		 * Calculates position and size of a GUI element in its current layout.
+		 * Returned position is relative to layout origin.
+		 */
 		// TODO - This method might fail if element is part of a more complex hierarchy
 		// other than just GUILayouts and base elements (e.g. a tree view) because for a lot
 		// of such custom container elements like tree view don't have method for calculating 

+ 2 - 2
BansheeEngine/Source/BsGUILayoutUtility.cpp

@@ -23,8 +23,8 @@ namespace BansheeEngine
 			const GUILayout* layout = static_cast<const GUILayout*>(elem);
 
 			GUIArea* parentGUIArea = layout->_getParentGUIArea();
-			parentArea.x = parentGUIArea->x();
-			parentArea.y = parentGUIArea->y();
+			parentArea.x = 0; // Zero because we want position relative to parent GUIArea
+			parentArea.y = 0;
 			parentArea.width = parentGUIArea->width();
 			parentArea.height = parentGUIArea->height();
 

+ 2 - 2
BansheeGLRenderSystem/Source/BsWin32GLSupport.cpp

@@ -30,9 +30,9 @@ namespace BansheeEngine
 	{		
 		if(parentWindow != nullptr)
 		{
-			HWND hWnd;
+			UINT64 hWnd;
 			parentWindow->getCustomAttribute("WINDOW", &hWnd);
-			desc.platformSpecific["parentWindowHandle"] = toString((UINT64)hWnd);
+			desc.platformSpecific["parentWindowHandle"] = toString(hWnd);
 		}
 
 		Win32Window* window = new (bs_alloc<Win32Window, PoolAlloc>()) Win32Window(desc, *this);

+ 4 - 4
BansheeGLRenderSystem/Source/BsWin32Window.cpp

@@ -562,8 +562,8 @@ namespace BansheeEngine
 		} 
 		else if(name == "WINDOW")
 		{
-			HWND *pHwnd = (HWND*)pData;
-			*pHwnd = mHWnd;
+			UINT64 *pHwnd = (UINT64*)pData;
+			*pHwnd = (UINT64)mHWnd;
 			return;
 		} 
 	}
@@ -699,8 +699,8 @@ namespace BansheeEngine
 	{
 		if (name == "WINDOW")
 		{
-			HWND *pHwnd = (HWND*)pData;
-			*pHwnd = getHWnd();
+			UINT64 *pHwnd = (UINT64*)pData;
+			*pHwnd = (UINT64)getHWnd();
 			return;
 		}
 	}

+ 2 - 0
BansheeMono/Source/BsMonoAssembly.cpp

@@ -60,6 +60,8 @@ namespace BansheeEngine
 			BS_EXCEPT(InvalidParametersException, "Cannot get script assembly image.");
 		}
 
+		mono_jit_exec(domain, monoAssembly, 0, nullptr);
+
 		mIsLoaded = true;
 		mIsDependency = false;
 	}

+ 2 - 2
BansheeOISInput/Source/BsInputHandlerOIS.cpp

@@ -241,10 +241,10 @@ namespace BansheeEngine
 
 	void InputHandlerOIS::_inputWindowChanged(const RenderWindow& win)
 	{
-		unsigned long long hWnd;
+		UINT64 hWnd = 0;
 		win.getCustomAttribute("WINDOW", &hWnd);
 
-		std::string normalString = toString((UINT64)hWnd).c_str();
+		std::string normalString = toString(hWnd).c_str();
 		mKeyboard->setCaptureContext(normalString);
 		mMouse->setCaptureContext(normalString);
 	}

+ 2 - 2
MBansheeEditor/Program.cs

@@ -4,11 +4,11 @@ using BansheeEngine;
 
 namespace BansheeEditor
 {
-    class ProgramEd
+    class Program
     {
         private static EditorApplication app;
 
-        static void Main()
+        static void Start()
         {
             app = new EditorApplication();
 

+ 2 - 2
MBansheeEditor/Scene/Handles.cs

@@ -54,9 +54,9 @@ namespace BansheeEditor
             Vector3 cameraPos = camera.sceneObject.position;
 
 		    Vector3 diff = position - cameraPos;
-		    float distAlongViewDir = Vector3.Dot(diff, camera.sceneObject.rotation.Forward);
+		    float distAlongViewDir = Math.Abs(Vector3.Dot(diff, camera.sceneObject.rotation.Forward));
 
-		    return EditorSettings.DefaultHandleSize / Math.Max(distAlongViewDir, 0.0001f);
+            return distAlongViewDir * EditorSettings.DefaultHandleSize;
         }
     }
 }

+ 13 - 29
MBansheeEditor/Scene/SceneWindow.cs

@@ -16,8 +16,6 @@ namespace BansheeEditor
         private GUIRenderTexture renderTextureGUI;
         private SceneViewHandler sceneViewHandler;
 
-        private bool dragActive;
-
         public Camera GetCamera()
         {
             return camera;
@@ -34,6 +32,7 @@ namespace BansheeEditor
             Vector2I windowPos = ScreenToWindowPos(screenPos);
 
             Rect2I bounds = GUILayoutUtility.CalculateBounds(renderTextureGUI);
+
             if (bounds.Contains(windowPos))
             {
                 scenePos.x = windowPos.x - bounds.x;
@@ -47,42 +46,28 @@ namespace BansheeEditor
 
         private void EditorUpdate()
         {
-            if (HasFocus)
+            if (!HasFocus)
+                return;
+
+            Vector2I scenePos;
+            if (ScreenToScenePos(Input.PointerPosition, out scenePos))
             {
+                Debug.Log(scenePos);
                 if (Input.IsButtonDown(ButtonCode.MouseLeft))
                 {
-                    sceneViewHandler.TrySelectHandle(Input.PointerPosition);
-
-                    Vector2I scenePos;
-                    if (ScreenToScenePos(Input.PointerPosition, out scenePos))
-                        dragActive = true;
+                    sceneViewHandler.TrySelectHandle(scenePos);
                 }
                 else if (Input.IsButtonUp(ButtonCode.MouseLeft))
                 {
-                    bool ctrlHeld = Input.IsButtonHeld(ButtonCode.LeftControl) || Input.IsButtonHeld(ButtonCode.RightControl);
+                    bool ctrlHeld = Input.IsButtonHeld(ButtonCode.LeftControl) ||
+                                    Input.IsButtonHeld(ButtonCode.RightControl);
 
                     if (sceneViewHandler.IsHandleActive())
                         sceneViewHandler.ClearHandleSelection();
                     else
-                        sceneViewHandler.PickObject(Input.PointerPosition, ctrlHeld);
-
-                    dragActive = false;
+                        sceneViewHandler.PickObject(scenePos, ctrlHeld);
                 }
 
-                if (!dragActive)
-                {
-                    Vector2I scenePos;
-                    if (ScreenToScenePos(Input.PointerPosition, out scenePos))
-                    {
-                        sceneViewHandler.Update(scenePos, Input.PointerDelta);
-                    }
-                }
-            }
-
-            if (dragActive)
-            {
-                Vector2I scenePos;
-                ScreenToScenePos(Input.PointerPosition, out scenePos);
                 sceneViewHandler.Update(scenePos, Input.PointerDelta);
             }
         }
@@ -99,14 +84,13 @@ namespace BansheeEditor
             if (!inFocus)
             {
                 sceneViewHandler.ClearHandleSelection();
-                dragActive = false;
             }
         }
 
         private void UpdateRenderTexture(int width, int height)
 	    {
-            width = Math.Max(20, width);
-            height = Math.Max(20, height);
+            width = MathEx.Max(20, width);
+            height = MathEx.Max(20, height);
 
             renderTexture = new RenderTexture2D(PixelFormat.R8G8B8A8, width, height);
             renderTexture.Priority = 1;

+ 1 - 5
MBansheeEngine/Math/MathEx.cs

@@ -118,15 +118,11 @@ namespace BansheeEngine
 
         public static float Abs(float f)
         {
-            // TODO - Try newer mono version
-            throw new NotImplementedException("Mono seems to have a problem calling Math.Abs()? Call it directly if you need it.");
             return Math.Abs(f);
         }
 
         public static int Abs(int value)
         {
-            // TODO - Try newer mono version
-            throw new NotImplementedException("Mono seems to have a problem calling Math.Abs()? Call it directly if you need it.");
             return Math.Abs(value);
         }
 
@@ -270,7 +266,7 @@ namespace BansheeEngine
         {
             const float inv360 = 1.0f/360.0f;
             float angleVal = angle.GetDegrees();
-            float wrapCount = (float)MathEx.Floor(Math.Abs(angleVal * inv360));
+            float wrapCount = (float)MathEx.Floor(MathEx.Abs(angleVal * inv360));
 
             if (angleVal > 0.0f)
                 angleVal -= 360.0f * wrapCount;

+ 3 - 3
MBansheeEngine/Math/Quaternion.cs

@@ -235,7 +235,7 @@ namespace BansheeEngine
         public float Normalize()
         {
             float len = w*w+x*x+y*y+z*z;
-            float factor = 1.0f / MathEx.Sqrt(len);
+            float factor = 1.0f / (float)MathEx.Sqrt(len);
 
             x *= factor;
             y *= factor;
@@ -490,8 +490,8 @@ namespace BansheeEngine
             Quaternion quat;
 
             float halfAngle = (float)(0.5f*angleDeg*MathEx.Deg2Rad);
-            float sin = MathEx.Sin(halfAngle);
-            quat.w = MathEx.Cos(halfAngle);
+            float sin = (float)MathEx.Sin(halfAngle);
+            quat.w = (float)MathEx.Cos(halfAngle);
             quat.x = sin * axis.x;
             quat.y = sin * axis.y;
             quat.z = sin * axis.z;

+ 2 - 2
MBansheeEngine/Math/Vector3.cs

@@ -64,7 +64,7 @@ namespace BansheeEngine
         {
             get
             {
-                return MathEx.Sqrt(x * x + y * y + z * z);
+                return (float)MathEx.Sqrt(x * x + y * y + z * z);
             }
         }
 
@@ -155,7 +155,7 @@ namespace BansheeEngine
 
         public static float Magnitude(Vector3 v)
         {
-            return MathEx.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
+            return (float)MathEx.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
         }
 
         public static float SqrMagnitude(Vector3 v)

+ 1 - 1
MBansheeEngine/Program.cs

@@ -115,7 +115,7 @@ namespace BansheeEngine
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void UnitTest1_GameObjectClone(SceneObject so);
 
-        static void Main()
+        static void Start()
         {
             UnitTest1_ManagedSerialization();
 

+ 52 - 0
Mono-3.8.0-IntegrationGuide.txt

@@ -0,0 +1,52 @@
+---------------------------------Compiling runtime-------------------------------------
+
+ - Retrieve Mono 3.8.0 source from GitHub (NOT the tar ball)
+    - Tar ball has a broken Visual Studio build. (You can try to fix it, likely only a small modification. I didn't bother)
+ - Open in VS2012 as is, or open in VS2013 and upgrade all projects to v120 toolkit
+ - Add "mono/utils/mono-conc-hashtable.c"  and "mono/utils/mono-conc-hashtable.c" to libmonoutils project
+ - For x64 release version make sure to disable "omit stack frames" optimization
+
+ - Move & modify:
+  MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic) MONO_INTERNAL; 
+from object-internals.h
+to:
+  MONO_API MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, mono_bool is_dynamic);
+in object.h
+
+In reflection.c change:
+  MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic)
+to:
+  MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, mono_bool is_dynamic)
+
+ - Compile mono project. You will receive mono-2.0.dll and mono-2.0.lib and output.
+ - Add mono-2.0.dll to (BansheeRootDir)/bin/(Platform)/(Configuration)
+ - Add mono-2.0.lib to (BansheeRootDir)/Dependencies/lib/(Platform)/(Configuration)
+ - TODO - mono.exe and mono compiler are not used at the moment. Update docs once they are.
+
+--------------------------------Compiling libraries-------------------------------------
+
+- Install Mono 3.2.3 (This is the latest binary release for Windows, you can use newer if there is one).
+- Add the "(InstallDir)\Mono-3.2.3\bin" to your PATH environment variable.
+- Install Cygwin 32-bit version using these command line parameters:
+ setup-x86.exe -qnNdO -R "C:\cygwin" -s "http://cygwin.mirror.constant.com" 
+  -l "C:\cygwin\var\cache\setup" -P autoconf -P automake -P bison -P gcc-core 
+  -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ 
+  -P mingw-pthreads -P mingw-w32api -P libtool -P make -P python -P gettext-devel 
+  -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl
+
+- Configure Cygwin mounting options by editing /etc/fstab and add "noacl" option like so:
+ - "none /cygdrive cygdrive binary,noacl,posix=0,user 0 0"
+
+- Retrieve Mono 3.8.0 source tar ball (NOT from git hub, opposite from above. 
+   - Github one has a broken Cygwin build. (You can try to fix it, likely only a small modification. , I didn't bother)
+- Go to your mono 3.8 source directory in Cygwin and enter these commands in order:
+ - "./autogen.sh --prefix="(OutputDir)" --with-preview=yes"" (Replace (OutputDir) with a folder where you want to output the binaries, e.g. "C:\MonoInstall")
+ - "./configure --host=i686-pc-mingw32"
+ - "make"
+ - "make install"
+- Your built mono should now be output to (OutputDir) folder. (If it's not in that folder
+  then check your Cygwin install folder under /usr/local)
+- Copy contents of (OutputDir)/include/mono/mono-2.0/mono to (BansheeRootDir)/Dependencies/Include/Mono
+  - Make sure to modify "object.h" as you did above when building the binaries
+- Copy folders (OutputDir)/etc and (OutputDir)/lib folders into (BansheeRootDir)/bin/Mono
+     - TODO - Not all files from /lib are needed, but I haven't yet determined which are

+ 2 - 2
SBansheeEditor/Source/BsEditorScriptManager.cpp

@@ -20,7 +20,7 @@ namespace BansheeEngine
 	{
 		const String ENGINE_ASSEMBLY_PATH = "..\\..\\Assemblies\\MBansheeEditor.dll";
 		const String ENGINE_ASSEMBLY_NAME = BansheeEditorAssemblyName;
-		const String ASSEMBLY_ENTRY_POINT = "ProgramEd::Main";
+		const String ASSEMBLY_ENTRY_POINT = "Program::Start";
 
 		mEditorAssembly = &MonoManager::instance().loadAssembly(ENGINE_ASSEMBLY_PATH, ENGINE_ASSEMBLY_NAME);
 		ScriptEditorWindow::registerManagedEditorWindows();
@@ -31,7 +31,7 @@ namespace BansheeEngine
 		ScriptGizmoManager::startUp(RuntimeScriptObjects::instance());
 		HandleManager::startUp<ScriptHandleManager>(RuntimeScriptObjects::instance());
 
-		mProgramEdClass = mEditorAssembly->getClass("BansheeEditor", "ProgramEd");
+		mProgramEdClass = mEditorAssembly->getClass("BansheeEditor", "Program");
 		mUpdateMethod = mProgramEdClass->getMethod("EditorUpdate");
 
 		mEditorAssembly->invoke(ASSEMBLY_ENTRY_POINT);

+ 1 - 1
SBansheeEngine/Source/BsScriptEnginePlugin.cpp

@@ -36,7 +36,7 @@ namespace BansheeEngine
 	{
 		const String ENGINE_ASSEMBLY_PATH = "..\\..\\Assemblies\\MBansheeEngine.dll";
 		const String ENGINE_ASSEMBLY_NAME = BansheeEngineAssemblyName;
-		const String ASSEMBLY_ENTRY_POINT = "Program::Main";
+		const String ASSEMBLY_ENTRY_POINT = "Program::Start";
 
 		MonoAssembly& bansheeEngineAssembly = MonoManager::instance().loadAssembly(ENGINE_ASSEMBLY_PATH, ENGINE_ASSEMBLY_NAME);
 

+ 5 - 2
TODO.txt

@@ -12,9 +12,12 @@
 
 See GDrive/Resources doc for resources refactor
 
-Scene view initial viewport size isn't valid size
- - Window resize message arrives before sync happens
+Handle lines don't draw in front of geometry
+
+I can get mono errors by checking g_print calls in goutput.c
+
 Screen grid isn't rendered
+ - Managed camera isn't properly registered with scene manager so its render calls aren't registered
 Handles aren't properly rendered
 Icon gizmo seems to sometimes get struck to the side of the camera