瀏覽代碼

Merge branch 'master' of github.com:taylor001/crown

Daniele Bartolini 10 年之前
父節點
當前提交
5f10c8d36e
共有 3 個文件被更改,包括 71 次插入4 次删除
  1. 44 0
      docs/lua_api.txt
  2. 24 4
      src/core/math/sphere.h
  3. 3 0
      src/input/input_device.h

+ 44 - 0
docs/lua_api.txt

@@ -756,6 +756,9 @@ Keyboard
 	**name** () : string
 		Returns the name of the input device.
 
+	**connected** () : bool
+		Returns whether the input device is connected and functioning.
+
 	**num_buttons** () : int
 		Returns the number of buttons of the input device.
 
@@ -780,6 +783,9 @@ Mouse
 	**name** () : string
 		Returns the name of the input device.
 
+	**connected** () : bool
+		Returns whether the input device is connected and functioning.
+
 	**num_buttons** () : int
 		Returns the number of buttons of the input device.
 
@@ -800,6 +806,8 @@ Mouse
 
 	**axis** (i) : Vector3
 		Returns the value of the axis *i*.
+		The returned vector holds x and y coordinates of the pointer
+		in window-space.
 
 Touch
 -----
@@ -807,6 +815,41 @@ Touch
 	**name** () : string
 		Returns the name of the input device.
 
+	**connected** () : bool
+		Returns whether the input device is connected and functioning.
+
+	**num_buttons** () : int
+		Returns the number of buttons of the input device.
+
+	**num_axes** () : int
+		Returns the number of axes of the input device.
+
+	**pressed** (i) : bool
+		Returns whether the button *i* is pressed in the current frame.
+
+	**released** (i) : bool
+		Returns whether the button *i* is released in the current frame.
+
+	**any_pressed** () : bool
+		Returns wheter any button is pressed in the current frame.
+
+	**any_released** () : bool
+		Returns whether any button is released in the current frame.
+
+	**axis** (i) : Vector3
+		Returns the value of the axis *i*.
+		The returned vector holds x and y coordinates of the pointer
+		in window-space.
+
+Pad1, Pad2, Pad3, Pad4
+----------------------
+
+	**name** () : string
+		Returns the name of the input device.
+
+	**connected** () : bool
+		Returns whether the input device is connected and functioning.
+
 	**num_buttons** () : int
 		Returns the number of buttons of the input device.
 
@@ -827,6 +870,7 @@ Touch
 
 	**axis** (i) : Vector3
 		Returns the value of the axis *i*.
+		The returned vector holds values in the range [-1;+1]
 
 Window
 ======

+ 24 - 4
src/core/math/sphere.h

@@ -13,8 +13,13 @@ namespace crown
 {
 namespace sphere
 {
+	void reset(Sphere& s);
+
 	float volume(const Sphere& s);
 
+	/// Adds @a num @a points to the sphere @a s, expanding its bounds if necessary.
+	void add_points(Sphere& s, uint32_t num, uint32_t stride, const void* points);
+
 	/// Adds @a num @a points to the sphere expanding if necessary.
 	void add_points(Sphere& s, uint32_t num, const Vector3* points);
 
@@ -27,21 +32,36 @@ namespace sphere
 
 namespace sphere
 {
+	inline void reset(Sphere& s)
+	{
+		s.c = VECTOR3_ZERO;
+		s.r = 0.0f;
+	}
+
 	inline float volume(const Sphere& s)
 	{
-		return float(4.0 / 3.0 * PI) * s.r*s.r*s.r;
+		return (4.0f/3.0f*PI) * (s.r*s.r*s.r);
 	}
 
-	inline void add_points(Sphere& s, uint32_t num, const Vector3* points)
+	inline void add_points(Sphere& s, uint32_t num, uint32_t stride, const void* points)
 	{
 		for (uint32_t i = 0; i < num; ++i)
 		{
-			const float dist = squared_length(points[i] - s.c);
-			if (dist >= s.r*s.r)
+			const Vector3* p = (const Vector3*)points;
+
+			const float dist = squared_length(*p - s.c);
+			if (dist > s.r*s.r)
 				s.r = sqrt(dist);
+
+			points = (const void*)((const char*)points + stride);
 		}
 	}
 
+	inline void add_points(Sphere& s, uint32_t num, const Vector3* points)
+	{
+		add_points(s, num, sizeof(Vector3), points);
+	}
+
 	inline void add_spheres(Sphere& s, uint32_t num, const Sphere* spheres)
 	{
 		for (uint32_t i = 0; i < num; ++i)

+ 3 - 0
src/input/input_device.h

@@ -11,6 +11,9 @@
 namespace crown
 {
 
+/// Represents a generic input device.
+///
+/// @ingroup Input
 struct InputDevice
 {
 	/// Returns the name of the input device.