Procházet zdrojové kódy

Use Vec2 in input devices even for integral types

Daniele Bartolini před 12 roky
rodič
revize
824ccd7657
4 změnil soubory, kde provedl 12 přidání a 14 odebrání
  1. 7 7
      src/input/Mouse.cpp
  2. 2 3
      src/input/Mouse.h
  3. 2 2
      src/input/Touch.cpp
  4. 1 2
      src/input/Touch.h

+ 7 - 7
src/input/Mouse.cpp

@@ -50,17 +50,17 @@ bool Mouse::button_released(MouseButton button) const
 }
 
 //-----------------------------------------------------------------------------
-Point2 Mouse::cursor_xy() const
+Vec2 Mouse::cursor_xy() const
 {
-	Point2 xy;
+	int32_t x, y;
 
-	os::get_cursor_xy(xy.x, xy.y);
+	os::get_cursor_xy(x, y);
 
-	return xy;
+	return Vec2(x, y);
 }
 
 //-----------------------------------------------------------------------------
-void Mouse::set_cursor_xy(const Point2& position)
+void Mouse::set_cursor_xy(const Vec2& position)
 {
 	os::set_cursor_xy(position.x, position.y);
 }
@@ -73,7 +73,7 @@ Vec2 Mouse::cursor_relative_xy() const
 
 	os::get_render_window_metrics(window_width, window_height);
 
-	Vec2 pos = cursor_xy().to_vec2();
+	Vec2 pos = cursor_xy();
 
 	pos.x = pos.x / (float) window_width;
 	pos.y = pos.y / (float) window_height;
@@ -89,7 +89,7 @@ void Mouse::set_cursor_relative_xy(const Vec2& position)
 
 	os::get_render_window_metrics(window_width, window_height);
 
-	set_cursor_xy(Point2((int32_t)(position.x * (float) window_width), (int32_t)(position.y * (float) window_height)));
+	set_cursor_xy(Vec2(position.x * (float) window_width, position.y * (float) window_height));
 }
 
 } // namespace crown

+ 2 - 3
src/input/Mouse.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Vec2.h"
-#include "Point2.h"
 
 namespace crown
 {
@@ -80,14 +79,14 @@ public:
 	/// Coordinates in window space have the origin at the
 	/// upper-left corner of the window. +X extends from left
 	/// to right and +Y extends from top to bottom.
-	Point2	cursor_xy() const;
+	Vec2	cursor_xy() const;
 
 	/// Sets the position of the cursor in window space.
 	/// @note
 	/// Coordinates in window space have the origin at the
 	/// upper-left corner of the window. +X extends from left
 	/// to right and +Y extends from top to bottom.
-	void	set_cursor_xy(const Point2& position);
+	void	set_cursor_xy(const Vec2& position);
 
 	/// Returns the relative position of the cursor in window space.
 	/// @note

+ 2 - 2
src/input/Touch.cpp

@@ -47,11 +47,11 @@ bool Touch::touch_down(uint16_t id) const
 }
 
 //----------------------------------------------------------------------------- 
-Point2 Touch::touch_xy(uint16_t id) const
+Vec2 Touch::touch_xy(uint16_t id) const
 {
 	const PointerData& data = m_pointers[id];
 
-	return Point2(data.x, data.y);
+	return Vec2(data.x, data.y);
 }
 
 //-----------------------------------------------------------------------------

+ 1 - 2
src/input/Touch.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Vec2.h"
-#include "Point2.h"
 
 namespace crown
 {
@@ -80,7 +79,7 @@ public:
 	/// Coordinates in window space have the origin at the
 	/// upper-left corner of the window. +X extends from left
 	/// to right and +Y extends from top to bottom.
-	Point2			touch_xy(uint16_t id) const;
+	Vec2			touch_xy(uint16_t id) const;
 
 	/// Returns the relative position of the pointer @id in window space.
 	/// @note