Browse Source

Added get/setGroupIndex (#129) and get/setFixedRotation (#113). Also fixed 3000 auto.lua-related warnings in MSVC.

rude 15 years ago
parent
commit
cd24dbcb8e

+ 1 - 1
src/love.cpp

@@ -294,7 +294,7 @@ int main(int argc, char ** argv)
 	}
 	}
 
 
 	// Boot
 	// Boot
-	if (luaL_loadbuffer(L, love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0)
+	if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0)
 		lua_call(L, 0, 0);
 		lua_call(L, 0, 0);
 
 
 	lua_close(L);
 	lua_close(L);

+ 1 - 1
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -892,7 +892,7 @@ namespace opengl
 
 
 		luax_register_module(L, w);
 		luax_register_module(L, w);
 
 
-		if (luaL_loadbuffer(L, graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0)
+		if (luaL_loadbuffer(L, (const char *)graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0)
 			lua_call(L, 0, 0);
 			lua_call(L, 0, 0);
 
 
 		return 0;
 		return 0;

+ 13 - 0
src/modules/physics/box2d/Body.cpp

@@ -282,6 +282,19 @@ namespace box2d
 		body->WakeUp();
 		body->WakeUp();
 	}
 	}
 
 
+	void Body::setFixedRotation(bool fixed)
+	{
+		if(fixed)
+			body->m_flags |= b2Body::e_fixedRotationFlag;
+		else
+			body->m_flags |= ~(b2Body::e_fixedRotationFlag);
+	}
+
+	bool Body::getFixedRotation() const
+	{
+		return (body->m_flags & b2Body::e_fixedRotationFlag) != 0;
+	}
+
 	b2Vec2 Body::getVector(lua_State * L)
 	b2Vec2 Body::getVector(lua_State * L)
 	{
 	{
 		love::luax_assert_argc(L, 2, 2);
 		love::luax_assert_argc(L, 2, 2);

+ 2 - 0
src/modules/physics/box2d/Body.h

@@ -331,6 +331,8 @@ namespace box2d
 		**/
 		**/
 		void wakeUp();
 		void wakeUp();
 
 
+		void setFixedRotation(bool fixed);
+		bool getFixedRotation() const;
 	private:
 	private:
 
 
 		/**
 		/**

+ 14 - 0
src/modules/physics/box2d/Shape.cpp

@@ -183,6 +183,20 @@ namespace box2d
 		return 0;
 		return 0;
 	}
 	}
 
 
+	void Shape::setGroupIndex(int index)
+	{
+		b2FilterData f = shape->GetFilterData();
+		f.groupIndex = (uint16)index;
+		shape->SetFilterData(f);
+		shape->GetBody()->GetWorld()->Refilter(shape);
+	}
+
+	int Shape::getGroupIndex() const
+	{
+		b2FilterData f = shape->GetFilterData();
+		return f.groupIndex;
+	}
+
 	int Shape::getCategory(lua_State * L)
 	int Shape::getCategory(lua_State * L)
 	{
 	{
 		return pushBits(L, shape->GetFilterData().categoryBits);
 		return pushBits(L, shape->GetFilterData().categoryBits);

+ 3 - 0
src/modules/physics/box2d/Shape.h

@@ -168,6 +168,9 @@ namespace box2d
 		**/
 		**/
 		void getFilterData(int * v);
 		void getFilterData(int * v);
 		
 		
+		void setGroupIndex(int index);
+		int getGroupIndex() const;
+
 		int setCategory(lua_State * L);
 		int setCategory(lua_State * L);
 		int setMask(lua_State * L);
 		int setMask(lua_State * L);
 		int getCategory(lua_State * L);
 		int getCategory(lua_State * L);

+ 18 - 0
src/modules/physics/box2d/wrap_Body.cpp

@@ -425,6 +425,22 @@ namespace box2d
 		return 0;
 		return 0;
 	}
 	}
 
 
+	int w_Body_setFixedRotation(lua_State * L)
+	{
+		Body * t = luax_checkbody(L, 1);
+		bool b = luax_toboolean(L, 2);
+		t->setFixedRotation(b);
+		return 0;
+	}
+
+	int w_Body_getFixedRotation(lua_State * L)
+	{
+		Body * t = luax_checkbody(L, 1);
+		bool b = t->getFixedRotation();
+		luax_pushboolean(L, b);
+		return 1;
+	}
+
 	int w_Body_destroy(lua_State * L)
 	int w_Body_destroy(lua_State * L)
 	{
 	{
 		Proxy * p = (Proxy *)lua_touserdata(L, 1);
 		Proxy * p = (Proxy *)lua_touserdata(L, 1);
@@ -477,6 +493,8 @@ namespace box2d
 		{ "setAllowSleeping", w_Body_setAllowSleeping },
 		{ "setAllowSleeping", w_Body_setAllowSleeping },
 		{ "putToSleep", w_Body_putToSleep },
 		{ "putToSleep", w_Body_putToSleep },
 		{ "wakeUp", w_Body_wakeUp },
 		{ "wakeUp", w_Body_wakeUp },
+		{ "setFixedRotation", w_Body_setFixedRotation },
+		{ "getFixedRotation", w_Body_getFixedRotation },
 		{ "destroy", w_Body_destroy },
 		{ "destroy", w_Body_destroy },
 		{ 0, 0 }
 		{ 0, 0 }
 	};
 	};

