Kaynağa Gözat

Moved GUIManager rendering to a specialized core thread GUIManagerCore
Removed sim-thread rendering callbacks from renderer
Removed DrawList, OverlayManager and COverlay as they are not being used anymore
GUIWidget now accepts a Camera instead of Viewport so GUIManager can interact with Renderer callbacks using it
GUIWidget renamed to CGUIWidget for consistent Component naming

BearishSun 10 yıl önce
ebeveyn
işleme
508b74a040
100 değiştirilmiş dosya ile 1080 ekleme ve 1191 silme
  1. 0 2
      BansheeCore/BansheeCore.vcxproj
  2. 0 6
      BansheeCore/BansheeCore.vcxproj.filters
  3. 1 0
      BansheeCore/Include/BsBlendState.h
  4. 1 3
      BansheeCore/Include/BsCorePrerequisites.h
  5. 1 0
      BansheeCore/Include/BsDepthStencilState.h
  6. 0 51
      BansheeCore/Include/BsDrawList.h
  7. 1 0
      BansheeCore/Include/BsRasterizerState.h
  8. 11 3
      BansheeCore/Include/BsShader.h
  9. 5 2
      BansheeCore/Source/BsBlendState.cpp
  10. 5 2
      BansheeCore/Source/BsDepthStencilState.cpp
  11. 0 26
      BansheeCore/Source/BsDrawList.cpp
  12. 5 2
      BansheeCore/Source/BsRasterizerState.cpp
  13. 17 9
      BansheeCore/Source/BsShader.cpp
  14. 1 1
      BansheeEditor/Include/BsDropDownWindow.h
  15. 3 3
      BansheeEditor/Include/BsDropDownWindowManager.h
  16. 1 1
      BansheeEditor/Include/BsEditorWidget.h
  17. 3 3
      BansheeEditor/Include/BsEditorWidgetContainer.h
  18. 2 2
      BansheeEditor/Include/BsGUIMenuBar.h
  19. 1 1
      BansheeEditor/Include/BsGUIResourceTreeView.h
  20. 4 4
      BansheeEditor/Include/BsGUIWindowFrameWidget.h
  21. 2 3
      BansheeEditor/Source/BsDockManager.cpp
  22. 6 4
      BansheeEditor/Source/BsDropDownWindow.cpp
  23. 1 1
      BansheeEditor/Source/BsEditorApplication.cpp
  24. 2 2
      BansheeEditor/Source/BsEditorWidget.cpp
  25. 2 2
      BansheeEditor/Source/BsEditorWidgetContainer.cpp
  26. 2 2
      BansheeEditor/Source/BsEditorWindowBase.cpp
  27. 1 1
      BansheeEditor/Source/BsGUIColor.cpp
  28. 2 2
      BansheeEditor/Source/BsGUIColorField.cpp
  29. 1 1
      BansheeEditor/Source/BsGUIComponentFoldout.cpp
  30. 1 1
      BansheeEditor/Source/BsGUIDockSlider.cpp
  31. 1 1
      BansheeEditor/Source/BsGUIDropButton.cpp
  32. 1 1
      BansheeEditor/Source/BsGUIFieldBase.cpp
  33. 2 2
      BansheeEditor/Source/BsGUIFloatField.cpp
  34. 1 1
      BansheeEditor/Source/BsGUIFoldout.cpp
  35. 2 2
      BansheeEditor/Source/BsGUIIntField.cpp
  36. 3 3
      BansheeEditor/Source/BsGUIMenuBar.cpp
  37. 2 2
      BansheeEditor/Source/BsGUIResourceTreeView.cpp
  38. 1 1
      BansheeEditor/Source/BsGUITabButton.cpp
  39. 1 1
      BansheeEditor/Source/BsGUITabbedTitleBar.cpp
  40. 2 2
      BansheeEditor/Source/BsGUITextField.cpp
  41. 2 2
      BansheeEditor/Source/BsGUIToggleField.cpp
  42. 1 1
      BansheeEditor/Source/BsGUITreeView.cpp
  43. 1 1
      BansheeEditor/Source/BsGUITreeViewEditBox.cpp
  44. 2 2
      BansheeEditor/Source/BsGUIVector2Field.cpp
  45. 2 2
      BansheeEditor/Source/BsGUIVector3Field.cpp
  46. 2 2
      BansheeEditor/Source/BsGUIVector4Field.cpp
  47. 1 1
      BansheeEditor/Source/BsGUIWindowFrame.cpp
  48. 6 6
      BansheeEditor/Source/BsGUIWindowFrameWidget.cpp
  49. 1 1
      BansheeEditor/Source/BsMainEditorWindow.cpp
  50. 1 1
      BansheeEditor/Source/BsModalWindow.cpp
  51. 0 1
      BansheeEditor/Source/BsSceneGrid.cpp
  52. 3 7
      BansheeEngine/BansheeEngine.vcxproj
  53. 9 21
      BansheeEngine/BansheeEngine.vcxproj.filters
  54. 234 220
      BansheeEngine/Include/BsCGUIWidget.h
  55. 6 6
      BansheeEngine/Include/BsCGUIWidgetRTTI.h
  56. 0 56
      BansheeEngine/Include/BsCOverlay.h
  57. 1 1
      BansheeEngine/Include/BsGUIContextMenu.h
  58. 3 3
      BansheeEngine/Include/BsGUIDropDownMenu.h
  59. 1 1
      BansheeEngine/Include/BsGUIElement.h
  60. 3 3
      BansheeEngine/Include/BsGUIElementBase.h
  61. 87 23
      BansheeEngine/Include/BsGUIManager.h
  62. 0 3
      BansheeEngine/Include/BsGUIMaterialInfo.h
  63. 1 1
      BansheeEngine/Include/BsGUIViewport.h
  64. 0 55
      BansheeEngine/Include/BsOverlayManager.h
  65. 2 5
      BansheeEngine/Include/BsPrerequisites.h
  66. 8 8
      BansheeEngine/Include/BsProfilerOverlay.h
  67. 0 3
      BansheeEngine/Source/BsApplication.cpp
  68. 1 9
      BansheeEngine/Source/BsBuiltinResources.cpp
  69. 378 363
      BansheeEngine/Source/BsCGUIWidget.cpp
  70. 0 23
      BansheeEngine/Source/BsCOverlay.cpp
  71. 1 1
      BansheeEngine/Source/BsGUIButton.cpp
  72. 1 1
      BansheeEngine/Source/BsGUIButtonBase.cpp
  73. 2 2
      BansheeEngine/Source/BsGUIContextMenu.cpp
  74. 1 1
      BansheeEngine/Source/BsGUIDropDownContent.cpp
  75. 1 1
      BansheeEngine/Source/BsGUIDropDownHitBox.cpp
  76. 7 4
      BansheeEngine/Source/BsGUIDropDownMenu.cpp
  77. 2 2
      BansheeEngine/Source/BsGUIElement.cpp
  78. 2 2
      BansheeEngine/Source/BsGUIElementBase.cpp
  79. 1 1
      BansheeEngine/Source/BsGUIInputBox.cpp
  80. 1 1
      BansheeEngine/Source/BsGUIInputCaret.cpp
  81. 1 1
      BansheeEngine/Source/BsGUIInputSelection.cpp
  82. 1 1
      BansheeEngine/Source/BsGUILabel.cpp
  83. 1 1
      BansheeEngine/Source/BsGUILayoutUtility.cpp
  84. 3 3
      BansheeEngine/Source/BsGUIListBox.cpp
  85. 172 61
      BansheeEngine/Source/BsGUIManager.cpp
  86. 1 1
      BansheeEngine/Source/BsGUIProgressBar.cpp
  87. 1 1
      BansheeEngine/Source/BsGUIRenderTexture.cpp
  88. 1 1
      BansheeEngine/Source/BsGUIScrollArea.cpp
  89. 1 1
      BansheeEngine/Source/BsGUIScrollBar.cpp
  90. 1 1
      BansheeEngine/Source/BsGUISlider.cpp
  91. 1 1
      BansheeEngine/Source/BsGUISliderHandle.cpp
  92. 1 1
      BansheeEngine/Source/BsGUITexture.cpp
  93. 1 1
      BansheeEngine/Source/BsGUIToggle.cpp
  94. 2 2
      BansheeEngine/Source/BsGUIViewport.cpp
  95. 0 43
      BansheeEngine/Source/BsOverlayManager.cpp
  96. 16 15
      BansheeEngine/Source/BsProfilerOverlay.cpp
  97. 2 2
      ExampleProject/Main/Main.cpp
  98. 0 10
      RenderBeast/Include/BsRenderBeast.h
  99. 0 40
      RenderBeast/Source/BsRenderBeast.cpp
  100. 1 1
      SBansheeEditor/Include/BsScriptDropDownWindow.h

+ 0 - 2
BansheeCore/BansheeCore.vcxproj

@@ -279,7 +279,6 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsCoreObjectCore.h" />
-    <ClInclude Include="Include\BsDrawList.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsMeshImportOptions.h" />
     <ClInclude Include="Include\BsMeshImportOptionsRTTI.h" />
@@ -442,7 +441,6 @@
   <ItemGroup>
     <ClCompile Include="Source\BsCoreObjectCore.cpp" />
     <ClCompile Include="Source\BsCoreThread.cpp" />
-    <ClCompile Include="Source\BsDrawList.cpp" />
     <ClCompile Include="Source\BsHString.cpp" />
     <ClCompile Include="Source\BsIResourceListener.cpp" />
     <ClCompile Include="Source\BsMaterialParam.cpp" />

+ 0 - 6
BansheeCore/BansheeCore.vcxproj.filters

@@ -455,9 +455,6 @@
     <ClInclude Include="Include\BsProfilingManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsDrawList.h">
-      <Filter>Header Files\Renderer</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsTextureImportOptions.h">
       <Filter>Header Files\Importer</Filter>
     </ClInclude>
@@ -820,9 +817,6 @@
     <ClCompile Include="Source\BsProfilingManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsDrawList.cpp">
-      <Filter>Source Files\Renderer</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsTextureImportOptions.cpp">
       <Filter>Source Files\Importer</Filter>
     </ClCompile>

+ 1 - 0
BansheeCore/Include/BsBlendState.h

@@ -248,6 +248,7 @@ namespace BansheeEngine
 		SPtr<CoreObjectCore> createCore() const override;
 
 		BlendProperties mProperties;
+		mutable UINT32 mId;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/

+ 1 - 3
BansheeCore/Include/BsCorePrerequisites.h

@@ -150,7 +150,6 @@ namespace BansheeEngine
 	class CameraCore;
 	class MeshCoreBase;
 	class MeshCore;
-	class DrawList;
 	struct SubMesh;
 	class TransientMeshCore;
 	class TextureCore;
@@ -265,7 +264,6 @@ namespace BansheeEngine
 	typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
 	typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
 	typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
-	typedef std::shared_ptr<DrawList> DrawListPtr;
 	typedef std::shared_ptr<RenderQueue> RenderQueuePtr;
 	typedef std::shared_ptr<GpuParamDesc> GpuParamDescPtr;
 	typedef std::shared_ptr<ResourceMetaData> ResourceMetaDataPtr;
@@ -344,7 +342,7 @@ namespace BansheeEngine
 		TID_PrefabDiff = 1078,
 		TID_PrefabObjectDiff = 1079,
 		TID_PrefabComponentDiff = 1080,
-		TID_GUIWidget = 1081,
+		TID_CGUIWidget = 1081,
 		TID_ProfilerOverlay = 1082,
 		TID_StringTable = 1083,
 		TID_LanguageData = 1084,

+ 1 - 0
BansheeCore/Include/BsDepthStencilState.h

@@ -251,6 +251,7 @@ namespace BansheeEngine
 		SPtr<CoreObjectCore> createCore() const override;
 
 		DepthStencilProperties mProperties;
+		mutable UINT32 mId;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/

+ 0 - 51
BansheeCore/Include/BsDrawList.h

@@ -1,51 +0,0 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsVector3.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Represents a single drawable object
-	 *			stored in a DrawList.
-	 */
-	struct BS_CORE_EXPORT DrawOperation
-	{
-		MaterialPtr material;
-		MeshBasePtr mesh;
-		UINT32 submeshIdx;
-		Vector3 worldPosition;
-	};
-
-	/**
-	 * @brief	A container you may use to queue
-	 *			custom drawable objects in.
-	 */
-	class BS_CORE_EXPORT DrawList
-	{
-	public:
-		/**
-		 * @brief	Adds a new drawable object.
-		 *
-		 * @param	material		Material to draw the object with.
-		 * @param	mesh			Parent mesh of the object.
-		 * @param	submeshIdx		Index of the sub-mesh to render, in the parent mesh.
-		 * @param	worldPosForSort	World position of the object that will be used for distance
-		 *							sorting before rendering.
-		 */
-		void add(const MaterialPtr& material, const MeshBasePtr& mesh, UINT32 submeshIdx, const Vector3& worldPosForSort);
-
-		/**
-		 * @brief	Removes all queued drawable objects.
-		 */
-		void clear();
-
-		/**
-		 * @brief	Returns all queued drawable objects.
-		 */
-		const Vector<DrawOperation>& getDrawOperations() const;
-
-	protected:
-		Vector<DrawOperation> mDrawOperations;
-	};
-}

+ 1 - 0
BansheeCore/Include/BsRasterizerState.h

@@ -225,6 +225,7 @@ namespace BansheeEngine
 		SPtr<CoreObjectCore> createCore() const override;
 
 		RasterizerProperties mProperties;
+		mutable UINT32 mId;
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/

+ 11 - 3
BansheeCore/Include/BsShader.h

@@ -234,7 +234,7 @@ namespace BansheeEngine
 		typedef typename TSHADER_DESC<Core>::SamplerStateType SamplerStateType;
 
 		TShader() { }
-		TShader(const String& name, const TSHADER_DESC<Core>& desc, const Vector<SPtr<TechniqueType>>& techniques);
+		TShader(const String& name, const TSHADER_DESC<Core>& desc, const Vector<SPtr<TechniqueType>>& techniques, UINT32 id);
 		virtual ~TShader();
 	
 		/**
@@ -369,10 +369,16 @@ namespace BansheeEngine
 		 */
 		UINT8* getDefaultValue(UINT32 index) const;
 
+		/**
+		 * @brief	Returns the unique shader ID.
+		 */
+		UINT32 getId() const { return mId; }
+
 	protected:
 		String mName;
 		TSHADER_DESC<Core> mDesc;
 		Vector<SPtr<TechniqueType>> mTechniques;
