Browse Source

Removed Point class and replaced it with existing Int2

Marko Pintera 12 years ago
parent
commit
638d7bcd6c

+ 1 - 1
BansheeEngine/Include/BsImageSprite.h

@@ -12,7 +12,7 @@ namespace BansheeEngine
 			borderTop(0), borderBottom(0)
 			borderTop(0), borderBottom(0)
 		{ }
 		{ }
 
 
-		CM::Point offset;
+		CM::Int2 offset;
 		UINT32 width;
 		UINT32 width;
 		UINT32 height;
 		UINT32 height;
 		CM::Rect clipRect;
 		CM::Rect clipRect;

+ 2 - 2
BansheeEngine/Include/BsSprite.h

@@ -1,7 +1,7 @@
 #pragma once
 #pragma once
 
 
 #include "BsPrerequisites.h"
 #include "BsPrerequisites.h"
-#include "CmPoint.h"
+#include "CmInt2.h"
 #include "CmRect.h"
 #include "CmRect.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
@@ -98,6 +98,6 @@ namespace BansheeEngine
 		void clearMesh() const;
 		void clearMesh() const;
 
 
 		void clipToRect(CM::Vector2* vertices, CM::Vector2* uv, UINT32 numQuads, const CM::Rect& clipRect) const;
 		void clipToRect(CM::Vector2* vertices, CM::Vector2* uv, UINT32 numQuads, const CM::Rect& clipRect) const;
-		CM::Point getAnchorOffset(SpriteAnchor anchor, UINT32 width, UINT32 height) const;
+		CM::Int2 getAnchorOffset(SpriteAnchor anchor, UINT32 width, UINT32 height) const;
 	};
 	};
 }
 }

+ 1 - 1
BansheeEngine/Include/BsTextSprite.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 			horzAlign(THA_Left), vertAlign(TVA_Top), wordWrap(false)
 			horzAlign(THA_Left), vertAlign(TVA_Top), wordWrap(false)
 		{ }
 		{ }
 
 
-		CM::Point offset;
+		CM::Int2 offset;
 		UINT32 width;
 		UINT32 width;
 		UINT32 height;
 		UINT32 height;
 		CM::Rect clipRect;
 		CM::Rect clipRect;

+ 0 - 1
BansheeEngine/Source/BsGUILabel.cpp

@@ -27,7 +27,6 @@ namespace BansheeEngine
 		mDesc.clipRect = Rect(0, 0, fixedWidth, fixedHeight);
 		mDesc.clipRect = Rect(0, 0, fixedWidth, fixedHeight);
 		mDesc.horzAlign = horzAlign;
 		mDesc.horzAlign = horzAlign;
 		mDesc.vertAlign = vertAlign;
 		mDesc.vertAlign = vertAlign;
-		mDesc.offset = Point(10, 20);
 		mTextSprite->update(mDesc);
 		mTextSprite->update(mDesc);
 
 
 		mBounds = mTextSprite->getBounds();
 		mBounds = mTextSprite->getBounds();

+ 1 - 1
BansheeEngine/Source/BsGUIManager.cpp

@@ -82,7 +82,7 @@ namespace BansheeEngine
 
 
 			for(auto& widget : mWidgets)
 			for(auto& widget : mWidgets)
 			{
 			{
-				//Int2 screenPos = Cursor::getWindowPosition(*window.first);
+				Int2 screenPos = Cursor::getWindowPosition(*window.first);
 			}
 			}
 		}
 		}
 	}
 	}

+ 1 - 1
BansheeEngine/Source/BsImageSprite.cpp

@@ -69,7 +69,7 @@ namespace BansheeEngine
 			renderElem.indexes[i * 6 + 5] = i * 4 + 2;
 			renderElem.indexes[i * 6 + 5] = i * 4 + 2;
 		}
 		}
 
 