+ 2 - 0
src/modules/physics/box2d/wrap_Body.h

@@ -73,6 +73,8 @@ namespace box2d
 	int w_Body_setAllowSleeping(lua_State * L);
 	int w_Body_setAllowSleeping(lua_State * L);
 	int w_Body_putToSleep(lua_State * L);
 	int w_Body_putToSleep(lua_State * L);
 	int w_Body_wakeUp(lua_State * L);
 	int w_Body_wakeUp(lua_State * L);
+	int w_Body_setFixedRotation(lua_State * L);
+	int w_Body_getFixedRotation(lua_State * L);
 	int w_Body_destroy(lua_State * L);
 	int w_Body_destroy(lua_State * L);
 	int luaopen_body(lua_State * L);
 	int luaopen_body(lua_State * L);
 
 

+ 18 - 0
src/modules/physics/box2d/wrap_Shape.cpp

@@ -198,6 +198,22 @@ namespace box2d
 		return t->getBoundingBox(L);
 		return t->getBoundingBox(L);
 	}
 	}
 
 
+	int w_Shape_getGroupIndex(lua_State * L)
+	{
+		Shape * t = luax_checkshape(L, 1);
+		int i = t->getGroupIndex();
+		lua_pushinteger(L, i);
+		return 1;
+	}
+
+	int w_Shape_setGroupIndex(lua_State * L)
+	{
+		Shape * t = luax_checkshape(L, 1);
+		int i = luaL_checkint(L, 2);
+		t->setGroupIndex(i);
+		return 0;
+	}
+
 	int w_Shape_destroy(lua_State * L)
 	int w_Shape_destroy(lua_State * L)
 	{
 	{
 		Proxy * p = (Proxy *)lua_touserdata(L, 1);
 		Proxy * p = (Proxy *)lua_touserdata(L, 1);
@@ -229,6 +245,8 @@ namespace box2d
 		{ "setData", w_Shape_setData },
 		{ "setData", w_Shape_setData },
 		{ "getData", w_Shape_getData },
 		{ "getData", w_Shape_getData },
 		{ "getBoundingBox", w_Shape_getBoundingBox },
 		{ "getBoundingBox", w_Shape_getBoundingBox },
+		{ "getGroupIndex", w_Shape_getGroupIndex },
+		{ "setGroupIndex", w_Shape_setGroupIndex },
 		{ "destroy", w_Shape_destroy },
 		{ "destroy", w_Shape_destroy },
 		{ 0, 0 }
 		{ 0, 0 }
 	};
 	};

+ 2 - 0
src/modules/physics/box2d/wrap_Shape.h

@@ -53,6 +53,8 @@ namespace box2d
 	int w_Shape_setData(lua_State * L);
 	int w_Shape_setData(lua_State * L);
 	int w_Shape_getData(lua_State * L);
 	int w_Shape_getData(lua_State * L);
 	int w_Shape_getBoundingBox(lua_State * L);
 	int w_Shape_getBoundingBox(lua_State * L);
+	int w_Shape_getGroupIndex();
+	int w_Shape_setGroupIndex();
 	int w_Shape_destroy(lua_State * L);
 	int w_Shape_destroy(lua_State * L);
 	int luaopen_shape(lua_State * L);
 	int luaopen_shape(lua_State * L);
 
 

+ 1 - 1
src/scripts/auto.lua

@@ -28,7 +28,7 @@ function auto(name)
 		end
 		end
 	end
 	end
 
 
-	local src_output = "const char "..cpp_name.."[] = \n{\n"
+	local src_output = "const unsigned char "..cpp_name.."[] = \n{\n"
 
 
 	for i,line in ipairs(lines) do
 	for i,line in ipairs(lines) do
 		local concat = {}
 		local concat = {}

+ 1 - 1
src/scripts/boot.lua.h

@@ -22,7 +22,7 @@ namespace love
 {
 {
 
 
 // [boot.lua]
 // [boot.lua]
-const char boot_lua[] = 
+const unsigned char boot_lua[] = 
 {
 {
 	0x1B,0x4C,0x75,0x61,0x51,0x00,0x01,0x04,0x04,0x04,0x08,0x00,0x0A,0x00,0x00,
 	0x1B,0x4C,0x75,0x61,0x51,0x00,0x01,0x04,0x04,0x04,0x08,0x00,0x0A,0x00,0x00,
 	0x00,0x40,0x62,0x6F,0x6F,0x74,0x2E,0x6C,0x75,0x61,0x00,0x00,0x00,0x00,0x00,
 	0x00,0x40,0x62,0x6F,0x6F,0x74,0x2E,0x6C,0x75,0x61,0x00,0x00,0x00,0x00,0x00,

+ 1 - 1
src/scripts/graphics.lua.h

@@ -22,7 +22,7 @@ namespace love
 {
 {
 
 
 // [graphics.lua]
 // [graphics.lua]
-const char graphics_lua[] = 
+const unsigned char graphics_lua[] = 
 {
 {
 	0x1B,0x4C,0x75,0x61,0x51,0x00,0x01,0x04,0x04,0x04,0x08,0x00,0x0E,0x00,0x00,
 	0x1B,0x4C,0x75,0x61,0x51,0x00,0x01,0x04,0x04,0x04,0x08,0x00,0x0E,0x00,0x00,
 	0x00,0x40,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x6C,0x75,0x61,0x00,
 	0x00,0x40,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x6C,0x75,0x61,0x00,