소스 검색

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

Daniele Bartolini 10 년 전
부모
커밋
e210a53fa9
9개의 변경된 파일51개의 추가작업 그리고 50개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 13 9
      src/console_server.cpp
  3. 4 4
      src/core/log.h
  4. 8 12
      src/core/math/plane.h
  5. 9 9
      src/core/os_event_queue.h
  6. 7 7
      src/core/profiler.h
  7. 3 3
      src/crown.h
  8. 4 4
      src/main/main_android.cpp
  9. 2 2
      src/resource/sound_resource.h

+ 1 - 0
.gitattributes

@@ -25,3 +25,4 @@
 *.tga binary
 *.dds binary
 *.wav binary
+*.ogg binary

+ 13 - 9
src/console_server.cpp

@@ -139,7 +139,8 @@ ReadResult ConsoleServer::update_client(TCPSocket client)
 	if (rr.error != ReadResult::NO_ERROR) return rr;
 
 	// Else read the message
-	Array<char> msg_buf(default_allocator());
+	TempAllocator4096 ta;
+	Array<char> msg_buf(ta);
 	array::resize(msg_buf, msg_len);
 	ReadResult msg_result = client.read(array::begin(msg_buf), msg_len);
 	array::push_back(msg_buf, '\0');
@@ -153,10 +154,11 @@ ReadResult ConsoleServer::update_client(TCPSocket client)
 
 void ConsoleServer::process(TCPSocket client, const char* json)
 {
-	Map<DynamicString, const char*> root(default_allocator());
+	TempAllocator4096 ta;
+	Map<DynamicString, const char*> root(ta);
 	json::parse_object(json, root);
 
-	DynamicString type;
+	DynamicString type(ta);
 	json::parse_string(root["type"], type);
 
 	if (type == "ping") process_ping(client, json);
@@ -172,26 +174,28 @@ void ConsoleServer::process_ping(TCPSocket client, const char* /*json*/)
 
 void ConsoleServer::process_script(TCPSocket /*client*/, const char* json)
 {
-	Map<DynamicString, const char*> root(default_allocator());
+	TempAllocator4096 ta;
+	Map<DynamicString, const char*> root(ta);
 	json::parse_object(json, root);
 
-	DynamicString script;
+	DynamicString script(ta);
 	json::parse_string(root["script"], script);
 	device()->lua_environment()->execute_string(script.c_str());
 }
 
 void ConsoleServer::process_command(TCPSocket /*client*/, const char* json)
 {
-	Map<DynamicString, const char*> root(default_allocator());
+	TempAllocator4096 ta;
+	Map<DynamicString, const char*> root(ta);
 	json::parse_object(json, root);
 
-	DynamicString cmd;
+	DynamicString cmd(ta);
 	json::parse_string(root["command"], cmd);
 
 	if (cmd == "reload")
 	{
-		DynamicString type;
-		DynamicString name;
+		DynamicString type(ta);
+		DynamicString name(ta);
 		json::parse_string(root["resource_type"], type);
 		json::parse_string(root["resource_name"], name);
 

+ 4 - 4
src/core/log.h

@@ -16,10 +16,10 @@ struct LogSeverity
 {
 	enum Enum
 	{
-		INFO	= 0,
-		WARN	= 1,
-		ERROR	= 2,
-		DEBUG	= 3
+		INFO,
+		WARN,
+		ERROR,
+		DEBUG
 	};
 };
 

+ 8 - 12
src/core/math/plane.h

@@ -5,10 +5,8 @@
 
 #pragma once
 
-#include "types.h"
-#include "sphere.h"
-#include "vector3.h"
 #include "math_types.h"
+#include "vector3.h"
 
 namespace crown
 {
@@ -28,21 +26,19 @@ namespace plane
 
 namespace plane
 {
-	const Plane ZERO = Plane(vector3::ZERO, 0.0);
-	const Plane	XAXIS = Plane(vector3::XAXIS, 0.0);
-	const Plane	YAXIS = Plane(vector3::YAXIS, 0.0);
-	const Plane	ZAXIS = Plane(vector3::ZAXIS, 0.0);
+	const Plane ZERO = Plane(vector3::ZERO, 0.0f);
+	const Plane XAXIS = Plane(vector3::XAXIS, 0.0f);
+	const Plane YAXIS = Plane(vector3::YAXIS, 0.0f);
+	const Plane ZAXIS = Plane(vector3::ZAXIS, 0.0f);
 
 	inline Plane& normalize(Plane& p)
 	{
-		float len = vector3::length(p.n);
+		const float len = vector3::length(p.n);
 
-		if (equals(len, (float) 0.0))
-		{
+		if (equals(len, 0.0f))
 			return p;
-		}
 
-		const float inv_len = (float) 1.0 / len;
+		const float inv_len = 1.0f / len;
 
 		p.n *= inv_len;
 		p.d *= inv_len;

+ 9 - 9
src/core/os_event_queue.h

@@ -62,8 +62,8 @@ struct OsTouchEvent
 
 	OsTouchEvent::Enum type;
 	uint8_t pointer_id;
-	uint16_t x;
-	uint16_t y;
+	int16_t x;
+	int16_t y;
 	bool pressed;
 };
 
@@ -80,12 +80,12 @@ struct OsEvent
 	/// Represents an event fired by the OS
 	enum Enum
 	{
-		NONE			= 0,
+		NONE,
 
-		KEYBOARD		= 1,
-		MOUSE			= 2,
-		TOUCH			= 3,
-		ACCELEROMETER	= 4,
+		KEYBOARD,
+		MOUSE,
+		TOUCH,
+		ACCELEROMETER,
 
 		METRICS,
 		PAUSE,
@@ -164,7 +164,7 @@ struct OsEventQueue
 		push_event(ev);
 	}
 
-	void push_touch_event(uint16_t x, uint16_t y, uint8_t pointer_id)
+	void push_touch_event(int16_t x, int16_t y, uint8_t pointer_id)
 	{
 		OsEvent ev;
 		ev.type = OsEvent::TOUCH;
@@ -176,7 +176,7 @@ struct OsEventQueue
 		push_event(ev);
 	}
 
-	void push_touch_event(uint16_t x, uint16_t y, uint8_t pointer_id, bool pressed)
+	void push_touch_event(int16_t x, int16_t y, uint8_t pointer_id, bool pressed)
 	{
 		OsEvent ev;
 		ev.type = OsEvent::TOUCH;

+ 7 - 7
src/core/profiler.h

@@ -15,14 +15,14 @@ namespace profiler
 	{
 		enum Enum
 		{
-			ENTER_PROFILE_SCOPE = 0,
-			LEAVE_PROFILE_SCOPE = 1,
-			RECORD_FLOAT = 2,
-			RECORD_VECTOR3 = 3,
-			ALLOCATE_MEMORY = 4,
-			DEALLOCATE_MEMORY = 5,
+			ENTER_PROFILE_SCOPE,
+			LEAVE_PROFILE_SCOPE,
+			RECORD_FLOAT,
+			RECORD_VECTOR3,
+			ALLOCATE_MEMORY,
+			DEALLOCATE_MEMORY,
 
-			COUNT,
+			COUNT
 		};
 	};
 

+ 3 - 3
src/crown.h

@@ -14,9 +14,9 @@ namespace crown
 	{
 		enum Enum
 		{
-			LINUX = 0,
-			WINDOWS = 1,
-			ANDROID = 2,
+			LINUX,
+			WINDOWS,
+			ANDROID,
 
 			COUNT
 		};

+ 4 - 4
src/main/main_android.cpp

@@ -150,19 +150,19 @@ struct AndroidDevice
 				case AMOTION_EVENT_ACTION_DOWN:
 				case AMOTION_EVENT_ACTION_POINTER_DOWN:
 				{
-					_queue.push_touch_event((uint16_t) x, (uint16_t) y, (uint8_t) pointerId, true);
+					_queue.push_touch_event((int16_t)x, (int16_t)y, (uint8_t)pointerId, true);
 					break;
 				}
 				case AMOTION_EVENT_ACTION_UP:
 				case AMOTION_EVENT_ACTION_POINTER_UP:
 				{
-					_queue.push_touch_event((uint16_t) x, (uint16_t) y, (uint8_t) pointerId, false);
+					_queue.push_touch_event((int16_t)x, (int16_t)y, (uint8_t)pointerId, false);
 					break;
 				}
 				case AMOTION_EVENT_ACTION_OUTSIDE:
 				case AMOTION_EVENT_ACTION_CANCEL:
 				{
-					_queue.push_touch_event((uint16_t) x, (uint16_t) y, (uint8_t) pointerId, false);
+					_queue.push_touch_event((int16_t)x, (int16_t)y, (uint8_t)pointerId, false);
 					break;
 				}
 				case AMOTION_EVENT_ACTION_MOVE:
@@ -172,7 +172,7 @@ struct AndroidDevice
 						const float xx = AMotionEvent_getX(event, index);
 						const float yy = AMotionEvent_getY(event, index);
 						const int32_t id = AMotionEvent_getPointerId(event, index);
-						_queue.push_touch_event((uint16_t) xx, (uint16_t) yy, (uint8_t) id);
+						_queue.push_touch_event((int16_t)xx, (int16_t)yy, (uint8_t)id);
 					}
 					break;
 				}

+ 2 - 2
src/resource/sound_resource.h

@@ -18,8 +18,8 @@ struct SoundType
 {
 	enum Enum
 	{
-		WAV = 0,
-		OGG = 1
+		WAV,
+		OGG
 	};
 };