Explorar o código

Renamed RectF to Rect2, RectI to Rect2I
Added Rect3
Added Capsule
Added LineSegment3

Marko Pintera %!s(int64=11) %!d(string=hai) anos
pai
achega
0ca6b3905a
Modificáronse 100 ficheiros con 979 adicións e 368 borrados
  1. 1 1
      BansheeCore/Include/BsInput.h
  2. 5 5
      BansheeCore/Include/BsViewport.h
  3. 5 5
      BansheeCore/Include/Win32/BsPlatformImpl.h
  4. 1 1
      BansheeCore/Source/BsInput.cpp
  5. 2 2
      BansheeCore/Source/BsViewport.cpp
  6. 2 2
      BansheeCore/Source/Win32/BsPlatformImpl.cpp
  7. 1 1
      BansheeCore/Source/Win32/BsPlatformWndProc.cpp
  8. 1 1
      BansheeD3D11RenderSystem/Source/BsD3D11RenderSystem.cpp
  9. 1 1
      BansheeD3D11RenderSystem/Source/BsD3D11RenderUtility.cpp
  10. 1 1
      BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h
  11. 3 3
      BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp
  12. 5 5
      BansheeEditor/Include/BsDockManager.h
  13. 1 1
      BansheeEditor/Include/BsDockManagerLayout.h
  14. 2 2
      BansheeEditor/Include/BsEditorWidgetContainer.h
  15. 1 1
      BansheeEditor/Include/BsGUIComponentFoldout.h
  16. 1 1
      BansheeEditor/Include/BsGUIFieldBase.h
  17. 1 1
      BansheeEditor/Include/BsGUIFoldout.h
  18. 1 1
      BansheeEditor/Include/BsGUIResourceTreeView.h
  19. 3 3
      BansheeEditor/Include/BsGUITabbedTitleBar.h
  20. 1 1
      BansheeEditor/Include/BsGUITextField.h
  21. 5 5
      BansheeEditor/Include/BsGUITreeView.h
  22. 2 2
      BansheeEditor/Include/BsGizmoManager.h
  23. 7 7
      BansheeEditor/Source/BsDockManager.cpp
  24. 3 3
      BansheeEditor/Source/BsEditorWidgetContainer.cpp
  25. 2 2
      BansheeEditor/Source/BsGUIColor.cpp
  26. 2 2
      BansheeEditor/Source/BsGUIComponentFoldout.cpp
  27. 1 1
      BansheeEditor/Source/BsGUIFieldBase.cpp
  28. 3 3
      BansheeEditor/Source/BsGUIFloatField.cpp
  29. 3 3
      BansheeEditor/Source/BsGUIFoldout.cpp
  30. 3 3
      BansheeEditor/Source/BsGUIIntField.cpp
  31. 4 4
      BansheeEditor/Source/BsGUIMenuBar.cpp
  32. 1 1
      BansheeEditor/Source/BsGUIResourceTreeView.cpp
  33. 12 12
      BansheeEditor/Source/BsGUITabbedTitleBar.cpp
  34. 1 1
      BansheeEditor/Source/BsGUITextField.cpp
  35. 14 14
      BansheeEditor/Source/BsGUITreeView.cpp
  36. 8 8
      BansheeEditor/Source/BsGUIWindowFrameWidget.cpp
  37. 5 5
      BansheeEditor/Source/BsGizmoManager.cpp
  38. 1 1
      BansheeEditor/Source/BsMainEditorWindow.cpp
  39. 1 1
      BansheeEditor/Source/BsSceneEditorWidget.cpp
  40. 1 1
      BansheeEngine/Include/BsCursor.h
  41. 3 3
      BansheeEngine/Include/BsDrawHelper2D.h
  42. 4 4
      BansheeEngine/Include/BsGUIArea.h
  43. 8 8
      BansheeEngine/Include/BsGUIDropDownBox.h
  44. 3 3
      BansheeEngine/Include/BsGUIDropDownHitBox.h
  45. 11 11
      BansheeEngine/Include/BsGUIElement.h
  46. 4 4
      BansheeEngine/Include/BsGUIElementBase.h
  47. 4 4
      BansheeEngine/Include/BsGUIInputBox.h
  48. 1 1
      BansheeEngine/Include/BsGUIInputCaret.h
  49. 3 3
      BansheeEngine/Include/BsGUIInputSelection.h
  50. 2 2
      BansheeEngine/Include/BsGUIInputTool.h
  51. 2 2
      BansheeEngine/Include/BsGUILayoutUtility.h
  52. 2 2
      BansheeEngine/Include/BsGUILayoutX.h
  53. 2 2
      BansheeEngine/Include/BsGUILayoutY.h
  54. 1 1
      BansheeEngine/Include/BsGUIScrollArea.h
  55. 3 3
      BansheeEngine/Include/BsGUIWidget.h
  56. 5 5
      BansheeEngine/Include/BsSprite.h
  57. 1 1
      BansheeEngine/Source/BsCursor.cpp
  58. 6 6
      BansheeEngine/Source/BsDrawHelper2D.cpp
  59. 1 1
      BansheeEngine/Source/BsDrawHelper3D.cpp
  60. 1 1
      BansheeEngine/Source/BsDrawHelperTemplate.cpp
  61. 3 3
      BansheeEngine/Source/BsGUIArea.cpp
  62. 7 7
      BansheeEngine/Source/BsGUIButtonBase.cpp
  63. 9 9
      BansheeEngine/Source/BsGUIDropDownBox.cpp
  64. 11 11
      BansheeEngine/Source/BsGUIElement.cpp
  65. 3 3
      BansheeEngine/Source/BsGUIElementBase.cpp
  66. 1 1
      BansheeEngine/Source/BsGUIElementContainer.cpp
  67. 12 12
      BansheeEngine/Source/BsGUIInputBox.cpp
  68. 5 5
      BansheeEngine/Source/BsGUIInputCaret.cpp
  69. 14 14
      BansheeEngine/Source/BsGUIInputSelection.cpp
  70. 5 5
      BansheeEngine/Source/BsGUIInputTool.cpp
  71. 5 5
      BansheeEngine/Source/BsGUILayoutUtility.cpp
  72. 8 8
      BansheeEngine/Source/BsGUILayoutX.cpp
  73. 8 8
      BansheeEngine/Source/BsGUILayoutY.cpp
  74. 5 5
      BansheeEngine/Source/BsGUIManager.cpp
  75. 7 7
      BansheeEngine/Source/BsGUIScrollArea.cpp
  76. 1 1
      BansheeEngine/Source/BsGUIScrollBar.cpp
  77. 3 3
      BansheeEngine/Source/BsGUIScrollBarHandle.cpp
  78. 1 1
      BansheeEngine/Source/BsGUIViewport.cpp
  79. 1 1
      BansheeEngine/Source/BsGUIWidget.cpp
  80. 6 6
      BansheeEngine/Source/BsSprite.cpp
  81. 1 1
      BansheeGLRenderSystem/Include/BsGLRenderSystem.h
  82. 3 3
      BansheeGLRenderSystem/Source/BsGLRenderSystem.cpp
  83. 10 4
      BansheeUtility/BansheeUtility.vcxproj
  84. 30 12
      BansheeUtility/BansheeUtility.vcxproj.filters
  85. 41 0
      BansheeUtility/Include/BsCapsule.h
  86. 2 2
      BansheeUtility/Include/BsFwdDeclUtil.h
  87. 40 0
      BansheeUtility/Include/BsLineSegment3.h
  88. 9 9
      BansheeUtility/Include/BsRect2.h
  89. 9 9
      BansheeUtility/Include/BsRect2I.h
  90. 46 0
      BansheeUtility/Include/BsRect3.h
  91. 1 0
      BansheeUtility/Include/BsStdHeaders.h
  92. 16 0
      BansheeUtility/Include/BsVector3.h
  93. 211 0
      BansheeUtility/Source/BsCapsule.cpp
  94. 79 0
      BansheeUtility/Source/BsLineSegment3.cpp
  95. 9 9
      BansheeUtility/Source/BsRect2.cpp
  96. 9 9
      BansheeUtility/Source/BsRect2I.cpp
  97. 153 0
      BansheeUtility/Source/BsRect3.cpp
  98. 3 3
      MBansheeEngine/GUI/GUILayoutUtility.cs
  99. 1 1
      MBansheeEngine/MBansheeEngine.csproj
  100. 6 6
      MBansheeEngine/Math/Rect2I.cs

+ 1 - 1
BansheeCore/Include/BsInput.h

@@ -2,7 +2,7 @@
 
 #include "BsCorePrerequisites.h"
 #include "BsModule.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsOSInputHandler.h"
 #include "BsRawInputHandler.h"
 #include "BsInputFwd.h"

+ 5 - 5
BansheeCore/Include/BsViewport.h

@@ -2,8 +2,8 @@
 
 #include "BsCorePrerequisites.h"
 #include "BsColor.h"
-#include "BsRectI.h"
-#include "BsRectF.h"
+#include "BsRect2I.h"
+#include "BsRect2.h"
 #include "BsEvent.h"
 
 namespace BansheeEngine 
@@ -98,14 +98,14 @@ namespace BansheeEngine
 		 *
 		 * @note	Sim thread only.
 		 */
-		RectI getArea() const;
+		Rect2I getArea() const;
 
 		/**
 		 * @brief	Returns the normalized area of the viewport.
 		 *
 		 * @note	Viewport coordinates are normalized in [0, 1] range.
 		 */
-		RectF getNormArea() const { return mNormArea; }
+		Rect2 getNormArea() const { return mNormArea; }
 
 		/**
 		 * @brief	Activates or deactivates clears for color, depth or stencil buffers.
@@ -172,7 +172,7 @@ namespace BansheeEngine
 
         RenderTargetPtr mTarget;
 
-		RectF mNormArea;
+		Rect2 mNormArea;
 
 		bool mRequiresColorClear;
 		bool mRequiresDepthClear;

+ 5 - 5
BansheeCore/Include/Win32/BsPlatformImpl.h

@@ -3,7 +3,7 @@
 #include "BsCorePrerequisites.h"
 #include "BsInputFwd.h"
 #include "BsVector2I.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsEvent.h"
 
 namespace BansheeEngine
@@ -40,7 +40,7 @@ namespace BansheeEngine
 	struct BS_CORE_EXPORT NonClientResizeArea
 	{
 		NonClientAreaBorderType type;
-		RectI area;
+		Rect2I area;
 	};
 
 	/**
@@ -49,7 +49,7 @@ namespace BansheeEngine
 	struct BS_CORE_EXPORT WindowNonClientAreaData
 	{
 		Vector<NonClientResizeArea> resizeAreas;
-		Vector<RectI> moveAreas;
+		Vector<Rect2I> moveAreas;
 	};
 
 	/**
@@ -105,7 +105,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Thread safe.
 		 */
-		static void clipCursorToRect(const RectI& screenRect);
+		static void clipCursorToRect(const Rect2I& screenRect);
 		/**
 		 * @brief	Disables cursor clipping.
 		 * 			
@@ -152,7 +152,7 @@ namespace BansheeEngine
 		 * 			All provided areas are relative to the specified window.
 		 * 			Mostly useful for frameless windows that don't have typical caption bar.
 		 */
-		static void setCaptionNonClientAreas(const RenderWindow& window, const Vector<RectI>& nonClientAreas);
+		static void setCaptionNonClientAreas(const RenderWindow& window, const Vector<Rect2I>& nonClientAreas);
 
 		/**
 		 * @brief	Sets custom non client areas for the specified window. Using custom client

+ 1 - 1
BansheeCore/Source/BsInput.cpp

@@ -1,7 +1,7 @@
 #include "BsInput.h"
 #include "BsTime.h"
 #include "BsMath.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsDebug.h"
 #include "BsRenderWindowManager.h"
 

+ 2 - 2
BansheeCore/Source/BsViewport.cpp

@@ -37,12 +37,12 @@ namespace BansheeEngine
 		markCoreDirty();
     }
 
-	RectI Viewport::getArea() const
+	Rect2I Viewport::getArea() const
 	{
 		float width = (float)mTarget->getProperties().getWidth();
 		float height = (float)mTarget->getProperties().getHeight();
 		
-		RectI area;
+		Rect2I area;
 		area.x = (int)(mNormArea.x * width);
 		area.y = (int)(mNormArea.y * height);
 		area.width = (int)(mNormArea.width * width);

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

@@ -165,7 +165,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void Platform::clipCursorToRect(const RectI& screenRect)
+	void Platform::clipCursorToRect(const Rect2I& screenRect)
 	{
 		RECT clipWindowRect;
 		clipWindowRect.left = screenRect.x;
@@ -259,7 +259,7 @@ namespace BansheeEngine
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
-	void Platform::setCaptionNonClientAreas(const RenderWindow& window, const Vector<RectI>& nonClientAreas)
+	void Platform::setCaptionNonClientAreas(const RenderWindow& window, const Vector<Rect2I>& nonClientAreas)
 	{
 		BS_LOCK_MUTEX(mSync);
 

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

@@ -214,7 +214,7 @@ namespace BansheeEngine
 						return translateNonClientAreaType(area.type);
 				}
 
-				Vector<RectI>& moveAreasPerWindow = iterFind->second.moveAreas;
+				Vector<Rect2I>& moveAreasPerWindow = iterFind->second.moveAreas;
 				for(auto area : moveAreasPerWindow)
 				{
 					if(area.contains(mousePosInt))

+ 1 - 1
BansheeD3D11RenderSystem/Source/BsD3D11RenderSystem.cpp

@@ -621,7 +621,7 @@ namespace BansheeEngine
 
 		const RenderTargetProperties& rtProps = mActiveRenderTarget->getCore()->getProperties();
 
-		RectI clearArea((int)mViewport.TopLeftX, (int)mViewport.TopLeftY, (int)mViewport.Width, (int)mViewport.Height);
+		Rect2I clearArea((int)mViewport.TopLeftX, (int)mViewport.TopLeftY, (int)mViewport.Width, (int)mViewport.Height);
 
 		bool clearEntireTarget = clearArea.width == 0 || clearArea.height == 0;
 		clearEntireTarget |= (clearArea.x == 0 && clearArea.y == 0 && clearArea.width == rtProps.getWidth() && clearArea.height == rtProps.getHeight());

+ 1 - 1
BansheeD3D11RenderSystem/Source/BsD3D11RenderUtility.cpp

@@ -2,7 +2,7 @@
 #include "BsD3D11Device.h"
 #include "BsVector3.h"
 #include "BsColor.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsD3D11BlendState.h"
 #include "BsD3D11RasterizerState.h"
 #include "BsD3D11DepthStencilState.h"

+ 1 - 1
BansheeD3D9RenderSystem/Include/BsD3D9RenderSystem.h

@@ -518,7 +518,7 @@ namespace BansheeEngine
 		 * @param	stencil			(optional) The value to initialize the stencil buffer with, if enabled.
 		 * @param	clearArea		(optional) Area in pixels to clear.
 		 */
-		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const RectI& clearArea = RectI::EMPTY);
+		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const Rect2I& clearArea = Rect2I::EMPTY);
 
 		/**
 		 * @brief	Triggered when device has been lost.

+ 3 - 3
BansheeD3D9RenderSystem/Source/BsD3D9RenderSystem.cpp

@@ -1330,19 +1330,19 @@ namespace BansheeEngine
 			return;
 
 		const RenderTargetProperties& rtProps = mActiveRenderTarget->getCore()->getProperties();
-		RectI clearRect(0, 0, rtProps.getWidth(), rtProps.getHeight());
+		Rect2I clearRect(0, 0, rtProps.getWidth(), rtProps.getHeight());
 
 		clearArea(buffers, color, depth, stencil, clearRect);
 	}
 
 	void D3D9RenderSystem::clearViewport(UINT32 buffers, const Color& color, float depth, UINT16 stencil)
 	{
-		RectI clearRect(mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight);
+		Rect2I clearRect(mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight);
 
 		clearArea(buffers, color, depth, stencil, clearRect);
 	}
 
-	void D3D9RenderSystem::clearArea(UINT32 buffers, const Color& color, float depth, UINT16 stencil, const RectI& clearRect)
+	void D3D9RenderSystem::clearArea(UINT32 buffers, const Color& color, float depth, UINT16 stencil, const Rect2I& clearRect)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 

+ 5 - 5
BansheeEditor/Include/BsDockManager.h

@@ -2,7 +2,7 @@
 
 #include "BsEditorPrerequisites.h"
 #include "BsGUIElementContainer.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 
 namespace BansheeEngine
 {
@@ -47,7 +47,7 @@ namespace BansheeEngine
 			 */
 			DockContainer* findAtPos(const Vector2I& pos);
 
-			RectI getContentBounds() const;
+			Rect2I getContentBounds() const;
 
 			bool mIsLeaf;
 			DockContainer* mChildren[2];
@@ -55,7 +55,7 @@ namespace BansheeEngine
 			DockManager* mManager;
 			EditorWidgetContainer* mWidgets;
 			GUIDockSlider* mSlider;
-			RectI mArea;
+			Rect2I mArea;
 			float mSplitPosition;
 			bool mIsHorizontal;
 
@@ -108,11 +108,11 @@ namespace BansheeEngine
 
 		RenderWindow* mParentWindow;
 		DockContainer mRootContainer;
-		RectI mArea;
+		Rect2I mArea;
 
 		HMesh mDropOverlayMesh;
 		HMaterial mDropOverlayMat;
-		RectI mLastOverlayBounds;
+		Rect2I mLastOverlayBounds;
 
 		DockContainer* mMouseOverContainer;
 		DockLocation mHighlightedDropLoc;

+ 1 - 1
BansheeEditor/Include/BsDockManagerLayout.h

@@ -2,7 +2,7 @@
 
 #include "BsEditorPrerequisites.h"
 #include "BsIReflectable.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 
 namespace BansheeEngine
 {

+ 2 - 2
BansheeEditor/Include/BsEditorWidgetContainer.h

@@ -24,8 +24,8 @@ namespace BansheeEngine
 		GUIWidget& getParentWidget() const { return *mParent; }
 		EditorWindow* getParentWindow() const { return mParentWindow; }
 
-		RectI getContentBounds() const;
-		Vector<RectI> getDraggableAreas() const;
+		Rect2I getContentBounds() const;
+		Vector<Rect2I> getDraggableAreas() const;
 
 		void _update();
 

+ 1 - 1
BansheeEditor/Include/BsGUIComponentFoldout.h

@@ -27,7 +27,7 @@ namespace BansheeEngine
 		void setContent(const GUIContent& content);
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		Vector2I _getOptimalSize() const;
 

+ 1 - 1
BansheeEditor/Include/BsGUIFieldBase.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 			const String& labelStyle, const GUILayoutOptions& layoutOptions, bool withLabel);
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		virtual Vector2I _getOptimalSize() const;
 