+		UINT32 mId;
 	};
 
 	/**
@@ -389,7 +395,9 @@ namespace BansheeEngine
 	protected:
 		friend class Shader;
 
-		ShaderCore(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques);
+		ShaderCore(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques, UINT32 id);
+
+		static std::atomic<UINT32> mNextShaderId;
 	};
 
 	/**
@@ -453,7 +461,7 @@ namespace BansheeEngine
 		static ShaderPtr createEmpty();
 
 	private:
-		Shader(const String& name, const SHADER_DESC& desc, const Vector<SPtr<Technique>>& techniques);
+		Shader(const String& name, const SHADER_DESC& desc, const Vector<SPtr<Technique>>& techniques, UINT32 id);
 
 		/**
 		 * @copydoc	CoreObject::getCoreDependencies

+ 5 - 2
BansheeCore/Source/BsBlendState.cpp

@@ -127,7 +127,7 @@ namespace BansheeEngine
 	}
 
 	BlendState::BlendState(const BLEND_STATE_DESC& desc)
-		:mProperties(desc)
+		:mProperties(desc), mId(0)
 	{ }
 
 	BlendState::~BlendState()
@@ -142,7 +142,10 @@ namespace BansheeEngine
 
 	SPtr<CoreObjectCore> BlendState::createCore() const
 	{
-		return RenderStateCoreManager::instance()._createBlendState(mProperties.mData);
+		SPtr<BlendStateCore> core = RenderStateCoreManager::instance()._createBlendState(mProperties.mData);
+		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
+
+		return core;
 	}
 
 	const BlendProperties& BlendState::getProperties() const

+ 5 - 2
BansheeCore/Source/BsDepthStencilState.cpp

@@ -64,7 +64,7 @@ namespace BansheeEngine
 	}
 
 	DepthStencilState::DepthStencilState(const DEPTH_STENCIL_STATE_DESC& desc)
-		:mProperties(desc)
+		:mProperties(desc), mId(0)
 	{
 
 	}
@@ -81,7 +81,10 @@ namespace BansheeEngine
 
 	SPtr<CoreObjectCore> DepthStencilState::createCore() const
 	{
-		return RenderStateCoreManager::instance()._createDepthStencilState(mProperties.mData);
+		SPtr<DepthStencilStateCore> core = RenderStateCoreManager::instance()._createDepthStencilState(mProperties.mData);
+		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
+
+		return core;
 	}
 
 	const DepthStencilStatePtr& DepthStencilState::getDefault()

+ 0 - 26
BansheeCore/Source/BsDrawList.cpp

@@ -1,26 +0,0 @@
-#include "BsDrawList.h"
-
-namespace BansheeEngine
-{
-	void DrawList::clear()
-	{
-		mDrawOperations.clear();
-	}
-
-	void DrawList::add(const MaterialPtr& material, const MeshBasePtr& mesh, UINT32 submeshIdx, const Vector3& worldPosForSort)
-	{
-		// TODO - Make sure RenderOperations are cached so we dont allocate memory for them every frame
-		mDrawOperations.push_back(DrawOperation());
-
-		DrawOperation& renderOp = mDrawOperations.back();
-		renderOp.material = material;
-		renderOp.mesh = mesh;
-		renderOp.worldPosition = worldPosForSort;
-		renderOp.submeshIdx = submeshIdx;
-	}
-
-	const Vector<DrawOperation>& DrawList::getDrawOperations() const
-	{
-		return mDrawOperations;
-	}
-}

+ 5 - 2
BansheeCore/Source/BsRasterizerState.cpp

@@ -56,7 +56,7 @@ namespace BansheeEngine
 	}
 
 	RasterizerState::RasterizerState(const RASTERIZER_STATE_DESC& desc)
-		: mProperties(desc)
+		: mProperties(desc), mId(0)
 	{
 
 	}
@@ -73,7 +73,10 @@ namespace BansheeEngine
 
 	SPtr<CoreObjectCore> RasterizerState::createCore() const
 	{
-		return RenderStateCoreManager::instance()._createRasterizerState(mProperties.mData);
+		SPtr<RasterizerStateCore> core = RenderStateCoreManager::instance()._createRasterizerState(mProperties.mData);
+		mId = core->getId(); // Accessing core from sim thread is okay here since core ID is immutable
+
+		return core;
 	}
 
 	const RasterizerProperties& RasterizerState::getProperties() const

+ 17 - 9
BansheeCore/Source/BsShader.cpp

@@ -10,6 +10,8 @@
 
 namespace BansheeEngine
 {
+	std::atomic<UINT32> ShaderCore::mNextShaderId = 0;
+
 	template<bool Core>
 	TSHADER_DESC<Core>::TSHADER_DESC()
 		:queuePriority(0), queueSortType(QueueSortType::None), separablePasses(false), flags(0)
@@ -144,8 +146,8 @@ namespace BansheeEngine
 	template struct TSHADER_DESC<true>;
 
 	template<bool Core>
-	TShader<Core>::TShader(const String& name, const TSHADER_DESC<Core>& desc, const Vector<SPtr<TechniqueType>>& techniques)
-		:mName(name), mDesc(desc), mTechniques(techniques)
+	TShader<Core>::TShader(const String& name, const TSHADER_DESC<Core>& desc, const Vector<SPtr<TechniqueType>>& techniques, UINT32 id)
+		:mName(name), mDesc(desc), mTechniques(techniques), mId(id)
 	{ }
 
 	template<bool Core>
@@ -300,15 +302,18 @@ namespace BansheeEngine
 	template class TShader < false > ;
 	template class TShader < true >;
 
-	ShaderCore::ShaderCore(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques)
-		:TShader(name, desc, techniques)
+	ShaderCore::ShaderCore(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques, UINT32 id)
+		:TShader(name, desc, techniques, id)
 	{
 		
 	}
 
 	SPtr<ShaderCore> ShaderCore::create(const String& name, const SHADER_DESC_CORE& desc, const Vector<SPtr<TechniqueCore>>& techniques)
 	{
-		ShaderCore* shaderCore = new (bs_alloc<ShaderCore>()) ShaderCore(name, desc, techniques);
+		UINT32 id = mNextShaderId.fetch_add(1, std::memory_order_relaxed);
+		assert(id < std::numeric_limits<UINT32>::max() && "Created too many shaders, reached maximum id.");
+
+		ShaderCore* shaderCore = new (bs_alloc<ShaderCore>()) ShaderCore(name, desc, techniques, id);
 		SPtr<ShaderCore> shaderCorePtr = bs_shared_ptr<ShaderCore>(shaderCore);
 		shaderCorePtr->_setThisPtr(shaderCorePtr);
 		shaderCorePtr->initialize();
@@ -316,8 +321,8 @@ namespace BansheeEngine
 		return shaderCorePtr;
 	}
 
-	Shader::Shader(const String& name, const SHADER_DESC& desc, const Vector<SPtr<Technique>>& techniques)
-		:TShader(name, desc, techniques)
+	Shader::Shader(const String& name, const SHADER_DESC& desc, const Vector<SPtr<Technique>>& techniques, UINT32 id)
+		:TShader(name, desc, techniques, id)
 	{
 		mMetaData = bs_shared_ptr_new<ShaderMetaData>();
 	}
@@ -339,7 +344,7 @@ namespace BansheeEngine
 		for (auto& technique : mTechniques)
 			techniques.push_back(technique->getCore());
 
-		ShaderCore* shaderCore = new (bs_alloc<ShaderCore>()) ShaderCore(mName, convertDesc(mDesc), techniques);
+		ShaderCore* shaderCore = new (bs_alloc<ShaderCore>()) ShaderCore(mName, convertDesc(mDesc), techniques, mId);
 		SPtr<ShaderCore> shaderCorePtr = bs_shared_ptr<ShaderCore>(shaderCore);
 		shaderCorePtr->_setThisPtr(shaderCorePtr);
 
@@ -468,7 +473,10 @@ namespace BansheeEngine
 
 	ShaderPtr Shader::_createPtr(const String& name, const SHADER_DESC& desc, const Vector<SPtr<Technique>>& techniques)
 	{
-		ShaderPtr newShader = bs_core_ptr<Shader>(new (bs_alloc<Shader>()) Shader(name, desc, techniques));
+		UINT32 id = ShaderCore::mNextShaderId.fetch_add(1, std::memory_order_relaxed);
+		assert(id < std::numeric_limits<UINT32>::max() && "Created too many shaders, reached maximum id.");
+
+		ShaderPtr newShader = bs_core_ptr<Shader>(new (bs_alloc<Shader>()) Shader(name, desc, techniques, id));
 		newShader->_setThisPtr(newShader);
 		newShader->initialize();
 

+ 1 - 1
BansheeEditor/Include/BsDropDownWindow.h

@@ -57,7 +57,7 @@ namespace BansheeEngine
 		virtual void update() { }
 
 	protected:
-		DropDownWindow(const RenderWindowPtr& parent, Viewport* target,
+		DropDownWindow(const RenderWindowPtr& parent, const CameraPtr& camera,
 			const Vector2I& position, UINT32 width = 200, UINT32 height = 200);
 
 		GUIPanel* mContents;

+ 3 - 3
BansheeEditor/Include/BsDropDownWindowManager.h

@@ -19,7 +19,7 @@ namespace BansheeEngine
 		 * @brief	Opens a new drop down window with the specified type and arguments.
 		 *
 		 * @param	parent		Render window parent in which to open the drop down window.
-		 * @param	target		Viewport parent in which to open the drop down window.
+		 * @param	camera		Camera in which to open the drop down window.
 		 * @param	position	Position relative to the viewport at which to open the drop down window.
 		 * @param	...args		A set of arguments to be passed along to the drop down window constructor.
 		 *
@@ -29,12 +29,12 @@ namespace BansheeEngine
 		 *			a new one.
 		 */
 		template<class T, class... Args>
