mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Support reference angle on revolute, prismatic, and weld joints (fixes #1194)
This commit is contained in:
@@ -219,11 +219,13 @@ int w_newRevoluteJoint(lua_State *L)
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB;
|
||||
bool collideConnected;
|
||||
float referenceAngle = 0.0f;
|
||||
if (lua_gettop(L) >= 6)
|
||||
{
|
||||
xB = (float)luaL_checknumber(L, 5);
|
||||
yB = (float)luaL_checknumber(L, 6);
|
||||
collideConnected = luax_optboolean(L, 7, false);
|
||||
referenceAngle = (float)luaL_optnumber(L, 8, referenceAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -233,7 +235,7 @@ int w_newRevoluteJoint(lua_State *L)
|
||||
}
|
||||
RevoluteJoint *j;
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newRevoluteJoint(body1, body2, xA, yA, xB, yB, collideConnected);
|
||||
j = instance()->newRevoluteJoint(body1, body2, xA, yA, xB, yB, collideConnected, referenceAngle);
|
||||
});
|
||||
luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j);
|
||||
j->release();
|
||||
@@ -248,6 +250,7 @@ int w_newPrismaticJoint(lua_State *L)
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB, ax, ay;
|
||||
bool collideConnected;
|
||||
float referenceAngle = 0.0f;
|
||||
if (lua_gettop(L) >= 8)
|
||||
{
|
||||
xB = (float)luaL_checknumber(L, 5);
|
||||
@@ -255,6 +258,7 @@ int w_newPrismaticJoint(lua_State *L)
|
||||
ax = (float)luaL_checknumber(L, 7);
|
||||
ay = (float)luaL_checknumber(L, 8);
|
||||
collideConnected = luax_optboolean(L, 9, false);
|
||||
referenceAngle = (float)luaL_optnumber(L, 10, referenceAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -266,7 +270,7 @@ int w_newPrismaticJoint(lua_State *L)
|
||||
}
|
||||
PrismaticJoint *j;
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected);
|
||||
j = instance()->newPrismaticJoint(body1, body2, xA, yA, xB, yB, ax, ay, collideConnected, referenceAngle);
|
||||
});
|
||||
luax_pushtype(L, PHYSICS_PRISMATIC_JOINT_ID, j);
|
||||
j->release();
|
||||
@@ -350,11 +354,13 @@ int w_newWeldJoint(lua_State *L)
|
||||
float yA = (float)luaL_checknumber(L, 4);
|
||||
float xB, yB;
|
||||
bool collideConnected;
|
||||
float referenceAngle = 0.0f;
|
||||
if (lua_gettop(L) >= 6)
|
||||
{
|
||||
xB = (float)luaL_checknumber(L, 5);
|
||||
yB = (float)luaL_checknumber(L, 6);
|
||||
collideConnected = luax_optboolean(L, 7, false);
|
||||
referenceAngle = (float)luaL_optnumber(L, 8, referenceAngle);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -364,7 +370,7 @@ int w_newWeldJoint(lua_State *L)
|
||||
}
|
||||
WeldJoint *j;
|
||||
luax_catchexcept(L, [&]() {
|
||||
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected);
|
||||
j = instance()->newWeldJoint(body1, body2, xA, yA, xB, yB, collideConnected, referenceAngle);
|
||||
});
|
||||
luax_pushtype(L, PHYSICS_WELD_JOINT_ID, j);
|
||||
j->release();
|
||||
|
||||
Reference in New Issue
Block a user