-		Point offset = getAnchorOffset(desc.anchor, desc.width, desc.height);
+		Int2 offset = getAnchorOffset(desc.anchor, desc.width, desc.height);
 		Vector2 uvOffset(0.0f, 0.0f);
 		Vector2 uvOffset(0.0f, 0.0f);
 		Vector2 uvScale(1.0f, 1.0f);
 		Vector2 uvScale(1.0f, 1.0f);
 		
 		

+ 11 - 11
BansheeEngine/Source/BsSprite.cpp

@@ -63,31 +63,31 @@ namespace BansheeEngine
 		return renderElem.numQuads;
 		return renderElem.numQuads;
 	}
 	}
 
 
-	Point Sprite::getAnchorOffset(SpriteAnchor anchor, UINT32 width, UINT32 height) const
+	Int2 Sprite::getAnchorOffset(SpriteAnchor anchor, UINT32 width, UINT32 height) const
 	{
 	{
 		switch(anchor)
 		switch(anchor)
 		{
 		{
 		case SA_TopLeft:
 		case SA_TopLeft:
-			return -Point(0, 0);
+			return -Int2(0, 0);
 		case SA_TopCenter:
 		case SA_TopCenter:
-			return -Point(width / 2, 0);
+			return -Int2(width / 2, 0);
 		case SA_TopRight:
 		case SA_TopRight:
-			return -Point(width, 0);
+			return -Int2(width, 0);
 		case SA_MiddleLeft:
 		case SA_MiddleLeft:
-			return -Point(0, height / 2);
+			return -Int2(0, height / 2);
 		case SA_MiddleCenter:
 		case SA_MiddleCenter:
-			return -Point(width / 2, height / 2);
+			return -Int2(width / 2, height / 2);
 		case SA_MiddleRight:
 		case SA_MiddleRight:
-			return -Point(width, height / 2);
+			return -Int2(width, height / 2);
 		case SA_BottomLeft:
 		case SA_BottomLeft:
-			return -Point(0, height);
+			return -Int2(0, height);
 		case SA_BottomCenter:
 		case SA_BottomCenter:
-			return -Point(width / 2, height);
+			return -Int2(width / 2, height);
 		case SA_BottomRight:
 		case SA_BottomRight:
-			return -Point(width, height);
+			return -Int2(width, height);
 		}
 		}
 
 
-		return Point();
+		return Int2();
 	}
 	}
 
 
 	void Sprite::updateBounds() const
 	void Sprite::updateBounds() const

+ 5 - 5
BansheeEngine/Source/BsTextSprite.cpp

@@ -181,8 +181,8 @@ namespace BansheeEngine
 		}
 		}
 
 
 		UINT32 getWidth() const { return mWidth; }
 		UINT32 getWidth() const { return mWidth; }
-		Point getPosition() const { return mPosition; }
-		void setPosition(const Point& pos) { mPosition = pos; }
+		Int2 getPosition() const { return mPosition; }
+		void setPosition(const Int2& pos) { mPosition = pos; }
 
 
 		void fillBuffer(const vector<SpriteRenderElement>::type& renderElements, vector<UINT32>::type& faceOffsets, const FontData& fontData)
 		void fillBuffer(const vector<SpriteRenderElement>::type& renderElements, vector<UINT32>::type& faceOffsets, const FontData& fontData)
 		{
 		{
@@ -249,7 +249,7 @@ namespace BansheeEngine
 		UINT32 mWidth;
 		UINT32 mWidth;
 		vector<TextWord*>::type mWords;
 		vector<TextWord*>::type mWords;
 		TextWord* mLastWord;
 		TextWord* mLastWord;
-		Point mPosition;
+		Int2 mPosition;
 
 
 		void calculateBounds()
 		void calculateBounds()
 		{
 		{
@@ -376,7 +376,7 @@ namespace BansheeEngine
 		}
 		}
 
 
 		// Calc horizontal alignment offset and set final line positions
 		// Calc horizontal alignment offset and set final line positions
-		Point offset = getAnchorOffset(desc.anchor, desc.width, desc.height);
+		Int2 offset = getAnchorOffset(desc.anchor, desc.width, desc.height);
 		UINT32 curY = 0;
 		UINT32 curY = 0;
 		for(size_t i = 0; i < textLines.size(); i++)
 		for(size_t i = 0; i < textLines.size(); i++)
 		{
 		{
@@ -394,7 +394,7 @@ namespace BansheeEngine
 				break;
 				break;
 			}
 			}
 
 
-			textLines[i]->setPosition(offset + Point(horzOffset, vertOffset + curY));
+			textLines[i]->setPosition(offset + Int2(horzOffset, vertOffset + curY));
 
 
 			curY += fontData->fontDesc.lineHeight;
 			curY += fontData->fontDesc.lineHeight;
 		}
 		}