+ 1 - 1
BansheeEditor/Include/BsGUIFoldout.h

@@ -28,7 +28,7 @@ namespace BansheeEngine
 		void setContent(const GUIContent& content);
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		Vector2I _getOptimalSize() const;
 

+ 1 - 1
BansheeEditor/Include/BsGUIResourceTreeView.h

@@ -69,7 +69,7 @@ namespace BansheeEngine
 			const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUILayoutOptions& layoutOptions);
 
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		virtual TreeElement& getRootElement() { return mRootElement; }
 		virtual const TreeElement& getRootElementConst() const { return mRootElement; }

+ 3 - 3
BansheeEditor/Include/BsGUITabbedTitleBar.h

@@ -2,7 +2,7 @@
 
 #include "BsEditorPrerequisites.h"
 #include "BsGUIElementContainer.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsEvent.h"
 
 namespace BansheeEngine
@@ -27,7 +27,7 @@ namespace BansheeEngine
 		UINT32 getTabIdx(UINT32 position) const;
 		UINT32 getNumTabs() const { return (UINT32)mTabButtons.size(); }
 
-		Vector<RectI> calcDraggableAreas(INT32 x, INT32 y, UINT32 width, UINT32 height) const;
+		Vector<Rect2I> calcDraggableAreas(INT32 x, INT32 y, UINT32 width, UINT32 height) const;
 
 		Event<void(UINT32)> onTabActivated;
 		Event<void(UINT32)> onTabClosed;
@@ -40,7 +40,7 @@ namespace BansheeEngine
 		void updateClippedBounds();
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 	protected:
 		static const UINT32 TAB_SPACING;
 		static const UINT32 OPTION_BTN_SPACING;

+ 1 - 1
BansheeEditor/Include/BsGUITextField.h

@@ -46,7 +46,7 @@ namespace BansheeEngine
 			const String& style, const GUILayoutOptions& layoutOptions, bool withLabel);
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		Vector2I _getOptimalSize() const;
 

+ 5 - 5
BansheeEditor/Include/BsGUITreeView.h

@@ -42,7 +42,7 @@ namespace BansheeEngine
 
 		struct InteractableElement
 		{
-			InteractableElement(TreeElement* parent, UINT32 index, const RectI& bounds)
+			InteractableElement(TreeElement* parent, UINT32 index, const Rect2I& bounds)
 				:parent(parent), index(index), bounds(bounds)
 			{ }
 
@@ -51,7 +51,7 @@ namespace BansheeEngine
 
 			TreeElement* parent;
 			UINT32 index;
-			RectI bounds;
+			Rect2I bounds;
 		};
 
 		struct SelectedElement
@@ -76,7 +76,7 @@ namespace BansheeEngine
 		void updateClippedBounds();
 
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 	protected:
 		static const UINT32 ELEMENT_EXTRA_SPACING;
 		static const UINT32 INDENT_SIZE;
@@ -110,8 +110,8 @@ namespace BansheeEngine
 		GUITexture* mDragHighlight;
 		GUITexture* mDragSepHighlight;
 
-		RectI mTopScrollBounds;
-		RectI mBottomScrollBounds;
+		Rect2I mTopScrollBounds;
+		Rect2I mBottomScrollBounds;
 		ScrollState mScrollState;
 		float mLastScrollTime;
 

+ 2 - 2
BansheeEditor/Include/BsGizmoManager.h

@@ -143,10 +143,10 @@ namespace BansheeEngine
 		void coreRender(const CameraProxy& camera);
 		void coreRenderSolidGizmos(Matrix4 viewMatrix, Matrix4 projMatrix, MeshProxyPtr mesh);
 		void coreRenderWireGizmos(Matrix4 viewMatrix, Matrix4 projMatrix, MeshProxyPtr mesh);
-		void coreRenderIconGizmos(RectI screenArea, MeshProxyPtr mesh, IconRenderDataVecPtr renderData);
+		void coreRenderIconGizmos(Rect2I screenArea, MeshProxyPtr mesh, IconRenderDataVecPtr renderData);
 
 		void coreRenderGizmosForPicking(Matrix4 viewMatrix, Matrix4 projMatrix, MeshProxyPtr mesh);
-		void coreRenderIconGizmosForPicking(RectI screenArea, MeshProxyPtr mesh, IconRenderDataVecPtr renderData);
+		void coreRenderIconGizmosForPicking(Rect2I screenArea, MeshProxyPtr mesh, IconRenderDataVecPtr renderData);
 
 		void coreUpdateData(const MeshProxyPtr& solidMeshProxy, const MeshProxyPtr& wireMeshProxy,
 			const MeshProxyPtr& iconMeshProxy, const IconRenderDataVecPtr& iconRenderData);

+ 7 - 7
BansheeEditor/Source/BsDockManager.cpp

@@ -96,7 +96,7 @@ namespace BansheeEngine
 	{
 		if(!mIsLeaf && mChildren[0] != nullptr && mChildren[1] != nullptr)
 		{
-			RectI clipRect = mArea;
+			Rect2I clipRect = mArea;
 			if(mIsHorizontal)
 			{
 				UINT32 remainingSize = (UINT32)std::max(0, (INT32)mArea.height - (INT32)SLIDER_SIZE);
@@ -110,7 +110,7 @@ namespace BansheeEngine
 				mSlider->_setWidth(mArea.width);
 				mSlider->_setHeight(SLIDER_SIZE);
 
-				RectI elemClipRect(clipRect.x - mArea.x, clipRect.y - mArea.y, clipRect.width, clipRect.height);
+				Rect2I elemClipRect(clipRect.x - mArea.x, clipRect.y - mArea.y, clipRect.width, clipRect.height);
 				mSlider->_setClipRect(elemClipRect);
 			}
 			else
@@ -126,7 +126,7 @@ namespace BansheeEngine
 				mSlider->_setWidth(SLIDER_SIZE);
 				mSlider->_setHeight(mArea.height);
 
-				RectI elemClipRect(clipRect.x - mArea.x, clipRect.y - mArea.y, clipRect.width, clipRect.height);
+				Rect2I elemClipRect(clipRect.x - mArea.x, clipRect.y - mArea.y, clipRect.width, clipRect.height);
 				mSlider->_setClipRect(elemClipRect);
 			}
 		}
@@ -382,7 +382,7 @@ namespace BansheeEngine
 		return nullptr;
 	}
 
-	RectI DockManager::DockContainer::getContentBounds() const
+	Rect2I DockManager::DockContainer::getContentBounds() const
 	{
 		if(!mIsLeaf || mWidgets == nullptr)
 			return mArea;
@@ -532,7 +532,7 @@ namespace BansheeEngine
 	void DockManager::setArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
 	{
 		mRootContainer.setArea(x, y, width, height);
-		mArea = RectI(x, y, width, height);
+		mArea = Rect2I(x, y, width, height);
 
 		updateDropOverlay(x, y, width, height);
 	}
@@ -933,7 +933,7 @@ namespace BansheeEngine
 			if(mMouseOverContainer == nullptr)
 				mMouseOverContainer = &mRootContainer;
 
-			RectI overlayBounds;
+			Rect2I overlayBounds;
 			
 			if(mMouseOverContainer != nullptr)
 				overlayBounds = mMouseOverContainer->getContentBounds();
@@ -991,7 +991,7 @@ namespace BansheeEngine
 
 			if(mouseOverContainer == nullptr)
 			{
-				RectI overlayBounds = mRootContainer.getContentBounds();
+				Rect2I overlayBounds = mRootContainer.getContentBounds();
 				if(overlayBounds.contains(windowPos))
 				{
 					insert(nullptr, draggedWidget, DockLocation::None);

+ 3 - 3
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -247,12 +247,12 @@ namespace BansheeEngine
 		}
 	}
 
-	RectI EditorWidgetContainer::getContentBounds() const
+	Rect2I EditorWidgetContainer::getContentBounds() const
 	{
-		return RectI(mX, mY + TitleBarHeight, mWidth, (UINT32)std::max(0, (INT32)mHeight - (INT32)TitleBarHeight));
+		return Rect2I(mX, mY + TitleBarHeight, mWidth, (UINT32)std::max(0, (INT32)mHeight - (INT32)TitleBarHeight));
 	}
 
-	Vector<RectI> EditorWidgetContainer::getDraggableAreas() const
+	Vector<Rect2I> EditorWidgetContainer::getDraggableAreas() const
 	{
 		return mTitleBar->calcDraggableAreas(mX, mY, mWidth, TitleBarHeight);
 	}

+ 2 - 2
BansheeEditor/Source/BsGUIColor.cpp

@@ -105,7 +105,7 @@ namespace BansheeEngine
 
 	void GUIColor::updateClippedBounds()
 	{
-		mClippedBounds = RectI(0, 0, mWidth, mHeight);
+		mClippedBounds = Rect2I(0, 0, mWidth, mHeight);
 
 		if(mClipRect.width > 0 && mClipRect.height > 0)
 			mClippedBounds.clip(mClipRect);
@@ -137,7 +137,7 @@ namespace BansheeEngine
 			UINT32 xOffset = (UINT32)(mWidth * ALPHA_SPLIT_POSITION);
 			alphaOffset.x += xOffset;
 
-			RectI alphaClipRect = mClipRect;
+			Rect2I alphaClipRect = mClipRect;
 			alphaClipRect.x -= xOffset;
 
 			mAlphaSprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, 

+ 2 - 2
BansheeEditor/Source/BsGUIComponentFoldout.cpp

@@ -80,7 +80,7 @@ namespace BansheeEngine
 	}
 
 	void GUIComponentFoldout::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		UINT32 toggleOffset = 0;
 
@@ -95,7 +95,7 @@ namespace BansheeEngine
 			mToggle->_setAreaDepth(areaDepth);
 			mToggle->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mToggle->_setClipRect(elemClipRect);
 
 			toggleOffset = optimalSize.x;

+ 1 - 1
BansheeEditor/Source/BsGUIFieldBase.cpp

@@ -23,7 +23,7 @@ namespace BansheeEngine
 	}
 
 	void GUIFieldBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
 	}

+ 3 - 3
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -44,7 +44,7 @@ namespace BansheeEngine
 
 	bool GUIFloatField::_hasCustomCursor(const Vector2I position, CursorType& type) const
 	{
-		RectI draggableArea;
+		Rect2I draggableArea;
 
 		if(mLabel != nullptr)
 			draggableArea = mLabel->_getCachedBounds();
@@ -62,7 +62,7 @@ namespace BansheeEngine
 	{
 		GUIElementContainer::mouseEvent(event);
 
-		RectI draggableArea;
+		Rect2I draggableArea;
 
 		if(mLabel != nullptr)
 			draggableArea = mLabel->_getCachedBounds();
@@ -137,7 +137,7 @@ namespace BansheeEngine
 	void GUIFloatField::updateClippedBounds()
 	{
 		Vector2I offset = _getOffset();
-		mClippedBounds = RectI(offset.x, offset.y, _getWidth(), _getHeight());
+		mClippedBounds = Rect2I(offset.x, offset.y, _getWidth(), _getHeight());
 	}
 
 	const String& GUIFloatField::getGUITypeName()

+ 3 - 3
BansheeEditor/Source/BsGUIFoldout.cpp

@@ -82,7 +82,7 @@ namespace BansheeEngine
 	}
 
 	void GUIFoldout::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		UINT32 toggleOffset = 0;
 
@@ -97,7 +97,7 @@ namespace BansheeEngine
 			mToggle->_setAreaDepth(areaDepth);
 			mToggle->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mToggle->_setClipRect(elemClipRect);
 
 			toggleOffset = optimalSize.x;
@@ -114,7 +114,7 @@ namespace BansheeEngine
 			mLabel->_setAreaDepth(areaDepth);
 			mLabel->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mLabel->_setClipRect(elemClipRect);
 		}
 	}

+ 3 - 3
BansheeEditor/Source/BsGUIIntField.cpp

@@ -46,7 +46,7 @@ namespace BansheeEngine
 
 	bool GUIIntField::_hasCustomCursor(const Vector2I position, CursorType& type) const
 	{
-		RectI draggableArea;
+		Rect2I draggableArea;
 
 		if(mLabel != nullptr)
 			draggableArea = mLabel->_getCachedBounds();
@@ -64,7 +64,7 @@ namespace BansheeEngine
 	{
 		GUIElementContainer::mouseEvent(event);
 
-		RectI draggableArea;
+		Rect2I draggableArea;
 
 		if(mLabel != nullptr)
 			draggableArea = mLabel->_getCachedBounds();
@@ -170,7 +170,7 @@ namespace BansheeEngine
 	void GUIIntField::updateClippedBounds()
 	{
 		Vector2I offset = _getOffset();
-		mClippedBounds = RectI(offset.x, offset.y, _getWidth(), _getHeight());
+		mClippedBounds = Rect2I(offset.x, offset.y, _getWidth(), _getHeight());
 	}
 
 	const String& GUIIntField::getGUITypeName()

+ 4 - 4
BansheeEditor/Source/BsGUIMenuBar.cpp

@@ -310,15 +310,15 @@ namespace BansheeEngine
 		// so force the update right away so we get correct element bounds
 		mMainArea->_update();
 
-		Vector<RectI> nonClientAreas;
+		Vector<Rect2I> nonClientAreas;
 		nonClientAreas.push_back(mLogoTexture->_getCachedBounds());
 
 		if(mChildMenus.size() > 0)
 		{
-			RectI lastButtonBounds = mChildMenus.back().button->_getCachedBounds();
-			RectI minButtonBounds = mMinBtn->_getCachedBounds();
+			Rect2I lastButtonBounds = mChildMenus.back().button->_getCachedBounds();
+			Rect2I minButtonBounds = mMinBtn->_getCachedBounds();
 
-			RectI emptyArea(lastButtonBounds.x + lastButtonBounds.width, mMainArea->y(), 
+			Rect2I emptyArea(lastButtonBounds.x + lastButtonBounds.width, mMainArea->y(), 
 				minButtonBounds.x - (lastButtonBounds.x + lastButtonBounds.width), mMainArea->height());
 
 			nonClientAreas.push_back(emptyArea);

+ 1 - 1
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -68,7 +68,7 @@ namespace BansheeEngine
 			foldoutBtnStyle, selectionBackgroundStyle, editBoxStyle, dragHighlightStyle, dragSepHighlightStyle, GUILayoutOptions::create(options));
 	}
 
-	void GUIResourceTreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIResourceTreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		GUITreeView::_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
 

+ 12 - 12
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -227,18 +227,18 @@ namespace BansheeEngine
 	void GUITabbedTitleBar::updateClippedBounds()
 	{
 		Vector2I offset = _getOffset();
-		mClippedBounds = RectI(offset.x, offset.y, _getWidth(), _getHeight());
+		mClippedBounds = Rect2I(offset.x, offset.y, _getWidth(), _getHeight());
 	}
 
 	void GUITabbedTitleBar::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		Vector2I minBtnOptimalSize = mMinBtn->_getOptimalSize();
 		Vector2I closeBtnOptimalSize = mCloseBtn->_getOptimalSize();
 
 		UINT32 endButtonWidth = minBtnOptimalSize.x + closeBtnOptimalSize.x + OPTION_BTN_SPACING;
 
-		RectI tabClipRect = clipRect;
+		Rect2I tabClipRect = clipRect;
 		tabClipRect.width -= endButtonWidth;
 
 		{
@@ -250,7 +250,7 @@ namespace BansheeEngine
 			mBackgroundImage->_setAreaDepth(areaDepth + 2);
 			mBackgroundImage->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mBackgroundImage->_setClipRect(elemClipRect);
 		}
 
@@ -282,7 +282,7 @@ namespace BansheeEngine
 			btn->_setAreaDepth(areaDepth + 1);
 			btn->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(tabClipRect.x - offset.x, tabClipRect.y - offset.y, tabClipRect.width, tabClipRect.height);
+			Rect2I elemClipRect(tabClipRect.x - offset.x, tabClipRect.y - offset.y, tabClipRect.width, tabClipRect.height);
 			btn->_setClipRect(elemClipRect);
 
 			curX += optimalSize.x;
@@ -299,7 +299,7 @@ namespace BansheeEngine
 			mMinBtn->_setAreaDepth(areaDepth + 1);
 			mMinBtn->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mMinBtn->_setClipRect(elemClipRect);
 		}
 
@@ -314,14 +314,14 @@ namespace BansheeEngine
 			mCloseBtn->_setAreaDepth(areaDepth + 1);
 			mCloseBtn->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mCloseBtn->_setClipRect(elemClipRect);
 		}
 	}
 
-	Vector<RectI> GUITabbedTitleBar::calcDraggableAreas(INT32 x, INT32 y, UINT32 width, UINT32 height) const
+	Vector<Rect2I> GUITabbedTitleBar::calcDraggableAreas(INT32 x, INT32 y, UINT32 width, UINT32 height) const
 	{
-		Vector<RectI> draggableAreas;
+		Vector<Rect2I> draggableAreas;
 
 		UINT32 curX = x + 1;
 		UINT32 curY = y;
@@ -330,7 +330,7 @@ namespace BansheeEngine
 			GUITabButton* btn = mTabButtons[i];
 			Vector2I optimalSize = btn->_getOptimalSize();
 
-			draggableAreas.push_back(RectI(curX, curY, TAB_SPACING, height));
+			draggableAreas.push_back(Rect2I(curX, curY, TAB_SPACING, height));
 
 			curX += TAB_SPACING + optimalSize.x;
 		}
@@ -342,7 +342,7 @@ namespace BansheeEngine
 		UINT32 remainingWidth = (UINT32)std::max(0, (INT32)(width - curX - endButtonWidth - 1));
 
 		if(remainingWidth > 0)