-		T* open(const RenderWindowPtr& parent, Viewport* target,
+		T* open(const RenderWindowPtr& parent, const CameraPtr& camera,
 			const Vector2I& position, Args &&...args)
 		{
 			close();
 
-			mOpenWindow = bs_new<T>(parent, target, position, std::forward<Args>(args)...);
+			mOpenWindow = bs_new<T>(parent, camera, position, std::forward<Args>(args)...);
 			return static_cast<T*>(mOpenWindow);
 		}
 

+ 1 - 1
BansheeEditor/Include/BsEditorWidget.h

@@ -173,7 +173,7 @@ namespace BansheeEngine
 		 * @brief	Returns the parent GUI widget. Before calling this you must ensure
 		 *			the widget has a container parent otherwise this method will fail.
 		 */
-		GUIWidget& getParentWidget() const;
+		CGUIWidget& getParentWidget() const;
 
 		/**
 		 * @brief	Frees widget resources and deletes the instance.

+ 3 - 3
BansheeEditor/Include/BsEditorWidgetContainer.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	class BS_ED_EXPORT EditorWidgetContainer
 	{
 	public:
-		EditorWidgetContainer(GUIWidget* parent, EditorWindowBase* parentEditorWindow);
+		EditorWidgetContainer(CGUIWidget* parent, EditorWindowBase* parentEditorWindow);
 		virtual ~EditorWidgetContainer();
 
 		/**
@@ -75,7 +75,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns the parent GUI widget the container is using to render the GUI on.
 		 */
-		GUIWidget& getParentWidget() const { return *mParent; }
+		CGUIWidget& getParentWidget() const { return *mParent; }
 
 		/**
 		 * @brief	Returns the parent editor window the container is docked in.
@@ -115,7 +115,7 @@ namespace BansheeEngine
 		EditorWindowBase* mParentWindow;
 		GUITabbedTitleBar* mTitleBar;
 		GUIPanel* mTitleBarPanel;
-		GUIWidget* mParent;
+		CGUIWidget* mParent;
 		INT32 mX, mY;
 		UINT32 mWidth, mHeight;
 		UnorderedMap<UINT32, EditorWidgetBase*> mWidgets;

+ 2 - 2
BansheeEditor/Include/BsGUIMenuBar.h

@@ -32,7 +32,7 @@ namespace BansheeEngine
 		 * @param	parent			Parent GUI widget the menu bar will be docked in.
 		 * @param	parentWindow	Window to trigger the min/max/close events on.
 		 */
-		GUIMenuBar(GUIWidget* parent, RenderWindow* parentWindow);
+		GUIMenuBar(CGUIWidget* parent, RenderWindow* parentWindow);
 		virtual ~GUIMenuBar();
 
 		/**
@@ -81,7 +81,7 @@ namespace BansheeEngine
 		static const UINT32 ELEMENT_SPACING;
 
 		RenderWindow* mParentWindow;
-		GUIWidget* mParentWidget;
+		CGUIWidget* mParentWidget;
 		GUIPanel* mMainPanel;
 		GUIPanel* mBgPanel;
 		GUILayout* mMainLayout;

+ 1 - 1
BansheeEditor/Include/BsGUIResourceTreeView.h

@@ -182,7 +182,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUITreeView::_changeParentWidget
 		 */	
-		void _changeParentWidget(GUIWidget* widget) override;
+		void _changeParentWidget(CGUIWidget* widget) override;
 
 		/**
 		 * @brief	Triggered when a drag and drop operation that was started by the tree view

+ 4 - 4
BansheeEditor/Include/BsGUIWindowFrameWidget.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "BsEditorPrerequisites.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsEvent.h"
 
 namespace BansheeEngine
@@ -11,7 +11,7 @@ namespace BansheeEngine
 	 *			create a window border, window background and provide resize
 	 *			functionality.
 	 */
-	class WindowFrameWidget : public GUIWidget
+	class WindowFrameWidget : public CGUIWidget
 	{
 	public:
 		/**
@@ -19,11 +19,11 @@ namespace BansheeEngine
 		 *
 		 * @param	parent			Parent SceneObject to attach the Component to.
 		 * @param	allowResize		Should the widget set up resize handles that can be dragged by the user.
-		 * @param	target			Viewport to draw the GUI elements in.
+		 * @param	camera			Camera to draw the GUI elements in.
 		 * @param	ownerWindow		Window that the frame widget will act on.
 		 * @param	skin			GUI skin used for the GUI child elements.
 		 */
-		WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* ownerWindow, const HGUISkin& skin);
+		WindowFrameWidget(const HSceneObject& parent, bool allowResize, const CameraPtr& camera, RenderWindow* ownerWindow, const HGUISkin& skin);
 		virtual ~WindowFrameWidget();
 
 	protected:

+ 2 - 3
BansheeEditor/Source/BsDockManager.cpp

@@ -7,14 +7,13 @@
 #include "BsMesh.h"
 #include "BsMaterial.h"
 #include "BsVector2.h"
-#include "BsDrawList.h"
 #include "BsCoreApplication.h"
 #include "BsRendererManager.h"
 #include "BsCoreRenderer.h"
 #include "BsSceneObject.h"
 #include "BsGUIManager.h"
 #include "BsBuiltinEditorResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsCCamera.h"
 #include "BsDragAndDropManager.h"
 #include "BsGUIDockSlider.h"
@@ -134,7 +133,7 @@ namespace BansheeEngine
 	void DockManager::DockContainer::makeLeaf(EditorWindowBase* parentWindow)
 	{
 		mGUIWidgetSO = SceneObject::create("DockContainer", SOF_Internal | SOF_Persistent | SOF_DontSave);
-		HGUIWidget guiWidget = mGUIWidgetSO->addComponent<GUIWidget>(parentWindow->getGUICamera()->getViewport().get());
+		HGUIWidget guiWidget = mGUIWidgetSO->addComponent<CGUIWidget>(parentWindow->getGUICamera());
 		guiWidget->setDepth(128);
 		guiWidget->setSkin(BuiltinEditorResources::instance().getSkin());
 

+ 6 - 4
BansheeEditor/Source/BsDropDownWindow.cpp

@@ -1,6 +1,6 @@
 #include "BsDropDownWindow.h"
 #include "BsSceneObject.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIPanel.h"
 #include "BsGUITexture.h"
 #include "BsGUIWindowFrame.h"
@@ -8,17 +8,18 @@
 #include "BsBuiltinEditorResources.h"
 #include "BsGUIDropDownHitBox.h"
 #include "BsDropDownWindowManager.h"
+#include "BsCamera.h"
 
 namespace BansheeEngine
 {
-	DropDownWindow::DropDownWindow(const RenderWindowPtr& parent, Viewport* target, 
+	DropDownWindow::DropDownWindow(const RenderWindowPtr& parent, const CameraPtr& camera,
 		const Vector2I& position, UINT32 width, UINT32 height)
 		:mRootPanel(nullptr), mPosition(position), mWidth(width), mHeight(height), 
 		mRenderWindow(parent), mFrontHitBox(nullptr), mBackHitBox(nullptr)
 	{
 		mSceneObject = SceneObject::create("EditorWindow", SOF_Internal | SOF_Persistent | SOF_DontSave);
 
-		mGUI = mSceneObject->addComponent<GUIWidget>(target);
+		mGUI = mSceneObject->addComponent<CGUIWidget>(camera);
 
 		mGUI->setDepth(0); // Needs to be in front of everything
 		mGUI->setSkin(BuiltinEditorResources::instance().getSkin());
@@ -35,9 +36,10 @@ namespace BansheeEngine
 		mBackHitBox = GUIDropDownHitBox::create(false, true);
 		backHitBoxPanel->addElement(mBackHitBox);
 		
+		ViewportPtr viewport = camera->getViewport();
 		GUIPanel* captureHitBoxPanel = mGUI->getPanel()->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
 		GUIDropDownHitBox* captureHitBox = GUIDropDownHitBox::create(true, false);
-		captureHitBox->setBounds(Rect2I(0, 0, target->getWidth(), target->getHeight()));
+		captureHitBox->setBounds(Rect2I(0, 0, viewport->getWidth(), viewport->getHeight()));
 		captureHitBoxPanel->addElement(captureHitBox);
 
 		setSize(width, height);

+ 1 - 1
BansheeEditor/Source/BsEditorApplication.cpp

@@ -38,7 +38,7 @@
 #include "BsVirtualInput.h"
 #include "BsFolderMonitor.h"
 #include "BsCCamera.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIButton.h"
 #include "BsGUILayout.h"
 #include "BsEvent.h"

+ 2 - 2
BansheeEditor/Source/BsEditorWidget.cpp

@@ -1,6 +1,6 @@
 #include "BsEditorWidget.h"
 #include "BsGUIManager.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUITexture.h"
 #include "BsGUISkin.h"
 #include "BsGUILayout.h"
@@ -167,7 +167,7 @@ namespace BansheeEngine
 		mContent->enableRecursively();
 	}
 
-	GUIWidget& EditorWidgetBase::getParentWidget() const
+	CGUIWidget& EditorWidgetBase::getParentWidget() const
 	{
 		return mParent->getParentWidget();
 	}

+ 2 - 2
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -4,7 +4,7 @@
 #include "BsDragAndDropManager.h"
 #include "BsEditorWindow.h"
 #include "BsGUIPanel.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsMath.h"
 #include "BsInput.h"
 #include "BsGUILayoutX.h"
@@ -16,7 +16,7 @@ namespace BansheeEngine
 {
 	const UINT32 EditorWidgetContainer::TitleBarHeight = 13;
 
-	EditorWidgetContainer::EditorWidgetContainer(GUIWidget* parent, EditorWindowBase* parentEditorWindow)
+	EditorWidgetContainer::EditorWidgetContainer(CGUIWidget* parent, EditorWindowBase* parentEditorWindow)
 		:mParent(parent), mX(0), mY(0), mWidth(0), mHeight(0), mTitleBar(nullptr), mActiveWidget(-1),
 		mTitleBarPanel(nullptr), mParentWindow(parentEditorWindow)
 	{

+ 2 - 2
BansheeEditor/Source/BsEditorWindowBase.cpp

@@ -70,12 +70,12 @@ namespace BansheeEngine
 		mCamera->setAspectRatio(1.0f);
 		mCamera->setLayers(0);
 
-		mGUI = mSceneObject->addComponent<GUIWidget>(mCamera->getViewport().get());
+		mGUI = mSceneObject->addComponent<CGUIWidget>(mCamera);
 		mGUI->setDepth(128);
 
 		mGUI->setSkin(BuiltinEditorResources::instance().getSkin());
 
-		mWindowFrame = mSceneObject->addComponent<WindowFrameWidget>(!mIsModal, mCamera->getViewport().get(), renderWindow.get(), BuiltinEditorResources::instance().getSkin());
+		mWindowFrame = mSceneObject->addComponent<WindowFrameWidget>(!mIsModal, mCamera->_getCamera(), renderWindow.get(), BuiltinEditorResources::instance().getSkin());
 		mWindowFrame->setDepth(129);
 
 		mResizedConn = renderWindow->onResized.connect(std::bind(&EditorWindowBase::resized, this));

+ 1 - 1
BansheeEditor/Source/BsGUIColor.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIColor.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"

+ 2 - 2
BansheeEditor/Source/BsGUIColorField.cpp

@@ -3,9 +3,9 @@
 #include "BsGUILabel.h"
 #include "BsGUIColor.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsCmdInputFieldValueChange.h"
 
 using namespace std::placeholders;

+ 1 - 1
BansheeEditor/Source/BsGUIComponentFoldout.cpp

@@ -5,7 +5,7 @@
 #include "BsGUIButton.h"
 #include "BsGUITexture.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 
 using namespace std::placeholders;

+ 1 - 1
BansheeEditor/Source/BsGUIDockSlider.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIDockSlider.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"

+ 1 - 1
BansheeEditor/Source/BsGUIDropButton.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIDropButton.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"

+ 1 - 1
BansheeEditor/Source/BsGUIFieldBase.cpp

@@ -1,7 +1,7 @@
 #include "BsGUIFieldBase.h"
 #include "BsGUILabel.h"
 #include "BsGUILayoutX.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUILayoutUtility.h"
 

+ 2 - 2
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -4,10 +4,10 @@
 #include "BsGUIInputBox.h"
 #include "BsGUISpace.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsCursor.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsViewport.h"
 #include "BsCmdInputFieldValueChange.h"
 #include <regex>

+ 1 - 1
BansheeEditor/Source/BsGUIFoldout.cpp

@@ -4,7 +4,7 @@
 #include "BsGUIToggle.h"
 #include "BsGUITexture.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 
 using namespace std::placeholders;

+ 2 - 2
BansheeEditor/Source/BsGUIIntField.cpp

@@ -4,9 +4,9 @@
 #include "BsGUIInputBox.h"
 #include "BsGUISpace.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsCursor.h"
 #include "BsUndoRedo.h"
 #include "BsViewport.h"

+ 3 - 3
BansheeEditor/Source/BsGUIMenuBar.cpp

@@ -19,7 +19,7 @@ namespace BansheeEngine
 	const UINT32 GUIMenuBar::NUM_ELEMENTS_AFTER_CONTENT = 8;
 	const UINT32 GUIMenuBar::ELEMENT_SPACING = 10;
 
-	GUIMenuBar::GUIMenuBar(GUIWidget* parent, RenderWindow* parentWindow)
+	GUIMenuBar::GUIMenuBar(CGUIWidget* parent, RenderWindow* parentWindow)
 		:mParentWidget(parent), mParentWindow(parentWindow), mMainPanel(nullptr), mMainLayout(nullptr),
 		mBgTexture(nullptr), mLogoTexture(nullptr), mSubMenuOpen(false), mSubMenuButton(nullptr), mBgPanel(nullptr)
 	{
@@ -284,10 +284,10 @@ namespace BansheeEngine
 				return;
 		}
 
-		GUIWidget* widget = subMenu->button->_getParentWidget();
+		CGUIWidget* widget = subMenu->button->_getParentWidget();
 
 		DROP_DOWN_BOX_DESC desc;
-		desc.target = widget->getTarget();
+		desc.camera = widget->getCamera();
 		desc.skin = widget->getSkinResource();
 		desc.placement = DropDownAreaPlacement::aroundBoundsHorz(subMenu->button->_getLayoutData().area);
 		desc.dropDownData = subMenu->menu->getDropDownData();

+ 2 - 2
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -6,7 +6,7 @@
 #include "BsResourceManifest.h"
 #include "BsProjectLibrary.h"
 #include "BsFileSystem.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsViewport.h"
 #include "BsRenderWindow.h"
 #include "BsPlatform.h"
@@ -453,7 +453,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUIResourceTreeView::_changeParentWidget(GUIWidget* widget)
+	void GUIResourceTreeView::_changeParentWidget(CGUIWidget* widget)
 	{
 		GUITreeView::_changeParentWidget(widget);
 

+ 1 - 1
BansheeEditor/Source/BsGUITabButton.cpp

@@ -1,5 +1,5 @@
 #include "BsGUITabButton.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"

+ 1 - 1
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -5,7 +5,7 @@
 #include "BsGUITabButton.h"
 #include "BsGUISpace.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsDragAndDropManager.h"
 #include "BsEditorWidget.h"

+ 2 - 2
BansheeEditor/Source/BsGUITextField.cpp

@@ -3,9 +3,9 @@
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsCmdInputFieldValueChange.h"
 
 using namespace std::placeholders;

+ 2 - 2
BansheeEditor/Source/BsGUIToggleField.cpp

@@ -3,9 +3,9 @@
 #include "BsGUILabel.h"
 #include "BsGUIToggle.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsCmdInputFieldValueChange.h"
 
 using namespace std::placeholders;

+ 1 - 1
BansheeEditor/Source/BsGUITreeView.cpp

@@ -4,7 +4,7 @@
 #include "BsGUIButton.h"
 #include "BsGUILabel.h"
 #include "BsGUISpace.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIToggle.h"
 #include "BsGUITreeViewEditBox.h"
 #include "BsGUIMouseEvent.h"

+ 1 - 1
BansheeEditor/Source/BsGUITreeViewEditBox.cpp

@@ -1,6 +1,6 @@
 #include "BsGUITreeViewEditBox.h"
 #include "BsGUICommandEvent.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 
 namespace BansheeEngine

+ 2 - 2
BansheeEditor/Source/BsGUIVector2Field.cpp

@@ -4,10 +4,10 @@
 #include "BsGUILabel.h"
 #include "BsGUIFloatField.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUISpace.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 
 using namespace std::placeholders;
 

+ 2 - 2
BansheeEditor/Source/BsGUIVector3Field.cpp

@@ -4,10 +4,10 @@
 #include "BsGUILabel.h"
 #include "BsGUIFloatField.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUISpace.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 
 using namespace std::placeholders;
 

+ 2 - 2
BansheeEditor/Source/BsGUIVector4Field.cpp

@@ -4,10 +4,10 @@
 #include "BsGUILabel.h"
 #include "BsGUIFloatField.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUISpace.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 
 using namespace std::placeholders;
 

+ 1 - 1
BansheeEditor/Source/BsGUIWindowFrame.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIWindowFrame.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"

+ 6 - 6
BansheeEditor/Source/BsGUIWindowFrameWidget.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIWindowFrameWidget.h"
 #include "BsGUIPanel.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIWindowFrame.h"
@@ -14,8 +14,8 @@ namespace BansheeEngine
 {
 	const UINT32 WindowFrameWidget::RESIZE_BORDER_WIDTH = 3;
 
-	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* parentWindow, const HGUISkin& skin)
-		:GUIWidget(parent, target), mWindowFramePanel(nullptr), mParentWindow(parentWindow), mAllowResize(allowResize)
+	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, const CameraPtr& camera, RenderWindow* parentWindow, const HGUISkin& skin)
+		:CGUIWidget(parent, camera), mWindowFramePanel(nullptr), mParentWindow(parentWindow), mAllowResize(allowResize)
 	{
 		setSkin(skin);
 
@@ -43,19 +43,19 @@ namespace BansheeEngine
 
 	bool WindowFrameWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
 	{
-		return GUIWidget::_mouseEvent(element, ev);
+		return CGUIWidget::_mouseEvent(element, ev);
 	}
 
 	void WindowFrameWidget::ownerWindowFocusChanged()
 	{
 		mWindowFrame->setFocused(mParentWindow->getProperties().hasFocus());
 
-		GUIWidget::ownerWindowFocusChanged();
+		CGUIWidget::ownerWindowFocusChanged();
 	}
 
 	void WindowFrameWidget::ownerTargetResized()
 	{
-		GUIWidget::ownerTargetResized();
+		CGUIWidget::ownerTargetResized();
 
 		refreshNonClientAreas();
 	}

+ 1 - 1
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -2,7 +2,7 @@
 #include "BsEditorWindowManager.h"
 #include "BsDockManager.h"
 #include "BsGUIMenuBar.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIPanel.h"
 #include "BsGUIStatusBar.h"
 #include "BsEditorTestSuite.h"

+ 1 - 1
BansheeEditor/Source/BsModalWindow.cpp

@@ -9,7 +9,7 @@
 #include "BsGUITexture.h"
 #include "BsGUILabel.h"
 #include "BsGUIPanel.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 
 namespace BansheeEngine
 {

+ 0 - 1
BansheeEditor/Source/BsSceneGrid.cpp

@@ -4,7 +4,6 @@
 #include "BsVertexDataDesc.h"
 #include "BsMaterial.h"
 #include "BsMesh.h"
-#include "BsDrawList.h"
 #include "BsBuiltinEditorResources.h"
 #include "BsCCamera.h"
 #include "BsRect3.h"

+ 3 - 7
BansheeEngine/BansheeEngine.vcxproj

@@ -273,7 +273,7 @@
     <ClInclude Include="Include\BsGUIProgressBar.h" />
     <ClInclude Include="Include\BsGUISkinRTTI.h" />
     <ClInclude Include="Include\BsGUISlider.h" />
-    <ClInclude Include="Include\BsGUIWidgetRTTI.h" />
+    <ClInclude Include="Include\BsCGUIWidgetRTTI.h" />
     <ClInclude Include="Include\BsHEString.h" />
     <ClInclude Include="Include\BsCLight.h" />
     <ClInclude Include="Include\BsLight.h" />
@@ -341,7 +341,7 @@
     <ClInclude Include="Include\BsGUIMaterialManager.h" />
     <ClInclude Include="Include\BsGUIMouseEvent.h" />
     <ClInclude Include="Include\BsGUISkin.h" />
-    <ClInclude Include="Include\BsGUIWidget.h" />
+    <ClInclude Include="Include\BsCGUIWidget.h" />
     <ClInclude Include="Include\BsImageSprite.h" />
     <ClInclude Include="Include\BsProfilerOverlay.h" />
     <ClInclude Include="Include\BsRectOffset.h" />
@@ -358,8 +358,6 @@
     <ClInclude Include="Include\BsTextSprite.h" />
     <ClInclude Include="Include\BsCCamera.h" />
     <ClInclude Include="Include\BsCCameraRTTI.h" />
-    <ClInclude Include="Include\BsCOverlay.h" />
-    <ClInclude Include="Include\BsOverlayManager.h" />
     <ClInclude Include="Include\BsCRenderable.h" />
     <ClInclude Include="Include\BsCRenderableRTTI.h" />
     <ClCompile Include="Source\BsGUIButtonBase.cpp" />
@@ -405,7 +403,7 @@
     <ClCompile Include="Source\BsGUITexture.cpp" />
     <ClCompile Include="Source\BsGUIToggle.cpp" />
     <ClCompile Include="Source\BsGUIToggleGroup.cpp" />
-    <ClCompile Include="Source\BsGUIWidget.cpp" />
+    <ClCompile Include="Source\BsCGUIWidget.cpp" />
     <ClCompile Include="Source\BsImageSprite.cpp" />
     <ClCompile Include="Source\BsProfilerOverlay.cpp" />
     <ClCompile Include="Source\BsSceneManager.cpp" />
@@ -415,8 +413,6 @@
     <ClCompile Include="Source\BsSpriteTexture.cpp" />
     <ClCompile Include="Source\BsTextSprite.cpp" />
     <ClCompile Include="Source\BsCCamera.cpp" />
-    <ClCompile Include="Source\BsCOverlay.cpp" />
-    <ClCompile Include="Source\BsOverlayManager.cpp" />
     <ClCompile Include="Source\BsCRenderable.cpp" />
     <ClCompile Include="Source\BsGUILayoutX.cpp" />
     <ClCompile Include="Source\BsGUIViewport.cpp" />

+ 9 - 21
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -59,9 +59,6 @@
     <ClInclude Include="Include\BsGUIMaterialManager.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsGUIWidget.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsGUISkin.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
@@ -83,9 +80,6 @@
     <ClInclude Include="Include\BsSceneManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsOverlayManager.h">
-      <Filter>Header Files\2D</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsGUILayout.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
@@ -305,9 +299,6 @@
     <ClInclude Include="Include\BsDropDownAreaPlacement.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsGUIWidgetRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsProfilerOverlayRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
@@ -332,9 +323,6 @@
     <ClInclude Include="Include\BsCLight.h">
       <Filter>Header Files\Components</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsCOverlay.h">
-      <Filter>Header Files\Components</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsCamera.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -353,6 +341,12 @@
     <ClInclude Include="Include\BsLightRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsCGUIWidget.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCGUIWidgetRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -370,9 +364,6 @@
     <ClCompile Include="Source\BsGUISkin.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsGUIWidget.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsImageSprite.cpp">
       <Filter>Source Files\2D</Filter>
     </ClCompile>
@@ -391,9 +382,6 @@
     <ClCompile Include="Source\BsSceneManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsOverlayManager.cpp">
-      <Filter>Source Files\2D</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsGUILayout.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
@@ -592,9 +580,6 @@
     <ClCompile Include="Source\BsCLight.cpp">
       <Filter>Source Files\Components</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsCOverlay.cpp">
-      <Filter>Source Files\Components</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsCamera.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -604,5 +589,8 @@
     <ClCompile Include="Source\BsLight.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsCGUIWidget.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 234 - 220
BansheeEngine/Include/BsGUIWidget.h → BansheeEngine/Include/BsCGUIWidget.h

@@ -1,221 +1,235 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsComponent.h"
-#include "BsRect2I.h"
-#include "BsVector3.h"
-#include "BsQuaternion.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	A top level container for all types of GUI elements. Every GUI element, layout or area
-	 *			must be assigned to a widget in order to be rendered.
-	 *
-	 *			Widgets are the only GUI objects that may be arbitrarily transformed, allowing you to create
-	 *			3D interfaces.
-	 */
-	class BS_EXPORT GUIWidget : public Component
-	{
-	public:
-		virtual ~GUIWidget();
-
-		/**
-		 * @brief	Sets the skin used for all GUI elements in the widget. This will update
-		 *			the look of all current elements.
-		 */
-		void setSkin(const HGUISkin& skin);
-
-		/**
-		 * @brief	Returns the currently active GUI skin.
-		 */
-		const GUISkin& getSkin() const;
-
-		/**
-		 * @brief	Returns the currently active GUI skin resource.
-		 */
-		const HGUISkin& getSkinResource() const { return mSkin; }
-
-		/**
-		 * @brief	Returns the root GUI panel for the widget.
-		 */
-		GUIPanel* getPanel() const { return mPanel; }
-
-		/**
-		 * @brief	Returns the depth to render the widget at. If two widgets overlap the
-		 *			widget with the lower depth will be rendered in front.
-		 */
-		UINT8 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Changes the depth to render the widget at. If two widgets overlap the
-		 *			widget with the lower depth will be rendered in front.
-		 */
-		void setDepth(UINT8 depth);
-
-		/**
-		 * @brief	Checks are the specified coordinates within widget bounds. Coordinates should
-		 *			be relative to the parent window.
-		 */
-		bool inBounds(const Vector2I& position) const;
-
-		/**
-		 * @brief	Returns bounds of the widget, relative to the parent window.
-		 */
-		const Rect2I& getBounds() const { return mBounds; }
-
-		/**
-		 * @brief	Return true if widget or any of its elements are dirty.
-		 *
-		 * @param	cleanIfDirty	If true, all dirty elements will be updated and widget will be marked as clean.
-		 *
-		 * @return	True if dirty, false if not. If "cleanIfDirty" is true, the returned state is the one before cleaning.
-		 */
-		bool isDirty(bool cleanIfDirty);
-
-		/**
-		 * @brief	Returns the viewport that this widget will be rendered on.
-		 */
-		Viewport* getTarget() const { return mTarget; }
-
-		/**
-		 * @brief	Returns a list of all elements parented to this widget.
-		 */
-		const Vector<GUIElement*>& getElements() const { return mElements; }
-
-		/**
-		 * @brief	Registers a new element as a child of the widget.
-		 *
-		 * @note	Internal method.
-		 */
-		void _registerElement(GUIElementBase* elem);
-		
-		/**
-		 * @brief	Unregisters an element from the widget. Usually called when the element
-		 *			is destroyed, or reparented to another widget.
-		 *
-		 * @note	Internal method.
-		 */
-		void _unregisterElement(GUIElementBase* elem);
-
-		/**
-		 * @brief	Marks the widget mesh dirty requiring a mesh rebuild. Provided element
-		 *			is the one that requested the mesh update.
-		 */
-		void _markMeshDirty(GUIElementBase* elem);
-
-		/**
-		 * @brief	Marks the elements content as dirty, meaning its internal mesh will need to be
-		 *			rebuilt (this implies the entire widget mesh will be rebuilt as well).
-		 */
-		void _markContentDirty(GUIElementBase* elem);
-
-		/**
-		 * @brief	Updates the layout of all child elements, repositioning and resizing them as needed.
-		 */
-		void _updateLayout();
-
-		/**
-		 * @brief	Updates the layout of the provided element, and queues content updates.
-		 */
-		void _updateLayout(GUIElementBase* elem);
-
-		/**
-		 * @brief	Forwards the specified mouse event to the specified element. The element
-		 * 			must be a child of this widget.
-		 */
-		virtual bool _mouseEvent(GUIElement* element, const GUIMouseEvent& ev);
-				
-		/**
-		 * @brief	Forwards the specified key event to the specified element. The element
-		 * 			must be a child of this widget.
-		 */
-		virtual bool _textInputEvent(GUIElement* element, const GUITextInputEvent& ev);
-
-		/**
-		 * @brief	Forwards the specified key event to the specified element. The element
-		 * 			must be a child of this widget.
-		 */
-		virtual bool _commandEvent(GUIElement* element, const GUICommandEvent& ev);
-
-		/**
-		 * @brief	Forwards the specified virtual button event to the specified element. The element
-		 * 			must be a child of this widget.
-		 */
-		virtual bool _virtualButtonEvent(GUIElement* element, const GUIVirtualButtonEvent& ev);
-
-	protected:
-		friend class SceneObject;
-		friend class GUIElementBase;
-		friend class GUIManager;
-
-		/**
-		 * @brief	Constructs a new GUI widget attached to the specified parent scene object.
-		 *			Widget elements will be rendered on the provided viewport.
-		 */
-		GUIWidget(const HSceneObject& parent, Viewport* target);
-
-		/**
-		 * @brief	Called when the viewport size changes and widget elements need to be updated.
-		 */
-		virtual void ownerTargetResized();
-
-		/**
-		 * @brief	Called when the parent window gained or lost focus.
-		 */
-		virtual void ownerWindowFocusChanged();
-
-		/**
-		 * @copydoc	Component::update
-		 */
-		virtual void update() override;
-
-		/**
-		 * @copydoc	Component::onDestroyed
-		 */
-		virtual void onDestroyed() override;
-	private:
-		GUIWidget(const GUIWidget& other) { }
-
-		/**
-		 * @brief	Calculates widget bounds using the bounds of all child elements.
-		 */
-		void updateBounds() const;
-
-		/**
-		 * @brief	Updates the size of the primary GUI panel based on the viewport.
-		 */
-		void updateRootPanel();
-
-		Viewport* mTarget;
-		Vector<GUIElement*> mElements;
-		GUIPanel* mPanel;
-		UINT8 mDepth;
-
-		Vector3 mLastFramePosition;
-		Quaternion mLastFrameRotation;
-		Vector3 mLastFrameScale;
-
-		HEvent mOwnerTargetResizedConn;
-
-		Set<GUIElement*> mDirtyContents;
-
-		mutable bool mWidgetIsDirty;
-		mutable Rect2I mBounds;
-		mutable Vector<HMesh> mCachedMeshes;
-		mutable Vector<HMaterial> mCachedMaterials;
-
-		HGUISkin mSkin;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class GUIWidgetRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-
-		GUIWidget() { } // Serialization only
-	};
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsComponent.h"
+#include "BsRect2I.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+#include "BsEvent.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	A top level container for all types of GUI elements. Every GUI element, layout or area
+	 *			must be assigned to a widget in order to be rendered.
+	 *
+	 *			Widgets are the only GUI objects that may be arbitrarily transformed, allowing you to create
+	 *			3D interfaces.
+	 */
+	class BS_EXPORT CGUIWidget : public Component
+	{
+	public:
+		virtual ~CGUIWidget();
+
+		/**
+		 * @brief	Sets the skin used for all GUI elements in the widget. This will update
+		 *			the look of all current elements.
+		 */
+		void setSkin(const HGUISkin& skin);
+
+		/**
+		 * @brief	Returns the currently active GUI skin.
+		 */
+		const GUISkin& getSkin() const;
+
+		/**
+		 * @brief	Returns the currently active GUI skin resource.
+		 */
+		const HGUISkin& getSkinResource() const { return mSkin; }
+
+		/**
+		 * @brief	Returns the root GUI panel for the widget.
+		 */
+		GUIPanel* getPanel() const { return mPanel; }
+
+		/**
+		 * @brief	Returns the depth to render the widget at. If two widgets overlap the
+		 *			widget with the lower depth will be rendered in front.
+		 */
+		UINT8 getDepth() const { return mDepth; }
+
+		/**
+		 * @brief	Changes the depth to render the widget at. If two widgets overlap the
+		 *			widget with the lower depth will be rendered in front.
+		 */
+		void setDepth(UINT8 depth);
+
+		/**
+		 * @brief	Checks are the specified coordinates within widget bounds. Coordinates should
+		 *			be relative to the parent window.
+		 */
+		bool inBounds(const Vector2I& position) const;
+
+		/**
+		 * @brief	Returns bounds of the widget, relative to the parent window.
+		 */
+		const Rect2I& getBounds() const { return mBounds; }
+
+		/**
+		 * @brief	Return true if widget or any of its elements are dirty.
+		 *
+		 * @param	cleanIfDirty	If true, all dirty elements will be updated and widget will be marked as clean.
+		 *
+		 * @return	True if dirty, false if not. If "cleanIfDirty" is true, the returned state is the one before cleaning.
+		 */
+		bool isDirty(bool cleanIfDirty);
+
+		/**
+		 * @brief	Returns the viewport that this widget will be rendered on.
+		 */
+		Viewport* getTarget() const;
+
+		/**
+		 * @brief	Returns the camera this widget is being rendered to.
+		 */
+		CameraPtr getCamera() const { return mCamera; }
+
+		/**
+		 * @brief	Returns a list of all elements parented to this widget.
+		 */
+		const Vector<GUIElement*>& getElements() const { return mElements; }
+
+		/**
+		 * @brief	Registers a new element as a child of the widget.
+		 *
+		 * @note	Internal method.
+		 */
+		void _registerElement(GUIElementBase* elem);
+		
+		/**
+		 * @brief	Unregisters an element from the widget. Usually called when the element
+		 *			is destroyed, or reparented to another widget.
+		 *
+		 * @note	Internal method.
+		 */
+		void _unregisterElement(GUIElementBase* elem);
+
+		/**
+		 * @brief	Marks the widget mesh dirty requiring a mesh rebuild. Provided element
+		 *			is the one that requested the mesh update.
+		 */
+		void _markMeshDirty(GUIElementBase* elem);
+
+		/**
+		 * @brief	Marks the elements content as dirty, meaning its internal mesh will need to be
+		 *			rebuilt (this implies the entire widget mesh will be rebuilt as well).
+		 */
+		void _markContentDirty(GUIElementBase* elem);
+
+		/**
+		 * @brief	Updates the layout of all child elements, repositioning and resizing them as needed.
+		 */
+		void _updateLayout();
+
+		/**
+		 * @brief	Updates the layout of the provided element, and queues content updates.
+		 */
+		void _updateLayout(GUIElementBase* elem);
+
+		/**
+		 * @brief	Forwards the specified mouse event to the specified element. The element
+		 * 			must be a child of this widget.
+		 */
+		virtual bool _mouseEvent(GUIElement* element, const GUIMouseEvent& ev);
+				
+		/**
+		 * @brief	Forwards the specified key event to the specified element. The element
+		 * 			must be a child of this widget.
+		 */
+		virtual bool _textInputEvent(GUIElement* element, const GUITextInputEvent& ev);
+
+		/**
+		 * @brief	Forwards the specified key event to the specified element. The element
+		 * 			must be a child of this widget.
+		 */
+		virtual bool _commandEvent(GUIElement* element, const GUICommandEvent& ev);
+
+		/**
+		 * @brief	Forwards the specified virtual button event to the specified element. The element
+		 * 			must be a child of this widget.
+		 */
+		virtual bool _virtualButtonEvent(GUIElement* element, const GUIVirtualButtonEvent& ev);
+
+	protected:
+		friend class SceneObject;
+		friend class GUIElementBase;
+		friend class GUIManager;
+
+		/**
+		 * @brief	Constructs a new GUI widget attached to the specified parent scene object.
+		 *			Widget elements will be rendered on the provided camera.
+		 */
+		CGUIWidget(const HSceneObject& parent, const CameraPtr& camera);
+
+		/**
+		 * @brief	Constructs a new GUI widget attached to the specified parent scene object.
+		 *			Widget elements will be rendered on the provided camera.
+		 */
+		CGUIWidget(const HSceneObject& parent, const HCamera& camera);
+
+		/**
+		 * @brief	Common code for constructors.
+		 */
+		void construct(const CameraPtr& camera);
+
+		/**
+		 * @brief	Called when the viewport size changes and widget elements need to be updated.
+		 */
+		virtual void ownerTargetResized();
+
+		/**
+		 * @brief	Called when the parent window gained or lost focus.
+		 */
+		virtual void ownerWindowFocusChanged();
+
+		/**
+		 * @copydoc	Component::update
+		 */
+		virtual void update() override;
+
+		/**
+		 * @copydoc	Component::onDestroyed
+		 */
+		virtual void onDestroyed() override;
+	private:
+		CGUIWidget(const CGUIWidget& other) { }
+
+		/**
+		 * @brief	Calculates widget bounds using the bounds of all child elements.
+		 */
+		void updateBounds() const;
+
+		/**
+		 * @brief	Updates the size of the primary GUI panel based on the viewport.
+		 */
+		void updateRootPanel();
+
+		CameraPtr mCamera;
+		Vector<GUIElement*> mElements;
+		GUIPanel* mPanel;
+		UINT8 mDepth;
+
+		Vector3 mLastFramePosition;
+		Quaternion mLastFrameRotation;
+		Vector3 mLastFrameScale;
+
+		HEvent mOwnerTargetResizedConn;
+
+		Set<GUIElement*> mDirtyContents;
+
+		mutable bool mWidgetIsDirty;
+		mutable Rect2I mBounds;
+
+		HGUISkin mSkin;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CGUIWidgetRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+
+		CGUIWidget() { } // Serialization only
+	};
 }

+ 6 - 6
BansheeEngine/Include/BsGUIWidgetRTTI.h → BansheeEngine/Include/BsCGUIWidgetRTTI.h

@@ -2,33 +2,33 @@
 
 #include "BsCorePrerequisites.h"
 #include "BsRTTIType.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGameObjectRTTI.h"
 
 namespace BansheeEngine
 {
-	class BS_EXPORT GUIWidgetRTTI : public RTTIType <GUIWidget, Component, GUIWidgetRTTI>
+	class BS_EXPORT CGUIWidgetRTTI : public RTTIType <CGUIWidget, Component, CGUIWidgetRTTI>
 	{
 	private:
 
 	public:
-		GUIWidgetRTTI()
+		CGUIWidgetRTTI()
 		{ }
 
 		virtual const String& getRTTIName() override
 		{
-			static String name = "GUIWidget";
+			static String name = "CGUIWidget";
 			return name;
 		}
 
 		virtual UINT32 getRTTIId() override
 		{
-			return TID_GUIWidget;
+			return TID_CGUIWidget;
 		}
 
 		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
-			return GameObjectRTTI::createGameObject<GUIWidget>();
+			return GameObjectRTTI::createGameObject<CGUIWidget>();
 		}
 	};
 }

+ 0 - 56
BansheeEngine/Include/BsCOverlay.h

@@ -1,56 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsComponent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Overlay components are a special type of components that can be attached directly
-	 * 			to a Viewport and used for rendering 2D graphics. Any overlay components will be 
-	 *			rendered after any other scene objects, so these components are usually used for 
-	 *			GUI elements and full screen effects.
-	 */
-	class BS_EXPORT COverlay : public Component
-	{
-	public:
-		virtual ~COverlay();
-
-		/**
-		 * @brief	Called by the renderer when rendering is in progress. Allows the overlay
-		 *			to queue itself for rendering.
-		 */
-		virtual void render(DrawList& drawList) const = 0;
-
-		/**
-		 * @copydoc	Component::update
-		 */
-		virtual void update() override {}
-
-		/**
-		 * @brief	Returns the viewport onto which this overlay will be overlaid on.
-		 */
-		Viewport* getTarget() const { return mRenderTarget; }
-
-		/**
-		 * @brief	Depth determines in which order the overlays render in case they overlap.
-		 * 			Smaller depth means the overlay is in front of anything with larger depth.
-		 */
-		INT32 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Depth determines in which order the overlays render in case they overlap.
-		 * 			Smaller depth means the overlay is in front of anything with larger depth.
-		 */
-		void setDepth(INT32 depth) { mDepth = depth; }
-
-	protected:
-		friend class SceneObject;
-
-		Viewport* mRenderTarget;
-		INT32 mDepth;
-
-		COverlay(const HSceneObject& parent, Viewport* target);
-	};
-}

+ 1 - 1
BansheeEngine/Include/BsGUIContextMenu.h

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		 * @brief	Opens a context menu at the specified position relative
 		 *			to the provided widget.
 		 */
-		void open(const Vector2I& position, GUIWidget& widget);
+		void open(const Vector2I& position, CGUIWidget& widget);
 
 	private:
 		/**

+ 3 - 3
BansheeEngine/Include/BsGUIDropDownMenu.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsVector2I.h"
 #include "BsRect2I.h"
 #include "BsEvent.h"
@@ -23,7 +23,7 @@ namespace BansheeEngine
 	 */
 	struct DROP_DOWN_BOX_DESC
 	{
-		Viewport* target; /**< Viewport on which to open the drop down box. */
+		CameraPtr camera; /**< Camera on which to open the drop down box. */
 		DropDownAreaPlacement placement; /**< Determines how is the drop down box positioned in the visible area. */
 		GUIDropDownData dropDownData; /**< Data to use for initializing menu items of the drop down box. */
 		HGUISkin skin; /**< Skin to use for drop down box GUI elements. */
@@ -113,7 +113,7 @@ namespace BansheeEngine
 	 * @brief	This is a generic GUI drop down box class that can be used for:
 	 * 			list boxes, menu bars or context menus.
 	 */
-	class BS_EXPORT GUIDropDownMenu : public GUIWidget
+	class BS_EXPORT GUIDropDownMenu : public CGUIWidget
 	{
 	public:
 		/**

+ 1 - 1
BansheeEngine/Include/BsGUIElement.h

@@ -208,7 +208,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElementBase::_changeParentWidget
 		 */
-		virtual void _changeParentWidget(GUIWidget* widget) override;
+		virtual void _changeParentWidget(CGUIWidget* widget) override;
 
 		/**
 		 * @brief	Returns depth for a specific render element. This contains a combination

+ 3 - 3
BansheeEngine/Include/BsGUIElementBase.h

@@ -253,7 +253,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		GUIWidget* _getParentWidget() const { return mParentWidget; }
+		CGUIWidget* _getParentWidget() const { return mParentWidget; }
 
 		/**
 		 * @brief	Returns true if element is disabled and won't be visible or interactable.
@@ -270,7 +270,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		virtual void _changeParentWidget(GUIWidget* widget);
+		virtual void _changeParentWidget(CGUIWidget* widget);
 
 		/**
 		 * @brief	Registers a new child element.
@@ -364,7 +364,7 @@ namespace BansheeEngine
 		 */
 		void setUpdateParent(GUIElementBase* updateParent);
 
-		GUIWidget* mParentWidget;
+		CGUIWidget* mParentWidget;
 		GUIPanel* mAnchorParent;
 		GUIElementBase* mUpdateParent;
 		GUIElementBase* mParentElement;

+ 87 - 23
BansheeEngine/Include/BsGUIManager.h

@@ -13,6 +13,8 @@
 
 namespace BansheeEngine
 {
+	class GUIManagerCore;
+
 	/**
 	 * @brief	Manages the rendering and input of all GUI widgets in the scene. 
 	 * 			
@@ -51,21 +53,31 @@ namespace BansheeEngine
 
 			Vector<TransientMeshPtr> cachedMeshes;
 			Vector<GUIMaterialInfo> cachedMaterials;
-			Vector<GUIWidget*> cachedWidgetsPerMesh;
-			Vector<GUIWidget*> widgets;
+			Vector<CGUIWidget*> cachedWidgetsPerMesh;
+			Vector<CGUIWidget*> widgets;
 			bool isDirty;
 		};
 
+		/**
+		 * @brief	Render data for a single GUI group used for notifying the core GUI renderer.
+		 */
+		struct GUICoreRenderData
+		{
+			SPtr<TransientMeshCore> mesh;
+			SPtr<MaterialCore> material;
+			Matrix4 worldTransform;
+		};
+
 		/**
 		 * @brief	Container for a GUI widget.
 		 */
 		struct WidgetInfo
 		{
-			WidgetInfo(GUIWidget* _widget)
+			WidgetInfo(CGUIWidget* _widget)
 				:widget(_widget)
 			{ }
 
-			GUIWidget* widget;
+			CGUIWidget* widget;
 		};
 
 		/**
@@ -73,12 +85,12 @@ namespace BansheeEngine
 		 */
 		struct ElementInfo
 		{
-			ElementInfo(GUIElement* element, GUIWidget* widget)
+			ElementInfo(GUIElement* element, CGUIWidget* widget)
 				:element(element), widget(widget)
 			{ }
 
 			GUIElement* element;
-			GUIWidget* widget;
+			CGUIWidget* widget;
 		};
 
 		/**
@@ -86,13 +98,13 @@ namespace BansheeEngine
 		 */
 		struct ElementInfoUnderPointer
 		{
-			ElementInfoUnderPointer(GUIElement* element, GUIWidget* widget)
+			ElementInfoUnderPointer(GUIElement* element, CGUIWidget* widget)
 				:element(element), widget(widget), usesMouseOver(false), 
 				receivedMouseOver(false), isHovering(false)
 			{ }
 
 			GUIElement* element;
-			GUIWidget* widget;
+			CGUIWidget* widget;
 			bool usesMouseOver;
 			bool receivedMouseOver;
 			bool isHovering;
@@ -115,25 +127,19 @@ namespace BansheeEngine
 		 * @brief	Registers a newly created widget with the GUI manager.
 		 *			This should be called by every GUI widget on creation.
 		 */
-		void registerWidget(GUIWidget* widget);
+		void registerWidget(CGUIWidget* widget);
 
 		/**
 		 * @brief	Unregisters a GUI widget from the GUI manager.
 		 *			This should be called by every GUI widget before getting deleted.
 		 */
-		void unregisterWidget(GUIWidget* widget);
+		void unregisterWidget(CGUIWidget* widget);
 
 		/**
 		 * @brief	Called once per frame.
 		 */
 		void update();
 
-		/**
-		 * @brief	Called by the renderer for each existing viewport. Allows the GUI manager
-		 *			to queue GUI render operations.
-		 */
-		void render(ViewportPtr& target, DrawList& drawList) const;
-
 		/**
 		 * @brief	Queues the GUI element for destruction. Element will be destroyed during the next
 		 *			call to update().
@@ -200,7 +206,15 @@ namespace BansheeEngine
 		 */
 		void setInputBridge(const RenderTexture* renderTex, const GUIElement* element);
 
+		/**
+		 * @brief	Gets the core thread portion of the GUI manager, responsible for rendering
+		 * 			of GUI elements.
+		 */
+		GUIManagerCore* getCore() const { return mCore.load(std::memory_order_relaxed); }
+
 	private:
+		friend class GUIManagerCore;
+
 		/**
 		 * @brief	Recreates all dirty GUI meshes and makes them ready for rendering.
 		 */
@@ -216,6 +230,13 @@ namespace BansheeEngine
 		 */
 		void updateTextSelectionTexture();
 
+		/**
+		 * @brief	Destroys the core thread counterpart of the GUI manager.
+		 *
+		 * @param	core	Previously constructed core thread GUI manager instance.
+		 */
+		void destroyCore(GUIManagerCore* core);
+
 		/**
 		 * @brief	Destroys any elements or widgets queued for destruction.
 		 *
@@ -299,7 +320,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Converts screen coordinates to coordinates relative to the specified widget.
 		 */
-		Vector2I getWidgetRelativePos(const GUIWidget& widget, const Vector2I& screenPos) const;
+		Vector2I getWidgetRelativePos(const CGUIWidget& widget, const Vector2I& screenPos) const;
 
 		/**
 		 * @brief	Converts window coordinates to coordinates relative to the specified bridged widget.
@@ -307,12 +328,12 @@ namespace BansheeEngine
 		 *
 		 * @param	If provided widget has no bridge, coordinates are returned as is.
 		 */
-		Vector2I windowToBridgedCoords(const GUIWidget& widget, const Vector2I& windowPos) const;
+		Vector2I windowToBridgedCoords(const CGUIWidget& widget, const Vector2I& windowPos) const;
 
 		/**
 		 * @brief	Returns the parent render window of the specified widget.
 		 */
-		const RenderWindow* getWidgetWindow(const GUIWidget& widget) const;
+		const RenderWindow* getWidgetWindow(const CGUIWidget& widget) const;
 
 		/**
 		 * @brief	Sends a mouse event to the specified GUI element.
@@ -321,7 +342,7 @@ namespace BansheeEngine
 		 * @param	element	Element to send the event to.
 		 * @param	event	Event data.
 		 */
-		bool sendMouseEvent(GUIWidget* widget, GUIElement* element, const GUIMouseEvent& event);
+		bool sendMouseEvent(CGUIWidget* widget, GUIElement* element, const GUIMouseEvent& event);
 
 		/**
 		 * @brief	Sends a text input event to the specified GUI element.
@@ -330,7 +351,7 @@ namespace BansheeEngine
 		 * @param	element	Element to send the event to.
 		 * @param	event	Event data.
 		 */
-		bool sendTextInputEvent(GUIWidget* widget, GUIElement* element, const GUITextInputEvent& event);
+		bool sendTextInputEvent(CGUIWidget* widget, GUIElement* element, const GUITextInputEvent& event);
 
 		/**
 		 * @brief	Sends a command event to the specified GUI element.
@@ -339,7 +360,7 @@ namespace BansheeEngine
 		 * @param	element	Element to send the event to.
 		 * @param	event	Event data.
 		 */
-		bool sendCommandEvent(GUIWidget* widget, GUIElement* element, const GUICommandEvent& event);
+		bool sendCommandEvent(CGUIWidget* widget, GUIElement* element, const GUICommandEvent& event);
 
 		/**
 		 * @brief	Sends a virtual button event to the specified GUI element.
@@ -348,7 +369,7 @@ namespace BansheeEngine
 		 * @param	element	Element to send the event to.
 		 * @param	event	Event data.
 		 */
-		bool sendVirtualButtonEvent(GUIWidget* widget, GUIElement* element, const GUIVirtualButtonEvent& event);
+		bool sendVirtualButtonEvent(CGUIWidget* widget, GUIElement* element, const GUIVirtualButtonEvent& event);
 
 		static const UINT32 DRAG_DISTANCE;
 
@@ -359,6 +380,9 @@ namespace BansheeEngine
 		UnorderedMap<const Viewport*, GUIRenderData> mCachedGUIData;
 		MeshHeapPtr mMeshHeap;
 
+		std::atomic<GUIManagerCore*> mCore;
+		bool mCoreDirty;
+
 		VertexDataDescPtr mVertexDesc;
 
 		Stack<GUIElement*> mScheduledForDestruction;
@@ -421,6 +445,46 @@ namespace BansheeEngine
 		HEvent mMouseLeftWindowConn;
 	};
 
+	/**
+	 * @brief	Handles GUI rendering on the core thread.
+	 */
+	class BS_EXPORT GUIManagerCore
+	{
+		friend class GUIManager;
+
+		/**
+		 * @brief	Contains mesh & material data for a group of GUI elements.
+		 */
+		struct RenderData
+		{
+			SPtr<TransientMeshCore> mesh;
+			SPtr<MaterialCore> material;
+			Matrix4 worldTransform;
+
+			MaterialParamMat4Core worldTransformParam;
+			MaterialParamFloatCore invViewportWidthParam;
+			MaterialParamFloatCore invViewportHeightParam;
+		};
+	public:
+		~GUIManagerCore();
+
+	private:
+		/**
+		 * @brief	Updates the internal data that determines what will be rendered on the next
+		 *			::render call.
+		 *
+		 * @param	data	GUI mesh/material per viewport.
+		 */
+		void updateData(const UnorderedMap<SPtr<CameraCore>, Vector<GUIManager::GUICoreRenderData>>& perCameraData);
+
+		/**
+		 * @brief	Triggered by the Renderer when the GUI should be rendered.
+		 */
+		void render(const SPtr<CameraCore>& camera);
+
+		UnorderedMap<SPtr<CameraCore>, Vector<RenderData>> mPerCameraData;
+	};
+
 	/**
 	 * @copydoc	GUIManager
 	 */

+ 0 - 3
BansheeEngine/Include/BsGUIMaterialInfo.h

@@ -11,9 +11,6 @@ namespace BansheeEngine
 	struct GUIMaterialInfo
 	{
 		HMaterial material;
-		MaterialParamMat4 worldTransform;
-		MaterialParamFloat invViewportWidth;
-		MaterialParamFloat invViewportHeight;
 		MaterialParamSampState mainTexSampler;
 		MaterialParamTexture mainTexture;
 		MaterialParamVec4 tint;

+ 1 - 1
BansheeEngine/Include/BsGUIViewport.h

@@ -95,7 +95,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElement::_changeParentWidget
 		 */
-		void _changeParentWidget(GUIWidget* widget) override;
+		void _changeParentWidget(CGUIWidget* widget) override;
 
 		HCamera mCamera;
 		float mAspectRatio;

+ 0 - 55
BansheeEngine/Include/BsOverlayManager.h

@@ -1,55 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsModule.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Handles overlay rendering by determining which overlay gets rendered 
-	 *			on which render target. Overlays are always rendered on top of any geometry.
-	 * 			
-	 * @note	Overlays could have been stored directly on a RenderTarget but this class
-	 * 			was created to decouple the connection.
-	 * 
-	 * @see Overlay
-	 */
-	class BS_EXPORT OverlayManager : public Module<OverlayManager>
-	{
-		/**
-		 * @brief	Used for comparing overlays in order to determine their rendering order.
-		 */
-		struct OverlayComparer
-		{
-			bool operator() (const COverlay* const& a, const COverlay* const& b);
-		};
-
-	public:
-		/**
-		 * @brief	Schedules any overlays for the specified viewport to be rendered.
-		 *			(adds them to the render queue).
-		 */
-		void render(ViewportPtr& target, DrawList& drawList) const;
-
-	private:
-		friend class COverlay;
-
-		/**
-		 * @brief	Attaches the specified overlay to the viewport.
-		 */
-		void attachOverlay(const Viewport* target, const COverlay* overlay);
-
-		/**
-		 * @brief	Detaches the specified overlay from the viewport.
-		 */
-		void detachOverlay(const Viewport* target, const COverlay* overlay);
-
-		/**
-		 * @brief	Detaches the specified overlay from all viewports.
-		 */
-		void detachOverlayFromAll(const COverlay* overlay);
-
-		UnorderedMap<const Viewport*, Set<const COverlay*, OverlayComparer>> mOverlaysPerTarget;
-	};
-}

+ 2 - 5
BansheeEngine/Include/BsPrerequisites.h

@@ -37,7 +37,7 @@ namespace BansheeEngine
 
 	// GUI
 	class GUIManager;
-	class GUIWidget;
+	class CGUIWidget;
 	class GUIElementBase;
 	class GUIElement;
 	class GUILabel;
@@ -100,17 +100,14 @@ namespace BansheeEngine
 	class TextSprite;
 	class ImageSprite;
 	class SpriteTexture;
-	class OverlayManager;
 
 	// Components
-	class COverlay;
 	class CRenderable;
 	class CCamera;
 	class CLight;
 
 	typedef std::shared_ptr<TextSprite> TextSpritePtr;
 	typedef std::shared_ptr<SpriteTexture> SpriteTexturePtr;
-	typedef std::shared_ptr<COverlay> COverlayPtr;
 	typedef std::shared_ptr<CCamera> CCameraPtr;
 	typedef std::shared_ptr<CRenderable> CRenderablePtr;
 	typedef std::shared_ptr<GUIToggleGroup> GUIToggleGroupPtr;
@@ -122,7 +119,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<GUISkin> GUISkinPtr;
 	typedef std::shared_ptr<GUIContextMenu> GUIContextMenuPtr;
 
-	typedef GameObjectHandle<GUIWidget> HGUIWidget;
+	typedef GameObjectHandle<CGUIWidget> HGUIWidget;
 	typedef GameObjectHandle<CCamera> HCamera;
 	typedef GameObjectHandle<CRenderable> HRenderable;
 	typedef GameObjectHandle<ProfilerOverlay> HProfilerOverlay;

+ 8 - 8
BansheeEngine/Include/BsProfilerOverlay.h

@@ -30,13 +30,13 @@ namespace BansheeEngine
 		/**
 		 * @brief	Constructs a new overlay attached to the specified parent and displayed on the provided viewport.
 		 */
-		ProfilerOverlay(const HSceneObject& parent, const ViewportPtr& target);
+		ProfilerOverlay(const HSceneObject& parent, const CameraPtr& target);
 		~ProfilerOverlay();
 
 		/**
-		 * @brief	Changes the viewport to display the overlay on.
+		 * @brief	Changes the camera to display the overlay on.
 		 */
-		void setTarget(const ViewportPtr& target);
+		void setTarget(const CameraPtr& target);
 
 		/**
 		 * @brief	Shows the overlay of the specified type.
@@ -155,15 +155,15 @@ namespace BansheeEngine
 
 	public:
 		/**
-		 * @brief	Constructs a new overlay attached to the specified parent and displayed on the provided viewport.
+		 * @brief	Constructs a new overlay attached to the specified parent and displayed on the provided camera.
 		 */
-		ProfilerOverlayInternal(const ViewportPtr& target);
+		ProfilerOverlayInternal(const CameraPtr& target);
 		~ProfilerOverlayInternal();
 
 		/**
-		 * @brief	Changes the viewport to display the overlay on.
+		 * @brief	Changes the camera to display the overlay on.
 		 */
-		void setTarget(const ViewportPtr& target);
+		void setTarget(const CameraPtr& target);
 
 		/**
 		 * @brief	Shows the overlay of the specified type.
@@ -215,7 +215,7 @@ namespace BansheeEngine
 		ViewportPtr mTarget;
 
 		HSceneObject mWidgetSO;
-		GameObjectHandle<GUIWidget> mWidget;
+		GameObjectHandle<CGUIWidget> mWidget;
 
 		GUILayout* mBasicLayoutLabels = nullptr;
 		GUILayout* mPreciseLayoutLabels = nullptr;

+ 0 - 3
BansheeEngine/Source/BsApplication.cpp

@@ -1,7 +1,6 @@
 #include "BsApplication.h"
 #include "BsGUIMaterialManager.h"
 #include "BsGUIManager.h"
-#include "BsOverlayManager.h"
 #include "BsShapeMeshes2D.h"
 #include "BsShapeMeshes3D.h"
 #include "BsBuiltinResources.h"
@@ -53,7 +52,6 @@ namespace BansheeEngine
 		GUIMaterialManager::instance().clearMaterials();
 
 		ShortcutManager::shutDown();
-		OverlayManager::shutDown();
 		GUIManager::shutDown();
 		GUIMaterialManager::shutDown();
 		BuiltinResources::shutDown();
@@ -71,7 +69,6 @@ namespace BansheeEngine
 		BuiltinResources::startUp();
 		GUIManager::startUp();
 		GUIMaterialManager::startUp();
-		OverlayManager::startUp();
 		ShortcutManager::startUp();
 
 		Cursor::startUp();

+ 1 - 9
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -773,9 +773,7 @@ namespace BansheeEngine
 	{
 		GUIMaterialInfo info;
 		info.material = Material::create(mShaderSpriteText);
-		info.invViewportWidth = info.material->getParamFloat("invViewportWidth");
-		info.invViewportHeight = info.material->getParamFloat("invViewportHeight");
-		info.worldTransform = info.material->getParamMat4("worldTransform");
+
 		info.mainTexture = info.material->getParamTexture("mainTexture");
 		info.mainTexSampler = info.material->getParamSamplerState("mainTexSamp");
 		info.tint = info.material->getParamVec4("tint");
@@ -787,9 +785,6 @@ namespace BansheeEngine
 	{
 		GUIMaterialInfo info;
 		info.material = Material::create(mShaderSpriteImage);
-		info.invViewportWidth = info.material->getParamFloat("invViewportWidth");
-		info.invViewportHeight = info.material->getParamFloat("invViewportHeight");
-		info.worldTransform = info.material->getParamMat4("worldTransform");
 		info.mainTexture = info.material->getParamTexture("mainTexture");
 		info.mainTexSampler = info.material->getParamSamplerState("mainTexSamp");
 		info.tint = info.material->getParamVec4("tint");
@@ -801,9 +796,6 @@ namespace BansheeEngine
 	{
 		GUIMaterialInfo info;
 		info.material = Material::create(mShaderSpriteNonAlphaImage);
-		info.invViewportWidth = info.material->getParamFloat("invViewportWidth");
-		info.invViewportHeight = info.material->getParamFloat("invViewportHeight");
-		info.worldTransform = info.material->getParamMat4("worldTransform");
 		info.mainTexture = info.material->getParamTexture("mainTexture");
 		info.mainTexSampler = info.material->getParamSamplerState("mainTexSamp");
 		info.tint = info.material->getParamVec4("tint");

+ 378 - 363
BansheeEngine/Source/BsGUIWidget.cpp → BansheeEngine/Source/BsCGUIWidget.cpp

@@ -1,364 +1,379 @@
-#include "BsGUIWidget.h"
-#include "BsGUIManager.h"
-#include "BsGUISkin.h"
-#include "BsGUILabel.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUIPanel.h"
-#include "BsCoreApplication.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsMaterial.h"
-#include "BsPass.h"
-#include "BsMesh.h"
-#include "BsVector2I.h"
-#include "BsOverlayManager.h"
-#include "BsCCamera.h"
-#include "BsViewport.h"
-#include "BsSceneObject.h"
-#include "BsRenderWindow.h"
-#include "BsGUIWidgetRTTI.h"
-#include "BsProfilerCPU.h"
-#include "BsDebug.h"
-
-namespace BansheeEngine
-{
-	GUIWidget::GUIWidget(const HSceneObject& parent, Viewport* target)
-		:Component(parent), mWidgetIsDirty(false), mTarget(nullptr), mDepth(0), mPanel(nullptr)
-	{
-		setName("GUIWidget");
-
-		mLastFramePosition = SO()->getWorldPosition();
-		mLastFrameRotation = SO()->getWorldRotation();
-		mLastFrameScale = SO()->getWorldScale();
-
-		assert(target != nullptr);
-
-		mTarget = target;
-
-		mOwnerTargetResizedConn = mTarget->getTarget()->onResized.connect(std::bind(&GUIWidget::ownerTargetResized, this));
-
-		GUIManager::instance().registerWidget(this);
-
-		mPanel = GUIPanel::create();
-		mPanel->_changeParentWidget(this);
-		updateRootPanel();
-	}
-
-	GUIWidget::~GUIWidget()
-	{ }
-
-	void GUIWidget::setDepth(UINT8 depth)
-	{
-		mDepth = depth; 
-		mWidgetIsDirty = true;
-
-		updateRootPanel();
-	}
-
-	void GUIWidget::onDestroyed()
-	{
-		GUILayout::destroy(mPanel);
-		mPanel = nullptr;
-
-		if (mTarget != nullptr)
-		{
-			GUIManager::instance().unregisterWidget(this);
-
-			mOwnerTargetResizedConn.disconnect();
-		}
-
-		mElements.clear();
-		mDirtyContents.clear();
-	}
-
-	void GUIWidget::update()
-	{
-		// If the widgets parent scene object moved, we need to mark it as dirty
-		// as the GUIManager batching relies on object positions, so it needs to be updated.
-		const float diffEpsilon = 0.0001f;
-
-		Vector3 position = SO()->getWorldPosition();
-		Quaternion rotation = SO()->getWorldRotation();
-		Vector3 scale = SO()->getWorldScale();
-
-		if(!mWidgetIsDirty)
-		{
-			Vector3 posDiff = mLastFramePosition - position;
-			if(Math::abs(posDiff.x) > diffEpsilon || Math::abs(posDiff.y) > diffEpsilon || Math::abs(posDiff.z) > diffEpsilon)
-			{
-				mWidgetIsDirty = true;
-			}
-			else
-			{
-				Quaternion rotDiff = mLastFrameRotation - rotation;
-				if(Math::abs(rotDiff.x) > diffEpsilon || Math::abs(rotDiff.y) > diffEpsilon || 
-					Math::abs(rotDiff.z) > diffEpsilon || Math::abs(rotDiff.w) > diffEpsilon)
-				{
-					mWidgetIsDirty = true;
-				}
-				else
-				{
-					Vector3 scaleDiff = mLastFrameScale - scale;
-					if(Math::abs(scaleDiff.x) > diffEpsilon || Math::abs(scaleDiff.y) > diffEpsilon || Math::abs(scaleDiff.z) > diffEpsilon)
-					{
-						mWidgetIsDirty = true;
-					}
-				}
-			}
-		}
-
-		mLastFramePosition = position;
-		mLastFrameRotation = rotation;
-		mLastFrameScale = scale;
-	}
-
-	void GUIWidget::_updateLayout()
-	{
-		bs_frame_mark();
-
-		// Determine dirty contents and layouts
-		FrameStack<GUIElementBase*> todo;
-		todo.push(mPanel);
-
-		while (!todo.empty())
-		{
-			GUIElementBase* currentElem = todo.top();
-			todo.pop();
-
-			if (currentElem->_isDirty())
-			{
-				GUIElementBase* updateParent = currentElem->_getUpdateParent();
-				assert(updateParent != nullptr || currentElem == mPanel);
-
-				if (updateParent != nullptr)
-					_updateLayout(updateParent);
-				else // Must be root panel
-					_updateLayout(mPanel);
-			}
-			else
-			{
-				UINT32 numChildren = currentElem->_getNumChildren();
-				for (UINT32 i = 0; i < numChildren; i++)
-					todo.push(currentElem->_getChild(i));
-			}
-		}
-
-		bs_frame_clear();
-	}
-
-	void GUIWidget::_updateLayout(GUIElementBase* elem)
-	{
-		GUIElementBase* parent = elem->_getParent();
-		bool isPanelOptimized = parent != nullptr && parent->_getType() == GUIElementBase::Type::Panel;
-
-		GUIElementBase* updateParent = nullptr;
-
-		if (isPanelOptimized)
-			updateParent = parent;
-		else
-			updateParent = elem;
-
-		// For GUIPanel we can do a an optimization and update only the element in question instead
-		// of all the children
-		if (isPanelOptimized)
-		{
-			GUIPanel* panel = static_cast<GUIPanel*>(updateParent);
-
-			GUIElementBase* dirtyElement = elem;
-			dirtyElement->_updateOptimalLayoutSizes();
-
-			LayoutSizeRange elementSizeRange = panel->_getElementSizeRange(dirtyElement);
-			Rect2I elementArea = panel->_getElementArea(panel->_getLayoutData().area, dirtyElement, elementSizeRange);
-
-			GUILayoutData childLayoutData = panel->_getLayoutData();
-			childLayoutData.area = elementArea;
-
-			panel->_updateChildLayout(dirtyElement, childLayoutData);
-		}
-		else
-		{
-			GUILayoutData childLayoutData = updateParent->_getLayoutData();
-			updateParent->_updateLayout(childLayoutData);
-		}
-		
-		// Mark dirty contents
-		bs_frame_mark();
-		{
-			FrameStack<GUIElementBase*> todo;
-			todo.push(elem);
-
-			while (!todo.empty())
-			{
-				GUIElementBase* currentElem = todo.top();
-				todo.pop();
-
-				if (currentElem->_getType() == GUIElementBase::Type::Element)
-					mDirtyContents.insert(static_cast<GUIElement*>(currentElem));
-
-				currentElem->_markAsClean();
-
-				UINT32 numChildren = currentElem->_getNumChildren();
-				for (UINT32 i = 0; i < numChildren; i++)
-					todo.push(currentElem->_getChild(i));
-			}
-		}
-		bs_frame_clear();
-	}
-
-	bool GUIWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
-	{
-		return element->_mouseEvent(ev);
-	}
-
-	bool GUIWidget::_textInputEvent(GUIElement* element, const GUITextInputEvent& ev)
-	{
-		return element->_textInputEvent(ev);
-	}
-
-	bool GUIWidget::_commandEvent(GUIElement* element, const GUICommandEvent& ev)
-	{
-		return element->_commandEvent(ev);
-	}
-
-	bool GUIWidget::_virtualButtonEvent(GUIElement* element, const GUIVirtualButtonEvent& ev)
-	{
-		return element->_virtualButtonEvent(ev);
-	}
-
-	void GUIWidget::_registerElement(GUIElementBase* elem)
-	{
-		assert(elem != nullptr && !elem->_isDestroyed());
-
-		if (elem->_getType() == GUIElementBase::Type::Element)
-		{
-			mElements.push_back(static_cast<GUIElement*>(elem));
-			mWidgetIsDirty = true;
-		}
-	}
-
-	void GUIWidget::_unregisterElement(GUIElementBase* elem)
-	{
-		assert(elem != nullptr);
-
-		auto iterFind = std::find(begin(mElements), end(mElements), elem);
-
-		if (iterFind != mElements.end())
-		{
-			mElements.erase(iterFind);
-			mWidgetIsDirty = true;
-		}
-
-		if (elem->_getType() == GUIElementBase::Type::Element)
-			mDirtyContents.erase(static_cast<GUIElement*>(elem));
-	}
-
-	void GUIWidget::_markMeshDirty(GUIElementBase* elem)
-	{
-		mWidgetIsDirty = true;
-	}
-
-	void GUIWidget::_markContentDirty(GUIElementBase* elem)
-	{
-		if (elem->_getType() == GUIElementBase::Type::Element)
-			mDirtyContents.insert(static_cast<GUIElement*>(elem));
-	}
-
-	void GUIWidget::setSkin(const HGUISkin& skin)
-	{
-		mSkin = skin;
-
-		for(auto& element : mElements)
-			element->_refreshStyle();
-	}
-
-	const GUISkin& GUIWidget::getSkin() const
-	{
-		static const HGUISkin DEFAULT_SKIN = GUISkin::create();
-
-		if(mSkin.isLoaded())
-			return *mSkin;
-		else
-			return *DEFAULT_SKIN;
-	}
-
-	bool GUIWidget::isDirty(bool cleanIfDirty)
-	{
-		bool dirty = mWidgetIsDirty || mDirtyContents.size() > 0;
-
-		if(cleanIfDirty && dirty)
-		{
-			mWidgetIsDirty = false;
-
-			for (auto& dirtyElement : mDirtyContents)
-				dirtyElement->_updateRenderElements();
-
-			mDirtyContents.clear();
-			updateBounds();
-		}
-		
-		return dirty;
-	}
-
-	bool GUIWidget::inBounds(const Vector2I& position) const
-	{
-		// Technically GUI widget bounds can be larger than the viewport, so make sure we clip to viewport first
-		if(!getTarget()->getArea().contains(position))
-			return false;
-
-		const Matrix4& worldTfrm = SO()->getWorldTfrm();
-		Vector3 vecPos((float)position.x, (float)position.y, 0.0f);
-		vecPos = worldTfrm.inverse().multiplyAffine(vecPos);
-
-		Vector2I localPos(Math::roundToInt(vecPos.x), Math::roundToInt(vecPos.y));
-		return mBounds.contains(localPos);
-	}
-
-	void GUIWidget::updateBounds() const
-	{
-		if(mElements.size() > 0)
-			mBounds = mElements[0]->_getClippedBounds();
-
-		for(auto& elem : mElements)
-		{
-			Rect2I elemBounds = elem->_getClippedBounds();
-			mBounds.encapsulate(elemBounds);
-		}
-	}
-
-	void GUIWidget::ownerTargetResized()
-	{
-		updateRootPanel();
-	}
-
-	void GUIWidget::updateRootPanel()
-	{
-		UINT32 width = getTarget()->getWidth();
-		UINT32 height = getTarget()->getHeight();
-
-		GUILayoutData layoutData;
-		layoutData.area.width = width;
-		layoutData.area.height = height;
-		layoutData.clipRect = Rect2I(0, 0, width, height);
-		layoutData.setWidgetDepth(mDepth);
-
-		mPanel->setWidth(width);
-		mPanel->setHeight(height);
-
-		mPanel->_setLayoutData(layoutData);
-		mPanel->_markLayoutAsDirty();
-	}
-
-	void GUIWidget::ownerWindowFocusChanged()
-	{
-
-	}
-
-	RTTITypeBase* GUIWidget::getRTTIStatic()
-	{
-		return GUIWidgetRTTI::instance();
-	}
-
-	RTTITypeBase* GUIWidget::getRTTI() const
-	{
-		return GUIWidget::getRTTIStatic();
-	}
+#include "BsCGUIWidget.h"
+#include "BsGUIManager.h"
+#include "BsGUISkin.h"
+#include "BsGUILabel.h"
+#include "BsGUIMouseEvent.h"
+#include "BsGUIPanel.h"
+#include "BsCoreApplication.h"
+#include "BsCoreThreadAccessor.h"
+#include "BsMaterial.h"
+#include "BsPass.h"
+#include "BsMesh.h"
+#include "BsVector2I.h"
+#include "BsCCamera.h"
+#include "BsViewport.h"
+#include "BsSceneObject.h"
+#include "BsRenderWindow.h"
+#include "BsCGUIWidgetRTTI.h"
+#include "BsProfilerCPU.h"
+#include "BsDebug.h"
+
+namespace BansheeEngine
+{
+	CGUIWidget::CGUIWidget(const HSceneObject& parent, const CameraPtr& camera)
+		:Component(parent), mWidgetIsDirty(false), mCamera(camera), mDepth(0), mPanel(nullptr)
+	{
+		setName("GUIWidget");
+
+		construct(camera);
+	}
+
+	CGUIWidget::CGUIWidget(const HSceneObject& parent, const HCamera& camera)
+		:Component(parent), mWidgetIsDirty(false), mCamera(camera->_getCamera()), mDepth(0), mPanel(nullptr)
+	{
+		setName("GUIWidget");
+
+		construct(mCamera);
+	}
+
+	void CGUIWidget::construct(const CameraPtr& camera)
+	{
+		mLastFramePosition = SO()->getWorldPosition();
+		mLastFrameRotation = SO()->getWorldRotation();
+		mLastFrameScale = SO()->getWorldScale();
+
+		assert(camera != nullptr);
+
+		mOwnerTargetResizedConn = mCamera->getViewport()->getTarget()->onResized.connect(std::bind(&CGUIWidget::ownerTargetResized, this));
+
+		GUIManager::instance().registerWidget(this);
+
+		mPanel = GUIPanel::create();
+		mPanel->_changeParentWidget(this);
+		updateRootPanel();
+	}
+
+	CGUIWidget::~CGUIWidget()
+	{ }
+
+	void CGUIWidget::setDepth(UINT8 depth)
+	{
+		mDepth = depth; 
+		mWidgetIsDirty = true;
+
+		updateRootPanel();
+	}
+
+	void CGUIWidget::onDestroyed()
+	{
+		GUILayout::destroy(mPanel);
+		mPanel = nullptr;
+
+		if (mCamera != nullptr)
+		{
+			GUIManager::instance().unregisterWidget(this);
+
+			mOwnerTargetResizedConn.disconnect();
+		}
+
+		mElements.clear();
+		mDirtyContents.clear();
+	}
+
+	Viewport* CGUIWidget::getTarget() const
+	{
+		return mCamera->getViewport().get();
+	}
+
+	void CGUIWidget::update()
+	{
+		// If the widgets parent scene object moved, we need to mark it as dirty
+		// as the GUIManager batching relies on object positions, so it needs to be updated.
+		const float diffEpsilon = 0.0001f;
+
+		Vector3 position = SO()->getWorldPosition();
+		Quaternion rotation = SO()->getWorldRotation();
+		Vector3 scale = SO()->getWorldScale();
+
+		if(!mWidgetIsDirty)
+		{
+			Vector3 posDiff = mLastFramePosition - position;
+			if(Math::abs(posDiff.x) > diffEpsilon || Math::abs(posDiff.y) > diffEpsilon || Math::abs(posDiff.z) > diffEpsilon)
+			{
+				mWidgetIsDirty = true;
+			}
+			else
+			{
+				Quaternion rotDiff = mLastFrameRotation - rotation;
+				if(Math::abs(rotDiff.x) > diffEpsilon || Math::abs(rotDiff.y) > diffEpsilon || 
+					Math::abs(rotDiff.z) > diffEpsilon || Math::abs(rotDiff.w) > diffEpsilon)
+				{
+					mWidgetIsDirty = true;
+				}
+				else
+				{
+					Vector3 scaleDiff = mLastFrameScale - scale;
+					if(Math::abs(scaleDiff.x) > diffEpsilon || Math::abs(scaleDiff.y) > diffEpsilon || Math::abs(scaleDiff.z) > diffEpsilon)
+					{
+						mWidgetIsDirty = true;
+					}
+				}
+			}
+		}
+
+		mLastFramePosition = position;
+		mLastFrameRotation = rotation;
+		mLastFrameScale = scale;
+	}
+
+	void CGUIWidget::_updateLayout()
+	{
+		bs_frame_mark();
+
+		// Determine dirty contents and layouts
+		FrameStack<GUIElementBase*> todo;
+		todo.push(mPanel);
+
+		while (!todo.empty())
+		{
+			GUIElementBase* currentElem = todo.top();
+			todo.pop();
+
+			if (currentElem->_isDirty())
+			{
+				GUIElementBase* updateParent = currentElem->_getUpdateParent();
+				assert(updateParent != nullptr || currentElem == mPanel);
+
+				if (updateParent != nullptr)
+					_updateLayout(updateParent);
+				else // Must be root panel
+					_updateLayout(mPanel);
+			}
+			else
+			{
+				UINT32 numChildren = currentElem->_getNumChildren();
+				for (UINT32 i = 0; i < numChildren; i++)
+					todo.push(currentElem->_getChild(i));
+			}
+		}
+
+		bs_frame_clear();
+	}
+
+	void CGUIWidget::_updateLayout(GUIElementBase* elem)
+	{
+		GUIElementBase* parent = elem->_getParent();
+		bool isPanelOptimized = parent != nullptr && parent->_getType() == GUIElementBase::Type::Panel;
+
+		GUIElementBase* updateParent = nullptr;
+
+		if (isPanelOptimized)
+			updateParent = parent;
+		else
+			updateParent = elem;
+
+		// For GUIPanel we can do a an optimization and update only the element in question instead
+		// of all the children
+		if (isPanelOptimized)
+		{
+			GUIPanel* panel = static_cast<GUIPanel*>(updateParent);
+
+			GUIElementBase* dirtyElement = elem;
+			dirtyElement->_updateOptimalLayoutSizes();
+
+			LayoutSizeRange elementSizeRange = panel->_getElementSizeRange(dirtyElement);
+			Rect2I elementArea = panel->_getElementArea(panel->_getLayoutData().area, dirtyElement, elementSizeRange);
+
+			GUILayoutData childLayoutData = panel->_getLayoutData();
+			childLayoutData.area = elementArea;
+
+			panel->_updateChildLayout(dirtyElement, childLayoutData);
+		}
+		else
+		{
+			GUILayoutData childLayoutData = updateParent->_getLayoutData();
+			updateParent->_updateLayout(childLayoutData);
+		}
+		
+		// Mark dirty contents
+		bs_frame_mark();
+		{
+			FrameStack<GUIElementBase*> todo;
+			todo.push(elem);
+
+			while (!todo.empty())
+			{
+				GUIElementBase* currentElem = todo.top();
+				todo.pop();
+
+				if (currentElem->_getType() == GUIElementBase::Type::Element)
+					mDirtyContents.insert(static_cast<GUIElement*>(currentElem));
+
+				currentElem->_markAsClean();
+
+				UINT32 numChildren = currentElem->_getNumChildren();
+				for (UINT32 i = 0; i < numChildren; i++)
+					todo.push(currentElem->_getChild(i));
+			}
+		}
+		bs_frame_clear();
+	}
+
+	bool CGUIWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
+	{
+		return element->_mouseEvent(ev);
+	}
+
+	bool CGUIWidget::_textInputEvent(GUIElement* element, const GUITextInputEvent& ev)
+	{
+		return element->_textInputEvent(ev);
+	}
+
+	bool CGUIWidget::_commandEvent(GUIElement* element, const GUICommandEvent& ev)
+	{
+		return element->_commandEvent(ev);
+	}
+
+	bool CGUIWidget::_virtualButtonEvent(GUIElement* element, const GUIVirtualButtonEvent& ev)
+	{
+		return element->_virtualButtonEvent(ev);
+	}
+
+	void CGUIWidget::_registerElement(GUIElementBase* elem)
+	{
+		assert(elem != nullptr && !elem->_isDestroyed());
+
+		if (elem->_getType() == GUIElementBase::Type::Element)
+		{
+			mElements.push_back(static_cast<GUIElement*>(elem));
+			mWidgetIsDirty = true;
+		}
+	}
+
+	void CGUIWidget::_unregisterElement(GUIElementBase* elem)
+	{
+		assert(elem != nullptr);
+
+		auto iterFind = std::find(begin(mElements), end(mElements), elem);
+
+		if (iterFind != mElements.end())
+		{
+			mElements.erase(iterFind);
+			mWidgetIsDirty = true;
+		}
+
+		if (elem->_getType() == GUIElementBase::Type::Element)
+			mDirtyContents.erase(static_cast<GUIElement*>(elem));
+	}
+
+	void CGUIWidget::_markMeshDirty(GUIElementBase* elem)
+	{
+		mWidgetIsDirty = true;
+	}
+
+	void CGUIWidget::_markContentDirty(GUIElementBase* elem)
+	{
+		if (elem->_getType() == GUIElementBase::Type::Element)
+			mDirtyContents.insert(static_cast<GUIElement*>(elem));
+	}
+
+	void CGUIWidget::setSkin(const HGUISkin& skin)
+	{
+		mSkin = skin;
+
+		for(auto& element : mElements)
+			element->_refreshStyle();
+	}
+
+	const GUISkin& CGUIWidget::getSkin() const
+	{
+		static const HGUISkin DEFAULT_SKIN = GUISkin::create();
+
+		if(mSkin.isLoaded())
+			return *mSkin;
+		else
+			return *DEFAULT_SKIN;
+	}
+
+	bool CGUIWidget::isDirty(bool cleanIfDirty)
+	{
+		bool dirty = mWidgetIsDirty || mDirtyContents.size() > 0;
+
+		if(cleanIfDirty && dirty)
+		{
+			mWidgetIsDirty = false;
+
+			for (auto& dirtyElement : mDirtyContents)
+				dirtyElement->_updateRenderElements();
+
+			mDirtyContents.clear();
+			updateBounds();
+		}
+		
+		return dirty;
+	}
+
+	bool CGUIWidget::inBounds(const Vector2I& position) const
+	{
+		// Technically GUI widget bounds can be larger than the viewport, so make sure we clip to viewport first
+		if(!getTarget()->getArea().contains(position))
+			return false;
+
+		const Matrix4& worldTfrm = SO()->getWorldTfrm();
+		Vector3 vecPos((float)position.x, (float)position.y, 0.0f);
+		vecPos = worldTfrm.inverse().multiplyAffine(vecPos);
+
+		Vector2I localPos(Math::roundToInt(vecPos.x), Math::roundToInt(vecPos.y));
+		return mBounds.contains(localPos);
+	}
+
+	void CGUIWidget::updateBounds() const
+	{
+		if(mElements.size() > 0)
+			mBounds = mElements[0]->_getClippedBounds();
+
+		for(auto& elem : mElements)
+		{
+			Rect2I elemBounds = elem->_getClippedBounds();
+			mBounds.encapsulate(elemBounds);
+		}
+	}
+
+	void CGUIWidget::ownerTargetResized()
+	{
+		updateRootPanel();
+	}
+
+	void CGUIWidget::updateRootPanel()
+	{
+		UINT32 width = getTarget()->getWidth();
+		UINT32 height = getTarget()->getHeight();
+
+		GUILayoutData layoutData;
+		layoutData.area.width = width;
+		layoutData.area.height = height;
+		layoutData.clipRect = Rect2I(0, 0, width, height);
+		layoutData.setWidgetDepth(mDepth);
+
+		mPanel->setWidth(width);
+		mPanel->setHeight(height);
+
+		mPanel->_setLayoutData(layoutData);
+		mPanel->_markLayoutAsDirty();
+	}
+
+	void CGUIWidget::ownerWindowFocusChanged()
+	{
+
+	}
+
+	RTTITypeBase* CGUIWidget::getRTTIStatic()
+	{
+		return CGUIWidgetRTTI::instance();
+	}
+
+	RTTITypeBase* CGUIWidget::getRTTI() const
+	{
+		return CGUIWidget::getRTTIStatic();
+	}
 }

+ 0 - 23
BansheeEngine/Source/BsCOverlay.cpp

@@ -1,23 +0,0 @@
-#include "BsCOverlay.h"
-#include "BsOverlayManager.h"
-
-namespace BansheeEngine
-{
-	COverlay::COverlay(const HSceneObject& parent, Viewport* target)
-		:Component(parent), mRenderTarget(nullptr), mDepth(0)
-	{
-		setName("Overlay");
-
-		if(mRenderTarget != nullptr)
-			OverlayManager::instance().detachOverlay(mRenderTarget, this);
-
-		mRenderTarget = target;
-
-		OverlayManager::instance().attachOverlay(mRenderTarget, this);	
-	}
-
-	COverlay::~COverlay()
-	{
-		OverlayManager::instance().detachOverlayFromAll(this);
-	}
-}

+ 1 - 1
BansheeEngine/Source/BsGUIButton.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIButton.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"

+ 1 - 1
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIButtonBase.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"

+ 2 - 2
BansheeEngine/Source/BsGUIContextMenu.cpp

@@ -15,10 +15,10 @@ namespace BansheeEngine
 		close();
 	}
 
-	void GUIContextMenu::open(const Vector2I& position, GUIWidget& widget)
+	void GUIContextMenu::open(const Vector2I& position, CGUIWidget& widget)
 	{
 		DROP_DOWN_BOX_DESC desc;
-		desc.target = widget.getTarget();
+		desc.camera = widget.getCamera();
 		desc.skin = widget.getSkinResource();
 		desc.placement = DropDownAreaPlacement::aroundPosition(position);
 		desc.dropDownData = getDropDownData();

+ 1 - 1
BansheeEngine/Source/BsGUIDropDownContent.cpp

@@ -4,7 +4,7 @@
 #include "BsGUIButton.h"
 #include "BsGUILabel.h"
 #include "BsGUISpace.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIToggle.h"
 #include "BsGUISkin.h"
 #include "BsGUIMouseEvent.h"

+ 1 - 1
BansheeEngine/Source/BsGUIDropDownHitBox.cpp

@@ -1,7 +1,7 @@
 #include "BsGUIDropDownHitBox.h"
 #include "BsGUICommandEvent.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 
 namespace BansheeEngine

+ 7 - 4
BansheeEngine/Source/BsGUIDropDownMenu.cpp

@@ -14,6 +14,7 @@
 #include "BsSceneObject.h"
 #include "BsGUIDropDownHitBox.h"
 #include "BsGUIDropDownContent.h"
+#include "BsCamera.h"
 #include "BsDebug.h"
 
 using namespace std::placeholders;
@@ -53,7 +54,7 @@ namespace BansheeEngine
 	}
 
 	GUIDropDownMenu::GUIDropDownMenu(const HSceneObject& parent, const DROP_DOWN_BOX_DESC& desc, GUIDropDownType type)
-		:GUIWidget(parent, desc.target), mRootMenu(nullptr), mFrontHitBox(nullptr), mCaptureHitBox(nullptr), mBackHitBox(nullptr)
+		:CGUIWidget(parent, desc.camera), mRootMenu(nullptr), mFrontHitBox(nullptr), mCaptureHitBox(nullptr), mBackHitBox(nullptr)
 	{
 		String stylePrefix = "";
 		switch(type)
@@ -98,7 +99,9 @@ namespace BansheeEngine
 		mBackHitBox->_changeParentWidget(this);
 		mBackHitBox->_markLayoutAsDirty();
 
-		Rect2I targetBounds(0, 0, desc.target->getWidth(), desc.target->getHeight());
+		ViewportPtr viewport = desc.camera->getViewport();
+
+		Rect2I targetBounds(0, 0, viewport->getWidth(), viewport->getHeight());
 		Vector<Rect2I> captureBounds;
 		targetBounds.cut(desc.additionalBounds, captureBounds);
 
@@ -113,7 +116,7 @@ namespace BansheeEngine
 
 		mAdditionalCaptureBounds = desc.additionalBounds;
 
-		Rect2I availableBounds(desc.target->getX(), desc.target->getY(), desc.target->getWidth(), desc.target->getHeight());
+		Rect2I availableBounds(viewport->getX(), viewport->getY(), viewport->getWidth(), viewport->getHeight());
 		mRootMenu = bs_new<DropDownSubMenu>(this, nullptr, desc.placement, availableBounds, desc.dropDownData, type, 0);
 	}
 
@@ -129,7 +132,7 @@ namespace BansheeEngine
 		GUIElement::destroy(mCaptureHitBox);
 		bs_delete(mRootMenu);
 
-		GUIWidget::onDestroyed();
+		CGUIWidget::onDestroyed();
 	}
 
 	void GUIDropDownMenu::dropDownFocusLost()

+ 2 - 2
BansheeEngine/Source/BsGUIElement.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIElement.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUILayout.h"
 #include "BsGUIManager.h"
@@ -85,7 +85,7 @@ namespace BansheeEngine
 		updateClippedBounds();
 	}
 
-	void GUIElement::_changeParentWidget(GUIWidget* widget)
+	void GUIElement::_changeParentWidget(CGUIWidget* widget)
 	{
 		if (_isDestroyed())
 			return;

+ 2 - 2
BansheeEngine/Source/BsGUIElementBase.cpp

@@ -6,7 +6,7 @@
 #include "BsGUISpace.h"
 #include "BsGUIElement.h"
 #include "BsException.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUILayoutUtility.h"
 #include "BsProfilerCPU.h"
 
@@ -339,7 +339,7 @@ namespace BansheeEngine
 			BS_EXCEPT(InvalidParametersException, "Provided element is not a part of this element.");
 	}
 
-	void GUIElementBase::_changeParentWidget(GUIWidget* widget)
+	void GUIElementBase::_changeParentWidget(CGUIWidget* widget)
 	{
 		assert(!_isDestroyed());
 

+ 1 - 1
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -1,7 +1,7 @@
 #include "BsGUIInputBox.h"
 #include "BsGUIManager.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"

+ 1 - 1
BansheeEngine/Source/BsGUIInputCaret.cpp

@@ -54,7 +54,7 @@ namespace BansheeEngine
 		mCaretDesc.height = getCaretHeight();
 		mCaretDesc.texture = GUIManager::instance().getCaretTexture().getInternalPtr();
 
-		GUIWidget* widget = nullptr;
+		CGUIWidget* widget = nullptr;
 		if (mElement != nullptr)
 			widget = mElement->_getParentWidget();
 

+ 1 - 1
BansheeEngine/Source/BsGUIInputSelection.cpp

@@ -38,7 +38,7 @@ namespace BansheeEngine
 			}
 		}
 
-		const GUIWidget* widget = nullptr;
+		const CGUIWidget* widget = nullptr;
 		if (mElement != nullptr)
 			widget = mElement->_getParentWidget();
 

+ 1 - 1
BansheeEngine/Source/BsGUILabel.cpp

@@ -2,7 +2,7 @@
 #include "BsGUIElementStyle.h"
 #include "BsTextSprite.h"
 #include "BsGUISkin.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIHelper.h"
 #include "BsTextData.h"

+ 1 - 1
BansheeEngine/Source/BsGUILayoutUtility.cpp

@@ -3,7 +3,7 @@
 #include "BsGUILayout.h"
 #include "BsGUIElement.h"
 #include "BsGUIElementStyle.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsViewport.h"
 #include "BsGUIPanel.h"
 #include "BsProfilerCPU.h"

+ 3 - 3
BansheeEngine/Source/BsGUIListBox.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIListBox.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"
@@ -106,9 +106,9 @@ namespace BansheeEngine
 			i++;
 		}
 
-		GUIWidget* widget = _getParentWidget();
+		CGUIWidget* widget = _getParentWidget();
 
-		desc.target = widget->getTarget();
+		desc.camera = widget->getCamera();
 		desc.skin = widget->getSkinResource();
 		desc.placement = DropDownAreaPlacement::aroundBoundsHorz(_getLayoutData().area);
 		

+ 172 - 61
BansheeEngine/Source/BsGUIManager.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIManager.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIElement.h"
 #include "BsImageSprite.h"
 #include "BsSpriteTexture.h"
@@ -17,7 +17,6 @@
 #include "BsInput.h"
 #include "BsPass.h"
 #include "BsDebug.h"
-#include "BsDrawList.h"
 #include "BsGUIInputCaret.h"
 #include "BsGUIInputSelection.h"
 #include "BsGUIListBox.h"
@@ -33,6 +32,9 @@
 #include "BsVirtualInput.h"
 #include "BsCursor.h"
 #include "BsCoreThread.h"
+#include "BsRendererManager.h"
+#include "BsRenderer.h"
+#include "BsCamera.h"
 
 using namespace std::placeholders;
 
@@ -68,7 +70,7 @@ namespace BansheeEngine
 		:mSeparateMeshesByWidget(true), mActiveMouseButton(GUIMouseButton::Left),
 		mCaretBlinkInterval(0.5f), mCaretLastBlinkTime(0.0f), mCaretColor(1.0f, 0.6588f, 0.0f), mIsCaretOn(false),
 		mTextSelectionColor(1.0f, 0.6588f, 0.0f), mInputCaret(nullptr), mInputSelection(nullptr), mDragState(DragState::NoDrag),
-		mActiveCursor(CursorType::Arrow)
+		mActiveCursor(CursorType::Arrow), mCoreDirty(false)
 	{
 		mOnPointerMovedConn = gInput().onPointerMoved.connect(std::bind(&GUIManager::onPointerMoved, this, _1));
 		mOnPointerPressedConn = gInput().onPointerPressed.connect(std::bind(&GUIManager::onPointerPressed, this, _1));
@@ -99,6 +101,8 @@ namespace BansheeEngine
 		// Need to defer this call because I want to make sure all managers are initialized first
 		deferredCall(std::bind(&GUIManager::updateCaretTexture, this));
 		deferredCall(std::bind(&GUIManager::updateTextSelectionTexture, this));
+
+		mCore.store(bs_new<GUIManagerCore>(), std::memory_order_release);
 	}
 
 	GUIManager::~GUIManager()
@@ -134,10 +138,17 @@ namespace BansheeEngine
 		bs_delete(mInputCaret);
 		bs_delete(mInputSelection);
 
+		gCoreAccessor().queueCommand(std::bind(&GUIManager::destroyCore, this, mCore.load(std::memory_order_relaxed)));
+
 		assert(mCachedGUIData.size() == 0);
 	}
 
-	void GUIManager::registerWidget(GUIWidget* widget)
+	void GUIManager::destroyCore(GUIManagerCore* core)
+	{
+		bs_delete(core);
+	}
+
+	void GUIManager::registerWidget(CGUIWidget* widget)
 	{
 		mWidgets.push_back(WidgetInfo(widget));
 
@@ -153,7 +164,7 @@ namespace BansheeEngine
 		windowData.isDirty = true;
 	}
 
-	void GUIManager::unregisterWidget(GUIWidget* widget)
+	void GUIManager::unregisterWidget(CGUIWidget* widget)
 	{
 		{
 			auto findIter = std::find_if(begin(mWidgets), end(mWidgets), [=] (const WidgetInfo& x) { return x.widget == widget; } );
@@ -290,60 +301,63 @@ namespace BansheeEngine
 		}
 
 		PROFILE_CALL(updateMeshes(), "UpdateMeshes");
-	}
-
-	void GUIManager::render(ViewportPtr& target, DrawList& drawList) const
-	{
-		auto findIter = mCachedGUIData.find(target.get());
-
-		if(findIter == mCachedGUIData.end())
-			return;
 
-		const GUIRenderData& renderData = findIter->second;
-
-		// Render the meshes
-		if(mSeparateMeshesByWidget)
+		// Send potentially updated meshes to core for rendering
+		if (mCoreDirty)
 		{
-			// TODO - Possible optimization. I currently divide by width/height inside the shader, while it
-			// might be more optimal to just scale the mesh as the resolution changes?
-			float invViewportWidth = 1.0f / (target->getWidth() * 0.5f);
-			float invViewportHeight = 1.0f / (target->getHeight() * 0.5f);
+			UnorderedMap<SPtr<CameraCore>, Vector<GUICoreRenderData>> corePerCameraData;
 
-			UINT32 meshIdx = 0;
-			for(auto& mesh : renderData.cachedMeshes)
+			for (auto& viewportData : mCachedGUIData)
 			{
-				GUIMaterialInfo materialInfo = renderData.cachedMaterials[meshIdx];
-				GUIWidget* widget = renderData.cachedWidgetsPerMesh[meshIdx];
+				const GUIRenderData& renderData = viewportData.second;
 
-				if(materialInfo.material == nullptr || !materialInfo.material.isLoaded())
+				SPtr<Camera> camera;
+				for (auto& widget : viewportData.second.widgets)
 				{
-					meshIdx++;
-					continue;
+					camera = widget->getCamera();
+					if (camera != nullptr)
+						break;
 				}
 
-				if(mesh == nullptr)
-				{
-					meshIdx++;
+				if (camera == nullptr)
 					continue;
-				}
 
-				materialInfo.invViewportWidth.set(invViewportWidth);
-				materialInfo.invViewportHeight.set(invViewportHeight);
-				materialInfo.worldTransform.set(widget->SO()->getWorldTfrm());
+				auto insertedData = corePerCameraData.insert(std::make_pair(camera->getCore(), Vector<GUICoreRenderData>()));
+				Vector<GUICoreRenderData>& cameraData = insertedData.first->second;
+
+				UINT32 meshIdx = 0;
+				for (auto& mesh : renderData.cachedMeshes)
+				{
+					GUIMaterialInfo materialInfo = renderData.cachedMaterials[meshIdx];
+					CGUIWidget* widget = renderData.cachedWidgetsPerMesh[meshIdx];
+
+					if (materialInfo.material == nullptr || !materialInfo.material.isLoaded())
+					{
+						meshIdx++;
+						continue;
+					}
+
+					if (mesh == nullptr)
+					{
+						meshIdx++;
+						continue;
+					}
+
+					cameraData.push_back(GUICoreRenderData());
+					GUICoreRenderData& newEntry = cameraData.back();
 
-				drawList.add(materialInfo.material.getInternalPtr(), mesh, 0, Vector3::ZERO);
+					newEntry.material = materialInfo.material->getCore();
+					newEntry.mesh = mesh->getCore();
+					newEntry.worldTransform = widget->SO()->getWorldTfrm();
 
-				meshIdx++;
+					meshIdx++;
+				}
 			}
-		}
-		else
-		{
-			// TODO: I want to avoid separating meshes by widget in the future. On DX11 and GL I can set up a shader
-			// that accepts multiple world transforms (one for each widget). Then I can add some instance information to vertices
-			// and render elements using multiple different transforms with a single call.
-			// Separating meshes can then be used as a compatibility mode for DX9
 
-			BS_EXCEPT(NotImplementedException, "Not implemented");
+			GUIManagerCore* core = mCore.load(std::memory_order_relaxed);
+			gCoreAccessor().queueCommand(std::bind(&GUIManagerCore::updateData, core, corePerCameraData));
+
+			mCoreDirty = false;
 		}
 	}
 
@@ -368,6 +382,8 @@ namespace BansheeEngine
 			if(!isDirty)
 				continue;
 
+			mCoreDirty = true;
+
 			bs_frame_mark();
 			{
 				// Make a list of all GUI elements, sorted from farthest to nearest (highest depth to lowest)
@@ -416,8 +432,7 @@ namespace BansheeEngine
 
 					const GUIMaterialInfo& matInfo = guiElem->_getMaterial(renderElemIdx);
 
-					UINT64 materialId = matInfo.material->getInternalID(); // TODO - I group based on material ID. So if two widgets used exact copies of the same material
-					// this system won't detect it. Find a better way of determining material similarity?
+					UINT64 materialId = matInfo.material->getInternalID(); 
 
 					// If this is a new material, add a new list of groups
 					auto findIterMaterial = materialGroups.find(materialId);
@@ -1165,7 +1180,7 @@ namespace BansheeEngine
 					continue;
 				}
 
-				GUIWidget* widget = widgetInfo.widget;
+				CGUIWidget* widget = widgetInfo.widget;
 				if(widgetWindows[widgetIdx] == windowUnderPointer && widget->inBounds(windowToBridgedCoords(*widget, windowPos)))
 				{
 					const Vector<GUIElement*>& elements = widget->getElements();
@@ -1211,7 +1226,7 @@ namespace BansheeEngine
 		for (auto& elementInfo : mNewElementsUnderPointer)
 		{
 			GUIElement* element = elementInfo.element;
-			GUIWidget* widget = elementInfo.widget;
+			CGUIWidget* widget = elementInfo.widget;
 
 			if (elementInfo.receivedMouseOver)
 			{
@@ -1272,7 +1287,7 @@ namespace BansheeEngine
 		for(auto& elementInfo : mElementsUnderPointer)
 		{
 			GUIElement* element = elementInfo.element;
-			GUIWidget* widget = elementInfo.widget;
+			CGUIWidget* widget = elementInfo.widget;
 
 			auto iterFind = std::find_if(mNewElementsUnderPointer.begin(), mNewElementsUnderPointer.end(),
 				[=](const ElementInfoUnderPointer& x) { return x.element == element; });
@@ -1321,7 +1336,7 @@ namespace BansheeEngine
 	{
 		for(auto& widgetInfo : mWidgets)
 		{
-			GUIWidget* widget = widgetInfo.widget;
+			CGUIWidget* widget = widgetInfo.widget;
 			if(getWidgetWindow(*widget) == &win)
 				widget->ownerWindowFocusChanged();
 		}
@@ -1331,7 +1346,7 @@ namespace BansheeEngine
 	{
 		for(auto& widgetInfo : mWidgets)
 		{
-			GUIWidget* widget = widgetInfo.widget;
+			CGUIWidget* widget = widgetInfo.widget;
 			if(getWidgetWindow(*widget) == &win)
 				widget->ownerWindowFocusChanged();
 		}
@@ -1370,7 +1385,7 @@ namespace BansheeEngine
 		for(auto& elementInfo : mElementsUnderPointer)
 		{
 			GUIElement* element = elementInfo.element;
-			GUIWidget* widget = elementInfo.widget;
+			CGUIWidget* widget = elementInfo.widget;
 
 			if(widget->getTarget()->getTarget().get() != &win)
 			{
@@ -1451,7 +1466,7 @@ namespace BansheeEngine
 		BS_EXCEPT(InvalidParametersException, "Provided button is not a GUI supported mouse button.");
 	}
 
-	Vector2I GUIManager::getWidgetRelativePos(const GUIWidget& widget, const Vector2I& screenPos) const
+	Vector2I GUIManager::getWidgetRelativePos(const CGUIWidget& widget, const Vector2I& screenPos) const
 	{
 		const RenderWindow* window = getWidgetWindow(widget);
 		if(window == nullptr)
@@ -1468,7 +1483,7 @@ namespace BansheeEngine
 		return curLocalPos;
 	}
 
-	Vector2I GUIManager::windowToBridgedCoords(const GUIWidget& widget, const Vector2I& windowPos) const
+	Vector2I GUIManager::windowToBridgedCoords(const CGUIWidget& widget, const Vector2I& windowPos) const
 	{
 		// This cast might not be valid (the render target could be a window), but we only really need to cast
 		// so that mInputBridge map allows us to search through it - we don't access anything unless the target is bridged
@@ -1499,7 +1514,7 @@ namespace BansheeEngine
 		return windowPos;
 	}
 
-	const RenderWindow* GUIManager::getWidgetWindow(const GUIWidget& widget) const
+	const RenderWindow* GUIManager::getWidgetWindow(const CGUIWidget& widget) const
 	{
 		// This cast might not be valid (the render target could be a window), but we only really need to cast
 		// so that mInputBridge map allows us to search through it - we don't access anything unless the target is bridged
@@ -1509,7 +1524,7 @@ namespace BansheeEngine
 		auto iterFind = mInputBridge.find(renderTexture);
 		if(iterFind != mInputBridge.end())
 		{
-			GUIWidget* parentWidget = iterFind->second->_getParentWidget();
+			CGUIWidget* parentWidget = iterFind->second->_getParentWidget();
 			if(parentWidget != &widget)
 			{
 				return getWidgetWindow(*parentWidget);
@@ -1526,7 +1541,7 @@ namespace BansheeEngine
 		return nullptr;
 	}
 
-	bool GUIManager::sendMouseEvent(GUIWidget* widget, GUIElement* element, const GUIMouseEvent& event)
+	bool GUIManager::sendMouseEvent(CGUIWidget* widget, GUIElement* element, const GUIMouseEvent& event)
 	{
 		if (element->_isDestroyed())
 			return false;
@@ -1534,7 +1549,7 @@ namespace BansheeEngine
 		return widget->_mouseEvent(element, event);
 	}
 
-	bool GUIManager::sendTextInputEvent(GUIWidget* widget, GUIElement* element, const GUITextInputEvent& event)
+	bool GUIManager::sendTextInputEvent(CGUIWidget* widget, GUIElement* element, const GUITextInputEvent& event)
 	{
 		if (element->_isDestroyed())
 			return false;
@@ -1542,7 +1557,7 @@ namespace BansheeEngine
 		return widget->_textInputEvent(element, event);
 	}
 
-	bool GUIManager::sendCommandEvent(GUIWidget* widget, GUIElement* element, const GUICommandEvent& event)
+	bool GUIManager::sendCommandEvent(CGUIWidget* widget, GUIElement* element, const GUICommandEvent& event)
 	{
 		if (element->_isDestroyed())
 			return false;
@@ -1550,7 +1565,7 @@ namespace BansheeEngine
 		return widget->_commandEvent(element, event);
 	}
 
-	bool GUIManager::sendVirtualButtonEvent(GUIWidget* widget, GUIElement* element, const GUIVirtualButtonEvent& event)
+	bool GUIManager::sendVirtualButtonEvent(CGUIWidget* widget, GUIElement* element, const GUIVirtualButtonEvent& event)
 	{
 		if (element->_isDestroyed())
 			return false;
@@ -1562,4 +1577,100 @@ namespace BansheeEngine
 	{
 		return GUIManager::instance();
 	}
+
+	GUIManagerCore::~GUIManagerCore()
+	{
+		CoreRendererPtr activeRenderer = RendererManager::instance().getActive();
+		for (auto& cameraData : mPerCameraData)
+			activeRenderer->_unregisterRenderCallback(cameraData.first.get(), -30);
+	}
+
+	void GUIManagerCore::updateData(const UnorderedMap<SPtr<CameraCore>, Vector<GUIManager::GUICoreRenderData>>& newPerCameraData)
+	{
+		bs_frame_mark();
+
+		{
+			FrameSet<SPtr<CameraCore>> validCameras;
+
+			CoreRendererPtr activeRenderer = RendererManager::instance().getActive();
+			for (auto& newCameraData : newPerCameraData)
+			{
+				UINT32 idx = 0;
+				Vector<RenderData>* renderData = nullptr;
+				for (auto& oldCameraData : mPerCameraData)
+				{
+					if (newCameraData.first == oldCameraData.first)
+					{
+						renderData = &oldCameraData.second;
+						validCameras.insert(oldCameraData.first);
+						break;
+					}
+
+					idx++;
+				}
+
+				if (renderData == nullptr)
+				{
+					SPtr<CameraCore> camera = newCameraData.first;
+
+					auto insertedData = mPerCameraData.insert(std::make_pair(newCameraData.first, Vector<RenderData>()));
+					renderData = &insertedData.first->second;
+
+					activeRenderer->_registerRenderCallback(camera.get(), -30, std::bind(&GUIManagerCore::render, this, camera));
+					validCameras.insert(camera);
+				}
+
+				renderData->clear();
+
+				for (auto& entry : newCameraData.second)
+				{
+					renderData->push_back(RenderData());
+					RenderData& newEntry = renderData->back();
+
+					newEntry.mesh = entry.mesh;
+					newEntry.material = entry.material;
+					newEntry.worldTransform = entry.worldTransform;
+					newEntry.invViewportWidthParam = newEntry.material->getParamFloat("invViewportWidth");
+					newEntry.invViewportHeightParam = newEntry.material->getParamFloat("invViewportHeight");
+					newEntry.worldTransformParam = newEntry.material->getParamMat4("worldTransform");
+				}
+			}
+
+			FrameVector<SPtr<CameraCore>> cameraToRemove;
+			for (auto& cameraData : mPerCameraData)
+			{
+				auto iterFind = validCameras.find(cameraData.first);
+				if (iterFind == validCameras.end())
+					cameraToRemove.push_back(cameraData.first);
+			}
+
+			for (auto& camera : cameraToRemove)
+			{
+				activeRenderer->_unregisterRenderCallback(camera.get(), -30);
+				mPerCameraData.erase(camera);
+			}
+		}
+
+		bs_frame_clear();
+	}
+
+	void GUIManagerCore::render(const SPtr<CameraCore>& camera)
+	{
+		Vector<RenderData>& renderData = mPerCameraData[camera];
+
+		float invViewportWidth = 1.0f / (camera->getViewport()->getWidth() * 0.5f);
+		float invViewportHeight = 1.0f / (camera->getViewport()->getHeight() * 0.5f);
+		for (auto& entry : renderData)
+		{
+			entry.invViewportWidthParam.set(invViewportWidth);
+			entry.invViewportHeightParam.set(invViewportHeight);
+			entry.worldTransformParam.set(entry.worldTransform);
+
+			// TODO - I shouldn't be re-applying the entire material for each entry, instead just check which programs
+			// changed, and apply only those + the modified constant buffers and/or texture.
+
+			CoreRenderer::setPass(entry.material, 0);
+			CoreRenderer::draw(entry.mesh, entry.mesh->getProperties().getSubMesh(0));
+		}
+	}
 }

+ 1 - 1
BansheeEngine/Source/BsGUIProgressBar.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIProgressBar.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUITexture.h"
 #include "BsSpriteTexture.h"

+ 1 - 1
BansheeEngine/Source/BsGUIRenderTexture.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIRenderTexture.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUIManager.h"
 #include "BsRenderTexture.h"

+ 1 - 1
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -1,7 +1,7 @@
 #include "BsGUIScrollArea.h"
 #include "BsGUIElementStyle.h"
 #include "BsGUISkin.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUILayoutY.h"
 #include "BsGUISkin.h"

+ 1 - 1
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -2,7 +2,7 @@
 #include "BsSpriteTexture.h"
 #include "BsGUIElementStyle.h"
 #include "BsGUISkin.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"

+ 1 - 1
BansheeEngine/Source/BsGUISlider.cpp

@@ -1,5 +1,5 @@
 #include "BsGUISlider.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUISliderHandle.h"
 #include "BsGUITexture.h"

+ 1 - 1
BansheeEngine/Source/BsGUISliderHandle.cpp

@@ -1,6 +1,6 @@
 #include "BsGUISliderHandle.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"

+ 1 - 1
BansheeEngine/Source/BsGUITexture.cpp

@@ -1,6 +1,6 @@
 #include "BsGUITexture.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"

+ 1 - 1
BansheeEngine/Source/BsGUIToggle.cpp

@@ -1,6 +1,6 @@
 #include "BsGUIToggle.h"
 #include "BsImageSprite.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"

+ 2 - 2
BansheeEngine/Source/BsGUIViewport.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIViewport.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
@@ -92,7 +92,7 @@ namespace BansheeEngine
 		viewport->setArea(x, y, width, height);
 	}
 
-	void GUIViewport::_changeParentWidget(GUIWidget* widget)
+	void GUIViewport::_changeParentWidget(CGUIWidget* widget)
 	{
 		GUIElement::_changeParentWidget(widget);
 

+ 0 - 43
BansheeEngine/Source/BsOverlayManager.cpp

@@ -1,43 +0,0 @@
-#include "BsOverlayManager.h"
-#include "BsCCamera.h"
-#include "BsCOverlay.h"
-
-namespace BansheeEngine
-{
-	bool OverlayManager::OverlayComparer::operator() (const COverlay* const& a, const COverlay* const& b)
-	{
-		return a->getDepth() > b->getDepth();
-	}
-
-	void OverlayManager::render(ViewportPtr& target, DrawList& drawList) const
-	{
-		auto overlays = mOverlaysPerTarget.find(target.get());
-
-		if(overlays == mOverlaysPerTarget.end())
-			return;
-
-		// Render all overlays. They should already be sorted by depth, front most rendering last
-		for(auto& overlay : overlays->second)
-		{
-			overlay->render(drawList);
-		}
-	}
-
-	void OverlayManager::attachOverlay(const Viewport* target, const COverlay* overlay)
-	{
-		mOverlaysPerTarget[target].insert(overlay);
-	}
-
-	void OverlayManager::detachOverlay(const Viewport* target, const COverlay* overlay)
-	{
-		mOverlaysPerTarget[target].erase(overlay);
-	}
-
-	void OverlayManager::detachOverlayFromAll(const COverlay* overlay)
-	{
-		for(auto& overlays : mOverlaysPerTarget)
-		{
-			overlays.second.erase(overlay);
-		}
-	}
-}

+ 16 - 15
BansheeEngine/Source/BsProfilerOverlay.cpp

@@ -1,6 +1,6 @@
 #include "BsProfilerOverlay.h"
 #include "BsSceneObject.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUIPanel.h"
 #include "BsGUILayout.h"
 #include "BsGUILayoutX.h"
@@ -14,6 +14,7 @@
 #include "BsProfilingManager.h"
 #include "BsRenderTarget.h"
 #include "BsProfilerOverlayRTTI.h"
+#include "BsCamera.h"
 #include <BsHEString.h>
 
 namespace BansheeEngine
@@ -24,10 +25,10 @@ namespace BansheeEngine
 		UINT32 curIdx;
 		GUILayout& labelLayout;
 		GUILayout& contentLayout;
-		GUIWidget& widget;
+		CGUIWidget& widget;
 		Vector<ProfilerOverlayInternal::BasicRow>& rows;
 
-		BasicRowFiller(Vector<ProfilerOverlayInternal::BasicRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, GUIWidget& _widget)
+		BasicRowFiller(Vector<ProfilerOverlayInternal::BasicRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, CGUIWidget& _widget)
 			:rows(_rows), curIdx(0), labelLayout(_labelLayout), contentLayout(_contentLayout), widget(_widget)
 		{ }
 
@@ -125,10 +126,10 @@ namespace BansheeEngine
 		UINT32 curIdx;
 		GUILayout& labelLayout;
 		GUILayout& contentLayout;
-		GUIWidget& widget;
+		CGUIWidget& widget;
 		Vector<ProfilerOverlayInternal::PreciseRow>& rows;
 
-		PreciseRowFiller(Vector<ProfilerOverlayInternal::PreciseRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, GUIWidget& _widget)
+		PreciseRowFiller(Vector<ProfilerOverlayInternal::PreciseRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, CGUIWidget& _widget)
 			:rows(_rows), curIdx(0), labelLayout(_labelLayout), contentLayout(_contentLayout), widget(_widget)
 		{ }
 
@@ -225,10 +226,10 @@ namespace BansheeEngine
 	public:
 		UINT32 curIdx;
 		GUILayout& layout;
-		GUIWidget& widget;
+		CGUIWidget& widget;
 		Vector<ProfilerOverlayInternal::GPUSampleRow>& rows;
 
-		GPUSampleRowFiller(Vector<ProfilerOverlayInternal::GPUSampleRow>& _rows, GUILayout& _layout, GUIWidget& _widget)
+		GPUSampleRowFiller(Vector<ProfilerOverlayInternal::GPUSampleRow>& _rows, GUILayout& _layout, CGUIWidget& _widget)
 			:rows(_rows), curIdx(0), layout(_layout), widget(_widget)
 		{ }
 
@@ -286,7 +287,7 @@ namespace BansheeEngine
 
 	const UINT32 ProfilerOverlayInternal::MAX_DEPTH = 4;
 
-	ProfilerOverlay::ProfilerOverlay(const HSceneObject& parent, const ViewportPtr& target)
+	ProfilerOverlay::ProfilerOverlay(const HSceneObject& parent, const CameraPtr& target)
 		:Component(parent), mInternal(nullptr)
 	{
 		mInternal = bs_new<ProfilerOverlayInternal>(target);
@@ -297,7 +298,7 @@ namespace BansheeEngine
 		bs_delete(mInternal);
 	}
 
-	void ProfilerOverlay::setTarget(const ViewportPtr& target)
+	void ProfilerOverlay::setTarget(const CameraPtr& target)
 	{
 		mInternal->setTarget(target);
 	}
@@ -327,10 +328,10 @@ namespace BansheeEngine
 		return ProfilerOverlay::getRTTIStatic();
 	}
 
-	ProfilerOverlayInternal::ProfilerOverlayInternal(const ViewportPtr& target)
+	ProfilerOverlayInternal::ProfilerOverlayInternal(const CameraPtr& camera)
 		:mIsShown(true), mType(ProfilerOverlayType::CPUSamples)
 	{
-		setTarget(target);
+		setTarget(camera);
 	}
 
 	ProfilerOverlayInternal::~ProfilerOverlayInternal()
@@ -342,20 +343,20 @@ namespace BansheeEngine
 			mWidgetSO->destroy();
 	}
 
-	void ProfilerOverlayInternal::setTarget(const ViewportPtr& target)
+	void ProfilerOverlayInternal::setTarget(const CameraPtr& camera)
 	{
 		if(mTarget != nullptr)
 			mTargetResizedConn.disconnect();
 
-		mTarget = target;
+		mTarget = camera->getViewport();
 
-		mTargetResizedConn = target->getTarget()->onResized.connect(std::bind(&ProfilerOverlayInternal::targetResized, this));
+		mTargetResizedConn = mTarget->getTarget()->onResized.connect(std::bind(&ProfilerOverlayInternal::targetResized, this));
 
 		if(mWidgetSO)
 			mWidgetSO->destroy();
 
 		mWidgetSO = SceneObject::create("ProfilerOverlay", SOF_Internal | SOF_Persistent | SOF_DontSave);
-		mWidget = mWidgetSO->addComponent<GUIWidget>(mTarget.get());
+		mWidget = mWidgetSO->addComponent<CGUIWidget>(camera);
 		mWidget->setDepth(127);
 		mWidget->setSkin(BuiltinResources::instance().getGUISkin());
 

+ 2 - 2
ExampleProject/Main/Main.cpp

@@ -12,7 +12,7 @@
 #include "BsVirtualInput.h"
 #include "BsCCamera.h"
 #include "BsCRenderable.h"
-#include "BsGUIWidget.h"
+#include "BsCGUIWidget.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
 #include "BsGUISpace.h"
@@ -319,7 +319,7 @@ namespace BansheeEngine
 
 		// Add a GUIWidget, the top-level GUI component, parent to all GUI elements. GUI widgets
 		// require you to specify a viewport that they will output rendered GUI elements to.
-		HGUIWidget gui = guiSO->addComponent<GUIWidget>(guiCamera->getViewport().get());
+		HGUIWidget gui = guiSO->addComponent<CGUIWidget>(guiCamera);
 
 		// Depth allows you to control how is a GUI widget rendered in relation to other widgets
 		// Lower depth means the widget will be rendered in front of those with higher. In this case we just

+ 0 - 10
RenderBeast/Include/BsRenderBeast.h

@@ -157,16 +157,6 @@ namespace BansheeEngine
 		 */
 		void _notifyRenderableRemoved(RenderableCore* renderable) override;
 
-		/**
-		 * @brief	Adds a new set of objects to the cameras render queue.
-		 *
-		 * @param	proxy			Proxy of the render queues camera to add the objects to.
-		 * @param	renderQueue		Objects to add to the cameras queue.
-		 *
-		 * @note	Core thread only.
-		 */
-		void addToRenderQueue(const SPtr<CameraCore>& proxy, RenderQueuePtr renderQueue);
-
 		/**
 		 * @brief	Updates the render options on the core thread.
 		 *

+ 0 - 40
RenderBeast/Source/BsRenderBeast.cpp

@@ -14,14 +14,12 @@
 #include "BsViewport.h"
 #include "BsRenderTarget.h"
 #include "BsRenderQueue.h"
-#include "BsOverlayManager.h"
 #include "BsGUIManager.h"
 #include "BsCoreThread.h"
 #include "BsGpuParams.h"
 #include "BsProfilerCPU.h"
 #include "BsShader.h"
 #include "BsTechnique.h"
-#include "BsDrawList.h"
 #include "BsHardwareBufferManager.h"
 #include "BsGpuParamBlockBuffer.h"
 #include "BsShader.h"
@@ -267,38 +265,6 @@ namespace BansheeEngine
 
 	void RenderBeast::renderAll() 
 	{
-		// Populate direct draw lists
-		const Map<Camera*, SceneCameraData>& allCameras = gSceneManager().getAllCameras();
-		for (auto& cameraData : allCameras)
-		{
-			CameraPtr camera = cameraData.second.camera;
-			HSceneObject cameraSO = cameraData.second.sceneObject;
-
-			DrawListPtr drawList = bs_shared_ptr_new<DrawList>();
-			ViewportPtr viewport = camera->getViewport();
-
-			// Get GUI render operations
-			GUIManager::instance().render(viewport, *drawList);
-
-			// Get overlay render operations
-			OverlayManager::instance().render(viewport, *drawList);
-
-			RenderQueuePtr renderQueue = bs_shared_ptr_new<RenderQueue>();
-			const Vector<DrawOperation>& drawOps = drawList->getDrawOperations();
-
-			for (auto& drawOp : drawOps)
-			{
-				SPtr<MaterialCore> materialCore = drawOp.material->getCore();
-				SPtr<MeshCoreBase> meshCore = drawOp.mesh->getCore();
-				SubMesh subMesh = meshCore->getProperties().getSubMesh(drawOp.submeshIdx);
-
-				float distanceToCamera = (cameraSO->getPosition() - drawOp.worldPosition).length();
-				renderQueue->add(materialCore, meshCore, subMesh, distanceToCamera);
-			}
-
-			gCoreAccessor().queueCommand(std::bind(&RenderBeast::addToRenderQueue, this, camera->getCore(), renderQueue));
-		}
-
 		// Sync all dirty sim thread CoreObject data to core thread
 		CoreObjectManager::instance().syncToCore(gCoreAccessor());
 
@@ -311,12 +277,6 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&RenderBeast::renderAllCore, this, gTime().getTime()));
 	}
 
-	void RenderBeast::addToRenderQueue(const SPtr<CameraCore>& camera, RenderQueuePtr renderQueue)
-	{
-		RenderQueuePtr cameraRenderQueue = mCameraData[camera.get()].renderQueue;
-		cameraRenderQueue->add(*renderQueue);
-	}
-
 	void RenderBeast::syncRenderOptions(const RenderBeastOptions& options)
 	{
 		bool filteringChanged = mCoreOptions->filtering != options.filtering;

+ 1 - 1
SBansheeEditor/Include/BsScriptDropDownWindow.h

@@ -59,7 +59,7 @@ namespace BansheeEngine
 	class BS_SCR_BED_EXPORT ManagedDropDownWindow : public DropDownWindow
 	{
 	public:
-		ManagedDropDownWindow(const RenderWindowPtr& parent, Viewport* target,
+		ManagedDropDownWindow(const RenderWindowPtr& parent, const CameraPtr& camera,
 			const Vector2I& position, MonoObject* managedInstance, UINT32 width, UINT32 height);
 		~ManagedDropDownWindow();
 

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor