Ver código fonte

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

Daniele Bartolini 10 anos atrás
pai
commit
f6a8bc5485

+ 1 - 1
docs/lua_api.txt

@@ -199,7 +199,7 @@ QuaternionBox
 	**QuaternionBox** (x, y, z, w) : QuaternionBox
 		Returns a new QuaternionBox from individual elements.
 
-	**store(q)** ()
+	**store(q)**
 		Stores the Quaternion *q* in the box.
 
 	**store** (x, y, z, w)

+ 1 - 1
samples/00-hello-world/lua/game.lua

@@ -17,7 +17,7 @@ function update(dt)
 	World.update(world, dt)
 
 	-- Stop the engine when the 'ESC' key is released
-	if Keyboard.button_released(Keyboard.ESCAPE) then
+	if Keyboard.released(Keyboard.button_id("escape")) then
 		Device.quit()
 	end
 end

+ 4 - 4
src/core/math/aabb.h

@@ -156,10 +156,10 @@ namespace aabb
 		vertices[6] = vertices[6] * m;
 		vertices[7] = vertices[7] * m;
 
-		AABB res;
-		reset(res);
-		add_points(res, 8, vertices);
-		return res;
+		AABB r;
+		reset(r);
+		add_points(r, 8, vertices);
+		return r;
 	}
 
 	inline void to_vertices(const AABB& b, Vector3 v[8])

+ 4 - 4
src/core/math/frustum.h

@@ -138,10 +138,10 @@ namespace frustum
 		vertices[6] = vertex(f, 6);
 		vertices[7] = vertex(f, 7);
 
-		AABB aabb;
-		aabb::reset(aabb);
-		aabb::add_points(aabb, 8, vertices);
-		return aabb;
+		AABB r;
+		aabb::reset(r);
+		aabb::add_points(r, 8, vertices);
+		return r;
 	}
 } // namespace frustum
 

+ 5 - 0
src/core/math/math_types.h

@@ -117,4 +117,9 @@ const Matrix3x3 MATRIX3X3_IDENTITY = { VECTOR3_XAXIS, VECTOR3_YAXIS, VECTOR3_ZAX
 
 const Matrix4x4 MATRIX4X4_IDENTITY = { VECTOR4_XAXIS, VECTOR4_YAXIS, VECTOR4_ZAXIS, VECTOR4_WAXIS };
 
+const Plane PLANE_ZERO  = { VECTOR3_ZERO,  0.0f };
+const Plane PLANE_XAXIS = { VECTOR3_XAXIS, 0.0f };
+const Plane PLANE_YAXIS = { VECTOR3_YAXIS, 0.0f };
+const Plane PLANE_ZAXIS = { VECTOR3_ZAXIS, 0.0f };
+
 } // namespace crown

+ 1 - 1
src/core/math/math_utils.h

@@ -9,9 +9,9 @@
 
 namespace crown
 {
-
 /// @addtogroup Math
 /// @{
+
 const float PI              = 3.1415926535897932f;
 const float TWO_PI          = PI * 2.0f;
 const float HALF_PI         = PI * 0.5f;

+ 3 - 3
src/core/math/matrix4x4.h

@@ -261,7 +261,7 @@ inline Matrix4x4 operator*(Matrix4x4 a, const Matrix4x4& b)
 }
 
 /// Sets the matrix @a m to perspective.