-			draggableAreas.push_back(RectI(curX, curY, remainingWidth, height));
+			draggableAreas.push_back(Rect2I(curX, curY, remainingWidth, height));
 
 		return draggableAreas;
 	}
@@ -400,7 +400,7 @@ namespace BansheeEngine
 		INT32 idx = uniqueIdxToSeqIdx(tabIdx);
 		if(idx != -1)
 		{
-			RectI bounds = _getCachedBounds();
+			Rect2I bounds = _getCachedBounds();
 			if(bounds.contains(dragPos))
 			{
 				if(!mDragInProgress)

+ 1 - 1
BansheeEditor/Source/BsGUITextField.cpp

@@ -156,7 +156,7 @@ namespace BansheeEngine
 	}
 
 	void GUITextField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
 	}

+ 14 - 14
BansheeEditor/Source/BsGUITreeView.cpp

@@ -818,14 +818,14 @@ namespace BansheeEngine
 	void GUITreeView::updateClippedBounds()
 	{
 		Vector2I offset = _getOffset();
-		mClippedBounds = RectI(offset.x, offset.y, _getWidth(), _getHeight());
+		mClippedBounds = Rect2I(offset.x, offset.y, _getWidth(), _getHeight());
 
-		RectI localClipRect(mClipRect.x + mOffset.x, mClipRect.y + mOffset.y, mClipRect.width, mClipRect.height);
+		Rect2I localClipRect(mClipRect.x + mOffset.x, mClipRect.y + mOffset.y, mClipRect.width, mClipRect.height);
 		mClippedBounds.clip(localClipRect);
 	}
 
 	void GUITreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		struct UpdateTreeElement
 		{
@@ -863,8 +863,8 @@ namespace BansheeEngine
 				Vector2I elementSize = current->mElement->_getOptimalSize();
 				btnHeight = elementSize.y;
 
-				mVisibleElements.push_back(InteractableElement(current->mParent, current->mSortedIdx * 2 + 0, RectI(x, offset.y, width, ELEMENT_EXTRA_SPACING)));
-				mVisibleElements.push_back(InteractableElement(current->mParent, current->mSortedIdx * 2 + 1, RectI(x, offset.y + ELEMENT_EXTRA_SPACING, width, btnHeight)));
+				mVisibleElements.push_back(InteractableElement(current->mParent, current->mSortedIdx * 2 + 0, Rect2I(x, offset.y, width, ELEMENT_EXTRA_SPACING)));
+				mVisibleElements.push_back(InteractableElement(current->mParent, current->mSortedIdx * 2 + 1, Rect2I(x, offset.y + ELEMENT_EXTRA_SPACING, width, btnHeight)));
 
 				offset.x = x + INITIAL_INDENT_OFFSET + indent * INDENT_SIZE;
 				offset.y += ELEMENT_EXTRA_SPACING;
@@ -875,7 +875,7 @@ namespace BansheeEngine
 				current->mElement->_setAreaDepth(areaDepth);
 				current->mElement->_setWidgetDepth(widgetDepth);
 
-				RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				current->mElement->_setClipRect(elemClipRect);
 
 				yOffset = btnHeight;
@@ -903,7 +903,7 @@ namespace BansheeEngine
 				current->mFoldoutBtn->_setAreaDepth(areaDepth);
 				current->mFoldoutBtn->_setWidgetDepth(widgetDepth);
 
-				RectI elemClipRect(clipRect.x - myOffset.x, clipRect.y - myOffset.y, clipRect.width, clipRect.height);
+				Rect2I elemClipRect(clipRect.x - myOffset.x, clipRect.y - myOffset.y, clipRect.width, clipRect.height);
 				current->mFoldoutBtn->_setClipRect(elemClipRect);
 			}
 
@@ -929,7 +929,7 @@ namespace BansheeEngine
 		UINT32 remainingHeight = (UINT32)std::max(0, (INT32)height - (offset.y - y));
 
 		if(remainingHeight > 0)
-			mVisibleElements.push_back(InteractableElement(&getRootElement(), (UINT32)getRootElement().mChildren.size() * 2, RectI(x, offset.y, width, remainingHeight)));
+			mVisibleElements.push_back(InteractableElement(&getRootElement(), (UINT32)getRootElement().mChildren.size() * 2, Rect2I(x, offset.y, width, remainingHeight)));
 
 		for(auto selectedElem : mSelectedElements)
 		{
@@ -944,7 +944,7 @@ namespace BansheeEngine
 			selectedElem.background->_setAreaDepth(areaDepth + 1);
 			selectedElem.background->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			selectedElem.background->_setClipRect(elemClipRect);
 		}
 
@@ -961,7 +961,7 @@ namespace BansheeEngine
 			mNameEditBox->_setAreaDepth(areaDepth);
 			mNameEditBox->_setWidgetDepth(widgetDepth);
 
-			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mNameEditBox->_setClipRect(elemClipRect);
 
 		}
@@ -995,7 +995,7 @@ namespace BansheeEngine
 					mDragHighlight->_setAreaDepth(areaDepth + 1);
 					mDragHighlight->_setWidgetDepth(widgetDepth);
 
-					RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+					Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 					mDragHighlight->_setClipRect(elemClipRect);
 				}
 				else
@@ -1013,7 +1013,7 @@ namespace BansheeEngine
 					mDragSepHighlight->_setAreaDepth(areaDepth + 1);
 					mDragSepHighlight->_setWidgetDepth(widgetDepth);
 
-					RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+					Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 					mDragSepHighlight->_setClipRect(elemClipRect);
 				}
 			}
