mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Expose axis vector of PrismaticJoint and WheelJoint (fixes #1176)
This commit is contained in:
@@ -6,6 +6,7 @@ Released: N/A
|
||||
* Added lovec.exe in Windows. It is the same as love.exe but built with the Console subsystem, so it always uses or provides a console.
|
||||
* Added 'shaderswitches' field to the table returned by love.graphics.getStats.
|
||||
* Added Quad:getTextureDimensions.
|
||||
* Added PrismaticJoint:getAxis and WheelJoint:getAxis.
|
||||
|
||||
* Fixed love on iOS 6.
|
||||
* Fixed os.execute always returning -1 on Linux.
|
||||
|
||||
@@ -138,6 +138,12 @@ int PrismaticJoint::getLimits(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
|
||||
int PrismaticJoint::getAxis(lua_State *L)
|
||||
{
|
||||
lua_pushnumber(L, joint->GetLocalAxisA().x);
|
||||
lua_pushnumber(L, joint->GetLocalAxisA().y);
|
||||
return 2;
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
|
||||
@@ -134,6 +134,13 @@ public:
|
||||
**/
|
||||
int getLimits(lua_State *L);
|
||||
|
||||
/**
|
||||
* Gets the axis unit vector, relative to body1.
|
||||
* @returns The X component of the axis unit vector.
|
||||
* @returns The Y component of the axis unit vector.
|
||||
**/
|
||||
int getAxis(lua_State *L);
|
||||
|
||||
private:
|
||||
|
||||
// The Box2D prismatic joint object.
|
||||
|
||||
@@ -113,6 +113,12 @@ float WheelJoint::getSpringDampingRatio() const
|
||||
return joint->GetSpringDampingRatio();
|
||||
}
|
||||
|
||||
int WheelJoint::getAxis(lua_State *L)
|
||||
{
|
||||
lua_pushnumber(L, joint->GetLocalAxisA().x);
|
||||
lua_pushnumber(L, joint->GetLocalAxisA().y);
|
||||
return 2;
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
|
||||
@@ -114,6 +114,13 @@ public:
|
||||
**/
|
||||
float getSpringDampingRatio() const;
|
||||
|
||||
/**
|
||||
* Gets the axis unit vector, relative to body1.
|
||||
* @returns The X component of the axis unit vector.
|
||||
* @returns The Y component of the axis unit vector.
|
||||
**/
|
||||
int getAxis(lua_State *L);
|
||||
|
||||
private:
|
||||
|
||||
// The Box2D wheel joint object.
|
||||
|
||||
@@ -164,6 +164,13 @@ int w_PrismaticJoint_getLimits(lua_State *L)
|
||||
return t->getLimits(L);
|
||||
}
|
||||
|
||||
int w_PrismaticJoint_getAxis(lua_State *L)
|
||||
{
|
||||
PrismaticJoint *t = luax_checkprismaticjoint(L, 1);
|
||||
lua_remove(L, 1);
|
||||
return t->getAxis(L);
|
||||
}
|
||||
|
||||
static const luaL_Reg w_PrismaticJoint_functions[] =
|
||||
{
|
||||
{ "getJointTranslation", w_PrismaticJoint_getJointTranslation },
|
||||
@@ -183,6 +190,7 @@ static const luaL_Reg w_PrismaticJoint_functions[] =
|
||||
{ "getLowerLimit", w_PrismaticJoint_getLowerLimit },
|
||||
{ "getUpperLimit", w_PrismaticJoint_getUpperLimit },
|
||||
{ "getLimits", w_PrismaticJoint_getLimits },
|
||||
{ "getAxis", w_PrismaticJoint_getAxis },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -132,6 +132,13 @@ int w_WheelJoint_getSpringDampingRatio(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_WheelJoint_getAxis(lua_State *L)
|
||||
{
|
||||
WheelJoint *t = luax_checkwheeljoint(L, 1);
|
||||
lua_remove(L, 1);
|
||||
return t->getAxis(L);
|
||||
}
|
||||
|
||||
static const luaL_Reg w_WheelJoint_functions[] =
|
||||
{
|
||||
{ "getJointTranslation", w_WheelJoint_getJointTranslation },
|
||||
@@ -147,6 +154,7 @@ static const luaL_Reg w_WheelJoint_functions[] =
|
||||
{ "getSpringFrequency", w_WheelJoint_getSpringFrequency },
|
||||
{ "setSpringDampingRatio", w_WheelJoint_setSpringDampingRatio },
|
||||
{ "getSpringDampingRatio", w_WheelJoint_getSpringDampingRatio },
|
||||
{ "getAxis", w_WheelJoint_getAxis },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user