mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Trying to figure out how hg works...
This commit is contained in:
@@ -160,6 +160,67 @@ namespace box2d
|
|||||||
v[2] = f.groupIndex;
|
v[2] = f.groupIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Shape::setCategory(lua_State * L)
|
||||||
|
{
|
||||||
|
b2FilterData f = shape->GetFilterData();
|
||||||
|
f.categoryBits = (uint16)getBits(L);
|
||||||
|
shape->SetFilterData(f);
|
||||||
|
shape->GetBody()->GetWorld()->Refilter(shape);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shape::setMask(lua_State * L)
|
||||||
|
{
|
||||||
|
b2FilterData f = shape->GetFilterData();
|
||||||
|
f.maskBits = ~(uint16)getBits(L);
|
||||||
|
shape->SetFilterData(f);
|
||||||
|
shape->GetBody()->GetWorld()->Refilter(shape);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shape::getCategory(lua_State * L)
|
||||||
|
{
|
||||||
|
return pushBits(L, shape->GetFilterData().categoryBits);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shape::getMask(lua_State * L)
|
||||||
|
{
|
||||||
|
return pushBits(L, ~(shape->GetFilterData().maskBits));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 Shape::getBits(lua_State * L)
|
||||||
|
{
|
||||||
|
// Get number of args.
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
|
// The new bitset.
|
||||||
|
std::bitset<16> b;
|
||||||
|
|
||||||
|
for(int i = 1;i<=argc;i++)
|
||||||
|
{
|
||||||
|
size_t bpos = (size_t)(lua_tointeger(L, i)-1);
|
||||||
|
if(bpos < 0 || bpos > 16)
|
||||||
|
return luaL_error(L, "Values must be in range 1-16.");
|
||||||
|
b.set(bpos, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uint16)b.to_ulong();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shape::pushBits(lua_State * L, uint16 bits)
|
||||||
|
{
|
||||||
|
// Create a bitset.
|
||||||
|
std::bitset<16> b((unsigned long)bits);
|
||||||
|
|
||||||
|
// Push all set bits.
|
||||||
|
for(int i = 0;i<16;i++)
|
||||||
|
if(b.test(i))
|
||||||
|
lua_pushinteger(L, i+1);
|
||||||
|
|
||||||
|
// Count number of set bits.
|
||||||
|
return (int)b.count();
|
||||||
|
}
|
||||||
|
|
||||||
int Shape::setData(lua_State * L)
|
int Shape::setData(lua_State * L)
|
||||||
{
|
{
|
||||||
love::luax_assert_argc(L, 1, 1);
|
love::luax_assert_argc(L, 1, 1);
|
||||||
|
|||||||
@@ -168,6 +168,13 @@ namespace box2d
|
|||||||
**/
|
**/
|
||||||
void getFilterData(int * v);
|
void getFilterData(int * v);
|
||||||
|
|
||||||
|
int setCategory(lua_State * L);
|
||||||
|
int setMask(lua_State * L);
|
||||||
|
int getCategory(lua_State * L);
|
||||||
|
int getMask(lua_State * L);
|
||||||
|
uint16 getBits(lua_State * L);
|
||||||
|
int pushBits(lua_State * L, uint16 bits);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function stores an in-C reference to
|
* This function stores an in-C reference to
|
||||||
* arbitrary Lua data in the Box2D shape object.
|
* arbitrary Lua data in the Box2D shape object.
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ namespace box2d
|
|||||||
{ "testSegment", w_Shape_testSegment },
|
{ "testSegment", w_Shape_testSegment },
|
||||||
{ "setFilterData", w_Shape_setFilterData },
|
{ "setFilterData", w_Shape_setFilterData },
|
||||||
{ "getFilterData", w_Shape_getFilterData },
|
{ "getFilterData", w_Shape_getFilterData },
|
||||||
|
{ "setCategory", w_Shape_setCategory },
|
||||||
|
{ "getCategory", w_Shape_getCategory },
|
||||||
|
{ "setMask", w_Shape_setMask },
|
||||||
|
{ "getMask", w_Shape_getMask },
|
||||||
{ "setData", w_Shape_setData },
|
{ "setData", w_Shape_setData },
|
||||||
{ "getData", w_Shape_getData },
|
{ "getData", w_Shape_getData },
|
||||||
{ "getBoundingBox", w_Shape_getBoundingBox },
|
{ "getBoundingBox", w_Shape_getBoundingBox },
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ namespace box2d
|
|||||||
{ "testSegment", w_Shape_testSegment },
|
{ "testSegment", w_Shape_testSegment },
|
||||||
{ "setFilterData", w_Shape_setFilterData },
|
{ "setFilterData", w_Shape_setFilterData },
|
||||||
{ "getFilterData", w_Shape_getFilterData },
|
{ "getFilterData", w_Shape_getFilterData },
|
||||||
|
{ "setCategory", w_Shape_setCategory },
|
||||||
|
{ "getCategory", w_Shape_getCategory },
|
||||||
|
{ "setMask", w_Shape_setMask },
|
||||||
|
{ "getMask", w_Shape_getMask },
|
||||||
{ "setData", w_Shape_setData },
|
{ "setData", w_Shape_setData },
|
||||||
{ "getData", w_Shape_getData },
|
{ "getData", w_Shape_getData },
|
||||||
{ "getBoundingBox", w_Shape_getBoundingBox },
|
{ "getBoundingBox", w_Shape_getBoundingBox },
|
||||||
|
|||||||
@@ -145,6 +145,34 @@ namespace box2d
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_Shape_setCategory(lua_State * L)
|
||||||
|
{
|
||||||
|
Shape * t = luax_checkshape(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
return t->setCategory(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
int w_Shape_getCategory(lua_State * L)
|
||||||
|
{
|
||||||
|
Shape * t = luax_checkshape(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
return t->getCategory(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
int w_Shape_setMask(lua_State * L)
|
||||||
|
{
|
||||||
|
Shape * t = luax_checkshape(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
return t->setMask(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
int w_Shape_getMask(lua_State * L)
|
||||||
|
{
|
||||||
|
Shape * t = luax_checkshape(L, 1);
|
||||||
|
lua_remove(L, 1);
|
||||||
|
return t->getMask(L);
|
||||||
|
}
|
||||||
|
|
||||||
int w_Shape_setData(lua_State * L)
|
int w_Shape_setData(lua_State * L)
|
||||||
{
|
{
|
||||||
Shape * t = luax_checkshape(L, 1);
|
Shape * t = luax_checkshape(L, 1);
|
||||||
@@ -180,6 +208,10 @@ namespace box2d
|
|||||||
{ "testSegment", w_Shape_testSegment },
|
{ "testSegment", w_Shape_testSegment },
|
||||||
{ "setFilterData", w_Shape_setFilterData },
|
{ "setFilterData", w_Shape_setFilterData },
|
||||||
{ "getFilterData", w_Shape_getFilterData },
|
{ "getFilterData", w_Shape_getFilterData },
|
||||||
|
{ "setCategory", w_Shape_setCategory },
|
||||||
|
{ "getCategory", w_Shape_getCategory },
|
||||||
|
{ "setMask", w_Shape_setMask },
|
||||||
|
{ "getMask", w_Shape_getMask },
|
||||||
{ "setData", w_Shape_setData },
|
{ "setData", w_Shape_setData },
|
||||||
{ "getData", w_Shape_getData },
|
{ "getData", w_Shape_getData },
|
||||||
{ "getBoundingBox", w_Shape_getBoundingBox },
|
{ "getBoundingBox", w_Shape_getBoundingBox },
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ namespace box2d
|
|||||||
int w_Shape_testSegment(lua_State * L);
|
int w_Shape_testSegment(lua_State * L);
|
||||||
int w_Shape_setFilterData(lua_State * L);
|
int w_Shape_setFilterData(lua_State * L);
|
||||||
int w_Shape_getFilterData(lua_State * L);
|
int w_Shape_getFilterData(lua_State * L);
|
||||||
|
int w_Shape_setCategory(lua_State * L);
|
||||||
|
int w_Shape_getCategory(lua_State * L);
|
||||||
|
int w_Shape_setMask(lua_State * L);
|
||||||
|
int w_Shape_getMask(lua_State * L);
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user