-inline void set_perspective(Matrix4x4& m, float fovy, float aspect, float near, float far)
+inline void perspective(Matrix4x4& m, float fovy, float aspect, float near, float far)
 {
 	const float height = 1.0f / tanf(to_rad(fovy) * 0.5f);
 	const float width = height * 1.0f / aspect;
@@ -290,7 +290,7 @@ inline void set_perspective(Matrix4x4& m, float fovy, float aspect, float near,
 }
 
 /// Sets the matrix @a m to orthographic.
-inline void set_orthographic(Matrix4x4& m, float left, float right, float bottom, float top, float near, float far)
+inline void orthographic(Matrix4x4& m, float left, float right, float bottom, float top, float near, float far)
 {
 	m.x.x = 2.0f / (right - left);
 	m.x.y = 0.0f;
@@ -353,7 +353,7 @@ inline Matrix4x4 get_transposed(Matrix4x4 m)
 }
 
 /// Sets the matrix @a m to look.
-inline void set_look(Matrix4x4& m, const Vector3& pos, const Vector3& target, const Vector3& up)
+inline void look(Matrix4x4& m, const Vector3& pos, const Vector3& target, const Vector3& up)
 {
 	Vector3 zaxis = pos - target;
 	normalize(zaxis);

+ 0 - 5
src/core/math/plane.h

@@ -11,11 +11,6 @@
 namespace crown
 {
 
-const Plane PLANE_ZERO  = { VECTOR3_ZERO, 0.0f };
-const Plane PLANE_XAXIS = { VECTOR3_XAXIS, 0.0f };
-const Plane PLANE_YAXIS = { VECTOR3_YAXIS, 0.0f };
-const Plane PLANE_ZAXIS = { VECTOR3_ZAXIS, 0.0f };
-
 /// Functions to manipulate Plane.
 ///
 /// @ingroup Math

+ 1 - 0
src/core/math/quaternion.h

@@ -147,6 +147,7 @@ inline Quaternion power(const Quaternion& q, float exp)
 	return q;
 }
 
+/// Returns the quaternion describing the rotation needed to face towards @a dir.
 inline Quaternion look(const Vector3& dir, const Vector3& up = VECTOR3_YAXIS)
 {
 	const Vector3 right = cross(dir, up);

+ 8 - 8
src/core/profiler.cpp

@@ -49,7 +49,7 @@ namespace profiler
 	}
 
 	template <typename T>
-	void push(EventType::Enum type, const T& ev)
+	void push(ProfilerEventType::Enum type, const T& ev)
 	{
 		if (_thread_buffer_size + 2*sizeof(uint32_t) + sizeof(ev) >= THREAD_BUFFER_SIZE)
 			flush_local_buffer();
@@ -70,7 +70,7 @@ namespace profiler
 		ev.name = name;
 		ev.time = os::clocktime();
 
-		push(EventType::ENTER_PROFILE_SCOPE, ev);
+		push(ProfilerEventType::ENTER_PROFILE_SCOPE, ev);
 	}
 
 	void leave_profile_scope()
@@ -78,7 +78,7 @@ namespace profiler
 		LeaveProfileScope ev;
 		ev.time = os::clocktime();
 
-		push(EventType::LEAVE_PROFILE_SCOPE, ev);
+		push(ProfilerEventType::LEAVE_PROFILE_SCOPE, ev);
 	}
 
 	void record_float(const char* name, float value)
@@ -87,7 +87,7 @@ namespace profiler
 		ev.name = name;
 		ev.value = value;
 
-		push(EventType::RECORD_FLOAT, ev);
+		push(ProfilerEventType::RECORD_FLOAT, ev);
 	}
 
 	void record_vector3(const char* name, const Vector3& value)
@@ -96,7 +96,7 @@ namespace profiler
 		ev.name = name;
 		ev.value = value;
 
-		push(EventType::RECORD_VECTOR3, ev);
+		push(ProfilerEventType::RECORD_VECTOR3, ev);
 	}
 
 	void allocate_memory(const char* name, uint32_t size)
@@ -105,7 +105,7 @@ namespace profiler
 		ev.name = name;
 		ev.size = size;
 
-		push(EventType::ALLOCATE_MEMORY, ev);
+		push(ProfilerEventType::ALLOCATE_MEMORY, ev);
 	}
 
 	void deallocate_memory(const char* name, uint32_t size)
@@ -114,7 +114,7 @@ namespace profiler
 		ev.name = name;
 		ev.size = size;
 
-		push(EventType::DEALLOCATE_MEMORY, ev);
+		push(ProfilerEventType::DEALLOCATE_MEMORY, ev);
 	}
 } // namespace profiler
 
@@ -123,7 +123,7 @@ namespace profiler_globals
 	void flush()
 	{
 		profiler::flush_local_buffer();
-		uint32_t end = profiler::EventType::COUNT;
+		uint32_t end = ProfilerEventType::COUNT;
 		array::push(*_buffer, (const char*)&end, (uint32_t)sizeof(end));
 	}
 

+ 42 - 41
src/core/profiler.h

