Browse Source

Extended interface for some core-level objects for easier creation
Added MessageHandler and ServiceLocator to utilities
Fixed crash on exit relating to Selection and tree views

Marko Pintera 11 years ago
parent
commit
3512c00011
62 changed files with 604 additions and 153 deletions
  1. 5 0
      BansheeCore/Include/BsGpuParamBlockBuffer.h
  2. 14 0
      BansheeCore/Include/BsGpuParams.h
  3. 13 13
      BansheeCore/Include/BsGpuProgram.h
  4. 5 0
      BansheeCore/Include/BsIndexBuffer.h
  5. 5 0
      BansheeCore/Include/BsMultiRenderTexture.h
  6. 0 2
      BansheeCore/Include/BsRenderSystem.h
  7. 0 1
      BansheeCore/Include/BsRenderSystemCapabilities.h
  8. 0 1
      BansheeCore/Include/BsRenderTarget.h
  9. 5 0
      BansheeCore/Include/BsRenderTexture.h
  10. 0 1
      BansheeCore/Include/BsSamplerState.h
  11. 5 0
      BansheeCore/Include/BsVertexBuffer.h
  12. 5 0
      BansheeCore/Include/BsVertexDeclaration.h
  13. 3 0
      BansheeCore/Source/BsCoreApplication.cpp
  14. 6 0
      BansheeCore/Source/BsGpuParamBlockBuffer.cpp
  15. 5 0
      BansheeCore/Source/BsIndexBuffer.cpp
  16. 6 0
      BansheeCore/Source/BsMultiRenderTexture.cpp
  17. 0 1
      BansheeCore/Source/BsRenderSystemCapabilities.cpp
  18. 5 0
      BansheeCore/Source/BsRenderTexture.cpp
  19. 5 0
      BansheeCore/Source/BsVertexBuffer.cpp
  20. 5 0
      BansheeCore/Source/BsVertexDeclaration.cpp
  21. 3 3
      BansheeD3D11RenderSystem/Source/BsD3D11RenderSystem.cpp
  22. 0 1
      BansheeD3D9RenderSystem/Include/BsD3D9Driver.h
  23. 0 1
      BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h
  24. 0 1
      BansheeD3D9RenderSystem/Source/BsD3D9HLSLProgramFactory.cpp
  25. 0 1
      BansheeD3D9RenderSystem/Source/BsD3D9Mappings.cpp
  26. 10 10
      BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp
  27. 2 0
      BansheeEditor/Include/BsEditorApplication.h
  28. 4 0
      BansheeEditor/Include/BsGUIResourceTreeView.h
  29. 4 0
      BansheeEditor/Include/BsGUISceneTreeView.h
  30. 2 0
      BansheeEditor/Include/BsGizmoManager.h
  31. 1 0
      BansheeEditor/Include/BsHandleSliderDisc.h
  32. 2 0
      BansheeEditor/Include/BsHandleSliderPlane.h
  33. 5 0
      BansheeEditor/Include/BsScenePicking.h
  34. 4 6
      BansheeEditor/Include/BsSelection.h
  35. 3 0
      BansheeEditor/Include/DbgEditorWidget1.h
  36. 40 40
      BansheeEditor/Source/BsBuiltinEditorResources.cpp
  37. 11 3
      BansheeEditor/Source/BsEditorApplication.cpp
  38. 9 0
      BansheeEditor/Source/BsGUIResourceTreeView.cpp
  39. 6 2
      BansheeEditor/Source/BsGUISceneTreeView.cpp
  40. 7 6
      BansheeEditor/Source/BsGizmoManager.cpp
  41. 10 1
      BansheeEditor/Source/BsHandleSliderDisc.cpp
  42. 10 1
      BansheeEditor/Source/BsHandleSliderPlane.cpp
  43. 11 0
      BansheeEditor/Source/BsSceneEditorWidget.cpp
  44. 37 17
      BansheeEditor/Source/BsScenePicking.cpp
  45. 20 8
      BansheeEditor/Source/BsSelection.cpp
  46. 1 1
      BansheeEditorExec/BsEditorExec.cpp
  47. 0 1
      BansheeEngine/Include/BsCamera.h
  48. 9 9
      BansheeEngine/Source/BsBuiltinResources.cpp
  49. 5 2
      BansheeGLRenderSystem/Source/GLSL/src/BsGLSLGpuProgram.cpp
  50. 3 3
      BansheeRenderer/Source/BsBansheeLitTexRenderableHandler.cpp
  51. 4 0
      BansheeUtility/BansheeUtility.vcxproj
  52. 12 0
      BansheeUtility/BansheeUtility.vcxproj.filters
  53. 0 1
      BansheeUtility/Include/BsDynLib.h
  54. 49 0
      BansheeUtility/Include/BsMessageHandler.h
  55. 64 0
      BansheeUtility/Include/BsMessageHandlerFwd.h
  56. 2 1
      BansheeUtility/Include/BsPrerequisitesUtil.h
  57. 43 0
      BansheeUtility/Include/BsServiceLocator.h
  58. 0 2
      BansheeUtility/Include/BsString.h
  59. 92 0
      BansheeUtility/Source/BsMessageHandler.cpp
  60. 0 1
      BansheeUtility/Source/BsString.cpp
  61. 1 1
      ExampleProject/Main/Main.cpp
  62. 26 11
      SceneView.txt

+ 5 - 0
BansheeCore/Include/BsGpuParamBlockBuffer.h

@@ -61,6 +61,11 @@ namespace BansheeEngine
 		 */
 		GpuParamBlockPtr getParamBlock() const { return mParamBlock; }
 
+		/**
+		 * @copydoc	HardwareBufferManager::createGpuParamBlockBuffer
+		 */
+		static GpuParamBlockBufferPtr create(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
+
 	protected:
 		GpuParamBlockUsage mUsage;
 		UINT32 mSize;

+ 14 - 0
BansheeCore/Include/BsGpuParams.h

@@ -171,6 +171,20 @@ namespace BansheeEngine
 			output = GpuParamVec4(&iterFind->second, mInternalData);
 		}
 
+		/**
+		 * @copydoc	getParam(const String&, GpuDataParamBase<T>&)
+		 */
+		template<>
+		void getParam<Color>(const String& name, TGpuDataParam<Color>& output) const
+		{
+			auto iterFind = mParamDesc->params.find(name);
+
+			if (iterFind == mParamDesc->params.end() || iterFind->second.type != GPDT_FLOAT4)
+				BS_EXCEPT(InvalidParametersException, "Cannot find color parameter with the name '" + name + "'");
+
+			output = GpuParamColor(&iterFind->second, mInternalData);
+		}
+
 		/**
 		 * @copydoc	getParam(const String&, GpuDataParamBase<T>&)
 		 */

+ 13 - 13
BansheeCore/Include/BsGpuProgram.h