@@ -1178,7 +1178,7 @@ namespace BansheeEngine
 
 		if(center)
 		{
-			RectI myBounds = _getClippedBounds();
+			Rect2I myBounds = _getClippedBounds();
 			INT32 clipVertCenter = myBounds.y + (INT32)Math::roundToInt(myBounds.height * 0.5f);
 			INT32 elemVertCenter = element->mElement->_getOffset().y + (INT32)Math::roundToInt(element->mElement->_getHeight() * 0.5f);
 
@@ -1189,7 +1189,7 @@ namespace BansheeEngine
 		}
 		else
 		{
-			RectI myBounds = _getClippedBounds();
+			Rect2I myBounds = _getClippedBounds();
 			INT32 elemVertTop = element->mElement->_getOffset().y;
 			INT32 elemVertBottom = element->mElement->_getOffset().y + element->mElement->_getHeight();
 

+ 8 - 8
BansheeEditor/Source/BsGUIWindowFrameWidget.cpp

@@ -70,35 +70,35 @@ namespace BansheeEngine
 		Vector<NonClientResizeArea> nonClientAreas(8);
 
 		nonClientAreas[0].type = NonClientAreaBorderType::TopLeft;
-		nonClientAreas[0].area = RectI(x, y, 
+		nonClientAreas[0].area = Rect2I(x, y, 
 			RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[1].type = NonClientAreaBorderType::Top;
-		nonClientAreas[1].area = RectI(x + RESIZE_BORDER_WIDTH, y, 
+		nonClientAreas[1].area = Rect2I(x + RESIZE_BORDER_WIDTH, y, 
 			width - 2 * RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[2].type = NonClientAreaBorderType::TopRight;
-		nonClientAreas[2].area = RectI(x + width - RESIZE_BORDER_WIDTH, y, 
+		nonClientAreas[2].area = Rect2I(x + width - RESIZE_BORDER_WIDTH, y, 
 			RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[3].type = NonClientAreaBorderType::Left;
-		nonClientAreas[3].area = RectI(x, y + RESIZE_BORDER_WIDTH, 
+		nonClientAreas[3].area = Rect2I(x, y + RESIZE_BORDER_WIDTH, 
 			RESIZE_BORDER_WIDTH, height - 2 * RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[4].type = NonClientAreaBorderType::Right;
-		nonClientAreas[4].area = RectI(x + width - RESIZE_BORDER_WIDTH, y + RESIZE_BORDER_WIDTH, 
+		nonClientAreas[4].area = Rect2I(x + width - RESIZE_BORDER_WIDTH, y + RESIZE_BORDER_WIDTH, 
 			RESIZE_BORDER_WIDTH, height - 2 * RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[5].type = NonClientAreaBorderType::BottomLeft;
-		nonClientAreas[5].area = RectI(x, y + height - RESIZE_BORDER_WIDTH, 
+		nonClientAreas[5].area = Rect2I(x, y + height - RESIZE_BORDER_WIDTH, 
 			RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[6].type = NonClientAreaBorderType::Bottom;
-		nonClientAreas[6].area = RectI(x + RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH, 
+		nonClientAreas[6].area = Rect2I(x + RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH, 
 			width - 2 * RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
 		nonClientAreas[7].type = NonClientAreaBorderType::BottomRight;
-		nonClientAreas[7].area = RectI(x + width - RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH, 
+		nonClientAreas[7].area = Rect2I(x + width - RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH, 
 			RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
 		Platform::setResizeNonClientAreas(*mParentWindow, nonClientAreas);

+ 5 - 5
BansheeEditor/Source/BsGizmoManager.cpp

@@ -345,7 +345,7 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&GizmoManager::coreRenderGizmosForPicking,
 			this, viewMat, projMat, wireMesh->_createProxy(0)));
 
-		RectI screenArea = mCamera->getViewport()->getArea();
+		Rect2I screenArea = mCamera->getViewport()->getArea();
 
 		gCoreAccessor().queueCommand(std::bind(&GizmoManager::coreRenderIconGizmosForPicking,
 			this, screenArea, iconMesh->_createProxy(0), iconRenderData));
@@ -744,9 +744,9 @@ namespace BansheeEngine
 		float width = (float)sceneRenderTarget->getCore()->getProperties().getWidth();
 		float height = (float)sceneRenderTarget->getCore()->getProperties().getHeight();
 
-		RectF normArea = camera.viewport.getNormArea();
+		Rect2 normArea = camera.viewport.getNormArea();
 
-		RectI screenArea;
+		Rect2I screenArea;
 		screenArea.x = (int)(normArea.x * width);
 		screenArea.y = (int)(normArea.y * height);
 		screenArea.width = (int)(normArea.width * width);
@@ -784,7 +784,7 @@ namespace BansheeEngine
 		Renderer::draw(*meshProxy);
 	}
 
-	void GizmoManager::coreRenderIconGizmos(RectI screenArea, MeshProxyPtr meshProxy, IconRenderDataVecPtr renderData)
+	void GizmoManager::coreRenderIconGizmos(Rect2I screenArea, MeshProxyPtr meshProxy, IconRenderDataVecPtr renderData)
 	{
 		RenderSystem& rs = RenderSystem::instance();
 		MeshBasePtr mesh;
@@ -851,7 +851,7 @@ namespace BansheeEngine
 		Renderer::draw(*meshProxy);
 	}
 
-	void GizmoManager::coreRenderIconGizmosForPicking(RectI screenArea, MeshProxyPtr meshProxy, IconRenderDataVecPtr renderData)
+	void GizmoManager::coreRenderIconGizmosForPicking(Rect2I screenArea, MeshProxyPtr meshProxy, IconRenderDataVecPtr renderData)
 	{
 		RenderSystem& rs = RenderSystem::instance();
 		MeshBasePtr mesh;

+ 1 - 1
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -18,7 +18,7 @@
 #include "BsTestTextSprite.h"
 #include "BsDrawHelper2D.h"
 #include "BsDrawHelper3D.h"
-#include "BsRectF.h"
+#include "BsRect2.h"
 #include "BsProfilerOverlay.h"
 #include "BsPlatform.h"
 

+ 1 - 1
BansheeEditor/Source/BsSceneEditorWidget.cpp

@@ -81,7 +81,7 @@ namespace BansheeEngine
 	{
 		Vector2I windowPos = mParentWindow->screenToWindowPos(screenPos);
 
-		RectI renderTextureBounds = GUILayoutUtility::calcBounds(mGUIRenderTexture);
+		Rect2I renderTextureBounds = GUILayoutUtility::calcBounds(mGUIRenderTexture);
 
 		if (renderTextureBounds.contains(windowPos))
 		{

+ 1 - 1
BansheeEngine/Include/BsCursor.h

@@ -59,7 +59,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Limit cursor movement to specific area on the screen.
 		 */
-		void clipToRect(const RectI& screenRect);
+		void clipToRect(const Rect2I& screenRect);
 
 		/**
 		 * @brief	Disables cursor clipping that was set using any of the "clipTo*" methods.

+ 3 - 3
BansheeEngine/Include/BsDrawHelper2D.h

@@ -31,7 +31,7 @@ namespace BansheeEngine
 		 *
 		 *			Primitives are output in the form of a triangle list.
 		 */
-		void solidQuad(const RectF& area, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
+		void solidQuad(const Rect2& area, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset);
 
 		/**
 		 * @copydoc	DrawHelperTemplate::pixelLine
@@ -63,7 +63,7 @@ namespace BansheeEngine
 		 *						the quad will stretch with the viewport so its normalized coordinates stay the same.
 		 * @param	timeout		Optional timeout on how long to display the quad in seconds. If 0 the quad will be displayed one frame.
 		 */
-		void drawSolidQuad(const HCamera& camera, const RectF& area, const Color& color = Color::White, DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
+		void drawSolidQuad(const HCamera& camera, const Rect2& area, const Color& color = Color::White, DebugDrawCoordType coordType = DebugDrawCoordType::Pixel, float timeout = 0.0f);
 
 		/**
 		 * @brief	Constructs a pixel perfect line and draws it in the specified camera. 
@@ -143,7 +143,7 @@ namespace BansheeEngine
 		 * @brief	Converts an area with normalized ([0, 1] range) coordinates and returns
 		 *			area in clip space coordinates.
 		 */
-		RectF normalizedCoordToClipSpace(const RectF& area) const;
+		Rect2 normalizedCoordToClipSpace(const Rect2& area) const;
 
 		/**
 		 * @brief	Converts a point with normalized ([0, 1] range) coordinates and returns

+ 4 - 4
BansheeEngine/Include/BsGUIArea.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 
 namespace BansheeEngine
 {
@@ -137,12 +137,12 @@ namespace BansheeEngine
 		 * @param	clipRect	Rectangle in coordinates relative to the area. If width or height
 		 *						is zero, no clipping will be done.
 		 */
-		void setClipRect(const RectI& clipRect);
+		void setClipRect(const Rect2I& clipRect);
 
 		/**
 		 * @brief	Gets a rectangle that is used for clipping of the area contents.
 		 */
-		RectI getClipRect() const { return mClipRect; }
+		Rect2I getClipRect() const { return mClipRect; }
 
 		/**
 		 * @brief	Hides the area and any child elements.
@@ -218,7 +218,7 @@ namespace BansheeEngine
 		INT32 mLeft, mRight, mTop, mBottom;
 		UINT32 mWidth, mHeight;
 		UINT16 mDepth;
-		RectI mClipRect;
+		Rect2I mClipRect;
 		bool mResizeXWithWidget;
 		bool mResizeYWithWidget;
 		bool mIsDirty;

+ 8 - 8
BansheeEngine/Include/BsGUIDropDownBox.h

@@ -112,14 +112,14 @@ namespace BansheeEngine
 		 * 			of the provided bounds. Vertically system prefers placing the box at the bottom of the bounds, but may choose
 		 * 			to align it with the top of the bounds if it offers more space for the contents.
 		 */
-		static GUIDropDownAreaPlacement aroundBoundsVert(const RectI& bounds);
+		static GUIDropDownAreaPlacement aroundBoundsVert(const Rect2I& bounds);
 		
 		/**
 		 * @brief	Drop down box will be placed at the specified bounds. Box will be vertically aligned to the top
 		 * 			of the provided bounds. Horizontally system prefers placing the box at the right of the bounds, but may choose
 		 * 			to align it with the left of the bounds if it offers more space for the contents.
 		 */
-		static GUIDropDownAreaPlacement aroundBoundsHorz(const RectI& bounds);
+		static GUIDropDownAreaPlacement aroundBoundsHorz(const Rect2I& bounds);
 
 		/**
 		 * @brief	Returns drop down box positioning type.
@@ -130,7 +130,7 @@ namespace BansheeEngine
 		 * @brief	Returns bounds around which to position the drop down box
 		 *			if one of the bounds positioning types is used.
 		 */
-		const RectI& getBounds() const { return mBounds; }
+		const Rect2I& getBounds() const { return mBounds; }
 
 		/**
 		 * @brief	Returns position around which to position the drop down box
@@ -142,7 +142,7 @@ namespace BansheeEngine
 		GUIDropDownAreaPlacement() { }
 
 		Type mType;
-		RectI mBounds;
+		Rect2I mBounds;
 		Vector2I mPosition;
 	};
 
@@ -197,7 +197,7 @@ namespace BansheeEngine
 			 *							increase this value for each level of the sub-menu hierarchy.
 			 */
 			DropDownSubMenu(GUIDropDownBox* owner, const GUIDropDownAreaPlacement& placement, 
-				const RectI& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset);
+				const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset);
 			~DropDownSubMenu();
 
 			/**
@@ -238,7 +238,7 @@ namespace BansheeEngine
 			/**
 			 * @brief	Returns actual visible bounds of the sub-menu.
 			 */
-			RectI getVisibleBounds() const { return mVisibleBounds; }
+			Rect2I getVisibleBounds() const { return mVisibleBounds; }
 
 			/**
 			 * @brief	Get localized name of a menu item element with the specified index.
@@ -253,8 +253,8 @@ namespace BansheeEngine
 			UINT32 mPage;
 			INT32 x, y;
 			UINT32 width, height;
-			RectI mVisibleBounds;
-			RectI mAvailableBounds;
+			Rect2I mVisibleBounds;
+			Rect2I mAvailableBounds;
 			UINT32 mDepthOffset;
 			bool mOpenedUpward;
 

+ 3 - 3
BansheeEngine/Include/BsGUIDropDownHitBox.h

@@ -40,12 +40,12 @@ namespace BansheeEngine
 		/**
 		 * Sets a single rectangle bounds in which the hitbox will capture mouse events.
 		 */
-		void setBounds(const RectI& bounds) { mBounds.clear(); mBounds.push_back(bounds); }
+		void setBounds(const Rect2I& bounds) { mBounds.clear(); mBounds.push_back(bounds); }
 
 		/**
 		 * Sets complex bounds consisting of multiple rectangles in which the hitbox will capture mouse events.
 		 */
-		void setBounds(const Vector<RectI>& bounds) { mBounds = bounds; }
+		void setBounds(const Vector<Rect2I>& bounds) { mBounds = bounds; }
 
 		/**
 		 * Triggered when hit box loses focus (e.g. user clicks outside of its bounds).
@@ -64,7 +64,7 @@ namespace BansheeEngine
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 		virtual bool _isInBounds(const Vector2I position) const;
 
-		Vector<RectI> mBounds;
+		Vector<Rect2I> mBounds;
 		bool mCaptureMouse;
 	};
 }

+ 11 - 11
BansheeEngine/Include/BsGUIElement.h

@@ -3,7 +3,7 @@
 #include "BsPrerequisites.h"
 #include "BsGUIElementBase.h"
 #include "BsGUIOptions.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsVector2I.h"
 
 namespace BansheeEngine
@@ -196,7 +196,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		void _setClipRect(const RectI& clipRect);
+		void _setClipRect(const Rect2I& clipRect);
 
 		/**
 		 * @brief	Gets non-clipped bounds that were assigned to the element by the parent layout.
@@ -205,7 +205,7 @@ namespace BansheeEngine
 		 *			if parent element bounds changed since.
 		 *			Internal method:
 		 */
-		RectI _getCachedBounds() const;
+		Rect2I _getCachedBounds() const;
 
 		/**
 		 * @copydoc	GUIElementBase::_changeParentWidget
@@ -283,7 +283,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		const RectI& _getClippedBounds() const { return mClippedBounds; }
+		const Rect2I& _getClippedBounds() const { return mClippedBounds; }
 
 		/**
 		 * @brief	Returns clip rect used for clipping the GUI element and related sprites
@@ -291,7 +291,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		const RectI& _getClipRect() const { return mClipRect; }
+		const Rect2I& _getClipRect() const { return mClipRect; }
 
 		/**
 		 * @brief	Returns GUI element padding. Padding is modified by changing element style and determines
@@ -357,7 +357,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		virtual RectI _getTextInputRect() const { return RectI(); }
+		virtual Rect2I _getTextInputRect() const { return Rect2I(); }
 
 		/**
 		 * @brief	Returns layout options that determine how is the element positioned within a GUILayout.
@@ -414,27 +414,27 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns clipped bounds excluding the margins. Relative to parent widget.
 		 */
-		RectI getVisibleBounds() const;
+		Rect2I getVisibleBounds() const;
 
 		/**
 		 * @brief	Returns bounds of the content contained within the GUI element. Relative to parent widget.
 		 */
-		RectI getContentBounds() const;
+		Rect2I getContentBounds() const;
 
 		/**
 		 * @brief	Returns a clip rectangle that can be used for clipping the contents of this
 		 *			GUI element. Clip rect is relative to GUI element origin.
 		 */
-		RectI getContentClipRect() const;
+		Rect2I getContentClipRect() const;
 
 		bool mIsDestroyed;
 		GUILayoutOptions mLayoutOptions;
-		RectI mClippedBounds;
+		Rect2I mClippedBounds;
 
 		UINT32 mDepth;
 		Vector2I mOffset;
 		UINT32 mWidth, mHeight;
-		RectI mClipRect;
+		Rect2I mClipRect;
 
 	private:
 		const GUIElementStyle* mStyle;

+ 4 - 4
BansheeEngine/Include/BsGUIElementBase.h

@@ -3,7 +3,7 @@
 #include "BsPrerequisites.h"
 #include "BsGUIMaterialInfo.h"
 #include "BsGUILayoutOptions.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsVector2I.h"
 #include "BsRectOffset.h"
 
@@ -60,7 +60,7 @@ namespace BansheeEngine
 		 * @note	Internal method.
 		 */
 		virtual void _updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, 
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		/**
 		 * @brief	Calculates optimal sizes of all child elements, as determined by their style and layout options.
@@ -75,7 +75,7 @@ namespace BansheeEngine
 		 * @note	Internal method.
 		 */
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		/**
 		 * @brief	Calculates positions & sizes of all elements in the layout. This method expects a pre-allocated array to store the data in.
@@ -88,7 +88,7 @@ namespace BansheeEngine
 		 * @param	numElements		Size of the element areas array.
 		 * @param	optimalSizes	Optimal sizes used by the elements. Array must be same size as elements array.
 		 */
-		virtual void _getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const;
+		virtual void _getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const;
 
 		/**
 		 * @brief	Sets a new parent for this element.

+ 4 - 4
BansheeEngine/Include/BsGUIInputBox.h

@@ -173,7 +173,7 @@ namespace BansheeEngine
 		 * @brief	Returns rectangle in which the text can be displayed, in local
 		 *			coordinates (i.e. text will start at 0, 0).
 		 */
-		virtual RectI _getTextInputRect() const;
+		virtual Rect2I _getTextInputRect() const;
 
 		/**
 		 * @copydoc	GUIElement::_getRenderElementDepth
@@ -207,7 +207,7 @@ namespace BansheeEngine
 		 *			with the provided index. Rectangle is in local coordiantes relative to
 		 *			element origin.
 		 */
-		RectI renderElemToClipRect(UINT32 renderElemIdx) const;
+		Rect2I renderElemToClipRect(UINT32 renderElemIdx) const;
 
 		/**
 		 * @brief	Inserts a new string into the current text at the specified index.
@@ -266,7 +266,7 @@ namespace BansheeEngine
 		 * @brief	Clamps the text offset (scroll)	so that the text fits in the
 		 *			provided bounds nicely with minimal white space.
 		 */
-		void clampScrollToBounds(RectI unclippedTextBounds);
+		void clampScrollToBounds(Rect2I unclippedTextBounds);
 
 		/**
 		 * @brief	Returns offset at which to render the text. Relative to parent widget.
@@ -276,7 +276,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns rectangle used for clipping the text. Relative to element.
 		 */
-		RectI getTextClipRect() const;
+		Rect2I getTextClipRect() const;
 
 		/**
 		 * @brief	Returns text sprite descriptor determining how is text sprite created.

+ 1 - 1
BansheeEngine/Include/BsGUIInputCaret.h

@@ -44,7 +44,7 @@ namespace BansheeEngine
 		 * @param	parentClipRect	Clip rectangle of the parent GUI element. Caret clip rectangle will additionally be
 		 *							clipped by this area. Relative to parent element.
 		 */
-		RectI getSpriteClipRect(const RectI& parentClipRect) const;
+		Rect2I getSpriteClipRect(const Rect2I& parentClipRect) const;
 
 		/**
 		 * @brief	Rebuilts internal caret sprite using current properties.

+ 3 - 3
BansheeEngine/Include/BsGUIInputSelection.h

@@ -34,7 +34,7 @@ namespace BansheeEngine
 		 * @param	parentClipRect	Clip rectangle of the parent GUI element. Selection clip rectangle will additionally be
 		 *							clipped by this area. Relative to parent element.
 		 */
-		RectI GUIInputSelection::getSelectionSpriteClipRect(UINT32 spriteIdx, const RectI& parentClipRect) const;
+		Rect2I GUIInputSelection::getSelectionSpriteClipRect(UINT32 spriteIdx, const Rect2I& parentClipRect) const;
 
 		/**
 		 * @brief	Recreates the selection clip sprites.
@@ -103,7 +103,7 @@ namespace BansheeEngine
 		 * @brief	Returns rectangles describing the currently selected areas. Rectangles
 		 *			are relative to parent GUI element.
 		 */
-		Vector<RectI> getSelectionRects() const;
+		Vector<Rect2I> getSelectionRects() const;
 
 	private:
 		UINT32 mSelectionStart;
@@ -111,7 +111,7 @@ namespace BansheeEngine
 		UINT32 mSelectionAnchor;
 		UINT32 mSelectionDragAnchor;
 
-		Vector<RectI> mSelectionRects;
+		Vector<Rect2I> mSelectionRects;
 		Vector<ImageSprite*> mSprites;
 	};
 }

+ 2 - 2
BansheeEngine/Include/BsGUIInputTool.h

@@ -104,13 +104,13 @@ namespace BansheeEngine
 		 * @brief	Returns a rectangle containing position and size of the character with the provided
 		 *			index, relative to parent widget.
 		 */
-		RectI getCharRect(UINT32 charIdx) const;
+		Rect2I getCharRect(UINT32 charIdx) const;
 
 		/**
 		 * @brief	Returns a rectangle containing position and size of the character with the provided
 		 *			index, relative to parent element.
 		 */
-		RectI getLocalCharRect(UINT32 charIdx) const;
+		Rect2I getLocalCharRect(UINT32 charIdx) const;
 
 		/**
 		 * @brief	Returns character index nearest to the specified position. Position should be relative

+ 2 - 2
BansheeEngine/Include/BsGUILayoutUtility.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsVector2I.h"
 
 namespace BansheeEngine
@@ -26,6 +26,6 @@ namespace BansheeEngine
 		// other than just GUILayouts and base elements (e.g. a tree view) because for a lot
 		// of such custom container elements like tree view don't have method for calculating 
 		// element bounds implemented
-		static RectI calcBounds(const GUIElementBase* elem);
+		static Rect2I calcBounds(const GUIElementBase* elem);
 	};
 }

+ 2 - 2
BansheeEngine/Include/BsGUILayoutX.h

@@ -29,7 +29,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUILayout::_getElementAreas
 		 */
-		void _getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const;
+		void _getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const;
 	protected:
 		/**
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
@@ -42,6 +42,6 @@ namespace BansheeEngine
 		 * @brief	widgetDepth	Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
 		 * @brief	areaDepth	Depth of the parent area. Determines depth at which child elements will be placed on. Takes priority over element-specific depth.
 		 */
-		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 	};
 }

+ 2 - 2
BansheeEngine/Include/BsGUILayoutY.h

@@ -29,7 +29,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUILayout::_getElementAreas
 		 */
-		void _getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const;
+		void _getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const;
 	protected:
 		/**
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
@@ -42,6 +42,6 @@ namespace BansheeEngine
 		 * @brief	widgetDepth	Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
 		 * @brief	areaDepth	Depth of the parent area. Determines depth at which child elements will be placed on. Takes priority over element-specific depth.
 		 */
-		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUIScrollArea.h

@@ -168,7 +168,7 @@ namespace BansheeEngine
 		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 */
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
 
 		ScrollBarType mVertBarType;
 		ScrollBarType mHorzBarType;

+ 3 - 3
BansheeEngine/Include/BsGUIWidget.h

@@ -2,7 +2,7 @@
 
 #include "BsPrerequisites.h"
 #include "BsComponent.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsVector3.h"
 #include "BsQuaternion.h"
 #include "BsEvent.h"
@@ -53,7 +53,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns bounds of the widget, relative to the parent window.
 		 */
-		const RectI& getBounds() const { return mBounds; }
+		const Rect2I& getBounds() const { return mBounds; }
 
 		/**
 		 * @brief	Return true if widget or any of its elements are dirty.
@@ -174,7 +174,7 @@ namespace BansheeEngine
 		HEvent mOwnerTargetResizedConn;
 
 		mutable bool mWidgetIsDirty;
-		mutable RectI mBounds;
+		mutable Rect2I mBounds;
 		mutable Vector<HMesh> mCachedMeshes;
 		mutable Vector<HMaterial> mCachedMaterials;
 

+ 5 - 5
BansheeEngine/Include/BsSprite.h

@@ -3,7 +3,7 @@
 #include "BsPrerequisites.h"
 #include "BsGUIMaterialInfo.h"
 #include "BsVector2I.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 
 namespace BansheeEngine
 {
@@ -60,7 +60,7 @@ namespace BansheeEngine
 		 *
 		 * @returns	Clipped sprite bounds.
 		 */
-		RectI getBounds(const Vector2I& offset, const RectI& clipRect) const;
+		Rect2I getBounds(const Vector2I& offset, const Rect2I& clipRect) const;
 
 		/**
 		 * @brief	Returns the number of separate render elements in the sprite. Normally this is 1, but some sprites
@@ -111,7 +111,7 @@ namespace BansheeEngine
 		 * @see		getNumQuads()
 		 */
 		UINT32 fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
-			UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx, const Vector2I& offset, const RectI& clipRect, bool clip = true) const;
+			UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx, const Vector2I& offset, const Rect2I& clipRect, bool clip = true) const;
 
 	protected:
 		/**
@@ -124,7 +124,7 @@ namespace BansheeEngine
 		 *						and uv coordinates have the same stride (as they are likely pointing to the same buffer).
 		 * @param	clipRect	Rectangle to clip the geometry to.
 		 */
-		static void clipToRect(UINT8* vertices, UINT8* uv, UINT32 numQuads, UINT32 vertStride, const RectI& clipRect);
+		static void clipToRect(UINT8* vertices, UINT8* uv, UINT32 numQuads, UINT32 vertStride, const Rect2I& clipRect);
 
 		/**
 		 * @brief	Returns the offset needed to move the sprite in order for it to respect the provided anchor.
@@ -141,7 +141,7 @@ namespace BansheeEngine
 		 */
 		void clearMesh() const;
 
-		mutable RectI mBounds;
+		mutable Rect2I mBounds;
 		mutable Vector<SpriteRenderElement> mCachedRenderElements;
 	};
 }

+ 1 - 1
BansheeEngine/Source/BsCursor.cpp

@@ -37,7 +37,7 @@ namespace BansheeEngine
 		Platform::clipCursorToWindow(window);
 	}
 
-	void Cursor::clipToRect(const RectI& screenRect)
+	void Cursor::clipToRect(const Rect2I& screenRect)
 	{
 		Platform::clipCursorToRect(screenRect);
 	}

+ 6 - 6
BansheeEngine/Source/BsDrawHelper2D.cpp

@@ -1,5 +1,5 @@
 #include "BsDrawHelper2D.h"
-#include "BsRectF.h"
+#include "BsRect2.h"
 #include "BsMesh.h"
 #include "BsTime.h"
 #include "BsVector2.h"
@@ -23,7 +23,7 @@ namespace BansheeEngine
 		mVertexDesc->addVertElem(VET_COLOR, VES_COLOR);
 	}
 
-	void DrawHelper2D::solidQuad(const RectF& area, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
+	void DrawHelper2D::solidQuad(const Rect2& area, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
 	{
 		UINT32* indexData = meshData->getIndices32();
 		UINT8* positionData = meshData->getElementData(VES_POSITION);
@@ -64,7 +64,7 @@ namespace BansheeEngine
 	/* 								2D - DRAW	                     		*/
 	/************************************************************************/
 
-	void DrawHelper2D::drawSolidQuad(const HCamera& camera, const RectF& area, const Color& color, DebugDrawCoordType coordType, float timeout)
+	void DrawHelper2D::drawSolidQuad(const HCamera& camera, const Rect2& area, const Color& color, DebugDrawCoordType coordType, float timeout)
 	{
 		const Viewport* viewport = camera->getViewport().get();
 
@@ -76,7 +76,7 @@ namespace BansheeEngine
 
 		MeshDataPtr meshData = bs_shared_ptr<MeshData, ScratchAlloc>(4, 6, mVertexDesc);
 
-		RectF actualArea = area;
+		Rect2 actualArea = area;
 		if(coordType == DebugDrawCoordType::Normalized)
 			actualArea = normalizedCoordToClipSpace(area);
 
@@ -413,9 +413,9 @@ namespace BansheeEngine
 		}
 	}
 
-	RectF DrawHelper2D::normalizedCoordToClipSpace(const RectF& area) const
+	Rect2 DrawHelper2D::normalizedCoordToClipSpace(const Rect2& area) const
 	{
-		RectF clipSpaceRect;
+		Rect2 clipSpaceRect;
 		clipSpaceRect.x = area.x * 2.0f - 1.0f;
 		clipSpaceRect.width = area.width * 2.0f;
 		clipSpaceRect.y = -area.y * 2.0f + 1.0f;

+ 1 - 1
BansheeEngine/Source/BsDrawHelper3D.cpp

@@ -1,5 +1,5 @@
 #include "BsDrawHelper3D.h"
-#include "BsRectF.h"
+#include "BsRect2.h"
 #include "BsMesh.h"
 #include "BsTime.h"
 #include "BsVector2.h"

+ 1 - 1
BansheeEngine/Source/BsDrawHelperTemplate.cpp

@@ -1,5 +1,5 @@
 #include "BsDrawHelperTemplate.h"
-#include "BsRectF.h"
+#include "BsRect2.h"
 #include "BsMesh.h"
 #include "BsTime.h"
 #include "BsVector2.h"

+ 3 - 3
BansheeEngine/Source/BsGUIArea.cpp

@@ -129,10 +129,10 @@ namespace BansheeEngine
 	{
 		if(!mIsDisabled && isDirty() && (mWidget != nullptr))
 		{
-			RectI clipRect(mLeft, mTop, mWidth, mHeight);
+			Rect2I clipRect(mLeft, mTop, mWidth, mHeight);
 			if (mClipRect.width > 0 && mClipRect.height > 0)
 			{
-				RectI newClipRect = RectI(mLeft + mClipRect.x, mTop + mClipRect.y, mClipRect.width, mClipRect.height);
+				Rect2I newClipRect = Rect2I(mLeft + mClipRect.x, mTop + mClipRect.y, mClipRect.width, mClipRect.height);
 				newClipRect.clip(clipRect);
 				clipRect = newClipRect;
 			}
@@ -166,7 +166,7 @@ namespace BansheeEngine
 		mIsDirty = true;
 	}
 
-	void GUIArea::setClipRect(const RectI& clipRect)
+	void GUIArea::setClipRect(const Rect2I& clipRect)
 	{
 		mClipRect = clipRect;
 

+ 7 - 7
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -182,18 +182,18 @@ namespace BansheeEngine
 			return;
 		}
 
-		RectI contentBounds = getContentBounds();
-		RectI contentClipRect = getContentClipRect();
-		RectI textBounds = mTextSprite->getBounds(Vector2I(), RectI());
+		Rect2I contentBounds = getContentBounds();
+		Rect2I contentClipRect = getContentClipRect();
+		Rect2I textBounds = mTextSprite->getBounds(Vector2I(), Rect2I());
 
 		Vector2I textOffset;
-		RectI textClipRect;
+		Rect2I textClipRect;
 
 		Vector2I imageOffset;
-		RectI imageClipRect;
+		Rect2I imageClipRect;
 		if(mContentImageSprite != nullptr)
 		{
-			RectI imageBounds = mContentImageSprite->getBounds(Vector2I(), RectI());
+			Rect2I imageBounds = mContentImageSprite->getBounds(Vector2I(), Rect2I());
 			UINT32 freeWidth = (UINT32)std::max(0, contentBounds.width - textBounds.width - imageBounds.width);
 			INT32 imageXOffset = (INT32)(freeWidth / 2);
 
@@ -291,7 +291,7 @@ namespace BansheeEngine
 		textDesc.font = _getStyle()->font;
 		textDesc.fontSize = _getStyle()->fontSize;
 
-		RectI textBounds = getContentBounds();
+		Rect2I textBounds = getContentBounds();
 
 		textDesc.width = textBounds.width;
 		textDesc.height = textBounds.height;

+ 9 - 9
BansheeEngine/Source/BsGUIDropDownBox.cpp

@@ -53,7 +53,7 @@ namespace BansheeEngine
 		return instance;
 	}
 
-	GUIDropDownAreaPlacement GUIDropDownAreaPlacement::aroundBoundsVert(const RectI& bounds)
+	GUIDropDownAreaPlacement GUIDropDownAreaPlacement::aroundBoundsVert(const Rect2I& bounds)
 	{
 		GUIDropDownAreaPlacement instance;
 		instance.mType = Type::BoundsVert;
@@ -62,7 +62,7 @@ namespace BansheeEngine
 		return instance;
 	}
 		
-	GUIDropDownAreaPlacement GUIDropDownAreaPlacement::aroundBoundsHorz(const RectI& bounds)
+	GUIDropDownAreaPlacement GUIDropDownAreaPlacement::aroundBoundsHorz(const Rect2I& bounds)
 	{
 		GUIDropDownAreaPlacement instance;
 		instance.mType = Type::BoundsHorz;
@@ -112,12 +112,12 @@ namespace BansheeEngine
 		mHitBox->_changeParentWidget(this);
 
 		mCaptureHitBox = GUIDropDownHitBox::create(true);
-		mCaptureHitBox->setBounds(RectI(0, 0, target->getWidth(), target->getHeight()));
+		mCaptureHitBox->setBounds(Rect2I(0, 0, target->getWidth(), target->getHeight()));
 		mCaptureHitBox->_setWidgetDepth(0);
 		mCaptureHitBox->_setAreaDepth(200);
 		mCaptureHitBox->_changeParentWidget(this);
 
-		RectI availableBounds(target->getX(), target->getY(), target->getWidth(), target->getHeight());
+		Rect2I availableBounds(target->getX(), target->getY(), target->getWidth(), target->getHeight());
 		mRootMenu = bs_new<DropDownSubMenu>(this, placement, availableBounds, dropDownData, type, 0);
 	}
 
@@ -136,7 +136,7 @@ namespace BansheeEngine
 
 	void GUIDropDownBox::notifySubMenuOpened(DropDownSubMenu* subMenu)
 	{
-		Vector<RectI> bounds;
+		Vector<Rect2I> bounds;
 
 		while(subMenu != nullptr)
 		{
@@ -150,7 +150,7 @@ namespace BansheeEngine
 
 	void GUIDropDownBox::notifySubMenuClosed(DropDownSubMenu* subMenu)
 	{
-		Vector<RectI> bounds;
+		Vector<Rect2I> bounds;
 
 		while(subMenu != nullptr)
 		{
@@ -163,7 +163,7 @@ namespace BansheeEngine
 	}
 
 	GUIDropDownBox::DropDownSubMenu::DropDownSubMenu(GUIDropDownBox* owner, const GUIDropDownAreaPlacement& placement, 
-		const RectI& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset)
+		const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset)
 		:mOwner(owner), mPage(0), mBackgroundFrame(nullptr), mBackgroundArea(nullptr), mContentArea(nullptr), 
 		mContentLayout(nullptr), mScrollUpBtn(nullptr), mScrollDownBtn(nullptr), x(0), y(0), width(0), height(0), 
 		mType(type), mSubMenu(nullptr), mData(dropDownData), mOpenedUpward(false), mDepthOffset(depthOffset)
@@ -174,7 +174,7 @@ namespace BansheeEngine
 		const GUIElementStyle* scrollDownStyle = mOwner->getSkin().getStyle(mOwner->mScrollDownStyle);
 		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
 
-		RectI dropDownListBounds = placement.getBounds();
+		Rect2I dropDownListBounds = placement.getBounds();
 		int potentialLeftStart = 0;
 		int potentialRightStart = 0;
 		int potentialTopStart = 0;
@@ -491,7 +491,7 @@ namespace BansheeEngine
 		mBackgroundArea->setSize(width, usedHeight);
 		mBackgroundArea->setPosition(x, actualY);
 
-		mVisibleBounds = RectI(x, actualY, width, usedHeight);
+		mVisibleBounds = Rect2I(x, actualY, width, usedHeight);
 
 		UINT32 contentWidth = (UINT32)std::max(0, (INT32)width - (INT32)backgroundStyle->margins.left - (INT32)backgroundStyle->margins.right);
 		UINT32 contentHeight = (UINT32)std::max(0, (INT32)usedHeight - (INT32)backgroundStyle->margins.top - (INT32)backgroundStyle->margins.bottom);

+ 11 - 11
BansheeEngine/Source/BsGUIElement.cpp

@@ -110,7 +110,7 @@ namespace BansheeEngine
 		mHeight = height;
 	}
 
-	void GUIElement::_setClipRect(const RectI& clipRect) 
+	void GUIElement::_setClipRect(const Rect2I& clipRect) 
 	{ 
 		if(mClipRect != clipRect)
 		{
@@ -198,9 +198,9 @@ namespace BansheeEngine
 		return Vector2I(optimalWidth, optimalHeight);
 	}
 
-	RectI GUIElement::_getCachedBounds() const
+	Rect2I GUIElement::_getCachedBounds() const
 	{
-		return RectI(mOffset.x, mOffset.y, mWidth, mHeight);
+		return Rect2I(mOffset.x, mOffset.y, mWidth, mHeight);
 	}
 
 	void GUIElement::setFocus(bool enabled)
@@ -216,9 +216,9 @@ namespace BansheeEngine
 		markContentAsDirty();
 	}
 
-	RectI GUIElement::getVisibleBounds() const
+	Rect2I GUIElement::getVisibleBounds() const
 	{
-		RectI bounds = _getClippedBounds();
+		Rect2I bounds = _getClippedBounds();
 		
 		bounds.x += mStyle->margins.left;
 		bounds.y += mStyle->margins.top;
@@ -228,9 +228,9 @@ namespace BansheeEngine
 		return bounds;
 	}
 
-	RectI GUIElement::getContentBounds() const
+	Rect2I GUIElement::getContentBounds() const
 	{
-		RectI bounds;
+		Rect2I bounds;
 
 		bounds.x = mOffset.x + mStyle->margins.left + mStyle->contentOffset.left;
 		bounds.y = mOffset.y + mStyle->margins.top + mStyle->contentOffset.top;
@@ -242,13 +242,13 @@ namespace BansheeEngine
 		return bounds;
 	}
 
-	RectI GUIElement::getContentClipRect() const
+	Rect2I GUIElement::getContentClipRect() const
 	{
-		RectI contentBounds = getContentBounds();
+		Rect2I contentBounds = getContentBounds();
 		
 		// Transform into element space so we can clip it using the element clip rectangle
 		Vector2I offsetDiff = Vector2I(contentBounds.x - mOffset.x, contentBounds.y - mOffset.y);
-		RectI contentClipRect(offsetDiff.x, offsetDiff.y, contentBounds.width, contentBounds.height);
+		Rect2I contentClipRect(offsetDiff.x, offsetDiff.y, contentBounds.width, contentBounds.height);
 		contentClipRect.clip(mClipRect);
 
 		// Transform into content sprite space
@@ -260,7 +260,7 @@ namespace BansheeEngine
 
 	bool GUIElement::_isInBounds(const Vector2I position) const
 	{
-		RectI contentBounds = getVisibleBounds();
+		Rect2I contentBounds = getVisibleBounds();
 
 		return contentBounds.contains(position);
 	}

+ 3 - 3
BansheeEngine/Source/BsGUIElementBase.cpp

@@ -96,7 +96,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUIElementBase::_updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIElementBase::_updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		_updateOptimalLayoutSizes(); // We calculate optimal sizes of all layouts as a pre-processing step, as they are requested often during update
 		_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
@@ -110,7 +110,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUIElementBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIElementBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		for(auto& child : mChildren)
 		{
@@ -118,7 +118,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUIElementBase::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
+	void GUIElementBase::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
 	{
 		assert(mChildren.size() == 0);
 	}

+ 1 - 1
BansheeEngine/Source/BsGUIElementContainer.cpp

@@ -27,7 +27,7 @@ namespace BansheeEngine
 
 	void GUIElementContainer::updateClippedBounds()
 	{
-		mClippedBounds = RectI(0, 0, 0, 0); // We don't want any mouse input for this element. This is just a container.
+		mClippedBounds = Rect2I(0, 0, 0, 0); // We don't want any mouse input for this element. This is just a container.
 	}
 
 	void GUIElementContainer::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 

+ 12 - 12
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -162,7 +162,7 @@ namespace BansheeEngine
 
 		// When text bounds are reduced the scroll needs to be adjusted so that
 		// input box isn't filled with mostly empty space.
-		clampScrollToBounds(mTextSprite->getBounds(mOffset, RectI()));
+		clampScrollToBounds(mTextSprite->getBounds(mOffset, Rect2I()));
 
 		GUIElement::updateRenderElementsInternal();
 	}
@@ -264,7 +264,7 @@ namespace BansheeEngine
 		return Vector2I();
 	}
 
-	RectI GUIInputBox::renderElemToClipRect(UINT32 renderElemIdx) const
+	Rect2I GUIInputBox::renderElemToClipRect(UINT32 renderElemIdx) const
 	{
 		UINT32 oldNumElements = 0;
 		UINT32 newNumElements = oldNumElements + mTextSprite->getNumRenderElements();
@@ -304,7 +304,7 @@ namespace BansheeEngine
 			}
 		}
 
-		return RectI();
+		return Rect2I();
 	}
 
 	Vector2I GUIInputBox::_getOptimalSize() const
@@ -331,9 +331,9 @@ namespace BansheeEngine
 		return mTextOffset;	
 	}
 
-	RectI GUIInputBox::_getTextInputRect() const
+	Rect2I GUIInputBox::_getTextInputRect() const
 	{
-		RectI textBounds = getContentBounds();
+		Rect2I textBounds = getContentBounds();
 		textBounds.x -= mOffset.x;
 		textBounds.y -= mOffset.y;
 
@@ -372,7 +372,7 @@ namespace BansheeEngine
 		UINT32 localRenderElementIdx;
 		Sprite* sprite = renderElemToSprite(renderElementIdx, localRenderElementIdx);
 		Vector2I offset = renderElemToOffset(renderElementIdx);
-		RectI clipRect = renderElemToClipRect(renderElementIdx);
+		Rect2I clipRect = renderElemToClipRect(renderElementIdx);
 
 		sprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, vertexStride, indexStride, localRenderElementIdx, offset, clipRect);
 	}
@@ -924,7 +924,7 @@ namespace BansheeEngine
 		markContentAsDirty();
 	}
 
-	void GUIInputBox::clampScrollToBounds(RectI unclippedTextBounds)
+	void GUIInputBox::clampScrollToBounds(Rect2I unclippedTextBounds)
 	{
 		TEXT_SPRITE_DESC textDesc = getTextDesc();
 
@@ -1032,14 +1032,14 @@ namespace BansheeEngine
 
 	Vector2I GUIInputBox::getTextOffset() const
 	{
-		RectI textBounds = getContentBounds();
+		Rect2I textBounds = getContentBounds();
 		return Vector2I(textBounds.x, textBounds.y) + mTextOffset;
 	}
 
-	RectI GUIInputBox::getTextClipRect() const
+	Rect2I GUIInputBox::getTextClipRect() const
 	{
-		RectI contentClipRect = getContentClipRect();
-		return RectI(contentClipRect.x - mTextOffset.x, contentClipRect.y - mTextOffset.y, contentClipRect.width, contentClipRect.height);
+		Rect2I contentClipRect = getContentClipRect();
+		return Rect2I(contentClipRect.x - mTextOffset.x, contentClipRect.y - mTextOffset.y, contentClipRect.width, contentClipRect.height);
 	}
 
 	TEXT_SPRITE_DESC GUIInputBox::getTextDesc() const
@@ -1049,7 +1049,7 @@ namespace BansheeEngine
 		textDesc.font = _getStyle()->font;
 		textDesc.fontSize = _getStyle()->fontSize;
 
-		RectI textBounds = getContentBounds();
+		Rect2I textBounds = getContentBounds();
 		textDesc.width = textBounds.width;
 		textDesc.height = textBounds.height;
 		textDesc.horzAlign = _getStyle()->textHorzAlign;

+ 5 - 5
BansheeEngine/Source/BsGUIInputCaret.cpp

@@ -23,14 +23,14 @@ namespace BansheeEngine
 		return getCaretPosition(getTextOffset());
 	}
 
-	RectI GUIInputCaret::getSpriteClipRect(const RectI& parentClipRect) const
+	Rect2I GUIInputCaret::getSpriteClipRect(const Rect2I& parentClipRect) const
 	{
 		Vector2I clipOffset = getSpriteOffset() - mElement->_getOffset() - 
 			Vector2I(mElement->_getTextInputRect().x, mElement->_getTextInputRect().y);
 
-		RectI clipRect(-clipOffset.x, -clipOffset.y, mTextDesc.width, mTextDesc.height);
+		Rect2I clipRect(-clipOffset.x, -clipOffset.y, mTextDesc.width, mTextDesc.height);
 
-		RectI localParentCliprect = parentClipRect;
+		Rect2I localParentCliprect = parentClipRect;
 
 		// Move parent rect to our space
 		localParentCliprect.x += mElement->_getTextInputOffset().x + clipRect.x;
@@ -133,7 +133,7 @@ namespace BansheeEngine
 
 		if(charIdx != -1)
 		{
-			RectI charRect = getCharRect(charIdx);
+			Rect2I charRect = getCharRect(charIdx);
 
 			float xCenter = charRect.x + charRect.width * 0.5f;
 			if(pos.x <= xCenter)
@@ -249,7 +249,7 @@ namespace BansheeEngine
 
 			charIdx = std::min((UINT32)(mTextDesc.text.size() - 1), charIdx);
 
-			RectI charRect = getCharRect(charIdx);
+			Rect2I charRect = getCharRect(charIdx);
 			UINT32 lineIdx = getLineForChar(charIdx);
 			UINT32 yOffset = getLineDesc(lineIdx).getLineYStart() + getTextOffset().y;
 

+ 14 - 14
BansheeEngine/Source/BsGUIInputSelection.cpp

@@ -56,14 +56,14 @@ namespace BansheeEngine
 		return Vector2I(mSelectionRects[spriteIdx].x, mSelectionRects[spriteIdx].y) + getTextOffset();
 	}
 
-	RectI GUIInputSelection::getSelectionSpriteClipRect(UINT32 spriteIdx, const RectI& parentClipRect) const
+	Rect2I GUIInputSelection::getSelectionSpriteClipRect(UINT32 spriteIdx, const Rect2I& parentClipRect) const
 	{
 		Vector2I selectionOffset(mSelectionRects[spriteIdx].x, mSelectionRects[spriteIdx].y);
 		Vector2I clipOffset = selectionOffset + mElement->_getTextInputOffset();
 
-		RectI clipRect(-clipOffset.x, -clipOffset.y, mTextDesc.width, mTextDesc.height);
+		Rect2I clipRect(-clipOffset.x, -clipOffset.y, mTextDesc.width, mTextDesc.height);
 
-		RectI localParentCliprect = parentClipRect;
+		Rect2I localParentCliprect = parentClipRect;
 
 		// Move parent rect to our space
 		localParentCliprect.x += mElement->_getTextInputOffset().x + clipRect.x;
@@ -78,9 +78,9 @@ namespace BansheeEngine
 		return clipRect;
 	}
 
-	Vector<RectI> GUIInputSelection::getSelectionRects() const
+	Vector<Rect2I> GUIInputSelection::getSelectionRects() const
 	{
-		Vector<RectI> selectionRects;
+		Vector<Rect2I> selectionRects;
 
 		if(mSelectionStart == mSelectionEnd)
 			return selectionRects;
@@ -106,10 +106,10 @@ namespace BansheeEngine
 
 			if(!isNewlineChar(startCharIdx) && !isNewlineChar(endCharIdx))
 			{
-				RectI startChar = getLocalCharRect(startCharIdx);
-				RectI endChar = getLocalCharRect(endCharIdx);
+				Rect2I startChar = getLocalCharRect(startCharIdx);
+				Rect2I endChar = getLocalCharRect(endCharIdx);
 
-				RectI selectionRect;
+				Rect2I selectionRect;
 				selectionRect.x = startChar.x;
 				selectionRect.y = lineDesc.getLineYStart();
 				selectionRect.height = lineDesc.getLineHeight();
@@ -129,10 +129,10 @@ namespace BansheeEngine
 			if(endCharIdx > 0)
 				endCharIdx = endCharIdx - 1;
 
-			RectI startChar = getLocalCharRect(lineDesc.getStartChar());
-			RectI endChar = getLocalCharRect(endCharIdx);
+			Rect2I startChar = getLocalCharRect(lineDesc.getStartChar());
+			Rect2I endChar = getLocalCharRect(endCharIdx);
 
-			RectI selectionRect;
+			Rect2I selectionRect;
 			selectionRect.x = startChar.x;
 			selectionRect.y = lineDesc.getLineYStart();
 			selectionRect.height = lineDesc.getLineHeight();
@@ -151,10 +151,10 @@ namespace BansheeEngine
 
 				if(!isNewlineChar(endCharIdx))
 				{
-					RectI startChar = getLocalCharRect(lineDesc.getStartChar());
-					RectI endChar = getLocalCharRect(endCharIdx);
+					Rect2I startChar = getLocalCharRect(lineDesc.getStartChar());
+					Rect2I endChar = getLocalCharRect(endCharIdx);
 
-					RectI selectionRect;
+					Rect2I selectionRect;
 					selectionRect.x = startChar.x;
 					selectionRect.y = lineDesc.getLineYStart();
 					selectionRect.height = lineDesc.getLineHeight();

+ 5 - 5
BansheeEngine/Source/BsGUIInputTool.cpp

@@ -71,9 +71,9 @@ namespace BansheeEngine
 		return mElement->_getOffset() + mElement->_getTextInputOffset() + Vector2I(mElement->_getTextInputRect().x, mElement->_getTextInputRect().y);
 	}
 
-	RectI GUIInputTool::getCharRect(UINT32 charIdx) const
+	Rect2I GUIInputTool::getCharRect(UINT32 charIdx) const
 	{
-		RectI charRect = getLocalCharRect(charIdx);
+		Rect2I charRect = getLocalCharRect(charIdx);
 		Vector2I textOffset = getTextOffset();
 
 		charRect.x += textOffset.x;
@@ -82,14 +82,14 @@ namespace BansheeEngine
 		return charRect;
 	}
 
-	RectI GUIInputTool::getLocalCharRect(UINT32 charIdx) const
+	Rect2I GUIInputTool::getLocalCharRect(UINT32 charIdx) const
 	{
 		UINT32 lineIdx = getLineForChar(charIdx);
 
 		// If char is newline we don't have any geometry to return
 		const GUIInputLineDesc& lineDesc = getLineDesc(lineIdx);
 		if(lineDesc.isNewline(charIdx))
-			return RectI();
+			return Rect2I();
 
 		UINT32 numNewlineChars = 0;
 		for(UINT32 i = 0; i < lineIdx; i++)
@@ -100,7 +100,7 @@ namespace BansheeEngine
 		{
 			UINT32 vertIdx = quadIdx * 4;
 
-			RectI charRect;
+			Rect2I charRect;
 			charRect.x = Math::roundToInt(mQuads[vertIdx + 0].x);
 			charRect.y = Math::roundToInt(mQuads[vertIdx + 0].y);
 			charRect.width = Math::roundToInt(mQuads[vertIdx + 3].x - charRect.x);

+ 5 - 5
BansheeEngine/Source/BsGUILayoutUtility.cpp

@@ -10,9 +10,9 @@ namespace BansheeEngine
 		return elem->_calculateOptimalLayoutSize();
 	}
 
-	RectI GUILayoutUtility::calcBounds(const GUIElementBase* elem)
+	Rect2I GUILayoutUtility::calcBounds(const GUIElementBase* elem)
 	{
-		RectI parentArea;
+		Rect2I parentArea;
 
 		GUIElementBase* parent = elem->_getParent();
 		if (parent != nullptr)
@@ -45,13 +45,13 @@ namespace BansheeEngine
 			optimalSizes.push_back(calcOptimalSize(elem));
 		}
 
-		RectI* elementAreas = nullptr;
+		Rect2I* elementAreas = nullptr;
 
 		if (numElements > 0)
-			elementAreas = stackConstructN<RectI>(numElements);
+			elementAreas = stackConstructN<Rect2I>(numElements);
 
 		parent->_getElementAreas(parentArea.x, parentArea.y, parentArea.width, parentArea.height, elementAreas, numElements, optimalSizes);
-		RectI myArea = elementAreas[myIndex];
+		Rect2I myArea = elementAreas[myIndex];
 
 		if (elementAreas != nullptr)
 			stackDeallocLast(elementAreas);

+ 8 - 8
BansheeEngine/Source/BsGUILayoutX.cpp

@@ -85,7 +85,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUILayoutX::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
+	void GUILayoutX::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
 	{
 		assert(mChildren.size() == numElements);
 
@@ -390,13 +390,13 @@ namespace BansheeEngine
 			stackDeallocLast(processedElements);
 	}
 
-	void GUILayoutX::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUILayoutX::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		UINT32 numElements = (UINT32)mChildren.size();
-		RectI* elementAreas = nullptr;
+		Rect2I* elementAreas = nullptr;
 
 		if (numElements > 0)
-			elementAreas = stackConstructN<RectI>(numElements);
+			elementAreas = stackConstructN<Rect2I>(numElements);
 
 		_getElementAreas(x, y,width, height, elementAreas, numElements, mOptimalSizes);
 
@@ -407,7 +407,7 @@ namespace BansheeEngine
 		mActualHeight = 0;
 		for(auto& child : mChildren)
 		{
-			RectI childArea = elementAreas[childIdx];
+			Rect2I childArea = elementAreas[childIdx];
 
 			if(child->_getType() == GUIElementBase::Type::Element)
 			{
@@ -420,10 +420,10 @@ namespace BansheeEngine
 				element->_setWidgetDepth(widgetDepth);
 				element->_setAreaDepth(areaDepth);
 
-				RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				element->_setClipRect(elemClipRect);
 
-				RectI newClipRect(offset.x, offset.y, childArea.width, childArea.height);
+				Rect2I newClipRect(offset.x, offset.y, childArea.width, childArea.height);
 				newClipRect.clip(clipRect);
 				element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, areaDepth);
 
@@ -433,7 +433,7 @@ namespace BansheeEngine
 			{
 				GUILayout* layout = static_cast<GUILayout*>(child);
 
-				RectI newClipRect(childArea.x, childArea.y, childArea.width, height);
+				Rect2I newClipRect(childArea.x, childArea.y, childArea.width, height);
 				newClipRect.clip(clipRect);
 				layout->_updateLayoutInternal(childArea.x, childArea.y, childArea.width, height, newClipRect, widgetDepth, areaDepth);
 

+ 8 - 8
BansheeEngine/Source/BsGUILayoutY.cpp

@@ -86,7 +86,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUILayoutY::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
+	void GUILayoutY::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
 	{
 		assert(mChildren.size() == numElements);
 
@@ -387,13 +387,13 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUILayoutY::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUILayoutY::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		UINT32 numElements = (UINT32)mChildren.size();
-		RectI* elementAreas = nullptr;
+		Rect2I* elementAreas = nullptr;
 		
 		if (numElements > 0)
-			elementAreas = stackConstructN<RectI>(numElements);
+			elementAreas = stackConstructN<Rect2I>(numElements);
 
 		_getElementAreas(x, y, width, height, elementAreas, numElements, mOptimalSizes);
 
@@ -404,7 +404,7 @@ namespace BansheeEngine
 		mActualHeight = 0;
 		for(auto& child : mChildren)
 		{
-			RectI childArea = elementAreas[childIdx];
+			Rect2I childArea = elementAreas[childIdx];
 
 			if(child->_getType() == GUIElementBase::Type::Element)
 			{
@@ -418,10 +418,10 @@ namespace BansheeEngine
 				element->_setWidgetDepth(widgetDepth);
 				element->_setAreaDepth(areaDepth);
 
-				RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
+				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				element->_setClipRect(elemClipRect);
 
-				RectI newClipRect(offset.x, offset.y, childArea.width, childArea.height);
+				Rect2I newClipRect(offset.x, offset.y, childArea.width, childArea.height);
 				newClipRect.clip(clipRect);
 				element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, areaDepth);
 
@@ -431,7 +431,7 @@ namespace BansheeEngine
 			{
 				GUILayout* layout = static_cast<GUILayout*>(child);
 
-				RectI newClipRect(childArea.x, childArea.y, width, childArea.height);
+				Rect2I newClipRect(childArea.x, childArea.y, width, childArea.height);
 				newClipRect.clip(clipRect);
 				layout->_updateLayoutInternal(childArea.x, childArea.y, width, childArea.height, newClipRect, widgetDepth, areaDepth);
 

+ 5 - 5
BansheeEngine/Source/BsGUIManager.cpp

@@ -12,7 +12,7 @@
 #include "BsUtil.h"
 #include "BsRenderWindowManager.h"
 #include "BsPlatform.h"
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsCoreApplication.h"
 #include "BsException.h"
 #include "BsInput.h"
@@ -57,7 +57,7 @@ namespace BansheeEngine
 		GUIMaterialInfo matInfo;
 		UINT32 numQuads;
 		UINT32 depth;
-		RectI bounds;
+		Rect2I bounds;
 		Vector<GUIGroupElement> elements;
 	};
 
@@ -411,7 +411,7 @@ namespace BansheeEngine
 				UINT32 renderElemIdx = elem.renderElement;
 				UINT32 elemDepth = guiElem->_getRenderElementDepth(renderElemIdx);
 
-				RectI tfrmedBounds = guiElem->_getClippedBounds();
+				Rect2I tfrmedBounds = guiElem->_getClippedBounds();
 				tfrmedBounds.transform(guiElem->_getParentWidget()->SO()->getWorldTfrm());
 
 				const GUIMaterialInfo& matInfo = guiElem->getMaterial(renderElemIdx);
@@ -455,7 +455,7 @@ namespace BansheeEngine
 						UINT32 startDepth = elemDepth;
 						UINT32 endDepth = group.depth;
 
-						RectI potentialGroupBounds = group.bounds;
+						Rect2I potentialGroupBounds = group.bounds;
 						potentialGroupBounds.encapsulate(tfrmedBounds);
 
 						bool foundOverlap = false;
@@ -1426,7 +1426,7 @@ namespace BansheeEngine
 			const Matrix4& worldTfrm = bridgeElement->_getParentWidget()->SO()->getWorldTfrm();
 
 			Vector4 vecLocalPos = worldTfrm.inverse().multiply3x4(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
-			RectI bridgeBounds = bridgeElement->_getCachedBounds();
+			Rect2I bridgeBounds = bridgeElement->_getCachedBounds();
 
 			// Find coordinates relative to the bridge element
 			float x = vecLocalPos.x - (float)bridgeBounds.x;

+ 7 - 7
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -34,7 +34,7 @@ namespace BansheeEngine
 
 	void GUIScrollArea::updateClippedBounds()
 	{
-		RectI bounds(0, 0, mWidth, mHeight);
+		Rect2I bounds(0, 0, mWidth, mHeight);
 		bounds.clip(mClipRect);
 		bounds.x += mOffset.x;
 		bounds.y += mOffset.y;
@@ -43,7 +43,7 @@ namespace BansheeEngine
 	}
 
 	void GUIScrollArea::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{
 		// We want elements to use their optimal height, since scroll area
 		// technically provides "infinite" space
@@ -67,7 +67,7 @@ namespace BansheeEngine
 		mClippedContentWidth = width;
 		mClippedContentHeight = height;
 
-		RectI layoutClipRect = clipRect;
+		Rect2I layoutClipRect = clipRect;
 		bool addHorzScrollbar = (mHorzBarType == ScrollBarType::ShowIfDoesntFit && mContentWidth > mWidth) || 
 			mHorzBarType == ScrollBarType::AlwaysShow && mHorzBarType != ScrollBarType::NeverShow;
 
@@ -176,11 +176,11 @@ namespace BansheeEngine
 			mVertScroll->_setWidgetDepth(widgetDepth);
 
 			UINT32 clippedScrollbarWidth = std::min(width, ScrollBarWidth);
-			RectI elemClipRect(0, 0, clippedScrollbarWidth, clipRect.height);
+			Rect2I elemClipRect(0, 0, clippedScrollbarWidth, clipRect.height);
 			mVertScroll->_setClipRect(elemClipRect);
 
 			// This element is not a child of any layout so we treat it as a root element
-			RectI scrollBarLayoutClipRect(clipRect.x + scrollBarOffset, clipRect.y, clippedScrollbarWidth, clipRect.height);
+			Rect2I scrollBarLayoutClipRect(clipRect.x + scrollBarOffset, clipRect.y, clippedScrollbarWidth, clipRect.height);
 			mVertScroll->_updateLayout(offset.x, offset.y, ScrollBarWidth, scrollBarHeight, scrollBarLayoutClipRect, widgetDepth, areaDepth);
 
 			// Set new handle size and update position to match the new size
@@ -233,11 +233,11 @@ namespace BansheeEngine
 			mHorzScroll->_setWidgetDepth(widgetDepth);
 
 			UINT32 clippedScrollbarHeight = std::min(height, ScrollBarWidth);
-			RectI elemClipRect(0, 0, clipRect.width, clippedScrollbarHeight);
+			Rect2I elemClipRect(0, 0, clipRect.width, clippedScrollbarHeight);
 			mHorzScroll->_setClipRect(elemClipRect);
 
 			// This element is not a child of any layout so we treat it as a root element
-			RectI scrollBarLayoutClipRect(clipRect.x, clipRect.y + scrollBarOffset, clipRect.width, clippedScrollbarHeight);
+			Rect2I scrollBarLayoutClipRect(clipRect.x, clipRect.y + scrollBarOffset, clipRect.width, clippedScrollbarHeight);
 			mHorzScroll->_updateLayout(offset.x, offset.y, scrollBarWidth, ScrollBarWidth, scrollBarLayoutClipRect, widgetDepth, areaDepth);
 
 			// Set new handle size and update position to match the new size

+ 1 - 1
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -98,7 +98,7 @@ namespace BansheeEngine
 
 	void GUIScrollBar::updateClippedBounds()
 	{
-		mClippedBounds = RectI(0, 0, 0, 0); // We don't want any mouse input for this element. This is just a container.
+		mClippedBounds = Rect2I(0, 0, 0, 0); // We don't want any mouse input for this element. This is just a container.
 	}
 
 	Vector2I GUIScrollBar::_getOptimalSize() const

+ 3 - 3
BansheeEngine/Source/BsGUIScrollBarHandle.cpp

@@ -111,9 +111,9 @@ namespace BansheeEngine
 
 	void GUIScrollBarHandle::updateClippedBounds()
 	{
-		mClippedBounds = RectI(mOffset.x, mOffset.y, mWidth, mHeight);
+		mClippedBounds = Rect2I(mOffset.x, mOffset.y, mWidth, mHeight);
 
-		RectI localClipRect(mClipRect.x + mOffset.x, mClipRect.y + mOffset.y, mClipRect.width, mClipRect.height);
+		Rect2I localClipRect(mClipRect.x + mOffset.x, mClipRect.y + mOffset.y, mClipRect.width, mClipRect.height);
 		mClippedBounds.clip(localClipRect);
 	}
 
@@ -136,7 +136,7 @@ namespace BansheeEngine
 		else
 			offset.y += Math::floorToInt(mHandlePos);
 
-		RectI clipRect = mClipRect;
+		Rect2I clipRect = mClipRect;
 		if(mHorizontal)
 			clipRect.x -= Math::floorToInt(mHandlePos);
 		else

+ 1 - 1
BansheeEngine/Source/BsGUIViewport.cpp

@@ -57,7 +57,7 @@ namespace BansheeEngine
 
 	void GUIViewport::updateClippedBounds()
 	{
-		RectI mBounds = RectI(0, 0, mWidth, mHeight);
+		Rect2I mBounds = Rect2I(0, 0, mWidth, mHeight);
 		mBounds.clip(mClipRect);
 		mBounds.x += mOffset.x;
 		mBounds.y += mOffset.y;

+ 1 - 1
BansheeEngine/Source/BsGUIWidget.cpp

@@ -257,7 +257,7 @@ namespace BansheeEngine
 
 		for(auto& elem : mElements)
 		{
-			RectI elemBounds = elem->_getClippedBounds();
+			Rect2I elemBounds = elem->_getClippedBounds();
 			mBounds.encapsulate(elemBounds);
 		}
 	}

+ 6 - 6
BansheeEngine/Source/BsSprite.cpp

@@ -14,9 +14,9 @@ namespace BansheeEngine
 		clearMesh();
 	}
 
-	RectI Sprite::getBounds(const Vector2I& offset, const RectI& clipRect) const 
+	Rect2I Sprite::getBounds(const Vector2I& offset, const Rect2I& clipRect) const 
 	{
-		RectI bounds = mBounds;
+		Rect2I bounds = mBounds;
 
 		if(clipRect.width > 0 && clipRect.height > 0)
 			bounds.clip(clipRect);
@@ -43,7 +43,7 @@ namespace BansheeEngine
 	}
 
 	UINT32 Sprite::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
-		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx, const Vector2I& offset, const RectI& clipRect, bool clip) const
+		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx, const Vector2I& offset, const Rect2I& clipRect, bool clip) const
 	{
 		auto renderElem = mCachedRenderElements.at(renderElementIdx);
 
@@ -219,7 +219,7 @@ namespace BansheeEngine
 
 		if(!foundStartingPoint)
 		{
-			mBounds = RectI(0, 0, 0, 0);
+			mBounds = Rect2I(0, 0, 0, 0);
 			return;
 		}
 
@@ -238,7 +238,7 @@ namespace BansheeEngine
 			}
 		}
 
-		mBounds = RectI((int)min.x, (int)min.y, (int)(max.x - min.x), (int)(max.y - min.y));
+		mBounds = Rect2I((int)min.x, (int)min.y, (int)(max.x - min.x), (int)(max.y - min.y));
 	}
 
 	void Sprite::clearMesh() const
@@ -270,7 +270,7 @@ namespace BansheeEngine
 	// This will only properly clip an array of quads
 	// Vertices in the quad must be in a specific order: top left, top right, bottom left, bottom right
 	// (0, 0) represents top left of the screen
-	void Sprite::clipToRect(UINT8* vertices, UINT8* uv, UINT32 numQuads, UINT32 vertStride, const RectI& clipRect)
+	void Sprite::clipToRect(UINT8* vertices, UINT8* uv, UINT32 numQuads, UINT32 vertStride, const Rect2I& clipRect)
 	{
 		float left = (float)clipRect.x;
 		float right = (float)clipRect.x + clipRect.width;

+ 1 - 1
BansheeGLRenderSystem/Include/BsGLRenderSystem.h

@@ -207,7 +207,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Clear a part of a render target.
 		 */
-		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const RectI& clearArea = RectI::EMPTY);
+		void clearArea(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0, const Rect2I& clearArea = Rect2I::EMPTY);
 
 		/**
 		 * @brief	Set up clip planes against which all geometry will get clipped.

+ 3 - 3
BansheeGLRenderSystem/Source/BsGLRenderSystem.cpp

@@ -708,19 +708,19 @@ namespace BansheeEngine
 			return;
 
 		const RenderTargetProperties& rtProps = mActiveRenderTarget->getCore()->getProperties();
-		RectI clearRect(0, 0, rtProps.getWidth(), rtProps.getHeight());
+		Rect2I clearRect(0, 0, rtProps.getWidth(), rtProps.getHeight());
 
 		clearArea(buffers, color, depth, stencil, clearRect);
 	}
 
 	void GLRenderSystem::clearViewport(UINT32 buffers, const Color& color, float depth, UINT16 stencil)
 	{
-		RectI clearRect(mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight);
+		Rect2I clearRect(mViewportLeft, mViewportTop, mViewportWidth, mViewportHeight);
 
 		clearArea(buffers, color, depth, stencil, clearRect);
 	}
 
-	void GLRenderSystem::clearArea(UINT32 buffers, const Color& color, float depth, UINT16 stencil, const RectI& clearRect)
+	void GLRenderSystem::clearArea(UINT32 buffers, const Color& color, float depth, UINT16 stencil, const Rect2I& clearRect)
 	{
 		THROW_IF_NOT_CORE_THREAD;
 

+ 10 - 4
BansheeUtility/BansheeUtility.vcxproj

@@ -246,7 +246,10 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsBounds.cpp" />
+    <ClCompile Include="Source\BsCapsule.cpp" />
     <ClCompile Include="Source\BsConvexVolume.cpp" />
+    <ClCompile Include="Source\BsLineSegment3.cpp" />
+    <ClCompile Include="Source\BsRect3.cpp" />
     <ClCompile Include="Source\BsTaskScheduler.cpp" />
     <ClCompile Include="Source\BsTestOutput.cpp" />
     <ClCompile Include="Source\BsTestSuite.cpp" />
@@ -258,7 +261,7 @@
     <ClCompile Include="Source\BsFrameAlloc.cpp" />
     <ClCompile Include="Source\BsMemorySerializer.cpp" />
     <ClCompile Include="Source\BsPath.cpp" />
-    <ClCompile Include="Source\BsRectF.cpp" />
+    <ClCompile Include="Source\BsRect2.cpp" />
     <ClCompile Include="Source\BsTorus.cpp" />
     <ClCompile Include="Source\BsVector2I.cpp" />
     <ClCompile Include="Source\BsManagedDataBlock.cpp" />
@@ -266,7 +269,7 @@
     <ClCompile Include="Source\BsMemStack.cpp" />
     <ClCompile Include="Source\BsRadian.cpp" />
     <ClCompile Include="Source\BsRay.cpp" />
-    <ClCompile Include="Source\BsRectI.cpp" />
+    <ClCompile Include="Source\BsRect2I.cpp" />
     <ClCompile Include="Source\BsSphere.cpp" />
     <ClCompile Include="Source\BsStringTable.cpp" />
     <ClCompile Include="Source\BsTexAtlasGenerator.cpp" />
@@ -274,8 +277,11 @@
     <ClCompile Include="Source\Win32\BsTimer.cpp" />
     <ClInclude Include="Include\BsAny.h" />
     <ClInclude Include="Include\BsBounds.h" />
+    <ClInclude Include="Include\BsCapsule.h" />
     <ClInclude Include="Include\BsConvexVolume.h" />
     <ClInclude Include="Include\BsEvent.h" />
+    <ClInclude Include="Include\BsLineSegment3.h" />
+    <ClInclude Include="Include\BsRect3.h" />
     <ClInclude Include="Include\BsSpinLock.h" />
     <ClInclude Include="Include\BsTaskScheduler.h" />
     <ClInclude Include="Include\BsTestOutput.h" />
@@ -294,7 +300,7 @@
     <ClInclude Include="Include\BsFileSystem.h" />
     <ClInclude Include="Include\BsFrameAlloc.h" />
     <ClInclude Include="Include\BsMemorySerializer.h" />
-    <ClInclude Include="Include\BsRectF.h" />
+    <ClInclude Include="Include\BsRect2.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsTorus.h" />
     <ClInclude Include="Include\BsVector2I.h" />
@@ -306,7 +312,7 @@
     <ClInclude Include="Include\BsModule.h" />
     <ClInclude Include="Include\BsPath.h" />
     <ClInclude Include="Include\BsRadian.h" />
-    <ClInclude Include="Include\BsRectI.h" />
+    <ClInclude Include="Include\BsRect2I.h" />
     <ClInclude Include="Include\BsRTTIField.h" />
     <ClInclude Include="Include\BsRTTIManagedDataBlockField.h" />
     <ClInclude Include="Include\BsRTTIPlainField.h" />

+ 30 - 12
BansheeUtility/BansheeUtility.vcxproj.filters

@@ -213,12 +213,6 @@
     <ClInclude Include="Include\BsRay.h">
       <Filter>Header Files\Math</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsRectF.h">
-      <Filter>Header Files\Math</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRectI.h">
-      <Filter>Header Files\Math</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsSphere.h">
       <Filter>Header Files\Math</Filter>
     </ClInclude>
@@ -255,6 +249,21 @@
     <ClInclude Include="Include\BsTorus.h">
       <Filter>Header Files\Math</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsLineSegment3.h">
+      <Filter>Header Files\Math</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRect3.h">
+      <Filter>Header Files\Math</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRect2.h">
+      <Filter>Header Files\Math</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRect2I.h">
+      <Filter>Header Files\Math</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCapsule.h">
+      <Filter>Header Files\Math</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsThreadPool.cpp">
@@ -368,12 +377,6 @@
     <ClCompile Include="Source\BsRay.cpp">
       <Filter>Source Files\Math</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsRectF.cpp">
-      <Filter>Source Files\Math</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsRectI.cpp">
-      <Filter>Source Files\Math</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsSphere.cpp">
       <Filter>Source Files\Math</Filter>
     </ClCompile>
@@ -407,5 +410,20 @@
     <ClCompile Include="Source\BsTorus.cpp">
       <Filter>Source Files\Math</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsRect3.cpp">
+      <Filter>Source Files\Math</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRect2.cpp">
+      <Filter>Source Files\Math</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRect2I.cpp">
+      <Filter>Source Files\Math</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsLineSegment3.cpp">
+      <Filter>Source Files\Math</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsCapsule.cpp">
+      <Filter>Source Files\Math</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 41 - 0
BansheeUtility/Include/BsCapsule.h

@@ -0,0 +1,41 @@
+#pragma once
+
+#include "BsPrerequisitesUtil.h"
+#include "BsVector3.h"
+#include "BsLineSegment3.h"
+
+namespace BansheeEngine
+{
+	/**
+	* @brief	Represents a capsule represented by a line segment and
+	*			a radius.
+	*/
+	class BS_UTILITY_EXPORT Capsule
+	{
+	public:
+		Capsule(const LineSegment3& segment, float radius);
+
+		/**
+		 * @brief	Ray/capsule intersection.
+		 *
+		 * @return	Boolean result and distance to the nearest intersection point.
+		 */
+		std::pair<bool, float> intersects(const Ray& ray) const;
+
+		/**
+		 * @brief	Returns the line segment along which the capsule lies.
+		 *			All capsule points are at equal distance from this segment.
+		 */
+		const LineSegment3& getSegment() const { return mSegment; }
+
+		/**
+		 * @brief	Returns the radius of the capsule. It defines the distance
+		 *			of the capsule from its line segment.
+		 */
+		float getRadius() const { return mRadius; }
+
+	private:
+		LineSegment3 mSegment;
+		float mRadius;
+	};
+}

+ 2 - 2
BansheeUtility/Include/BsFwdDeclUtil.h

@@ -33,8 +33,8 @@ namespace BansheeEngine
 	class Vector3;
 	class Vector4;
 	struct Vector2I;
-	class RectI;
-	class RectF;
+	class Rect2I;
+	class Rect2;
 	class Color;
 	class DynLib;
 	class DynLibManager;

+ 40 - 0
BansheeUtility/Include/BsLineSegment3.h

@@ -0,0 +1,40 @@
+#pragma once
+
+#include "BsPrerequisitesUtil.h"
+#include "BsVector3.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Represents a line segment in three dimensional space defined by
+	 *			a start and an end point.
+	 */
+	class BS_UTILITY_EXPORT LineSegment3
+	{
+	public:
+		LineSegment3(const Vector3& start, const Vector3& end);
+
+		/**
+		 * @brief	Find the nearest point on the line segment and the provided ray.
+		 *
+		 * @return	Set of nearest points and distance from the points. First
+		 *			nearest point is a point along the ray, while the second is along the
+		 *			line segment.
+		 *
+		 * @note	If segment and ray are parallel the set of points at the segment origin are returned.
+		 */
+		std::pair<std::array<Vector3, 2>, float> getNearestPoint(const Ray& ray) const;
+
+		/**
+		 * @brief	Returns the starting point of the line segment.
+		 */
+		const Vector3& getStart() const { return mStart; }
+
+		/**
+		 * @brief	Returns the ending point of the line segment.
+		 */
+		const Vector3& getEnd() const { return mEnd; }
+	private:
+		Vector3 mStart, mEnd;
+	};
+}

+ 9 - 9
BansheeUtility/Include/BsRectF.h → BansheeUtility/Include/BsRect2.h

@@ -8,11 +8,11 @@ namespace BansheeEngine
 	 * @brief	Represents a 2D rectangle using real values.
 	 * 			Rectangle is represented with an origin and size values.
 	 */
-	class BS_UTILITY_EXPORT RectF
+	class BS_UTILITY_EXPORT Rect2
 	{
 	public:
-		RectF();
-		RectF(float _x, float _y, float _width, float _height);
+		Rect2();
+		Rect2(float _x, float _y, float _width, float _height);
 
 		float x, y, width, height;
 
@@ -26,19 +26,19 @@ namespace BansheeEngine
 		 * 			Also returns true if the rectangles are contained within each other completely
 		 * 			(no intersecting edges).
 		 */
-		bool overlaps(const RectF& other) const;
+		bool overlaps(const Rect2& other) const;
 
 		/**
 		 * @brief	Extends this rectangle so that the provided rectangle is
 		 * 			completely contained within it.
 		 */
-		void encapsulate(const RectF& other);
+		void encapsulate(const Rect2& other);
 
 		/**
 		 * @brief	Clips current rectangle so that it does not overlap
 		 * 			the provided rectangle.
 		 */
-		void clip(const RectF& clipRect);
+		void clip(const Rect2& clipRect);
 
 		/**
 		 * @brief	Transforms the bounds by the given matrix.
@@ -49,16 +49,16 @@ namespace BansheeEngine
 		 */
 		void transform(const Matrix4& matrix);
 
-		inline bool operator== (const RectF& rhs) const
+		inline bool operator== (const Rect2& rhs) const
 		{
 			return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height;
 		}
 
-		inline bool operator!= (const RectF& rhs) const
+		inline bool operator!= (const Rect2& rhs) const
 		{
 			return !(*this == rhs);
 		}
 
-		static const RectF EMPTY;
+		static const Rect2 EMPTY;
 	};
 }

+ 9 - 9
BansheeUtility/Include/BsRectI.h → BansheeUtility/Include/BsRect2I.h

@@ -8,11 +8,11 @@ namespace BansheeEngine
 	 * @brief	Represents a 2D rectangle using integer values.
 	 * 			Rectangle is represented with an origin and size values.
 	 */
-	class BS_UTILITY_EXPORT RectI
+	class BS_UTILITY_EXPORT Rect2I
 	{
 	public:
-		RectI();
-		RectI(int _x, int _y, int _width, int _height);
+		Rect2I();
+		Rect2I(int _x, int _y, int _width, int _height);
 
 		int x, y, width, height;
 
@@ -26,19 +26,19 @@ namespace BansheeEngine
 		 * 			Also returns true if the rectangles are contained within each other completely
 		 * 			(no intersecting edges).
 		 */
-		bool overlaps(const RectI& other) const;
+		bool overlaps(const Rect2I& other) const;
 
 		/**
 		 * @brief	Extends this rectangle so that the provided rectangle is
 		 * 			completely contained within it.
 		 */
-		void encapsulate(const RectI& other);
+		void encapsulate(const Rect2I& other);
 
 		/**
 		 * @brief	Clips current rectangle so that it does not overlap
 		 * 			the provided rectangle.
 		 */
-		void clip(const RectI& clipRect);
+		void clip(const Rect2I& clipRect);
 
 		/**
 		 * @brief	Transforms the bounds by the given matrix.
@@ -49,16 +49,16 @@ namespace BansheeEngine
 		 */
 		void transform(const Matrix4& matrix);
 
-		inline bool operator== (const RectI& rhs) const
+		inline bool operator== (const Rect2I& rhs) const
 		{
 			return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height;
 		}
 
-		inline bool operator!= (const RectI& rhs) const
+		inline bool operator!= (const Rect2I& rhs) const
 		{
 			return !(*this == rhs);
 		}
 
-		static const RectI EMPTY;
+		static const Rect2I EMPTY;
 	};
 }

+ 46 - 0
BansheeUtility/Include/BsRect3.h

@@ -0,0 +1,46 @@
+#pragma once
+
+#include "BsPrerequisitesUtil.h"
+#include "BsVector3.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Represents a rectangle in three dimensional space.
+	 */
+	class BS_UTILITY_EXPORT Rect3
+	{
+	public:
+		Rect3(const Vector3& center, const std::array<Vector3, 2>& axes,
+			const std::array<float, 2>& extents);
+
+		/**
+		 * @brief	Find the nearest points of the provided ray and the rectangle.
+		 *
+		 * @return	A set of nearest points and nearest distance.
+		 *			First value in the set corresponds to nearest point on the ray, and the second to the nearest point on the rectangle.
+		 *			They are same in the case of intersection. When ray is parallel to the rectangle there are two sets of nearest points
+		 *			but only one the set nearest to the ray origin is returned.
+		 */
+		std::pair<std::array<Vector3, 2>, float> getNearestPoint(const Ray& ray) const;
+
+		/**
+		 * @brief	Find the nearest point on the rectangle to the provided point.
+		 *
+		 * @return	Nearest point and distance to nearest point.
+		 */
+		std::pair<Vector3, float> getNearestPoint(const Vector3& point) const;
+
+		/**
+		 * @brief	Ray/rectangle intersection.
+		 *
+		 * @return	Boolean result and distance to intersection point.
+		 */
+		std::pair<bool, float> intersects(const Ray& ray) const;
+
+	private:
+		Vector3 mCenter;
+		std::array<Vector3, 2> mAxes;
+		std::array<float, 2> mExtents;
+	};
+}

+ 1 - 0
BansheeUtility/Include/BsStdHeaders.h

@@ -24,6 +24,7 @@
 #include <deque>
 #include <queue>
 #include <bitset>
+#include <array>
 
 // Note - not in the original STL, but exists in SGI STL and STLport
 // For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html

+ 16 - 0
BansheeUtility/Include/BsVector3.h

@@ -383,6 +383,22 @@ namespace BansheeEngine
             return Vector3(*this - (2 * this->dot(normal) * normal));
         }
 
+		/**
+		 * @brief	Calculates two vectors orthonormal to the current vector, and
+		 *			normalizes the current vector if not already.
+		 */
+		void orthogonalComplement(Vector3& a, Vector3& b)
+		{
+			if (fabs(a.x) > fabs(a.y))
+				a = Vector3(-a.z, 0, a.x);
+			else
+				a = Vector3(0, a.z, -a.y);
+
+			b = cross(a);
+
+			orthonormalize(*this, a, b);
+		}
+
 		/**
 		 * @brief	Performs Gram-Schmidt orthonormalization
 		 */

+ 211 - 0
BansheeUtility/Source/BsCapsule.cpp

@@ -0,0 +1,211 @@
+#include "BsCapsule.h"
+#include "BsRay.h"
+
+namespace BansheeEngine
+{
+	Capsule::Capsule(const LineSegment3& segment, float radius)
+		:mSegment(segment), mRadius(radius)
+	{ }
+
+	std::pair<bool, float> Capsule::intersects(const Ray& ray) const
+	{
+		const Vector3& org = ray.getOrigin();
+		const Vector3& dir = ray.getDirection();
+
+		Vector3 segDir = mSegment.getEnd() - mSegment.getStart();
+		float segExtent = segDir.normalize() * 0.5f;
+		Vector3 segCenter = mSegment.getStart() + segDir * segExtent;
+
+		Vector3 basis[3];
+		basis[0] = segDir;
+		basis[0].orthogonalComplement(basis[1], basis[2]);
+
+		float rSqr = mRadius * mRadius;
+
+		Vector3 diff = org - segCenter;
+		Vector3 P(basis[1].dot(diff), basis[2].dot(diff), basis[0].dot(diff));
+
+		// Get the z-value, in capsule coordinates, of the incoming line's
+		// unit-length direction.
+		float dz = basis[0].dot(dir);
+		if (std::abs(dz) == 1.0f)
+		{
+			// The line is parallel to the capsule axis.  Determine whether the
+			// line intersects the capsule hemispheres.
+			float radialSqrDist = rSqr - P[0] * P[0] - P[1] * P[1];
+			if (radialSqrDist < 0.0f)
+			{
+				// The line is outside the cylinder of the capsule, so there is no
+				// intersection.
+				return std::make_pair(false, 0.0f);
+			}
+
+			// The line intersects the hemispherical caps.
+			float zOffset = std::sqrt(radialSqrDist) + segExtent;
+			if (dz > 0.0f)
+				return std::make_pair(true, -P[2] - zOffset);
+			else
+				return std::make_pair(true, P[2] - zOffset);
+		}
+
+		// Convert the incoming line unit-length direction to capsule coordinates.
+		Vector3 D(basis[1].dot(dir), basis[2].dot(dir), dz);
+
+		// Test intersection of line with infinite cylinder 
+		float a0 = P[0] * P[0] + P[1] * P[1] - rSqr;
+		float a1 = P[0] * D[0] + P[1] * D[1];
+		float a2 = D[0] * D[0] + D[1] * D[1];
+		float discr = a1*a1 - a0*a2;
+
+		if (discr < 0.0f)
+		{
+			// The line does not intersect the infinite cylinder.
+			return std::make_pair(false, 0.0f);
+		}
+
+		float root, inv, tValue, zValue;
+		float nearestT = std::numeric_limits<float>::max();
+		bool foundOneIntersection = false;
+
+		if (discr > 0.0f)
+		{
+			// The line intersects the infinite cylinder in two places.
+			root = std::sqrt(discr);
+			inv = 1.0f / a2;
+
+			tValue = (-a1 - root)*inv;
+			zValue = P[2] + tValue*D[2];
+			if (std::abs(zValue) <= segExtent)
+			{
+				nearestT = tValue;
+				foundOneIntersection = true;
+			}
+
+			tValue = (-a1 + root)*inv;
+			zValue = P[2] + tValue*D[2];
+			if (std::abs(zValue) <= segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+		}
+		else
+		{
+			// The line is tangent to the infinite cylinder but intersects the
+			// cylinder in a single point.
+			tValue = -a1 / a2;
+			zValue = P[2] + tValue*D[2];
+			if (std::abs(zValue) <= segExtent)
+				return std::make_pair(true, tValue);
+		}
+
+		// Test intersection with bottom hemisphere.
+		float PZpE = P[2] + segExtent;
+		a1 += PZpE*D[2];
+		a0 += PZpE*PZpE;
+		discr = a1*a1 - a0;
+		if (discr > 0)
+		{
+			root = sqrt(discr);
+			tValue = -a1 - root;
+			zValue = P[2] + tValue*D[2];
+			if (zValue <= -segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT < tValue ? nearestT : tValue);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+
+			tValue = -a1 + root;
+			zValue = P[2] + tValue*D[2];
+			if (zValue <= -segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT < tValue ? nearestT : tValue);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+		}
+		else if (discr == 0.0f)
+		{
+			tValue = -a1;
+			zValue = P[2] + tValue*D[2];
+			if (zValue <= -segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT < tValue ? nearestT : tValue);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+		}
+
+		// Test intersection with top hemisphere
+		a1 -= 2.0f*segExtent*D[2];
+		a0 -= 4.0f*segExtent*P[2];
+		discr = a1*a1 - a0;
+		if (discr > 0.0f)
+		{
+			root = sqrt(discr);
+			tValue = -a1 - root;
+			zValue = P[2] + tValue*D[2];
+			if (zValue >= segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT < tValue ? nearestT : tValue);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+
+			tValue = -a1 + root;
+			zValue = P[2] + tValue*D[2];
+			if (zValue >= segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT < tValue ? nearestT : tValue);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+		}
+		else if (discr == 0.0f)
+		{
+			tValue = -a1;
+			zValue = P[2] + tValue*D[2];
+			if (zValue >= segExtent)
+			{
+				if (foundOneIntersection)
+					return std::make_pair(true, nearestT < tValue ? nearestT : tValue);
+				else
+				{
+					nearestT = tValue;
+					foundOneIntersection = true;
+				}
+			}
+		}
+
+		if (foundOneIntersection)
+			return std::make_pair(true, nearestT);
+
+		return std::make_pair(false, 0.0f);
+	}
+}

+ 79 - 0
BansheeUtility/Source/BsLineSegment3.cpp

@@ -0,0 +1,79 @@
+#include "BsLineSegment3.h"
+#include "BsRay.h"
+
+namespace BansheeEngine
+{
+	LineSegment3::LineSegment3(const Vector3& start, const Vector3& end)
+		:mStart(start), mEnd(end)
+	{ 
+
+	}
+
+	std::pair<std::array<Vector3, 2>, float>  LineSegment3::getNearestPoint(const Ray& ray) const
+	{
+		const Vector3& org = ray.getOrigin();
+		const Vector3& dir = ray.getDirection();
+
+		Vector3 segDir = mEnd - mStart;
+		float segExtent = segDir.normalize() * 0.5f;
+		Vector3 segCenter = mStart + segDir * segExtent;
+
+		Vector3 diff = org - segCenter;
+		float a01 = -dir.dot(segDir);
+		float b0 = diff.dot(dir);
+		float c = diff.dot(diff);
+		float det = fabs(1.0f - a01*a01);
+
+		float s0, s1;
+		float sqrDistance;
+		if (det > 0.0f) // Not parallel
+		{
+			
+			float b1 = -diff.dot(segDir);
+			s1 = a01 * b0 - b1;
+			float extDet = segExtent * det;
+
+			if (s1 >= -extDet)
+			{
+				if (s1 <= extDet) // Interior of the segment and interior of the ray are closest
+				{
+					float invDet = 1.0f / det;
+					s0 = (a01*b1 - b0)*invDet;
+					s1 *= invDet;
+
+					sqrDistance = s0*(s0 + a01*s1 + 2.0f*b0) +
+						s1*(a01*s0 + s1 + 2.0f*b1) + c;
+				}
+				else // Segment end and interior of the ray are closest
+				{
+					s1 = segExtent;
+					s0 = -(a01*s1 + b0);
+					sqrDistance = -s0*s0 + s1*(s1 + (2.0f)*b1) + c;
+				}
+			}
+			else // Segment start and interior of the ray are closest
+			{
+				s1 = -segExtent;
+				s0 = -(a01*s1 + b0);
+				sqrDistance = -s0*s0 + s1*(s1 + (2.0f)*b1) + c;
+			}
+		}
+		else // Parallel
+		{
+			s1 = 0;
+			s0 = -b0;
+			sqrDistance = b0*s0 + c;
+		}
+
+		if (sqrDistance < 0.0f)
+			sqrDistance = 0.0f;
+
+		float distance = std::sqrt(sqrDistance);
+
+		std::array<Vector3, 2> nearestPoints;
+		nearestPoints[0] = org + s0 * dir;
+		nearestPoints[1] = segCenter + s1 * segDir;
+
+		return std::make_pair(nearestPoints, distance);
+	}
+}

+ 9 - 9
BansheeUtility/Source/BsRectF.cpp → BansheeUtility/Source/BsRect2.cpp

@@ -1,21 +1,21 @@
-#include "BsRectF.h"
+#include "BsRect2.h"
 #include "BsVector2.h"
 #include "BsMatrix4.h"
 #include "BsMath.h"
 
 namespace BansheeEngine
 {
-	const RectF RectF::EMPTY = RectF();
+	const Rect2 Rect2::EMPTY = Rect2();
 
-	RectF::RectF()
+	Rect2::Rect2()
 		:x(0), y(0), width(0), height(0)
 	{ }
 
-	RectF::RectF(float _x, float _y, float _width, float _height)
+	Rect2::Rect2(float _x, float _y, float _width, float _height)
 		:x(_x), y(_y), width(_width), height(_height)
 	{ }
 
-	bool RectF::contains(const Vector2& point) const
+	bool Rect2::contains(const Vector2& point) const
 	{
 		if(point.x >= x && point.x <= (x + width))
 		{
@@ -26,7 +26,7 @@ namespace BansheeEngine
 		return false;
 	}
 
-	bool RectF::overlaps(const RectF& other) const
+	bool Rect2::overlaps(const Rect2& other) const
 	{
 		float otherRight = other.x + other.width;
 		float myRight = x + width;
@@ -41,7 +41,7 @@ namespace BansheeEngine
 		return false;
 	}
 
-	void RectF::encapsulate(const RectF& other)
+	void Rect2::encapsulate(const Rect2& other)
 	{
 		float myRight = x + width;
 		float myBottom = y + height;
@@ -65,7 +65,7 @@ namespace BansheeEngine
 			height = myBottom - y;
 	}
 
-	void RectF::clip(const RectF& clipRect)
+	void Rect2::clip(const Rect2& clipRect)
 	{
 		float newLeft = std::max(x, clipRect.x);
 		float newTop = std::max(y, clipRect.y);
@@ -79,7 +79,7 @@ namespace BansheeEngine
 		height = newBottom - newTop;
 	}
 
-	void RectF::transform(const Matrix4& matrix)
+	void Rect2::transform(const Matrix4& matrix)
 	{
 		Vector4 verts[4];
 		verts[0] = Vector4(x, y, 0.0f, 1.0f);

+ 9 - 9
BansheeUtility/Source/BsRectI.cpp → BansheeUtility/Source/BsRect2I.cpp

@@ -1,21 +1,21 @@
-#include "BsRectI.h"
+#include "BsRect2I.h"
 #include "BsVector2I.h"
 #include "BsMatrix4.h"
 #include "BsMath.h"
 
 namespace BansheeEngine
 {
-	const RectI RectI::EMPTY = RectI();
+	const Rect2I Rect2I::EMPTY = Rect2I();
 
-	RectI::RectI()
+	Rect2I::Rect2I()
 		:x(0), y(0), width(0), height(0)
 	{ }
 
-	RectI::RectI(int _x, int _y, int _width, int _height)
+	Rect2I::Rect2I(int _x, int _y, int _width, int _height)
 		:x(_x), y(_y), width(_width), height(_height)
 	{ }
 
-	bool RectI::contains(const Vector2I& point) const
+	bool Rect2I::contains(const Vector2I& point) const
 	{
 		if(point.x >= x && point.x < (x + width))
 		{
@@ -26,7 +26,7 @@ namespace BansheeEngine
 		return false;
 	}
 
-	bool RectI::overlaps(const RectI& other) const
+	bool Rect2I::overlaps(const Rect2I& other) const
 	{
 		INT32 otherRight = other.x + other.width;
 		INT32 myRight = x + width;
@@ -41,7 +41,7 @@ namespace BansheeEngine
 		return false;
 	}
 
-	void RectI::encapsulate(const RectI& other)
+	void Rect2I::encapsulate(const Rect2I& other)
 	{
 		int myRight = x + width;
 		int myBottom = y + height;
@@ -65,7 +65,7 @@ namespace BansheeEngine
 			height = myBottom - y;
 	}
 
-	void RectI::clip(const RectI& clipRect)
+	void Rect2I::clip(const Rect2I& clipRect)
 	{
 		int newLeft = std::max(x, clipRect.x);
 		int newTop = std::max(y, clipRect.y);
@@ -79,7 +79,7 @@ namespace BansheeEngine
 		height = std::max(0, newBottom - newTop);
 	}
 
-	void RectI::transform(const Matrix4& matrix)
+	void Rect2I::transform(const Matrix4& matrix)
 	{
 		Vector4 verts[4];
 		verts[0] = Vector4((float)x, (float)y, 0.0f, 1.0f);

+ 153 - 0
BansheeUtility/Source/BsRect3.cpp

@@ -0,0 +1,153 @@
+#include "BsRect3.h"
+#include "BsRay.h"
+#include "BsLineSegment3.h"
+
+namespace BansheeEngine
+{
+	Rect3::Rect3(const Vector3& center, const std::array<Vector3, 2>& axes,
+		const std::array<float, 2>& extents)
+		:mCenter(center), mAxes(axes), mExtents(extents)
+	{
+
+	}
+
+	std::pair<std::array<Vector3, 2>, float> Rect3::getNearestPoint(const Ray& ray) const
+	{
+		const Vector3& org = ray.getOrigin();
+		const Vector3& dir = ray.getDirection();
+
+		bool foundNearest = false;
+		float t = 0.0f;
+		std::array<Vector3, 2> nearestPoints;
+		float distance = 0.0f;
+
+		// Check if Ray intersects the rectangle
+		auto intersectResult = intersects(ray);
+		if (intersectResult.first)
+		{
+			t = intersectResult.second;
+
+			nearestPoints[0] = org + dir * t;
+			nearestPoints[1] = nearestPoints[0]; // Just one point of intersection
+			foundNearest = true;
+		}
+
+		// Ray is either passing next to the rectangle or parallel to it, 
+		// compare ray to 4 edges of the rectangle
+		if (!foundNearest)
+		{
+			Vector3 scaledAxes[2];
+			scaledAxes[0] = mExtents[0] * mAxes[0];
+			scaledAxes[1] = mExtents[1] * mAxes[1];
+
+			distance = std::numeric_limits<float>::max();
+			for (UINT32 i = 0; i < 2; i++)
+			{
+				for (UINT32 j = 0; j < 2; j++)
+				{
+					float sign = (float)(2 * j - 1);
+					Vector3 segCenter = mCenter + sign * scaledAxes[i];
+					Vector3 segStart = segCenter - scaledAxes[1 - i];
+					Vector3 segEnd = segCenter + scaledAxes[1 - i];
+
+					LineSegment3 segment(segStart, segEnd);
+					auto segResult = segment.getNearestPoint(ray);
+
+					if (segResult.second < distance)
+					{
+						nearestPoints = segResult.first;
+						distance = segResult.second;
+					}
+				}
+			}
+		}
+
+		// Front of the ray is nearest, use found points
+		if (t >= 0.0f)
+		{
+			// Do nothing, we already have the points
+		}
+		else // Rectangle is behind the ray origin, find nearest point to origin
+		{
+			auto nearestPointToOrg = getNearestPoint(org);
+
+			nearestPoints[0] = org;
+			nearestPoints[1] = nearestPointToOrg.first;
+			distance = nearestPointToOrg.second;
+		}
+
+		return std::make_pair(nearestPoints, distance);
+	}
+
+	std::pair<Vector3, float> Rect3::getNearestPoint(const Vector3& point) const
+	{
+		Vector3 diff = mCenter - point;
+		float b0 = diff.dot(mAxes[0]);
+		float b1 = diff.dot(mAxes[1]);
+		float s0 = -b0, s1 = -b1;
+		float sqrDistance = diff.dot(diff);
+
+		if (s0 < -mExtents[0])
+			s0 = -mExtents[0];
+		else if (s0 > mExtents[0])
+			s0 = mExtents[0];
+
+		sqrDistance += s0*(s0 + 2.0f*b0);
+
+		if (s1 < -mExtents[1])
+			s1 = -mExtents[1];
+		else if (s1 > mExtents[1])
+			s1 = mExtents[1];
+
+		sqrDistance += s1*(s1 + 2.0f*b1);
+
+		if (sqrDistance < 0.0f)
+			sqrDistance = 0.0f;
+
+		float dist = std::sqrt(sqrDistance);
+		Vector3 nearestPoint = mCenter + s0 * mAxes[0] + s1 * mAxes[1];
+
+		return std::make_pair(nearestPoint, dist);
+	}
+
+	std::pair<bool, float> Rect3::intersects(const Ray& ray) const
+	{
+		const Vector3& org = ray.getOrigin();
+		const Vector3& dir = ray.getDirection();
+
+		Vector3 normal = mAxes[0].cross(mAxes[1]);
+		float NdotD = normal.dot(ray.getDirection());
+		if (fabs(NdotD) > 0.0f)
+		{
+			Vector3 diff = ray.getOrigin() - mCenter;
+			Vector3 basis[3];
+
+			basis[0] = ray.getDirection();
+			basis[0].orthogonalComplement(basis[1], basis[2]);
+
+			float UdD0 = basis[1].dot(mAxes[0]);
+			float UdD1 = basis[1].dot(mAxes[1]);
+			float UdPmC = basis[1].dot(diff);
+			float VdD0 = basis[2].dot(mAxes[0]);
+			float VdD1 = basis[2].dot(mAxes[1]);
+			float VdPmC = basis[2].dot(diff);
+			float invDet = 1.0f / (UdD0*VdD1 - UdD1*VdD0);
+
+			float s0 = (VdD1*UdPmC - UdD1*VdPmC)*invDet;
+			float s1 = (UdD0*VdPmC - VdD0*UdPmC)*invDet;
+
+			if (fabs(s0) <= mExtents[0] && fabs(s1) <= mExtents[1])
+			{
+				float DdD0 = dir.dot(mAxes[0]);
+				float DdD1 = dir.dot(mAxes[1]);
+				float DdDiff = dir.dot(diff);
+
+				float t = s0 * DdD0 + s1 * DdD1 - DdDiff;
+
+				return std::make_pair(true, t);
+			}
+		}
+
+		return std::make_pair(false, 0.0f);
+	}
+}

+ 3 - 3
MBansheeEngine/GUI/GUILayoutUtility.cs

@@ -15,9 +15,9 @@ namespace BansheeEngine
             return output;
         }
 
-        public static RectI CalculateBounds(GUIElement element)
+        public static Rect2I CalculateBounds(GUIElement element)
         {
-            RectI output;
+            Rect2I output;
             Internal_CalculateBounds(element.GetCachedPtr(), out output);
             return output;
         }
@@ -26,6 +26,6 @@ namespace BansheeEngine
         private static extern void Internal_CalculateOptimalSize(IntPtr element, out Vector2I output);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CalculateBounds(IntPtr element, out RectI output);
+        private static extern void Internal_CalculateBounds(IntPtr element, out Rect2I output);
     }
 }

+ 1 - 1
MBansheeEngine/MBansheeEngine.csproj

@@ -82,7 +82,7 @@
     <Compile Include="Math\Matrix3.cs" />
     <Compile Include="Math\Matrix4.cs" />
     <Compile Include="Math\Radian.cs" />
-    <Compile Include="Math\RectI.cs" />
+    <Compile Include="Math\Rect2I.cs" />
     <Compile Include="Math\Vector2I.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 6 - 6
MBansheeEngine/Math/RectI.cs → MBansheeEngine/Math/Rect2I.cs

@@ -7,9 +7,9 @@ using System.Text;
 namespace BansheeEngine
 {
     [StructLayout(LayoutKind.Sequential)]
-    public class RectI
+    public class Rect2I
     {
-        public RectI(int x, int y, int width, int height)
+        public Rect2I(int x, int y, int width, int height)
         {
             this.x = x;
             this.y = y;
@@ -17,12 +17,12 @@ namespace BansheeEngine
             this.height = height;
         }
 
-		public static bool operator== (RectI lhs, RectI rhs)
+		public static bool operator== (Rect2I lhs, Rect2I rhs)
 		{
 			return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height;
 		}
 
-		public static bool operator!= (RectI lhs, RectI rhs)
+		public static bool operator!= (Rect2I lhs, Rect2I rhs)
 		{
 			return !(lhs == rhs);
 		}
@@ -40,10 +40,10 @@ namespace BansheeEngine
 
         public override bool Equals(object other)
         {
-            if (!(other is RectI))
+            if (!(other is Rect2I))
                 return false;
 
-            RectI rect = (RectI)other;
+            Rect2I rect = (Rect2I)other;
             if (x.Equals(rect.x) && y.Equals(rect.y) && width.Equals(rect.width) && height.Equals(rect.height))
                 return true;
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio