mirror of https://github.com/bjornbytes/lovr.git
rm Joint anchor setters;
For consistency, since not all the joints support them.
This commit is contained in:
parent
851b12b292
commit
d8d194e8ec
|
@ -153,14 +153,6 @@ static int l_lovrBallJointGetAnchors(lua_State* L) {
|
|||
return 6;
|
||||
}
|
||||
|
||||
static int l_lovrBallJointSetAnchor(lua_State* L) {
|
||||
BallJoint* joint = luax_checktype(L, 1, BallJoint);
|
||||
float anchor[3];
|
||||
luax_readvec3(L, 2, anchor, NULL);
|
||||
lovrBallJointSetAnchor(joint, anchor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrBallJointGetResponseTime(lua_State* L) {
|
||||
Joint* joint = luax_checkjoint(L, 1);
|
||||
float responseTime = lovrBallJointGetResponseTime(joint);
|
||||
|
@ -194,7 +186,6 @@ static int l_lovrBallJointSetTightness(lua_State* L) {
|
|||
const luaL_Reg lovrBallJoint[] = {
|
||||
lovrJoint,
|
||||
{ "getAnchors", l_lovrBallJointGetAnchors },
|
||||
{ "setAnchor", l_lovrBallJointSetAnchor },
|
||||
{ "getResponseTime", l_lovrBallJointGetResponseTime},
|
||||
{ "setResponseTime", l_lovrBallJointSetResponseTime},
|
||||
{ "getTightness", l_lovrBallJointGetTightness},
|
||||
|
@ -215,15 +206,6 @@ static int l_lovrDistanceJointGetAnchors(lua_State* L) {
|
|||
return 6;
|
||||
}
|
||||
|
||||
static int l_lovrDistanceJointSetAnchors(lua_State* L) {
|
||||
DistanceJoint* joint = luax_checktype(L, 1, DistanceJoint);
|
||||
float anchor1[3], anchor2[3];
|
||||
int index = luax_readvec3(L, 2, anchor1, NULL);
|
||||
luax_readvec3(L, index, anchor2, NULL);
|
||||
lovrDistanceJointSetAnchors(joint, anchor1, anchor2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrDistanceJointGetDistance(lua_State* L) {
|
||||
DistanceJoint* joint = luax_checktype(L, 1, DistanceJoint);
|
||||
lua_pushnumber(L, lovrDistanceJointGetDistance(joint));
|
||||
|
@ -270,7 +252,6 @@ static int l_lovrDistanceJointSetTightness(lua_State* L) {
|
|||
const luaL_Reg lovrDistanceJoint[] = {
|
||||
lovrJoint,
|
||||
{ "getAnchors", l_lovrDistanceJointGetAnchors },
|
||||
{ "setAnchors", l_lovrDistanceJointSetAnchors },
|
||||
{ "getDistance", l_lovrDistanceJointGetDistance },
|
||||
{ "setDistance", l_lovrDistanceJointSetDistance },
|
||||
{ "getResponseTime", l_lovrDistanceJointGetResponseTime},
|
||||
|
@ -293,14 +274,6 @@ static int l_lovrHingeJointGetAnchors(lua_State* L) {
|
|||
return 6;
|
||||
}
|
||||
|
||||
static int l_lovrHingeJointSetAnchor(lua_State* L) {
|
||||
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
||||
float anchor[3];
|
||||
luax_readvec3(L, 2, anchor, NULL);
|
||||
lovrHingeJointSetAnchor(joint, anchor);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrHingeJointGetAxis(lua_State* L) {
|
||||
HingeJoint* joint = luax_checktype(L, 1, HingeJoint);
|
||||
float axis[3];
|
||||
|
@ -370,7 +343,6 @@ static int l_lovrHingeJointSetLimits(lua_State* L) {
|
|||
const luaL_Reg lovrHingeJoint[] = {
|
||||
lovrJoint,
|
||||
{ "getAnchors", l_lovrHingeJointGetAnchors },
|
||||
{ "setAnchor", l_lovrHingeJointSetAnchor },
|
||||
{ "getAxis", l_lovrHingeJointGetAxis },
|
||||
{ "setAxis", l_lovrHingeJointSetAxis },
|
||||
{ "getAngle", l_lovrHingeJointGetAngle },
|
||||
|
|
|
@ -225,7 +225,6 @@ void lovrWeldJointGetAnchors(WeldJoint* joint, float anchor1[3], float anchor2[3
|
|||
|
||||
BallJoint* lovrBallJointCreate(Collider* a, Collider* b, float anchor[3]);
|
||||
void lovrBallJointGetAnchors(BallJoint* joint, float anchor1[3], float anchor2[3]);
|
||||
void lovrBallJointSetAnchor(BallJoint* joint, float anchor[3]);
|
||||
float lovrBallJointGetResponseTime(Joint* joint);
|
||||
void lovrBallJointSetResponseTime(Joint* joint, float responseTime);
|
||||
float lovrBallJointGetTightness(Joint* joint);
|
||||
|
@ -233,7 +232,6 @@ void lovrBallJointSetTightness(Joint* joint, float tightness);
|
|||
|
||||
DistanceJoint* lovrDistanceJointCreate(Collider* a, Collider* b, float anchor1[3], float anchor2[3]);
|
||||
void lovrDistanceJointGetAnchors(DistanceJoint* joint, float anchor1[3], float anchor2[3]);
|
||||
void lovrDistanceJointSetAnchors(DistanceJoint* joint, float anchor1[3], float anchor2[3]);
|
||||
float lovrDistanceJointGetDistance(DistanceJoint* joint);
|
||||
void lovrDistanceJointSetDistance(DistanceJoint* joint, float distance);
|
||||
float lovrDistanceJointGetResponseTime(Joint* joint);
|
||||
|
@ -243,7 +241,6 @@ void lovrDistanceJointSetTightness(Joint* joint, float tightness);
|
|||
|
||||
HingeJoint* lovrHingeJointCreate(Collider* a, Collider* b, float anchor[3], float axis[3]);
|
||||
void lovrHingeJointGetAnchors(HingeJoint* joint, float anchor1[3], float anchor2[3]);
|
||||
void lovrHingeJointSetAnchor(HingeJoint* joint, float anchor[3]);
|
||||
void lovrHingeJointGetAxis(HingeJoint* joint, float axis[3]);
|
||||
void lovrHingeJointSetAxis(HingeJoint* joint, float axis[3]);
|
||||
float lovrHingeJointGetAngle(HingeJoint* joint);
|
||||
|
|
|
@ -1200,12 +1200,6 @@ void lovrBallJointGetAnchors(BallJoint* joint, float anchor1[3], float anchor2[3
|
|||
lovrJointGetAnchors((Joint*) joint, anchor1, anchor2);
|
||||
}
|
||||
|
||||
void lovrBallJointSetAnchor(BallJoint* joint, float anchor[3]) {
|
||||
JPH_PointConstraint* constraint = (JPH_PointConstraint*) joint->constraint;
|
||||
JPH_PointConstraint_SetPoint1(constraint, JPH_ConstraintSpace_WorldSpace, vec3_toJolt(anchor));
|
||||
JPH_PointConstraint_SetPoint2(constraint, JPH_ConstraintSpace_WorldSpace, vec3_toJolt(anchor));
|
||||
}
|
||||
|
||||
float lovrBallJointGetResponseTime(Joint* joint) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt does not support BallJoint response time");
|
||||
}
|
||||
|
@ -1243,11 +1237,6 @@ void lovrDistanceJointGetAnchors(DistanceJoint* joint, float anchor1[3], float a
|
|||
lovrJointGetAnchors((Joint*) joint, anchor1, anchor2);
|
||||
}
|
||||
|
||||
void lovrDistanceJointSetAnchors(DistanceJoint* joint, float anchor1[3], float anchor2[3]) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt does not support modifying joint anchors after creation");
|
||||
// todo: no setter available, but the constraint could be removed and re-added
|
||||
}
|
||||
|
||||
float lovrDistanceJointGetDistance(DistanceJoint* joint) {
|
||||
return JPH_DistanceConstraint_GetMaxDistance((JPH_DistanceConstraint*) joint->constraint);
|
||||
}
|
||||
|
@ -1303,11 +1292,6 @@ void lovrHingeJointGetAnchors(HingeJoint* joint, float anchor1[3], float anchor2
|
|||
lovrJointGetAnchors(joint, anchor1, anchor2);
|
||||
}
|
||||
|
||||
void lovrHingeJointSetAnchor(HingeJoint* joint, float anchor[3]) {
|
||||
lovrLog(LOG_WARN, "PHY", "Jolt does not support modifying joint anchors after creation");
|
||||
// todo: no setter available, but the constraint could be removed and re-added
|
||||
}
|
||||
|
||||
void lovrHingeJointGetAxis(HingeJoint* joint, float axis[3]) {
|
||||
JPH_Vec3 resultAxis;
|
||||
JPH_HingeConstraintSettings* settings = JPH_HingeConstraint_GetSettings((JPH_HingeConstraint*) joint->constraint);
|
||||
|
@ -1334,7 +1318,6 @@ void lovrHingeJointSetAxis(HingeJoint* joint, float axis[3]) {
|
|||
// todo: no setter available, but the constraint could be removed and re-added
|
||||
}
|
||||
|
||||
|
||||
float lovrHingeJointGetAngle(HingeJoint* joint) {
|
||||
return -JPH_HingeConstraint_GetCurrentAngle((JPH_HingeConstraint*) joint->constraint);
|
||||
}
|
||||
|
|
|
@ -1107,7 +1107,7 @@ BallJoint* lovrBallJointCreate(Collider* a, Collider* b, float anchor[3]) {
|
|||
joint->id = dJointCreateBall(a->world->id, 0);
|
||||
dJointSetData(joint->id, joint);
|
||||
dJointAttach(joint->id, a->body, b->body);
|
||||
lovrBallJointSetAnchor(joint, anchor);
|
||||
dJointSetBallAnchor(joint->id, anchor[0], anchor[1], anchor[2]);
|
||||
lovrRetain(joint);
|
||||
return joint;
|
||||
}
|
||||
|
@ -1124,10 +1124,6 @@ void lovrBallJointGetAnchors(BallJoint* joint, float anchor1[3], float anchor2[3
|
|||
anchor2[2] = anchor[2];
|
||||
}
|
||||
|
||||
void lovrBallJointSetAnchor(BallJoint* joint, float anchor[3]) {
|
||||
dJointSetBallAnchor(joint->id, anchor[0], anchor[1], anchor[2]);
|
||||
}
|
||||
|
||||
float lovrBallJointGetResponseTime(Joint* joint) {
|
||||
return dJointGetBallParam(joint->id, dParamCFM);
|
||||
}
|
||||
|
@ -1152,7 +1148,8 @@ DistanceJoint* lovrDistanceJointCreate(Collider* a, Collider* b, float anchor1[3
|
|||
joint->id = dJointCreateDBall(a->world->id, 0);
|
||||
dJointSetData(joint->id, joint);
|
||||
dJointAttach(joint->id, a->body, b->body);
|
||||
lovrDistanceJointSetAnchors(joint, anchor1, anchor2);
|
||||
dJointSetDBallAnchor1(joint->id, anchor1[0], anchor1[1], anchor1[2]);
|
||||
dJointSetDBallAnchor2(joint->id, anchor2[0], anchor2[1], anchor2[2]);
|
||||
lovrRetain(joint);
|
||||
return joint;
|
||||
}
|
||||
|
@ -1169,11 +1166,6 @@ void lovrDistanceJointGetAnchors(DistanceJoint* joint, float anchor1[3], float a
|
|||
anchor2[2] = anchor[2];
|
||||
}
|
||||
|
||||
void lovrDistanceJointSetAnchors(DistanceJoint* joint, float anchor1[3], float anchor2[3]) {
|
||||
dJointSetDBallAnchor1(joint->id, anchor1[0], anchor1[1], anchor1[2]);
|
||||
dJointSetDBallAnchor2(joint->id, anchor2[0], anchor2[1], anchor2[2]);
|
||||
}
|
||||
|
||||
float lovrDistanceJointGetDistance(DistanceJoint* joint) {
|
||||
return dJointGetDBallDistance(joint->id);
|
||||
}
|
||||
|
@ -1206,7 +1198,7 @@ HingeJoint* lovrHingeJointCreate(Collider* a, Collider* b, float anchor[3], floa
|
|||
joint->id = dJointCreateHinge(a->world->id, 0);
|
||||
dJointSetData(joint->id, joint);
|
||||
dJointAttach(joint->id, a->body, b->body);
|
||||
lovrHingeJointSetAnchor(joint, anchor);
|
||||
dJointSetHingeAnchor(joint->id, anchor[0], anchor[1], anchor[2]);
|
||||
lovrHingeJointSetAxis(joint, axis);
|
||||
lovrRetain(joint);
|
||||
return joint;
|
||||
|
@ -1224,10 +1216,6 @@ void lovrHingeJointGetAnchors(HingeJoint* joint, float anchor1[3], float anchor2
|
|||
anchor2[2] = anchor[2];
|
||||
}
|
||||
|
||||
void lovrHingeJointSetAnchor(HingeJoint* joint, float anchor[3]) {
|
||||
dJointSetHingeAnchor(joint->id, anchor[0], anchor[1], anchor[2]);
|
||||
}
|
||||
|
||||
void lovrHingeJointGetAxis(HingeJoint* joint, float axis[3]) {
|
||||
dReal daxis[4];
|
||||
dJointGetHingeAxis(joint->id, daxis);
|
||||
|
|
Loading…
Reference in New Issue