@@ -27,19 +27,19 @@ namespace BansheeEngine
 	enum GpuProgramProfile
 	{
 		GPP_NONE,
-		GPP_PS_1_1,
-		GPP_PS_1_2,
-		GPP_PS_1_3,
-		GPP_PS_1_4,
-		GPP_PS_2_0,
-		GPP_PS_2_x,
-		GPP_PS_2_a,
-		GPP_PS_2_b,
-		GPP_PS_3_0,
-		GPP_PS_3_x,
-		GPP_PS_4_0,
-		GPP_PS_4_1,
-		GPP_PS_5_0,
+		GPP_FS_1_1,
+		GPP_FS_1_2,
+		GPP_FS_1_3,
+		GPP_FS_1_4,
+		GPP_FS_2_0,
+		GPP_FS_2_x,
+		GPP_FS_2_a,
+		GPP_FS_2_b,
+		GPP_FS_3_0,
+		GPP_FS_3_x,
+		GPP_FS_4_0,
+		GPP_FS_4_1,
+		GPP_FS_5_0,
 		GPP_VS_1_1,
 		GPP_VS_2_0,
 		GPP_VS_2_x,

+ 5 - 0
BansheeCore/Include/BsIndexBuffer.h

@@ -38,6 +38,11 @@ namespace BansheeEngine
 		 */
 		UINT32 getIndexSize() const { return mIndexSize; }
 
+		/**
+		 * @copydoc	HardwareBufferManager::createIndexBuffer
+		 */
+		static IndexBufferPtr create(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
 	protected:
 		IndexBuffer(IndexType idxType, UINT32 numIndexes, GpuBufferUsage usage, bool useSystemMemory);
 

+ 5 - 0
BansheeCore/Include/BsMultiRenderTexture.h

@@ -97,6 +97,11 @@ namespace BansheeEngine
 		 */
 		MultiRenderTextureCore* getCore() const;
 
+		/**
+		 * @copydoc	TextureManager::createMultiRenderTexture
+		 */
+		static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
+
 	protected:
 		MultiRenderTexture() { }
 

+ 0 - 2
BansheeCore/Include/BsRenderSystem.h

@@ -3,8 +3,6 @@
 
 #include <memory>
 
-#include "BsString.h"
-
 #include "BsSamplerState.h"
 #include "BsCommandQueue.h"
 #include "BsDrawOps.h"

+ 0 - 1
BansheeCore/Include/BsRenderSystemCapabilities.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include "BsCorePrerequisites.h"
-#include "BsString.h"
 #include "BsGpuProgram.h"
 
 #define CAPS_CATEGORY_SIZE 8i64

+ 0 - 1
BansheeCore/Include/BsRenderTarget.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include "BsCorePrerequisites.h"
-#include "BsString.h"
 #include "BsPixelUtil.h"
 #include "BsViewport.h"
 #include "BsCoreObject.h"

+ 5 - 0
BansheeCore/Include/BsRenderTexture.h

@@ -97,6 +97,11 @@ namespace BansheeEngine
 			PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 multisampleCount = 0, 
 			const String& multisampleHint = "", bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
 
+		/**
+		 * @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&)
+		 */
+		static RenderTexturePtr create(const RENDER_TEXTURE_DESC& desc);
+
 		/**
 		 * @copydoc	RenderTexture::requiresTextureFlipping
 		 */

+ 0 - 1
BansheeCore/Include/BsSamplerState.h

@@ -2,7 +2,6 @@
 
 #include "BsCorePrerequisites.h"
 #include "BsMatrix4.h"
-#include "BsString.h"
 #include "BsPixelUtil.h"
 #include "BsTexture.h"
 #include "BsColor.h"

+ 5 - 0
BansheeCore/Include/BsVertexBuffer.h

@@ -31,6 +31,11 @@ namespace BansheeEngine
 		 */
 		virtual bool vertexColorReqRGBFlip() { return false; }
 
+		/**
+		 * @copydoc	HardwareBufferManager::createVertexBuffer
+		 */
+		static VertexBufferPtr create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
+
 		static const int MAX_SEMANTIC_IDX = 8;
 	protected:
 		VertexBuffer(UINT32 vertexSize, UINT32 numVertices, GpuBufferUsage usage, bool useSystemMemory);

+ 5 - 0
BansheeCore/Include/BsVertexDeclaration.h

@@ -162,6 +162,11 @@ namespace BansheeEngine
 		 */
 		virtual UINT32 getVertexSize(UINT16 source);
 
+		/**
+		 * @copydoc		HardwareBufferManager::createVertexDeclaration
+		 */
+		static VertexDeclarationPtr createVertexDeclaration(const VertexDeclaration::VertexElementList& elements);
+
     protected:
 		friend class HardwareBufferManager;
 

+ 3 - 0
BansheeCore/Source/BsCoreApplication.cpp

@@ -39,6 +39,7 @@
 #include "BsTaskScheduler.h"
 #include "BsUUID.h"
 #include "BsRenderStats.h"
+#include "BsMessageHandler.h"
 
 #include "BsMaterial.h"
 #include "BsShader.h"
@@ -67,6 +68,7 @@ namespace BansheeEngine
 		Platform::_startUp();
 		MemStack::beginThread();
 
+		MessageHandler::startUp();
 		RenderTargetManager::startUp();
 		UUIDGenerator::startUp();
 		ProfilerCPU::startUp();
@@ -152,6 +154,7 @@ namespace BansheeEngine
 		ProfilerCPU::shutDown();
 		UUIDGenerator::shutDown();
 		RenderTargetManager::shutDown();
+		MessageHandler::shutDown();
 
 		MemStack::endThread();
 		Platform::_shutDown();

+ 6 - 0
BansheeCore/Source/BsGpuParamBlockBuffer.cpp

@@ -1,5 +1,6 @@
 #include "BsGpuParamBlockBuffer.h"
 #include "BsGpuParamBlock.h"
+#include "BsHardwareBufferManager.h"
 
 namespace BansheeEngine
 {
@@ -57,4 +58,9 @@ namespace BansheeEngine
 
 		GpuParamBlockBuffer::destroy_internal();
 	}
+
+	static GpuParamBlockBufferPtr create(UINT32 size, GpuParamBlockUsage usage)
+	{
+		return HardwareBufferManager::instance().createGpuParamBlockBuffer(size, usage);
+	}
 }

+ 5 - 0
BansheeCore/Source/BsIndexBuffer.cpp

@@ -24,4 +24,9 @@ namespace BansheeEngine
     {
 
     }
+
+	IndexBufferPtr IndexBuffer::create(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage)
+	{
+		return HardwareBufferManager::instance().createIndexBuffer(itype, numIndexes, usage);
+	}
 }

+ 6 - 0
BansheeCore/Source/BsMultiRenderTexture.cpp

@@ -3,6 +3,7 @@
 #include "BsException.h"
 #include "BsDebug.h"
 #include "BsCoreThread.h"
+#include "BsTextureManager.h"
 
 namespace BansheeEngine
 {
@@ -182,4 +183,9 @@ namespace BansheeEngine
 
 		return createCore(coreProperties, mDesc);
 	}
+
+	MultiRenderTexturePtr MultiRenderTexture::create(const MULTI_RENDER_TEXTURE_DESC& desc)
+	{
+		return TextureManager::instance().createMultiRenderTexture(desc);
+	}
 }

+ 0 - 1
BansheeCore/Source/BsRenderSystemCapabilities.cpp

@@ -1,6 +1,5 @@
 #include "BsRenderSystemCapabilities.h"
 #include "BsException.h"
-#include "BsString.h"
 
 namespace BansheeEngine 
 {

+ 5 - 0
BansheeCore/Source/BsRenderTexture.cpp

@@ -102,6 +102,11 @@ namespace BansheeEngine
 			multisampleCount, multisampleHint, createDepth, depthStencilFormat);
 	}
 
+	RenderTexturePtr RenderTexture::create(const RENDER_TEXTURE_DESC& desc)
+	{
+		return TextureManager::instance().createRenderTexture(desc);
+	}
+
 	const RenderTextureProperties& RenderTexture::getProperties() const 
 	{ 
 		THROW_IF_CORE_THREAD;

+ 5 - 0
BansheeCore/Source/BsVertexBuffer.cpp

@@ -12,4 +12,9 @@ namespace BansheeEngine
     {
         mSizeInBytes = mVertexSize * numVertices;
     }
+
+	VertexBufferPtr VertexBuffer::create(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut)
+	{
+		return HardwareBufferManager::instance().createVertexBuffer(vertexSize, numVerts, usage, streamOut);
+	}
 }

+ 5 - 0
BansheeCore/Source/BsVertexDeclaration.cpp

@@ -209,6 +209,11 @@ namespace BansheeEngine
 		return size;
 	}
 
+	VertexDeclarationPtr VertexDeclaration::createVertexDeclaration(const VertexDeclaration::VertexElementList& elements)
+	{
+		return HardwareBufferManager::instance().createVertexDeclaration(elements);
+	}
+
 	/************************************************************************/
 	/* 								SERIALIZATION                      		*/
 	/************************************************************************/

+ 3 - 3
BansheeD3D11RenderSystem/Source/BsD3D11RenderSystem.cpp

@@ -767,7 +767,7 @@ namespace BansheeEngine
 			rsc->addShaderProfile("vs_4_0");
 			rsc->addShaderProfile("gs_4_0");
 
-			rsc->addGpuProgramProfile(GPP_PS_4_0, "ps_4_0");
+			rsc->addGpuProgramProfile(GPP_FS_4_0, "ps_4_0");
 			rsc->addGpuProgramProfile(GPP_VS_4_0, "vs_4_0");
 			rsc->addGpuProgramProfile(GPP_GS_4_0, "gs_4_0");
 
@@ -792,7 +792,7 @@ namespace BansheeEngine
 			rsc->addShaderProfile("vs_4_1");
 			rsc->addShaderProfile("gs_4_1");
 
-			rsc->addGpuProgramProfile(GPP_PS_4_1, "ps_4_1");
+			rsc->addGpuProgramProfile(GPP_FS_4_1, "ps_4_1");
 			rsc->addGpuProgramProfile(GPP_VS_4_1, "vs_4_1");
 			rsc->addGpuProgramProfile(GPP_GS_4_1, "gs_4_1");
 		}
@@ -806,7 +806,7 @@ namespace BansheeEngine
 			rsc->addShaderProfile("hs_5_0");
 			rsc->addShaderProfile("ds_5_0");
 
-			rsc->addGpuProgramProfile(GPP_PS_5_0, "ps_5_0");
+			rsc->addGpuProgramProfile(GPP_FS_5_0, "ps_5_0");
 			rsc->addGpuProgramProfile(GPP_VS_5_0, "vs_5_0");
 			rsc->addGpuProgramProfile(GPP_GS_5_0, "gs_5_0");
 			rsc->addGpuProgramProfile(GPP_CS_5_0, "cs_5_0");