+ 1 - 1
CamelotCore/Include/CmInput.h

@@ -54,7 +54,7 @@ namespace CamelotFramework
 		float* mTimesHistoryBuffer;
 		float* mTimesHistoryBuffer;
 		int	mCurrentBufferIdx;
 		int	mCurrentBufferIdx;
 
 
-		Point mMouseLastRel;
+		Int2 mMouseLastRel;
 		Rect mClipRect;
 		Rect mClipRect;
 		bool mUsingClipRect;
 		bool mUsingClipRect;
 
 

+ 3 - 3
CamelotCore/Include/CmInputHandler.h

@@ -2,7 +2,7 @@
 
 
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include <boost/signal.hpp>
 #include <boost/signal.hpp>
-#include "CmPoint.h"
+#include "CmInt2.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -163,8 +163,8 @@ namespace CamelotFramework
 
 
 	struct MouseEvent
 	struct MouseEvent
 	{
 	{
-		Point coords;
-		Point relCoords;
+		Int2 coords;
+		Int2 relCoords;
 
 
 		int z;
 		int z;
 		int relZ;
 		int relZ;

+ 3 - 3
CamelotCore/Include/Win32/CmCursorImpl.h

@@ -16,10 +16,10 @@ namespace CamelotFramework
 		static Int2 getScreenPosition();
 		static Int2 getScreenPosition();
 		static void setScreenPosition(const Int2& pos);
 		static void setScreenPosition(const Int2& pos);
 
 
-		static Int2 getWindowPosition(RenderWindow& window);
-		static void setWindowPosition(RenderWindow& window, const Int2& pos);
+		static Int2 getWindowPosition(const RenderWindow& window);
+		static void setWindowPosition(const RenderWindow& window, const Int2& pos);
 
 
-		static void clipToWindow(RenderWindow& window);
+		static void clipToWindow(const RenderWindow& window);
 		static void clipToRect(const Rect& screenRect);
 		static void clipToRect(const Rect& screenRect);
 		static void clipDisable();
 		static void clipDisable();
 
 

+ 2 - 2
CamelotCore/Source/CmInput.cpp

@@ -92,7 +92,7 @@ namespace CamelotFramework
 
 
 		onMouseMoved(event);
 		onMouseMoved(event);
 
 
-		mMouseLastRel = Point(-event.relCoords.x, -event.relCoords.y);
+		mMouseLastRel = Int2(-event.relCoords.x, -event.relCoords.y);
 	}
 	}
 
 
 	void Input::mouseDown(const MouseEvent& event, MouseButton buttonID)
 	void Input::mouseDown(const MouseEvent& event, MouseButton buttonID)
@@ -159,7 +159,7 @@ namespace CamelotFramework
 		mSmoothHorizontalAxis = Math::Clamp(horizontalTotal / HISTORY_BUFFER_SIZE, -1.0f, 1.0f);
 		mSmoothHorizontalAxis = Math::Clamp(horizontalTotal / HISTORY_BUFFER_SIZE, -1.0f, 1.0f);
 		mSmoothVerticalAxis = Math::Clamp(verticalTotal / HISTORY_BUFFER_SIZE, -1.0f, 1.0f);
 		mSmoothVerticalAxis = Math::Clamp(verticalTotal / HISTORY_BUFFER_SIZE, -1.0f, 1.0f);
 
 