@@ -10,58 +10,59 @@
 
 namespace crown
 {
-namespace profiler
+
+struct ProfilerEventType
 {
-	struct EventType
+	enum Enum
 	{
-		enum Enum
-		{
-			ENTER_PROFILE_SCOPE,
-			LEAVE_PROFILE_SCOPE,
-			RECORD_FLOAT,
-			RECORD_VECTOR3,
-			ALLOCATE_MEMORY,
-			DEALLOCATE_MEMORY,
+		ENTER_PROFILE_SCOPE,
+		LEAVE_PROFILE_SCOPE,
+		RECORD_FLOAT,
+		RECORD_VECTOR3,
+		ALLOCATE_MEMORY,
+		DEALLOCATE_MEMORY,
 
-			COUNT
-		};
+		COUNT
 	};
+};
 
-	struct RecordFloat
-	{
-		const char* name;
-		float value;
-	};
+struct RecordFloat
+{
+	const char* name;
+	float value;
+};
 
-	struct RecordVector3
-	{
-		const char* name;
-		Vector3 value;
-	};
+struct RecordVector3
+{
+	const char* name;
+	Vector3 value;
+};
 
-	struct EnterProfileScope
-	{
-		const char* name;
-		int64_t time;
-	};
+struct EnterProfileScope
+{
+	const char* name;
+	int64_t time;
+};
 
-	struct LeaveProfileScope
-	{
-		int64_t time;
-	};
+struct LeaveProfileScope
+{
+	int64_t time;
+};
 
-	struct AllocateMemory
-	{
-		const char* name;
-		uint32_t size;
-	};
+struct AllocateMemory
+{
+	const char* name;
+	uint32_t size;
+};
 
-	struct DeallocateMemory
-	{
-		const char* name;
-		uint32_t size;
-	};
+struct DeallocateMemory
+{
+	const char* name;
+	uint32_t size;
+};
 
+namespace profiler
+{
 	void enter_profile_scope(const char* name);
 	void leave_profile_scope();
 	void record_float(const char* name, float value);

+ 3 - 3
src/core/strings/path.cpp

@@ -15,9 +15,9 @@ namespace path
 	{
 		CE_ASSERT(path != NULL, "Path must be != NULL");
 #if CROWN_PLATFORM_POSIX
-		return strlen32(path) > 0 && path[0] == SEPARATOR;
+		return strlen32(path) > 0 && path[0] == PATH_SEPARATOR;
 #elif CROWN_PLATFORM_WINDOWS
-		return strlen32(path) > 2 && isalpha(path[0]) && path[1] == ':' && path[2] == SEPARATOR;
+		return strlen32(path) > 2 && isalpha(path[0]) && path[1] == ':' && path[2] == PATH_SEPARATOR;
 #endif
 	}
 
@@ -37,7 +37,7 @@ namespace path
 		const uint32_t lb = strlen32(b);
 		path.reserve(la + lb + 1);
 		path += a;
-		path += SEPARATOR;
+		path += PATH_SEPARATOR;
 		path += b;
 	}
 

+ 6 - 6
src/core/strings/path.h

@@ -12,17 +12,17 @@ namespace crown
 {
 /// @defgroup Path Path
 
+#if CROWN_PLATFORM_POSIX
+	const char PATH_SEPARATOR = '/';
+#elif CROWN_PLATFORM_WINDOWS
+	const char PATH_SEPARATOR = '\\';
+#endif // CROWN_PLATFORM_POSIX
+
 /// Functions for operating on strings as file paths.
 ///
 /// @ingroup Path
 namespace path
 {
-#if CROWN_PLATFORM_POSIX
-	const char SEPARATOR = '/';
-#elif CROWN_PLATFORM_WINDOWS
-	const char SEPARATOR = '\\';
-#endif // CROWN_PLATFORM_POSIX
-
 	/// Returns whether the @a path is absolute.
 	bool is_absolute_path(const char* path);
 

+ 1 - 1
src/renderers/gui.cpp

@@ -89,7 +89,7 @@ Gui::Gui(uint16_t width, uint16_t height, const char* material)
 	, m_height(height)
 	, m_pose(MATRIX4X4_IDENTITY)
 {
-	set_orthographic(m_projection, 0, width, 0, height, -0.01f, 100.0f);
+	orthographic(m_projection, 0, width, 0, height, -0.01f, 100.0f);
 
 	m_material = material_manager::get()->create_material(ResourceId(material));
 }