Jelajahi Sumber

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

Daniele Bartolini 10 tahun lalu
induk
melakukan
f7d7404161
2 mengubah file dengan 7 tambahan dan 145 penghapusan
  1. 0 128
      src/lua/lua_math.cpp
  2. 7 17
      src/main/main_linux.cpp

+ 0 - 128
src/lua/lua_math.cpp

@@ -16,118 +16,6 @@
 namespace crown
 namespace crown
 {
 {
 
 
-static int math_to_rad(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(to_rad(stack.get_float(1)));
-	return 1;
-}
-
-static int math_to_deg(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(to_deg(stack.get_float(1)));
-	return 1;
-}
-
-static int math_next_pow_2(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_uint32(next_pow_2(stack.get_int(1)));
-	return 1;
-}
-
-static int math_is_pow_2(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_bool(is_pow_2(stack.get_int(1)));
-	return 1;
-}
-
-static int math_ceil(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(ceil(stack.get_float(1)));
-	return 1;
-}
-
-static int math_floor(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(floor(stack.get_float(1)));
-	return 1;
-}
-
-static int math_sqrt(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(sqrt(stack.get_float(1)));
-	return 1;
-}
-
-static int math_inv_sqrt(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(inv_sqrt(stack.get_float(1)));
-	return 1;
-}
-
-static int math_sin(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(sin(stack.get_float(1)));
-	return 1;
-}
-
-static int math_cos(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(cos(stack.get_float(1)));
-	return 1;
-}
-
-static int math_asin(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(asin(stack.get_float(1)));
-	return 1;
-}
-
-static int math_acos(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(acos(stack.get_float(1)));
-	return 1;
-}
-
-static int math_tan(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(tan(stack.get_float(1)));
-	return 1;
-}
-
-static int math_atan2(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(atan2(stack.get_float(1), stack.get_float(2)));
-	return 1;
-}
-
-static int math_abs(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(abs(stack.get_float(1)));
-	return 1;
-}
-
-static int math_fmod(lua_State* L)
-{
-	LuaStack stack(L);
-	stack.push_float(fmod(stack.get_float(1), stack.get_float(2)));
-	return 1;
-}
-
 static int math_ray_obb_intersection(lua_State* L)
 static int math_ray_obb_intersection(lua_State* L)
 {
 {
 	LuaStack stack(L);
 	LuaStack stack(L);
@@ -912,22 +800,6 @@ static int lightuserdata_newindex(lua_State* L)
 
 
 void load_math(LuaEnvironment& env)
 void load_math(LuaEnvironment& env)
 {
 {
-	env.load_module_function("Math", "to_rad",               math_to_rad);
-	env.load_module_function("Math", "to_deg",               math_to_deg);
-	env.load_module_function("Math", "next_pow_2",           math_next_pow_2);
-	env.load_module_function("Math", "is_pow_2",             math_is_pow_2);
-	env.load_module_function("Math", "ceil",                 math_ceil);
-	env.load_module_function("Math", "floor",                math_floor);
-	env.load_module_function("Math", "sqrt",                 math_sqrt);
-	env.load_module_function("Math", "inv_sqrt",             math_inv_sqrt);
-	env.load_module_function("Math", "sin",                  math_sin);
-	env.load_module_function("Math", "cos",                  math_cos);
-	env.load_module_function("Math", "asin",                 math_asin);
-	env.load_module_function("Math", "acos",                 math_acos);
-	env.load_module_function("Math", "tan",                  math_tan);
-	env.load_module_function("Math", "atan2",                math_atan2);
-	env.load_module_function("Math", "abs",                  math_abs);
-	env.load_module_function("Math", "fmod",                 math_fmod);
 	env.load_module_function("Math", "ray_obb_intersection", math_ray_obb_intersection);
 	env.load_module_function("Math", "ray_obb_intersection", math_ray_obb_intersection);
 
 
 	env.load_module_function("Vector3", "new",            vector3_new);
 	env.load_module_function("Vector3", "new",            vector3_new);

+ 7 - 17
src/main/main_linux.cpp

@@ -233,7 +233,8 @@ struct LinuxDevice
 			| KeyReleaseMask
 			| KeyReleaseMask
 			| ButtonPressMask
 			| ButtonPressMask
 			| ButtonReleaseMask
 			| ButtonReleaseMask
-			| PointerMotionMask;
+			| PointerMotionMask
+			| EnterWindowMask;
 
 
 		_x11_window = XCreateWindow(_x11_display
 		_x11_window = XCreateWindow(_x11_display
 			, parent_window
 			, parent_window
@@ -284,22 +285,6 @@ struct LinuxDevice
 		Thread main_thread;
 		Thread main_thread;
 		main_thread.start(func, &mta);
 		main_thread.start(func, &mta);
 
 
-		// Push initial mouse position
-		Window dummy1;
-		int dummy2;
-		unsigned int dummy3;
-		int mx, my;
-		XQueryPointer(_x11_display
-			, _x11_window
-			, &dummy1
-			, &dummy1
-			, &dummy2
-			, &dummy2
-			, &mx, &my
-			, &dummy3
-			);
-		_queue.push_mouse_event(mx, my);
-
 		while (!s_exit)
 		while (!s_exit)
 		{
 		{
 			pump_events();
 			pump_events();
@@ -337,6 +322,11 @@ struct LinuxDevice
 
 
 			switch (event.type)
 			switch (event.type)
 			{
 			{
+				case EnterNotify:
+				{
+					_queue.push_mouse_event(event.xcrossing.x, event.xcrossing.y);
+					break;
+				}
 				case ClientMessage:
 				case ClientMessage:
 				{
 				{
 					if ((Atom)event.xclient.data.l[0] == _wm_delete_message)
 					if ((Atom)event.xclient.data.l[0] == _wm_delete_message)