2017-12-10 20:40:37 +00:00
|
|
|
#include "api.h"
|
2017-05-25 00:38:03 +00:00
|
|
|
#include "physics/physics.h"
|
|
|
|
|
2019-06-02 07:20:10 +00:00
|
|
|
void luax_pushjoint(lua_State* L, Joint* joint) {
|
|
|
|
switch (joint->type) {
|
|
|
|
case JOINT_BALL: luax_pushtype(L, BallJoint, joint); break;
|
|
|
|
case JOINT_DISTANCE: luax_pushtype(L, DistanceJoint, joint); break;
|
|
|
|
case JOINT_HINGE: luax_pushtype(L, HingeJoint, joint); break;
|
|
|
|
case JOINT_SLIDER: luax_pushtype(L, SliderJoint, joint); break;
|
2019-11-12 00:27:30 +00:00
|
|
|
default: lovrThrow("Unreachable");
|
2019-06-02 07:20:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Joint* luax_checkjoint(lua_State* L, int index) {
|
|
|
|
Proxy* p = lua_touserdata(L, index);
|
2019-09-07 22:07:07 +00:00
|
|
|
|
|
|
|
if (p) {
|
|
|
|
const uint64_t hashes[] = {
|
|
|
|
hash64("BallJoint", strlen("BallJoint")),
|
|
|
|
hash64("DistanceJoint", strlen("DistanceJoint")),
|
|
|
|
hash64("HingeJoint", strlen("HingeJoint")),
|
|
|
|
hash64("SliderJoint", strlen("SliderJoint"))
|
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(hashes) / sizeof(hashes[0]); i++) {
|
|
|
|
if (p->hash == hashes[i]) {
|
|
|
|
return p->object;
|
|
|
|
}
|
|
|
|
}
|
2019-06-02 07:20:10 +00:00
|
|
|
}
|
2019-09-07 22:07:07 +00:00
|
|
|
|
|
|
|
luaL_typerror(L, index, "Joint");
|
|
|
|
return NULL;
|
2019-06-02 07:20:10 +00:00
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrJointDestroy(lua_State* L) {
|
2019-06-02 07:20:10 +00:00
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
2017-05-25 00:38:03 +00:00
|
|
|
lovrJointDestroyData(joint);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrJointGetType(lua_State* L) {
|
2019-06-02 07:20:10 +00:00
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
2018-07-05 03:11:52 +00:00
|
|
|
lua_pushstring(L, JointTypes[lovrJointGetType(joint)]);
|
2017-05-25 00:38:03 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrJointGetColliders(lua_State* L) {
|
2019-06-02 07:20:10 +00:00
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
2017-05-25 00:38:03 +00:00
|
|
|
Collider* a;
|
|
|
|
Collider* b;
|
|
|
|
lovrJointGetColliders(joint, &a, &b);
|
2019-06-02 07:20:10 +00:00
|
|
|
luax_pushtype(L, Collider, a);
|
|
|
|
luax_pushtype(L, Collider, b);
|
2017-05-25 00:38:03 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrJointGetUserData(lua_State* L) {
|
2019-06-02 07:20:10 +00:00
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
2019-03-17 07:58:01 +00:00
|
|
|
union { int i; void* p; } ref = { .p = lovrJointGetUserData(joint) };
|
|
|
|
lua_rawgeti(L, LUA_REGISTRYINDEX, ref.i);
|
2017-05-25 00:38:03 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrJointSetUserData(lua_State* L) {
|
2019-06-02 07:20:10 +00:00
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
2019-03-17 07:58:01 +00:00
|
|
|
union { int i; void* p; } ref = { .p = lovrJointGetUserData(joint) };
|
|
|
|
if (ref.i) {
|
|
|
|
luaL_unref(L, LUA_REGISTRYINDEX, ref.i);
|
2017-05-25 00:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lua_gettop(L) < 2) {
|
|
|
|
lua_pushnil(L);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_settop(L, 2);
|
2019-03-17 07:58:01 +00:00
|
|
|
ref.i = luaL_ref(L, LUA_REGISTRYINDEX);
|
|
|
|
lovrJointSetUserData(joint, ref.p);
|
2017-05-25 00:38:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-12 00:27:30 +00:00
|
|
|
static int l_lovrJointIsEnabled(lua_State* L) {
|
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
|
|
|
lua_pushboolean(L, lovrJointIsEnabled(joint));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int l_lovrJointSetEnabled(lua_State* L) {
|
|
|
|
Joint* joint = luax_checkjoint(L, 1);
|
|
|
|
bool enable = lua_toboolean(L, 2);
|
|
|
|
lovrJointSetEnabled(joint, enable);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-02 07:20:10 +00:00
|
|
|
#define lovrJoint \
|
|
|
|
{ "destroy", l_lovrJointDestroy }, \
|
|
|
|
{ "getType", l_lovrJointGetType }, \
|
|
|
|
{ "getColliders", l_lovrJointGetColliders }, \
|
|
|
|
{ "getUserData", l_lovrJointGetUserData }, \
|
2019-11-12 00:27:30 +00:00
|
|
|
{ "setUserData", l_lovrJointSetUserData }, \
|
|
|
|
{ "isEnabled", l_lovrJointIsEnabled }, \
|
|
|
|
{ "setEnabled", l_lovrJointSetEnabled }
|
2017-05-25 00:38:03 +00:00
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrBallJointGetAnchors(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
BallJoint* joint = luax_checktype(L, 1, BallJoint);
|
2017-05-25 06:47:16 +00:00
|
|
|
float x1, y1, z1, x2, y2, z2;
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrBallJointGetAnchors(joint, &x1, &y1, &z1, &x2, &y2, &z2);
|
2017-05-25 06:47:16 +00:00
|
|
|
lua_pushnumber(L, x1);
|
|
|
|
lua_pushnumber(L, y1);
|
|
|
|
lua_pushnumber(L, z1);
|
|
|
|
lua_pushnumber(L, x2);
|
|
|
|
lua_pushnumber(L, y2);
|
|
|
|
lua_pushnumber(L, z2);
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrBallJointSetAnchor(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
BallJoint* joint = luax_checktype(L, 1, BallJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float x = luax_checkfloat(L, 2);
|
|
|
|
float y = luax_checkfloat(L, 3);
|
|
|
|
float z = luax_checkfloat(L, 4);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrBallJointSetAnchor(joint, x, y, z);
|
2017-05-25 06:47:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-25 00:38:03 +00:00
|
|
|
const luaL_Reg lovrBallJoint[] = {
|
2019-06-02 07:20:10 +00:00
|
|
|
lovrJoint,
|
2017-05-25 06:47:16 +00:00
|
|
|
{ "getAnchors", l_lovrBallJointGetAnchors },
|
|
|
|
{ "setAnchor", l_lovrBallJointSetAnchor },
|
2017-05-25 00:38:03 +00:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
2017-05-25 06:51:27 +00:00
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrDistanceJointGetAnchors(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
DistanceJoint* joint = luax_checktype(L, 1, DistanceJoint);
|
|
|
|
float x1, y1, z1, x2, y2, z2;
|
|
|
|
lovrDistanceJointGetAnchors(joint, &x1, &y1, &z1, &x2, &y2, &z2);
|
|
|
|
lua_pushnumber(L, x1);
|
|
|
|
lua_pushnumber(L, y1);
|
|
|
|
lua_pushnumber(L, z1);
|
|
|
|
lua_pushnumber(L, x2);
|
|
|
|
lua_pushnumber(L, y2);
|
|
|
|
lua_pushnumber(L, z2);
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrDistanceJointSetAnchors(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
DistanceJoint* joint = luax_checktype(L, 1, DistanceJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float x1 = luax_checkfloat(L, 2);
|
|
|
|
float y1 = luax_checkfloat(L, 3);
|
|
|
|
float z1 = luax_checkfloat(L, 4);
|
|
|
|
float x2 = luax_checkfloat(L, 5);
|
|
|
|
float y2 = luax_checkfloat(L, 6);
|
|
|
|
float z2 = luax_checkfloat(L, 7);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrDistanceJointSetAnchors(joint, x1, y1, z1, x2, y2, z2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrDistanceJointGetDistance(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
DistanceJoint* joint = luax_checktype(L, 1, DistanceJoint);
|
|
|
|
lua_pushnumber(L, lovrDistanceJointGetDistance(joint));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrDistanceJointSetDistance(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
DistanceJoint* joint = luax_checktype(L, 1, DistanceJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float distance = luax_checkfloat(L, 2);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrDistanceJointSetDistance(joint, distance);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const luaL_Reg lovrDistanceJoint[] = {
|
2019-06-02 07:20:10 +00:00
|
|
|
lovrJoint,
|
2017-06-10 22:13:19 +00:00
|
|
|
{ "getAnchors", l_lovrDistanceJointGetAnchors },
|
|
|
|
{ "setAnchors", l_lovrDistanceJointSetAnchors },
|
|
|
|
{ "getDistance", l_lovrDistanceJointGetDistance },
|
|
|
|
{ "setDistance", l_lovrDistanceJointSetDistance },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointGetAnchors(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2017-05-25 06:51:27 +00:00
|
|
|
float x1, y1, z1, x2, y2, z2;
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointGetAnchors(joint, &x1, &y1, &z1, &x2, &y2, &z2);
|
2017-05-25 06:51:27 +00:00
|
|
|
lua_pushnumber(L, x1);
|
|
|
|
lua_pushnumber(L, y1);
|
|
|
|
lua_pushnumber(L, z1);
|
|
|
|
lua_pushnumber(L, x2);
|
|
|
|
lua_pushnumber(L, y2);
|
|
|
|
lua_pushnumber(L, z2);
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointSetAnchor(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float x = luax_checkfloat(L, 2);
|
|
|
|
float y = luax_checkfloat(L, 3);
|
|
|
|
float z = luax_checkfloat(L, 4);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointSetAnchor(joint, x, y, z);
|
2017-05-25 06:51:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointGetAxis(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2017-05-25 06:51:27 +00:00
|
|
|
float x, y, z;
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointGetAxis(joint, &x, &y, &z);
|
2017-05-25 06:51:27 +00:00
|
|
|
lua_pushnumber(L, x);
|
|
|
|
lua_pushnumber(L, y);
|
|
|
|
lua_pushnumber(L, z);
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointSetAxis(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float x = luax_checkfloat(L, 2);
|
|
|
|
float y = luax_checkfloat(L, 3);
|
|
|
|
float z = luax_checkfloat(L, 4);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointSetAxis(joint, x, y, z);
|
2017-05-25 06:51:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointGetAngle(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
|
|
|
lua_pushnumber(L, lovrHingeJointGetAngle(joint));
|
2017-05-25 06:51:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointGetLowerLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
|
|
|
lua_pushnumber(L, lovrHingeJointGetLowerLimit(joint));
|
2017-05-25 22:20:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointSetLowerLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float limit = luax_checkfloat(L, 2);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointSetLowerLimit(joint, limit);
|
2017-05-25 22:20:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointGetUpperLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
|
|
|
lua_pushnumber(L, lovrHingeJointGetUpperLimit(joint));
|
2017-05-25 22:20:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointSetUpperLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float limit = luax_checkfloat(L, 2);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointSetUpperLimit(joint, limit);
|
2017-05-25 22:20:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointGetLimits(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
|
|
|
lua_pushnumber(L, lovrHingeJointGetLowerLimit(joint));
|
|
|
|
lua_pushnumber(L, lovrHingeJointGetUpperLimit(joint));
|
2017-05-25 22:20:55 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrHingeJointSetLimits(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float lower = luax_checkfloat(L, 2);
|
|
|
|
float upper = luax_checkfloat(L, 3);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrHingeJointSetLowerLimit(joint, lower);
|
|
|
|
lovrHingeJointSetUpperLimit(joint, upper);
|
2017-05-25 22:20:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-25 06:51:27 +00:00
|
|
|
const luaL_Reg lovrHingeJoint[] = {
|
2019-06-02 07:20:10 +00:00
|
|
|
lovrJoint,
|
2017-05-25 06:51:27 +00:00
|
|
|
{ "getAnchors", l_lovrHingeJointGetAnchors },
|
|
|
|
{ "setAnchor", l_lovrHingeJointSetAnchor },
|
|
|
|
{ "getAxis", l_lovrHingeJointGetAxis },
|
|
|
|
{ "setAxis", l_lovrHingeJointSetAxis },
|
|
|
|
{ "getAngle", l_lovrHingeJointGetAngle },
|
2017-05-25 22:20:55 +00:00
|
|
|
{ "getLowerLimit", l_lovrHingeJointGetLowerLimit },
|
|
|
|
{ "setLowerLimit", l_lovrHingeJointSetLowerLimit },
|
|
|
|
{ "getUpperLimit", l_lovrHingeJointGetUpperLimit },
|
|
|
|
{ "setUpperLimit", l_lovrHingeJointSetUpperLimit },
|
|
|
|
{ "getLimits", l_lovrHingeJointGetLimits },
|
|
|
|
{ "setLimits", l_lovrHingeJointSetLimits },
|
2017-05-25 06:51:27 +00:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
2017-05-25 07:48:02 +00:00
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointGetAxis(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
2017-05-25 07:48:02 +00:00
|
|
|
float x, y, z;
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrSliderJointGetAxis(joint, &x, &y, &z);
|
2017-05-25 07:48:02 +00:00
|
|
|
lua_pushnumber(L, x);
|
|
|
|
lua_pushnumber(L, y);
|
|
|
|
lua_pushnumber(L, z);
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointSetAxis(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float x = luax_checkfloat(L, 2);
|
|
|
|
float y = luax_checkfloat(L, 3);
|
|
|
|
float z = luax_checkfloat(L, 4);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrSliderJointSetAxis(joint, x, y, z);
|
2017-05-25 07:48:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointGetPosition(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
|
|
|
lua_pushnumber(L, lovrSliderJointGetPosition(joint));
|
2017-05-25 07:48:02 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointGetLowerLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
|
|
|
lua_pushnumber(L, lovrSliderJointGetLowerLimit(joint));
|
2017-05-25 22:20:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointSetLowerLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float limit = luax_checkfloat(L, 2);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrSliderJointSetLowerLimit(joint, limit);
|
2017-05-25 22:20:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointGetUpperLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
|
|
|
lua_pushnumber(L, lovrSliderJointGetUpperLimit(joint));
|
2017-05-25 22:20:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointSetUpperLimit(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float limit = luax_checkfloat(L, 2);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrSliderJointSetUpperLimit(joint, limit);
|
2017-05-25 22:20:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointGetLimits(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
|
|
|
lua_pushnumber(L, lovrSliderJointGetLowerLimit(joint));
|
|
|
|
lua_pushnumber(L, lovrSliderJointGetUpperLimit(joint));
|
2017-05-25 22:20:55 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:52:22 +00:00
|
|
|
static int l_lovrSliderJointSetLimits(lua_State* L) {
|
2017-06-10 22:13:19 +00:00
|
|
|
SliderJoint* joint = luax_checktype(L, 1, SliderJoint);
|
2019-01-29 10:28:55 +00:00
|
|
|
float lower = luax_checkfloat(L, 2);
|
|
|
|
float upper = luax_checkfloat(L, 3);
|
2017-06-10 22:13:19 +00:00
|
|
|
lovrSliderJointSetLowerLimit(joint, lower);
|
|
|
|
lovrSliderJointSetUpperLimit(joint, upper);
|
2017-05-25 22:20:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-25 07:48:02 +00:00
|
|
|
const luaL_Reg lovrSliderJoint[] = {
|
2019-06-02 07:20:10 +00:00
|
|
|
lovrJoint,
|
2017-05-25 07:48:02 +00:00
|
|
|
{ "getAxis", l_lovrSliderJointGetAxis },
|
|
|
|
{ "setAxis", l_lovrSliderJointSetAxis },
|
2017-05-25 22:20:55 +00:00
|
|
|
{ "getPosition", l_lovrSliderJointGetPosition },
|
|
|
|
{ "getLowerLimit", l_lovrSliderJointGetLowerLimit },
|
|
|
|
{ "setLowerLimit", l_lovrSliderJointSetLowerLimit },
|
|
|
|
{ "getUpperLimit", l_lovrSliderJointGetUpperLimit },
|
|
|
|
{ "setUpperLimit", l_lovrSliderJointSetUpperLimit },
|
|
|
|
{ "getLimits", l_lovrSliderJointGetLimits },
|
|
|
|
{ "setLimits", l_lovrSliderJointSetLimits },
|
2017-05-25 07:48:02 +00:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|