+ 0 - 1
BansheeD3D9RenderSystem/Include/BsD3D9Driver.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include "BsD3D9Prerequisites.h"
-#include "BsString.h"
 
 namespace BansheeEngine
 {

+ 0 - 1
BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include "BsD3D9Prerequisites.h"
-#include "BsString.h"
 #include "BsRenderSystem.h"
 #include "BsRenderSystemCapabilities.h"
 #include "BsD3D9Mappings.h"

+ 0 - 1
BansheeD3D9RenderSystem/Source/BsD3D9HLSLProgramFactory.cpp

@@ -1,5 +1,4 @@
 #include "BsD3D9HLSLProgramFactory.h"
-#include "BsString.h"
 #include "BsD3D9GpuProgram.h"
 
 namespace BansheeEngine

+ 0 - 1
BansheeD3D9RenderSystem/Source/BsD3D9Mappings.cpp

@@ -1,5 +1,4 @@
 #include "BsD3D9Mappings.h"
-#include "BsString.h"
 #include "BsException.h"
 #include "BsDebug.h"
 

+ 10 - 10
BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp

@@ -2037,49 +2037,49 @@ namespace BansheeEngine
 			if (minor > 0)
 			{
 				rsc->addShaderProfile("ps_3_x");
-				rsc->addGpuProgramProfile(GPP_PS_3_x, "ps_3_x");
+				rsc->addGpuProgramProfile(GPP_FS_3_x, "ps_3_x");
 			}
 
 			rsc->addShaderProfile("ps_3_0");
-			rsc->addGpuProgramProfile(GPP_PS_3_0, "ps_3_0");
+			rsc->addGpuProgramProfile(GPP_FS_3_0, "ps_3_0");
 		case 2:
 			if (ps2x)
 			{
 				rsc->addShaderProfile("ps_2_x");
-				rsc->addGpuProgramProfile(GPP_PS_2_x, "ps_2_x");
+				rsc->addGpuProgramProfile(GPP_FS_2_x, "ps_2_x");
 			}
 			if (ps2a)
 			{
 				rsc->addShaderProfile("ps_2_a");
-				rsc->addGpuProgramProfile(GPP_PS_2_a, "ps_2_a");
+				rsc->addGpuProgramProfile(GPP_FS_2_a, "ps_2_a");
 			}
 			if (ps2b)
 			{
 				rsc->addShaderProfile("ps_2_b");
-				rsc->addGpuProgramProfile(GPP_PS_2_b, "ps_2_b");
+				rsc->addGpuProgramProfile(GPP_FS_2_b, "ps_2_b");
 			}
 
 			rsc->addShaderProfile("ps_2_0");
-			rsc->addGpuProgramProfile(GPP_PS_2_0, "ps_2_0");
+			rsc->addGpuProgramProfile(GPP_FS_2_0, "ps_2_0");
 		case 1:
 			if (major > 1 || minor >= 4)
 			{
 				rsc->addShaderProfile("ps_1_4");
-				rsc->addGpuProgramProfile(GPP_PS_1_4, "ps_1_4");
+				rsc->addGpuProgramProfile(GPP_FS_1_4, "ps_1_4");
 			}
 			if (major > 1 || minor >= 3)
 			{
 				rsc->addShaderProfile("ps_1_3");
-				rsc->addGpuProgramProfile(GPP_PS_1_3, "ps_1_3");
+				rsc->addGpuProgramProfile(GPP_FS_1_3, "ps_1_3");
 			}
 			if (major > 1 || minor >= 2)
 			{
 				rsc->addShaderProfile("ps_1_2");
-				rsc->addGpuProgramProfile(GPP_PS_1_2, "ps_1_2");
+				rsc->addGpuProgramProfile(GPP_FS_1_2, "ps_1_2");
 			}
 
 			rsc->addShaderProfile("ps_1_1");
-			rsc->addGpuProgramProfile(GPP_PS_1_1, "ps_1_1");
+			rsc->addGpuProgramProfile(GPP_FS_1_1, "ps_1_1");
 		}
 	}
 

+ 2 - 0
BansheeEditor/Include/BsEditorApplication.h

@@ -18,6 +18,8 @@ namespace BansheeEngine
 		bool isGameViewFocused() const;
 		bool isSceneViewFocused() const;
 		const Path& getActiveProjectPath() const;
+
+
 	private:
 		virtual void onStartUp();
 		virtual void update();

+ 4 - 0
BansheeEditor/Include/BsGUIResourceTreeView.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "BsEditorPrerequisites.h"
+#include "BsServiceLocator.h"
 #include "BsGUITreeView.h"
 #include "BsProjectLibrary.h"
 #include "BsEvent.h"
@@ -48,6 +49,7 @@ namespace BansheeEngine
 		void setSelection(const Vector<Path>& paths);
 
 		Event<void()> onSelectionChanged;
+		static const MessageId SELECTION_CHANGED_MSG;
 
 	protected:
 		virtual ~GUIResourceTreeView();
@@ -104,4 +106,6 @@ namespace BansheeEngine
 
 		void _changeParentWidget(GUIWidget* widget);
 	};
+
+	typedef ServiceLocator<GUIResourceTreeView> ResourceTreeViewLocator;
 }

+ 4 - 0
BansheeEditor/Include/BsGUISceneTreeView.h

@@ -3,6 +3,7 @@
 #include "BsEditorPrerequisites.h"
 #include "BsGUITreeView.h"
 #include "BsEvent.h"
+#include "BsServiceLocator.h"
 
 namespace BansheeEngine
 {
@@ -46,6 +47,7 @@ namespace BansheeEngine
 		void setSelection(const Vector<HSceneObject>& objects);
 
 		Event<void()> onSelectionChanged;
+		static const MessageId SELECTION_CHANGED_MSG;
 	protected:
 		virtual ~GUISceneTreeView();
 
@@ -72,4 +74,6 @@ namespace BansheeEngine
 
 		void deleteTreeElementInternal(TreeElement* element);
 	};
+
+	typedef ServiceLocator<GUISceneTreeView> SceneTreeViewLocator;
 }

+ 2 - 0
BansheeEditor/Include/BsGizmoManager.h

@@ -108,6 +108,7 @@ namespace BansheeEngine
 
 			// Core
 			MaterialProxyPtr proxy;
+			GpuParamsPtr mFragParams;
 			GpuParamMat4 mViewProj;
 			GpuParamTexture mTexture;
 		};
@@ -127,6 +128,7 @@ namespace BansheeEngine
 
 			// Core
 			MaterialProxyPtr proxy;
+			GpuParamsPtr mFragParams;
 			GpuParamMat4 mViewProj;
 			GpuParamTexture mTexture;
 		};

+ 1 - 0
BansheeEditor/Include/BsHandleSliderDisc.h

@@ -21,6 +21,7 @@ namespace BansheeEngine
 
 	protected:
 		virtual void updateCachedTransform() const;
+		virtual void reset();
 
 		static const float TORUS_RADIUS;
 

+ 2 - 0
BansheeEditor/Include/BsHandleSliderPlane.h

@@ -20,6 +20,8 @@ namespace BansheeEngine
 		Vector3 getNewPosition() const { return mPosition; /* TODO */ }
 
 	protected:
+		void reset();
+
 		Vector3 mDirection1;
 		Vector3 mDirection2;
 		float mLength;

+ 5 - 0
BansheeEditor/Include/BsScenePicking.h

@@ -44,6 +44,11 @@ namespace BansheeEngine
 			MaterialProxyPtr mMatPickingProxy;
 			MaterialProxyPtr mMatPickingAlphaProxy;
 
+			GpuParamsPtr mParamPickingVertParams;
+			GpuParamsPtr mParamPickingFragParams;
+			GpuParamsPtr mParamPickingAlphaVertParams;
+			GpuParamsPtr mParamPickingAlphaFragParams;
+
 			GpuParamMat4 mParamPickingWVP;
 			GpuParamMat4 mParamPickingAlphaWVP;
 			GpuParamColor mParamPickingColor;

+ 4 - 6
BansheeEditor/Include/BsSelection.h

@@ -2,13 +2,14 @@
 
 #include "BsEditorPrerequisites.h"
 #include "BsModule.h"
+#include "BsPath.h"
 
 namespace BansheeEngine
 {
 	class BS_ED_EXPORT Selection : public Module<Selection>
 	{
 	public:
-		Selection(GUISceneTreeView* sceneTreeView, GUIResourceTreeView* resourceTreeView);
+		Selection();
 		~Selection();
 
 		const Vector<HSceneObject>& getSceneObjects() const;
@@ -24,13 +25,10 @@ namespace BansheeEngine
 		void sceneSelectionChanged();
 		void resourceSelectionChanged();
 
-		GUISceneTreeView* mSceneTreeView;
-		GUIResourceTreeView* mResourceTreeView;
-
 		Vector<HSceneObject> mSelectedSceneObjects;
 		Vector<Path> mSelectedResourcePaths;
 
-		HEvent mSceneSelectionChangedConn;
-		HEvent mResourceSelectionChangedConn;
+		HMessage mSceneSelectionChangedConn;
+		HMessage mResourceSelectionChangedConn;
 	};
 }

+ 3 - 0
BansheeEditor/Include/DbgEditorWidget1.h

@@ -18,6 +18,9 @@ namespace BansheeEngine
 		static void close();
 		static const String& getTypeName();
 