-		mMouseLastRel = Point(0, 0);
+		mMouseLastRel = Int2(0, 0);
 	}
 	}
 
 
 	Input& gInput()
 	Input& gInput()

+ 3 - 3
CamelotCore/Source/Win32/CmCursorImpl.cpp

@@ -10,7 +10,7 @@ namespace CamelotFramework
 	HCURSOR Cursor::mCursor;
 	HCURSOR Cursor::mCursor;
 	bool Cursor::mUsingCustom = false;
 	bool Cursor::mUsingCustom = false;
 
 
-	Int2 Cursor::getWindowPosition(RenderWindow& window)
+	Int2 Cursor::getWindowPosition(const RenderWindow& window)
 	{
 	{
 		POINT screenPos;
 		POINT screenPos;
 		GetCursorPos(&screenPos);
 		GetCursorPos(&screenPos);
@@ -23,7 +23,7 @@ namespace CamelotFramework
 		return Int2(screenPos.x, screenPos.y);
 		return Int2(screenPos.x, screenPos.y);
 	}
 	}
 
 
-	void Cursor::setWindowPosition(RenderWindow& window, const Int2& pos)
+	void Cursor::setWindowPosition(const RenderWindow& window, const Int2& pos)
 	{
 	{
 		POINT screenPos;
 		POINT screenPos;
 
 
@@ -85,7 +85,7 @@ namespace CamelotFramework
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 	}
 
 
-	void Cursor::clipToWindow(RenderWindow& window)
+	void Cursor::clipToWindow(const RenderWindow& window)
 	{
 	{
 		HWND hwnd;
 		HWND hwnd;
 		window.getCustomAttribute("WINDOW", &hwnd);
 		window.getCustomAttribute("WINDOW", &hwnd);

+ 7 - 7
CamelotOISInput/Source/CmInputHandlerOIS.cpp

@@ -1,5 +1,5 @@
 #include "CmInputHandlerOIS.h"
 #include "CmInputHandlerOIS.h"
-#include "CmPoint.h"
+#include "CmInt2.h"
 #include "OIS/OISException.h"
 #include "OIS/OISException.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
@@ -77,8 +77,8 @@ namespace CamelotFramework
 	bool InputHandlerOIS::mouseMoved(const OIS::MouseEvent& arg)
 	bool InputHandlerOIS::mouseMoved(const OIS::MouseEvent& arg)
 	{
 	{
 		MouseEvent event;
 		MouseEvent event;
-		event.coords = Point(arg.state.X.abs, arg.state.Y.abs);
-		event.relCoords = Point(arg.state.X.rel, arg.state.Y.rel);
+		event.coords = Int2(arg.state.X.abs, arg.state.Y.abs);
+		event.relCoords = Int2(arg.state.X.rel, arg.state.Y.rel);
 		event.z = arg.state.Z.abs;
 		event.z = arg.state.Z.abs;
 		event.relZ = arg.state.Z.rel;
 		event.relZ = arg.state.Z.rel;
 		onMouseMoved(event);
 		onMouseMoved(event);
@@ -89,8 +89,8 @@ namespace CamelotFramework
 	bool InputHandlerOIS::mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
 	bool InputHandlerOIS::mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
 	{
 	{
 		MouseEvent event;
 		MouseEvent event;
-		event.coords = Point(arg.state.X.abs, arg.state.Y.abs);
-		event.relCoords = Point(arg.state.X.rel, arg.state.Y.rel);
+		event.coords = Int2(arg.state.X.abs, arg.state.Y.abs);
+		event.relCoords = Int2(arg.state.X.rel, arg.state.Y.rel);
 		event.z = arg.state.Z.abs;
 		event.z = arg.state.Z.abs;
 		event.relZ = arg.state.Z.rel;
 		event.relZ = arg.state.Z.rel;
 		onMouseDown(event, (MouseButton)(int)id);
 		onMouseDown(event, (MouseButton)(int)id);
@@ -101,8 +101,8 @@ namespace CamelotFramework
 	bool InputHandlerOIS::mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
 	bool InputHandlerOIS::mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
 	{
 	{
 		MouseEvent event;
 		MouseEvent event;
-		event.coords = Point(arg.state.X.abs, arg.state.Y.abs);
-		event.relCoords = Point(0, 0);
+		event.coords = Int2(arg.state.X.abs, arg.state.Y.abs);
+		event.relCoords = Int2(0, 0);
 		event.z = arg.state.Z.abs;
 		event.z = arg.state.Z.abs;
 		onMouseUp(event, (MouseButton)(int)id);
 		onMouseUp(event, (MouseButton)(int)id);
 
 

+ 0 - 1
CamelotUtility/CamelotUtility.vcxproj

@@ -191,7 +191,6 @@
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmORect.h" />
     <ClInclude Include="Include\CmORect.h" />
     <ClInclude Include="Include\CmPath.h" />
     <ClInclude Include="Include\CmPath.h" />
-    <ClInclude Include="Include\CmPoint.h" />
     <ClInclude Include="Include\CmRect.h" />
     <ClInclude Include="Include\CmRect.h" />
     <ClInclude Include="Include\CmRTTIField.h" />
     <ClInclude Include="Include\CmRTTIField.h" />
     <ClInclude Include="Include\CmRTTIManagedDataBlockField.h" />
     <ClInclude Include="Include\CmRTTIManagedDataBlockField.h" />

+ 0 - 3
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -177,9 +177,6 @@
     <ClInclude Include="Include\CmFileSystem.h">
     <ClInclude Include="Include\CmFileSystem.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmPoint.h">
-      <Filter>Header Files\Math</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmRect.h">
     <ClInclude Include="Include\CmRect.h">
       <Filter>Header Files\Math</Filter>
       <Filter>Header Files\Math</Filter>
     </ClInclude>
     </ClInclude>

+ 5 - 0
CamelotUtility/Include/CmInt2.h

@@ -9,6 +9,11 @@ namespace CamelotFramework
 		int x;
 		int x;
 		int y;
 		int y;
 
 
+		inline Int2()
+			: x(0), y(0)
+		{
+		}
+
 		inline Int2(const int _x, const int _y )
 		inline Int2(const int _x, const int _y )
             : x( _x ), y( _y )
             : x( _x ), y( _y )
         {
         {

+ 0 - 31
CamelotUtility/Include/CmPoint.h

@@ -1,31 +0,0 @@
-#pragma once
-
-#include "CmPrerequisitesUtil.h"
-
-namespace CamelotFramework
-{
-	class Point
-	{
-	public:
-		Point()
-			:x(0), y(0)
-		{ }
-		Point(int _x, int _y)
-			:x(_x), y(_y)
-		{ }
-
-		int x, y;
-
-		inline friend Point operator + (const Point& lhs, const Point& rhs)
-		{
-			return Point(
-				lhs.x + rhs.x,
-				lhs.y + rhs.y);
-		}
-
-		inline Point operator - () const
-		{
-			return Point(-x, -y);
-		}
-	};
-}

+ 2 - 2
CamelotUtility/Include/CmRect.h

@@ -1,7 +1,7 @@
 #pragma once
 #pragma once
 
 
 #include "CmPrerequisitesUtil.h"
 #include "CmPrerequisitesUtil.h"
-#include "CmPoint.h"
+#include "CmInt2.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -21,7 +21,7 @@ namespace CamelotFramework
 			:x(_x), y(_y), width(_width), height(_height)
 			:x(_x), y(_y), width(_width), height(_height)
 		{ }
 		{ }
 
 
-		bool contains(Point point)
+		bool contains(Int2 point)
 		{
 		{
 			if(point.x >= x && point.x <= (x + width))
 			if(point.x >= x && point.x <= (x + width))
 			{
 			{