+		GUISceneTreeView* getSceneTreeView() const { return mSceneTreeView; }
+		GUIResourceTreeView* getResourceTreeView() const { return mResourceTreeView; }
+
 	private:
 		static DbgEditorWidget1* Instance;
 		GUISceneTreeView* mSceneTreeView = nullptr;

+ 40 - 40
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -1064,65 +1064,65 @@ namespace BansheeEngine
 		static const GpuProgramImportData GPU_PROGRAM_IMPORT_DATA[] = 
 		{
 			{ SceneGridVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ SceneGridPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ SceneGridPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ ShaderDockOverlayVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ ShaderDockOverlayPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ ShaderDockOverlayPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ PickingVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ PickingPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ PickingPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ PickingAlphaVSFile,		"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ PickingAlphaPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ PickingAlphaPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ ShaderWireGizmoVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ ShaderWireGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ ShaderWireGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ ShaderSolidGizmoVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ ShaderSolidGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ ShaderSolidGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ ShaderIconGizmo0VSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ ShaderIconGizmo0PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ ShaderIconGizmo0PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ ShaderIconGizmo1VSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ ShaderIconGizmo1PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ ShaderIconGizmo1PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ GizmoPickingVSFile,		"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ GizmoPickingPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ GizmoPickingPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ GizmoPickingAlphaVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL11ShaderSubFolder },
-			{ GizmoPickingAlphaPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL11ShaderSubFolder },
+			{ GizmoPickingAlphaPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"hlsl", HLSL11ShaderSubFolder },
 			{ SceneGridVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ SceneGridPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ SceneGridPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0,		"hlsl", HLSL9ShaderSubFolder },
 			{ ShaderDockOverlayVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderDockOverlayPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ PickingVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ PickingPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ PickingAlphaVSFile,		"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ PickingAlphaPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderWireGizmoVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderWireGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderSolidGizmoVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderSolidGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderIconGizmo0VSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderIconGizmo0PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderIconGizmo1VSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ ShaderIconGizmo1PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ GizmoPickingVSFile,		"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ GizmoPickingPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ GizmoPickingAlphaVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"hlsl", HLSL9ShaderSubFolder },
-			{ GizmoPickingAlphaPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderDockOverlayPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ PickingVSFile,			"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ PickingPSFile,			"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ PickingAlphaVSFile,		"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ PickingAlphaPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderWireGizmoVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderWireGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderSolidGizmoVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderSolidGizmoPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderIconGizmo0VSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderIconGizmo0PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderIconGizmo1VSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ ShaderIconGizmo1PSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ GizmoPickingVSFile,		"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ GizmoPickingPSFile,		"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ GizmoPickingAlphaVSFile,	"vs_main",	GPT_VERTEX_PROGRAM,		GPP_VS_3_0,		"hlsl", HLSL9ShaderSubFolder },
+			{ GizmoPickingAlphaPSFile,	"ps_main",	GPT_FRAGMENT_PROGRAM,	GPP_FS_3_0,		"hlsl", HLSL9ShaderSubFolder },
 			{ SceneGridVSFile,			"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ SceneGridPSFile,			"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ SceneGridPSFile,			"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ ShaderDockOverlayVSFile,	"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ ShaderDockOverlayPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ ShaderDockOverlayPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ PickingVSFile,			"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ PickingPSFile,			"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ PickingPSFile,			"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ PickingAlphaVSFile,		"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ PickingAlphaPSFile,		"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ PickingAlphaPSFile,		"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ ShaderWireGizmoVSFile,	"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ ShaderWireGizmoPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ ShaderWireGizmoPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ ShaderSolidGizmoVSFile,	"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ ShaderSolidGizmoPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ ShaderSolidGizmoPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ ShaderIconGizmo0VSFile,	"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ ShaderIconGizmo0PSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ ShaderIconGizmo0PSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ ShaderIconGizmo1VSFile,	"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ ShaderIconGizmo1PSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ ShaderIconGizmo1PSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ GizmoPickingVSFile,		"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ GizmoPickingPSFile,		"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ GizmoPickingPSFile,		"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 			{ GizmoPickingAlphaVSFile,	"main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0,		"glsl", GLSLShaderSubFolder },
-			{ GizmoPickingAlphaPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0,		"glsl", GLSLShaderSubFolder },
+			{ GizmoPickingAlphaPSFile,	"main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0,		"glsl", GLSLShaderSubFolder },
 		};
 
 		if (FileSystem::exists(DefaultSkinFolderRaw))
@@ -1331,7 +1331,7 @@ namespace BansheeEngine
 		newPass->setFragmentProgram(psProgram);
 
 		RASTERIZER_STATE_DESC rasterizerDesc;
-		rasterizerDesc.scissorEnable = true;
+		rasterizerDesc.scissorEnable = false;
 		rasterizerDesc.cullMode = cullMode;
 
 		HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);
@@ -1361,7 +1361,7 @@ namespace BansheeEngine
 		newPass->setFragmentProgram(psProgram);
 
 		RASTERIZER_STATE_DESC rasterizerDesc;
-		rasterizerDesc.scissorEnable = true;
+		rasterizerDesc.scissorEnable = false;
 		rasterizerDesc.cullMode = cullMode;
 
 		HRasterizerState rasterizerState = RasterizerState::create(rasterizerDesc);

+ 11 - 3
BansheeEditor/Source/BsEditorApplication.cpp

@@ -37,6 +37,8 @@
 #include "BsGUILayout.h"
 #include "BsEvent.h"
 #include "BsRenderer.h"
+#include "BsScenePicking.h"
+#include "BsSelection.h"
 
 namespace BansheeEngine
 {
@@ -79,10 +81,16 @@ namespace BansheeEngine
 		UndoRedo::startUp();
 		EditorWindowManager::startUp();
 		EditorWidgetManager::startUp();
+
+		ScenePicking::startUp();
+		Selection::startUp();
 	}
 
 	EditorApplication::~EditorApplication()
 	{
+		Selection::shutDown();
+		ScenePicking::shutDown();
+
 		saveWidgetLayout(EditorWidgetManager::instance().getLayout());
 
 		EditorWidgetManager::shutDown();
@@ -165,7 +173,7 @@ namespace BansheeEngine
 										 psLoc = L"..\\..\\..\\..\\Data\\hlsl11_ps.gpuprog";
 										 vsLoc = L"..\\..\\..\\..\\Data\\hlsl11_vs.gpuprog";
 										 language = "hlsl";
-										 psProfile = GPP_PS_4_0;
+										 psProfile = GPP_FS_4_0;
 										 vsProfile = GPP_VS_4_0;
 										 psEntry = "ps_main";
 										 vsEntry = "vs_main";
@@ -176,7 +184,7 @@ namespace BansheeEngine
 										psLoc = L"..\\..\\..\\..\\Data\\hlsl9_ps.gpuprog";
 										vsLoc = L"..\\..\\..\\..\\Data\\hlsl9_vs.gpuprog";
 										language = "hlsl";
-										psProfile = GPP_PS_2_0;
+										psProfile = GPP_FS_2_0;
 										vsProfile = GPP_VS_2_0;
 										psEntry = "ps_main";
 										vsEntry = "vs_main";
@@ -187,7 +195,7 @@ namespace BansheeEngine
 										   psLoc = L"..\\..\\..\\..\\Data\\glsl_ps.gpuprog";
 										   vsLoc = L"..\\..\\..\\..\\Data\\glsl_vs.gpuprog";
 										   language = "glsl";
-										   psProfile = GPP_PS_2_0;
+										   psProfile = GPP_FS_2_0;
 										   vsProfile = GPP_VS_2_0;
 										   psEntry = "main";
 										   vsEntry = "main";

+ 9 - 0
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -11,11 +11,14 @@
 #include "BsRenderWindow.h"
 #include "BsPlatform.h"
 #include "BsPath.h"
+#include "BsSelection.h"
 
 using namespace std::placeholders;
 
 namespace BansheeEngine
 {
+	const MessageId GUIResourceTreeView::SELECTION_CHANGED_MSG = MessageId("ResourceTreeView_SelectionChanged");
+
 	GUIResourceTreeView::InternalDraggedResources::InternalDraggedResources(UINT32 numObjects)
 		:numObjects(numObjects)
 	{
@@ -34,6 +37,8 @@ namespace BansheeEngine
 		:GUITreeView(backgroundStyle, elementBtnStyle, foldoutBtnStyle, selectionBackgroundStyle, editBoxStyle, dragHighlightStyle,
 		dragSepHighlightStyle, layoutOptions), mDraggedResources(nullptr), mCurrentWindow(nullptr), mDropTarget(nullptr), mDropTargetDragActive(false)
 	{
+		ResourceTreeViewLocator::_provide(this);
+
 		ProjectLibrary::instance().onEntryAdded.connect(std::bind(&GUIResourceTreeView::entryAdded, this, _1));
 		ProjectLibrary::instance().onEntryRemoved.connect(std::bind(&GUIResourceTreeView::entryRemoved, this, _1));
 
@@ -50,6 +55,8 @@ namespace BansheeEngine
 	GUIResourceTreeView::~GUIResourceTreeView()
 	{
 		clearDropTarget();
+
+		ResourceTreeViewLocator::_provide(nullptr);
 	}
 
 	GUIResourceTreeView* GUIResourceTreeView::create(const String& backgroundStyle, const String& elementBtnStyle, 
@@ -466,6 +473,8 @@ namespace BansheeEngine
 	void GUIResourceTreeView::selectionChanged()
 	{
 		onSelectionChanged();
+
+		sendMessage(SELECTION_CHANGED_MSG);
 	}
 
 	Vector<Path> GUIResourceTreeView::getSelection() const

+ 6 - 2
BansheeEditor/Source/BsGUISceneTreeView.cpp

@@ -5,9 +5,12 @@
 #include "BsCmdEditPlainFieldGO.h"
 #include "BsDragAndDropManager.h"
 #include "BsCmdReparentSO.h"
+#include "BsSelection.h"
 
 namespace BansheeEngine
 {
+	const MessageId GUISceneTreeView::SELECTION_CHANGED_MSG = MessageId("SceneTreeView_SelectionChanged");
+
 	DraggedSceneObjects::DraggedSceneObjects(UINT32 numObjects)
 		:numObjects(numObjects)
 	{
@@ -26,12 +29,12 @@ namespace BansheeEngine
 		:GUITreeView(backgroundStyle, elementBtnStyle, foldoutBtnStyle, selectionBackgroundStyle, editBoxStyle, dragHighlightStyle,
 		dragSepHighlightStyle, layoutOptions)
 	{
-		
+		SceneTreeViewLocator::_provide(this);
 	}
 
 	GUISceneTreeView::~GUISceneTreeView()
 	{
-		
+		SceneTreeViewLocator::_provide(nullptr);
 	}
 
 	GUISceneTreeView* GUISceneTreeView::create(const String& backgroundStyle, const String& elementBtnStyle, 
@@ -263,6 +266,7 @@ namespace BansheeEngine
 	void GUISceneTreeView::selectionChanged()
 	{
 		onSelectionChanged();
+		sendMessage(SELECTION_CHANGED_MSG);
 	}
 
 	Vector<HSceneObject> GUISceneTreeView::getSelection() const

+ 7 - 6
BansheeEditor/Source/BsGizmoManager.cpp

@@ -102,9 +102,9 @@ namespace BansheeEngine
 
 			vertParams->getParam("matViewProj", mIconMaterial.mViewProj);
 
-			GpuParamsPtr fragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
+			mIconMaterial.mFragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
 
-			fragParams->getTextureParam("mainTexture", mIconMaterial.mTexture);
+			mIconMaterial.mFragParams->getTextureParam("mainTexture", mIconMaterial.mTexture);
 		}
 
 		{
@@ -120,12 +120,11 @@ namespace BansheeEngine
 
 			vertParams->getParam("matViewProj", mAlphaPickingMaterial.mViewProj);
 
-			GpuParamsPtr fragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
-
-			fragParams->getTextureParam("mainTexture", mAlphaPickingMaterial.mTexture);
+			mAlphaPickingMaterial.mFragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
+			mAlphaPickingMaterial.mFragParams->getTextureParam("mainTexture", mAlphaPickingMaterial.mTexture);
 
 			GpuParamFloat alphaCutoffParam;
-			fragParams->getParam("alphaCutoff", alphaCutoffParam);
+			mAlphaPickingMaterial.mFragParams->getParam("alphaCutoff", alphaCutoffParam);
 			alphaCutoffParam.set(PICKING_ALPHA_CUTOFF);
 		}
 
@@ -707,6 +706,7 @@ namespace BansheeEngine
 			for (auto curRenderData : *renderData)
 			{
 				mIconMaterial.mTexture.set(curRenderData.texture);
+				rs.bindGpuParams(GPT_FRAGMENT_PROGRAM, mIconMaterial.mFragParams);
 
 				rs.drawIndexed(curIndexOffset, curRenderData.count * 6, 0, curRenderData.count * 4);
 				curIndexOffset += curRenderData.count * 6;
@@ -772,6 +772,7 @@ namespace BansheeEngine
 		for (auto curRenderData : *renderData)
 		{
 			mAlphaPickingMaterial.mTexture.set(curRenderData.texture);
+			rs.bindGpuParams(GPT_FRAGMENT_PROGRAM, mAlphaPickingMaterial.mFragParams);
 
 			rs.drawIndexed(curIndexOffset, curRenderData.count * 6, 0, curRenderData.count * 4);
 			curIndexOffset += curRenderData.count * 6;

+ 10 - 1
BansheeEditor/Source/BsHandleSliderDisc.cpp

@@ -45,11 +45,20 @@ namespace BansheeEngine
 		auto intersect = mCollider.intersects(ray);
 
 		if (intersect.first)
-			return intersect.second;
+		{
+			t = intersect.second;
+
+			return true;
+		}
 
 		return false;
 	}
 
+	void HandleSliderDisc::reset()
+	{
+		// TODO - Clear delta
+	}
+
 	void HandleSliderDisc::update(const HCamera& camera, const Vector2I& pointerPos, const Ray& ray)
 	{
 		assert(getState() == State::Active);

+ 10 - 1
BansheeEditor/Source/BsHandleSliderPlane.cpp

@@ -36,11 +36,20 @@ namespace BansheeEngine
 		auto intersect = mCollider.intersects(ray);
 
 		if (intersect.first)
-			return intersect.second;
+		{
+			t = intersect.second;
+
+			return true;
+		}
 
 		return false;
 	}
 
+	void HandleSliderPlane::reset()
+	{
+		// TODO - Clear delta
+	}
+
 	void HandleSliderPlane::update(const HCamera& camera, const Vector2I& pointerPos, const Ray& ray)
 	{
 		assert(getState() == State::Active);

+ 11 - 0
BansheeEditor/Source/BsSceneEditorWidget.cpp

@@ -20,6 +20,7 @@
 #include "BsSceneGrid.h"
 #include "BsInput.h"
 #include "BsGUILayoutUtility.h"
+#include "BsScenePicking.h"
 
 // DEBUG ONLY
 #include "BsTime.h"
@@ -110,6 +111,16 @@ namespace BansheeEngine
 		Vector2I scenePos;
 		if (!toSceneViewPos(event.screenPos, scenePos))
 			return;
+
+		HSceneObject pickedObject = ScenePicking::instance().pickClosestSceneObject(mCamera, scenePos, Vector2I(1, 1));
+		if (pickedObject)
+		{
+			LOGDBG("PICKED OBJECT: " + pickedObject->getName());
+		}
+		else
+		{
+			LOGDBG("PICKED NO OBJECT!");
+		}
 	}
 
 	void SceneEditorWidget::doOnResized(UINT32 width, UINT32 height)

+ 37 - 17
BansheeEditor/Source/BsScenePicking.cpp

@@ -52,28 +52,27 @@ namespace BansheeEngine
 			{
 				// TODO - Make a better interface when dealing with parameters through proxies?
 				MaterialProxyPtr proxy = md.mMatPickingProxy;
-				GpuParamsPtr vertParams = proxy->params[proxy->passes[0].vertexProgParamsIdx];
 
-				vertParams->getParam("matWorldViewProj", md.mParamPickingWVP);
+				md.mParamPickingVertParams = proxy->params[proxy->passes[0].vertexProgParamsIdx];
+				md.mParamPickingVertParams->getParam("matWorldViewProj", md.mParamPickingWVP);
 
-				GpuParamsPtr fragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
-
-				fragParams->getParam("colorIndex", md.mParamPickingColor);
+				md.mParamPickingFragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
+				md.mParamPickingFragParams->getParam("colorIndex", md.mParamPickingColor);
 			}
 
 			{
 				MaterialProxyPtr proxy = md.mMatPickingAlphaProxy;
-				GpuParamsPtr vertParams = proxy->params[proxy->passes[0].vertexProgParamsIdx];
 
-				vertParams->getParam("matWorldViewProj", md.mParamPickingAlphaWVP);
+				md.mParamPickingAlphaVertParams = proxy->params[proxy->passes[0].vertexProgParamsIdx];
+				md.mParamPickingAlphaVertParams->getParam("matWorldViewProj", md.mParamPickingAlphaWVP);
 
-				GpuParamsPtr fragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
+				md.mParamPickingAlphaFragParams = proxy->params[proxy->passes[0].fragmentProgParamsIdx];
 
-				fragParams->getParam("colorIndex", md.mParamPickingAlphaColor);
-				fragParams->getTextureParam("mainTexture", md.mParamPickingAlphaTexture);
+				md.mParamPickingAlphaFragParams->getParam("colorIndex", md.mParamPickingAlphaColor);
+				md.mParamPickingAlphaFragParams->getTextureParam("mainTexture", md.mParamPickingAlphaTexture);
 
 				GpuParamFloat alphaCutoffParam;
-				fragParams->getParam("alphaCutoff", alphaCutoffParam);
+				md.mParamPickingAlphaFragParams->getParam("alphaCutoff", alphaCutoffParam);
 				alphaCutoffParam.set(ALPHA_CUTOFF);
 			}
 		}
@@ -129,6 +128,8 @@ namespace BansheeEngine
 				return (UINT32)a.alpha > (UINT32)b.alpha;
 		};
 
+		Matrix4 viewProjMatrix = cam->getProjectionMatrix() * cam->getViewMatrix();
+
 		const Vector<HRenderable>& renderables = SceneManager::instance().getAllRenderables();
 		RenderableSet pickData(comparePickElement);
 		Map<UINT32, HRenderable> idxToRenderable;
@@ -170,7 +171,14 @@ namespace BansheeEngine
 
 						firstPass = originalMat->getPass(0); // Note: We only ever check the first pass, problem?
 						bool useAlphaShader = firstPass->hasBlending();
-						CullingMode cullMode = firstPass->getRasterizerState()->getCullMode();
+						
+						RasterizerStatePtr rasterizerState;
+						if (firstPass->getRasterizerState() == nullptr)
+							rasterizerState = RasterizerState::getDefault();
+						else
+							rasterizerState = firstPass->getRasterizerState().getInternalPtr();
+
+						CullingMode cullMode = rasterizerState->getCullMode();
 
 						MeshProxyPtr meshProxy;
 
@@ -194,7 +202,9 @@ namespace BansheeEngine
 						}
 
 						idxToRenderable[idx] = renderable;
-						pickData.insert({ meshProxy, idx, worldTransform, useAlphaShader, cullMode, mainTexture });
+
+						Matrix4 wvpTransform = viewProjMatrix * worldTransform;
+						pickData.insert({ meshProxy, idx, wvpTransform, useAlphaShader, cullMode, mainTexture });
 					}
 				}
 			}
@@ -211,7 +221,10 @@ namespace BansheeEngine
 
 		for (auto& selectedObject : selectedObjects)
 		{
-			results.push_back({ idxToRenderable[selectedObject]->SO(), 0, PickResult::Type::SceneObject });
+			auto iterFind = idxToRenderable.find(selectedObject);
+
+			if (iterFind != idxToRenderable.end())
+				results.push_back({ iterFind->second->SO(), 0, PickResult::Type::SceneObject });
 		}
 
 		return results;
@@ -233,7 +246,7 @@ namespace BansheeEngine
 		TexturePtr outputTexture = rtt->getBindableColorTexture().getInternalPtr();
 
 		rs.setViewport(vp);
-		rs.clearRenderTarget(FBT_COLOR, Color::White);
+		rs.clearRenderTarget(FBT_COLOR | FBT_DEPTH | FBT_STENCIL, Color::White);
 		rs.setScissorRect(position.x, position.y, position.x + area.x, position.y + area.y);
 
 		Renderer::setPass(*mMaterialData[0].mMatPickingProxy, 0);
@@ -262,11 +275,17 @@ namespace BansheeEngine
 				md.mParamPickingAlphaWVP.set(renderable.wvpTransform);
 				md.mParamPickingAlphaColor.set(color);
 				md.mParamPickingAlphaTexture.set(renderable.mainTexture);
+
+				rs.bindGpuParams(GPT_VERTEX_PROGRAM, md.mParamPickingAlphaVertParams);
+				rs.bindGpuParams(GPT_FRAGMENT_PROGRAM, md.mParamPickingAlphaFragParams);
 			}
 			else
 			{
 				md.mParamPickingWVP.set(renderable.wvpTransform);
 				md.mParamPickingColor.set(color);
+
+				rs.bindGpuParams(GPT_VERTEX_PROGRAM, md.mParamPickingVertParams);
+				rs.bindGpuParams(GPT_FRAGMENT_PROGRAM, md.mParamPickingFragParams);
 			}
 
 			Renderer::draw(*renderable.mesh);
@@ -279,6 +298,7 @@ namespace BansheeEngine
 
 		rs.readSubresource(outputTexture, 0, outputData, unused);
 
+		// TODO - Only search scissor rect
 		Map<UINT32, UINT32> selectionScores;
 		UINT32 numPixels = outputPixelData->getWidth() * outputPixelData->getHeight();
 		for (UINT32 y = 0; y < outputPixelData->getHeight(); y++)
@@ -306,7 +326,7 @@ namespace BansheeEngine
 		UINT32 idx = 0;
 		for (auto& selectionScore : selectionScores)
 		{
-			selectedObjects[idx++] = { selectionScore.second, selectionScore.first };
+			selectedObjects[idx++] = { selectionScore.first, selectionScore.second };
 		}
 
 		std::sort(selectedObjects.begin(), selectedObjects.end(),
@@ -319,7 +339,7 @@ namespace BansheeEngine
 		for (auto& selectedObject : selectedObjects)
 			results.push_back(selectedObject.index);
 
-		asyncOp._completeOperation(selectedObjects);
+		asyncOp._completeOperation(results);
 	}
 
 	Color ScenePicking::encodeIndex(UINT32 index)

+ 20 - 8
BansheeEditor/Source/BsSelection.cpp

@@ -3,14 +3,17 @@
 #include "BsGUIResourceTreeView.h"
 #include "BsProjectLibrary.h"
 #include "BsProjectResourceMeta.h"
+#include "BsMessageHandler.h"
 
 namespace BansheeEngine
 {
-	Selection::Selection(GUISceneTreeView* sceneTreeView, GUIResourceTreeView* resourceTreeView)
-		:mSceneTreeView(sceneTreeView), mResourceTreeView(resourceTreeView)
+	Selection::Selection()
 	{
-		mSceneSelectionChangedConn = mSceneTreeView->onSelectionChanged.connect(std::bind(&Selection::sceneSelectionChanged, this));
-		mResourceSelectionChangedConn = mResourceTreeView->onSelectionChanged.connect(std::bind(&Selection::resourceSelectionChanged, this));
+		mSceneSelectionChangedConn = MessageHandler::instance().listen(
+			GUISceneTreeView::SELECTION_CHANGED_MSG, std::bind(&Selection::sceneSelectionChanged, this));
+
+		mResourceSelectionChangedConn = MessageHandler::instance().listen(
+			GUIResourceTreeView::SELECTION_CHANGED_MSG, std::bind(&Selection::resourceSelectionChanged, this));
 	}
 
 	Selection::~Selection()
@@ -27,7 +30,10 @@ namespace BansheeEngine
 	void Selection::setSceneObjects(const Vector<HSceneObject>& sceneObjects)
 	{
 		mSelectedSceneObjects = sceneObjects;
-		mResourceTreeView->setSelection(mSelectedResourcePaths);
+
+		GUISceneTreeView* sceneTreeView = SceneTreeViewLocator::instance();
+		if (sceneTreeView != nullptr)
+			sceneTreeView->setSelection(mSelectedSceneObjects);
 	}
 
 	const Vector<Path>& Selection::getResourcePaths() const
@@ -66,16 +72,22 @@ namespace BansheeEngine
 				mSelectedResourcePaths.push_back(path);
 		}
 
-		mResourceTreeView->setSelection(mSelectedResourcePaths);
+		GUIResourceTreeView* resourceTreeView = ResourceTreeViewLocator::instance();
+		if (resourceTreeView != nullptr)
+			resourceTreeView->setSelection(mSelectedResourcePaths);
 	}
 
 	void Selection::sceneSelectionChanged()
 	{
-		mSelectedSceneObjects = mSceneTreeView->getSelection();
+		GUISceneTreeView* sceneTreeView = SceneTreeViewLocator::instance();
+		if (sceneTreeView != nullptr)
+			mSelectedSceneObjects = sceneTreeView->getSelection();
 	}
 
 	void Selection::resourceSelectionChanged()
 	{
-		mSelectedResourcePaths = mResourceTreeView->getSelection();
+		GUIResourceTreeView* resourceTreeView = ResourceTreeViewLocator::instance();
+		if (resourceTreeView != nullptr)
+			mSelectedResourcePaths = resourceTreeView->getSelection();
 	}
 }

+ 1 - 1
BansheeEditorExec/BsEditorExec.cpp

@@ -11,7 +11,7 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	)
 {
-	EditorApplication::startUp(RenderSystemPlugin::OpenGL);
+	EditorApplication::startUp(RenderSystemPlugin::DX11);
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();
 

+ 0 - 1
BansheeEngine/Include/BsCamera.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsString.h"
 #include "BsMatrix4.h"
 #include "BsVector3.h"
 #include "BsVector2.h"

+ 9 - 9
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -630,23 +630,23 @@ namespace BansheeEngine
 		static const GpuProgramImportData GPU_PROGRAM_IMPORT_DATA[] =
 		{
 			{ ShaderSpriteTextVSFile,				"vs_main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder},
-			{ ShaderSpriteTextPSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0, "hlsl", HLSL11ShaderSubFolder },
+			{ ShaderSpriteTextPSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
 			{ ShaderSpriteImageVSFile,				"vs_main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
-			{ ShaderSpriteImagePSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0, "hlsl", HLSL11ShaderSubFolder },
+			{ ShaderSpriteImagePSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
 			{ ShaderDummyVSFile,					"vs_main",		GPT_VERTEX_PROGRAM,		GPP_VS_4_0, "hlsl", HLSL11ShaderSubFolder },
-			{ ShaderDummyPSFile,					"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0, "hlsl", HLSL11ShaderSubFolder },
+			{ ShaderDummyPSFile,					"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0, "hlsl", HLSL11ShaderSubFolder },
 			{ ShaderSpriteTextVSFile,				"vs_main",		GPT_VERTEX_PROGRAM,		GPP_VS_2_0, "hlsl", HLSL9ShaderSubFolder },
-			{ ShaderSpriteTextPSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0, "hlsl", HLSL9ShaderSubFolder },
+			{ ShaderSpriteTextPSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0, "hlsl", HLSL9ShaderSubFolder },
 			{ ShaderSpriteImageVSFile,				"vs_main",		GPT_VERTEX_PROGRAM,		GPP_VS_2_0, "hlsl", HLSL9ShaderSubFolder },
-			{ ShaderSpriteImagePSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0, "hlsl", HLSL9ShaderSubFolder },
+			{ ShaderSpriteImagePSFile,				"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0, "hlsl", HLSL9ShaderSubFolder },
 			{ ShaderDummyVSFile,					"vs_main",		GPT_VERTEX_PROGRAM,		GPP_VS_2_0, "hlsl", HLSL9ShaderSubFolder },
-			{ ShaderDummyPSFile,					"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_PS_2_0, "hlsl", HLSL9ShaderSubFolder },
+			{ ShaderDummyPSFile,					"ps_main",		GPT_FRAGMENT_PROGRAM,	GPP_FS_2_0, "hlsl", HLSL9ShaderSubFolder },
 			{ ShaderSpriteTextVSFile,				"main",			GPT_VERTEX_PROGRAM,		GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
-			{ ShaderSpriteTextPSFile,				"main",			GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0, "glsl", GLSLShaderSubFolder },
+			{ ShaderSpriteTextPSFile,				"main",			GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
 			{ ShaderSpriteImageVSFile,				"main",			GPT_VERTEX_PROGRAM,		GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
-			{ ShaderSpriteImagePSFile,				"main",			GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0, "glsl", GLSLShaderSubFolder },
+			{ ShaderSpriteImagePSFile,				"main",			GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
 			{ ShaderDummyVSFile,					"main",			GPT_VERTEX_PROGRAM,		GPP_VS_4_0, "glsl", GLSLShaderSubFolder },
-			{ ShaderDummyPSFile,					"main",			GPT_FRAGMENT_PROGRAM,	GPP_PS_4_0, "glsl", GLSLShaderSubFolder },
+			{ ShaderDummyPSFile,					"main",			GPT_FRAGMENT_PROGRAM,	GPP_FS_4_0, "glsl", GLSLShaderSubFolder },
 		};
 
 		if (FileSystem::exists(DefaultCursorFolderRaw))

+ 5 - 2
BansheeGLRenderSystem/Source/GLSL/src/BsGLSLGpuProgram.cpp

@@ -20,6 +20,9 @@ namespace BansheeEngine
 	{
 		StringStream stream;
 
+		GLint linkCompileSuccess = 0;
+		glGetProgramiv(programObj, GL_LINK_STATUS, &linkCompileSuccess);
+
 		GLenum glErr;
 		bool errorsFound = false;
 
@@ -40,7 +43,7 @@ namespace BansheeEngine
 			errorsFound = true;
 		}
 
-		if (errorsFound && programObj > 0)
+		if ((errorsFound || !linkCompileSuccess) && programObj > 0)
 		{
 			GLint infologLength = 0;
 			glGetProgramiv(programObj, GL_INFO_LOG_LENGTH, &infologLength);
@@ -62,7 +65,7 @@ namespace BansheeEngine
 
 		outErrorMsg = stream.str();
 
-		return errorsFound;
+		return errorsFound || !linkCompileSuccess;
 	}
 	
 	GLSLGpuProgram::GLSLGpuProgram(const String& source, const String& entryPoint, GpuProgramType gptype, 

+ 3 - 3
BansheeRenderer/Source/BsBansheeLitTexRenderableHandler.cpp

@@ -305,7 +305,7 @@ namespace BansheeEngine
 			})";	
 
 			vsProgram = GpuProgram::create(vsCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
-			psProgram = GpuProgram::create(psCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+			psProgram = GpuProgram::create(psCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0);
 		}
 		else if (rsName == RenderSystemDX9)
 		{
@@ -333,7 +333,7 @@ namespace BansheeEngine
 			})";
 
 			vsProgram = GpuProgram::create(vsCode, "vs_main", "hlsl", GPT_VERTEX_PROGRAM, GPP_VS_2_0);
-			psProgram = GpuProgram::create(psCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_PS_2_0);
+			psProgram = GpuProgram::create(psCode, "ps_main", "hlsl", GPT_FRAGMENT_PROGRAM, GPP_FS_2_0);
 		}
 		else if (rsName == RenderSystemOpenGL)
 		{
@@ -371,7 +371,7 @@ namespace BansheeEngine
 			})";
 
 			vsProgram = GpuProgram::create(vsCode, "main", "glsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
-			psProgram = GpuProgram::create(psCode, "main", "glsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+			psProgram = GpuProgram::create(psCode, "main", "glsl", GPT_FRAGMENT_PROGRAM, GPP_FS_4_0);
 		}
 
 		vsProgram.synchronize();

+ 4 - 0
BansheeUtility/BansheeUtility.vcxproj

@@ -249,6 +249,7 @@
     <ClCompile Include="Source\BsCapsule.cpp" />
     <ClCompile Include="Source\BsConvexVolume.cpp" />
     <ClCompile Include="Source\BsLineSegment3.cpp" />
+    <ClCompile Include="Source\BsMessageHandler.cpp" />
     <ClCompile Include="Source\BsRect3.cpp" />
     <ClCompile Include="Source\BsTaskScheduler.cpp" />
     <ClCompile Include="Source\BsTestOutput.cpp" />
@@ -281,7 +282,10 @@
     <ClInclude Include="Include\BsConvexVolume.h" />
     <ClInclude Include="Include\BsEvent.h" />
     <ClInclude Include="Include\BsLineSegment3.h" />
+    <ClInclude Include="Include\BsMessageHandler.h" />
+    <ClInclude Include="Include\BsMessageHandlerFwd.h" />
     <ClInclude Include="Include\BsRect3.h" />
+    <ClInclude Include="Include\BsServiceLocator.h" />
     <ClInclude Include="Include\BsSpinLock.h" />
     <ClInclude Include="Include\BsTaskScheduler.h" />
     <ClInclude Include="Include\BsTestOutput.h" />

+ 12 - 0
BansheeUtility/BansheeUtility.vcxproj.filters

@@ -264,6 +264,15 @@
     <ClInclude Include="Include\BsCapsule.h">
       <Filter>Header Files\Math</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsServiceLocator.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsMessageHandler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsMessageHandlerFwd.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsThreadPool.cpp">
@@ -425,5 +434,8 @@
     <ClCompile Include="Source\BsCapsule.cpp">
       <Filter>Source Files\Math</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsMessageHandler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 0 - 1
BansheeUtility/Include/BsDynLib.h

@@ -1,7 +1,6 @@
 #pragma once
 
 #include "BsPrerequisitesUtil.h"
-#include "BsString.h"
 
 #if BS_PLATFORM == BS_PLATFORM_WIN32
 #    define DYNLIB_HANDLE hInstance

+ 49 - 0
BansheeUtility/Include/BsMessageHandler.h

@@ -0,0 +1,49 @@
+#pragma once
+
+#include "BsPrerequisitesUtil.h"
+#include "BsModule.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Allows you to transparently pass messages
+	 *			between different systems.
+	 *
+	 * @note		Sim thread only.
+	 */
+	class BS_UTILITY_EXPORT MessageHandler : public Module<MessageHandler>
+	{
+		struct MessageHandlerData
+		{
+			UINT32 id;
+			std::function<void()> callback;
+		};
+
+	public:
+		MessageHandler();
+
+		/**
+		 * @brief	Sends a message to all subscribed listeners.
+		 */
+		void send(MessageId message);
+
+		/**
+		 * @brief	Subscribes a message listener for the specified message.
+		 *			Provided callback will be triggered whenever that message
+		 *			gets sent.
+		 *
+		 * @returns	A handle to the message subscription that you can use to
+		 *			unsubscribe from listening.
+		 */
+		HMessage listen(MessageId message, std::function<void()> callback);
+
+	private:
+		friend class HMessage;
+		void unsubscribe(UINT32 handleId);
+
+		Map<UINT32, Vector<MessageHandlerData>> mMessageHandlers;
+		Map<UINT32, UINT32> mHandlerIdToMessageMap;
+
+		UINT32 mNextCallbackId;
+	};
+}

+ 64 - 0
BansheeUtility/Include/BsMessageHandlerFwd.h

@@ -0,0 +1,64 @@
+#pragma once
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Identifier for message used with the global messaging system.
+	 *
+	 * @note	Primary purpose of this class is to avoid expensive string compare (i.e. button names),
+	 * 			and instead use a unique message identifier for compare. Generally you want to create
+	 * 			one of these using the message name, and then store it for later use.
+	 *
+	 *			This class is not thread safe and should only be used on the sim thread.
+	 */
+	class BS_UTILITY_EXPORT MessageId
+	{
+	public:
+		MessageId();
+		MessageId(const String& name);
+
+		bool operator== (const MessageId& rhs) const
+		{
+			return (mMsgIdentifier == rhs.mMsgIdentifier);
+		}
+	private:
+		friend class MessageHandler;
+
+		static Map<String, UINT32> UniqueMessageIds;
+		static UINT32 NextMessageId;
+
+		UINT32 mMsgIdentifier;
+	};
+
+	/**
+	 * @brief	Handle to a subscription for a specific message
+	 *			in the global messaging system.
+	 */
+	class BS_UTILITY_EXPORT HMessage
+	{
+	public:
+		HMessage();
+
+		/**
+		* @brief	Disconnects the message listener so it will no longer
+		*			receive events from the messaging system.
+		*/
+		void disconnect();
+
+	private:
+		friend class MessageHandler;
+
+		HMessage(UINT32 id);
+
+		UINT32 mId;
+	};
+
+	/**
+	 * @brief	Sends a message using the global messaging system.
+	 *
+	 * @note	Sim thread only.
+	 */
+	void BS_UTILITY_EXPORT sendMessage(MessageId message);
+
+	class MessageHandler;
+}

+ 2 - 1
BansheeUtility/Include/BsPrerequisitesUtil.h

@@ -60,4 +60,5 @@
 
 #include "BsRTTIPrerequisites.h"
 
-#include "BsString.h"
+#include "BsString.h"
+#include "BsMessageHandlerFwd.h"

+ 43 - 0
BansheeUtility/Include/BsServiceLocator.h

@@ -0,0 +1,43 @@
+#pragma once
+
+#include "BsPrerequisitesUtil.h"
+#include "BsException.h"
+
+namespace BansheeEngine
+{
+	/**
+	* @brief	A locator system that allows you to quickly find a service of
+	*			a specific type.
+	*
+	* @note		This is similar to a singleton pattern but unlike singleton the active instance 
+	*			is not required to be available and can be replaced with another system during 
+	*			runtime, or completely removed.
+	*/
+	template <class T>
+	class ServiceLocator
+	{
+	public:
+		/**
+		 * @brief	Returns an instance of the service we are looking for,
+		 *			if one is available.
+		 *
+		 * @note	Can return null.
+		 */
+		static T* instance() { return mService; }
+
+		/**
+		 * @brief	Starts providing a new service when "instance()" is called.
+		 *			Replaces the previous service. 
+		 */
+		static void _provide(T* service)
+		{
+			mService = service;
+		}
+
+	private:
+		static T* mService;
+	};
+
+	template <class T>
+	T* ServiceLocator<T>::mService = nullptr;
+}

+ 0 - 2
BansheeUtility/Include/BsString.h

@@ -1,7 +1,5 @@
 #pragma once
 
-#include "BsPrerequisitesUtil.h"
-
 namespace BansheeEngine 
 {
 	/**

+ 92 - 0
BansheeUtility/Source/BsMessageHandler.cpp

@@ -0,0 +1,92 @@
+#include "BsMessageHandler.h"
+
+namespace BansheeEngine
+{
+	Map<String, UINT32> MessageId::UniqueMessageIds;
+	UINT32 MessageId::NextMessageId = 0;
+
+	MessageId::MessageId()
+		: mMsgIdentifier(0)
+	{ }
+
+	MessageId::MessageId(const String& name)
+	{
+		auto findIter = UniqueMessageIds.find(name);
+
+		if (findIter != UniqueMessageIds.end())
+			mMsgIdentifier = findIter->second;
+		else
+		{
+			mMsgIdentifier = NextMessageId;
+			UniqueMessageIds[name] = NextMessageId++;
+		}
+	}
+
+	HMessage::HMessage()
+		:mId(0)
+	{ }
+
+	HMessage::HMessage(UINT32 id)
+		:mId(id)
+	{ }
+
+	void HMessage::disconnect()
+	{
+		if (mId > 0)
+			MessageHandler::instance().unsubscribe(mId);
+	}
+
+	MessageHandler::MessageHandler()
+		:mNextCallbackId(1) // 0 is reserved
+	{ }
+
+	void MessageHandler::send(MessageId message)
+	{
+		auto iterFind = mMessageHandlers.find(message.mMsgIdentifier);
+		if (iterFind != mMessageHandlers.end())
+		{
+			for (auto& handlerData : iterFind->second)
+			{
+				handlerData.callback();
+			}
+		}
+	}
+
+	HMessage MessageHandler::listen(MessageId message, std::function<void()> callback)
+	{
+		UINT32 callbackId = mNextCallbackId++;
+		
+		MessageHandlerData data;
+		data.id = callbackId;
+		data.callback = callback;
+
+		mMessageHandlers[message.mMsgIdentifier].push_back(data);
+		mHandlerIdToMessageMap[callbackId] = message.mMsgIdentifier;
+
+		return HMessage(callbackId);
+	}
+
+	void MessageHandler::unsubscribe(UINT32 handleId)
+	{
+		UINT32 msgId = mHandlerIdToMessageMap[handleId];
+
+		auto iterFind = mMessageHandlers.find(msgId);
+		if (iterFind != mMessageHandlers.end())
+		{
+			Vector<MessageHandlerData>& handlerData = iterFind->second;
+
+			std::remove_if(handlerData.begin(), handlerData.end(), 
+				[&](MessageHandlerData& x)
+				{
+					return x.id == handleId;
+				});
+		}
+
+		mHandlerIdToMessageMap.erase(handleId);
+	}
+
+	void sendMessage(MessageId message)
+	{
+		MessageHandler::instance().send(message);
+	}
+}

+ 0 - 1
BansheeUtility/Source/BsString.cpp

@@ -1,4 +1,3 @@
-#include "BsString.h"
 #include "BsColor.h"
 #include "BsMath.h"
 #include "BsMatrix3.h"

+ 1 - 1
ExampleProject/Main/Main.cpp

@@ -199,7 +199,7 @@ namespace BansheeEngine
 			importOptions->setLanguage("hlsl");
 
 			// GPU program profile specifying what feature-set the shader code uses.
-			importOptions->setProfile(GPP_PS_4_0);
+			importOptions->setProfile(GPP_FS_4_0);
 
 			// Type of the shader.
 			importOptions->setType(GPT_FRAGMENT_PROGRAM);

+ 26 - 11
SceneView.txt

@@ -2,20 +2,35 @@
 TODO:
  - Core thread gets stuck on shutdown when OpenGL is used...Somewhere in kernel
 
-CONCRETE TASK:
- - Hook up gizmo manager to ScenePicking so gizmos are considered when picking
-   - I'll likely need to update GizmoManager so I can query gizmo SceneObject based on gizmo index
- - Selection/ScenePicking/GizmoManager need to be started
-
-IMMEDIATE:
- - SceneGrid is very ugly. Consider using default lines for now and come back with a better approach later.
-   - Potentially enable line AA?
- - Picking code is completely untested and will likely need major fixing
- - Test all the new DrawHelper3D methods
-
  GIZMO TODO:
   - Figure out how to deal with builtin components like Camera and Renderable (e.g. how will they have gizmos since they're not managed components?)
 
+TESTING:
+Ensure all 3 render systems compile and run
+ - Test selection on all 3 render systems
+ - RE-ENABLE SCISSOR TEST FOR PICKING SHADERS!!
+ - FIX SHUTDOWN AS IT BREAKS BECAUSE OF Selection (and potentially others)
+ - Picking need to test something with alpha
+ - Ensure that selecting an item in scene properly marks it in scene view
+ - Ensure that selecting an item in scene or resource tree view properly updates Selection
+
+Test gizmos
+ - START UP GIZMO MANAGER SOMEWHERE
+ - Test rendering of basic 2D and 3D gizmos
+ - Test rendering of icon gizmos
+ - Test them all from C#
+ - HOOK UP GIZMO SELECTION and test it
+
+Test handles
+ - Test basic move handle
+ - Test a custom handle from C#
+ - FINISH HANDLE IMPLEMENTATION AND GLUE EVERYTHING TOGHETHER
+
+IMPLEMENT SELECTION RENDERING
+
+IMPROVE SceneGrid LOOK AND ENSURE IT RENDERS FINE ON ALL APIS
+ - LIKELY USE PIXEL SceneGrid WITH AA
+
 LATER:
  - Need a way to render text for gizmos and handles, and in scene in general
  - Add drag to select