mirror of https://github.com/bjornbytes/lovr.git
Limit simulation parameters to positive values
This commit is contained in:
parent
139808cab0
commit
5d18933411
|
@ -132,6 +132,7 @@ static int l_lovrBallJointGetResponseTime(lua_State* L) {
|
||||||
static int l_lovrBallJointSetResponseTime(lua_State* L) {
|
static int l_lovrBallJointSetResponseTime(lua_State* L) {
|
||||||
Joint* joint = luax_checkjoint(L, 1);
|
Joint* joint = luax_checkjoint(L, 1);
|
||||||
float responseTime = luax_checkfloat(L, 2);
|
float responseTime = luax_checkfloat(L, 2);
|
||||||
|
lovrAssert(responseTime >= 0, "Negative response time causes simulation instability");
|
||||||
lovrBallJointSetResponseTime(joint, responseTime);
|
lovrBallJointSetResponseTime(joint, responseTime);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +147,7 @@ static int l_lovrBallJointGetTightness(lua_State* L) {
|
||||||
static int l_lovrBallJointSetTightness(lua_State* L) {
|
static int l_lovrBallJointSetTightness(lua_State* L) {
|
||||||
Joint* joint = luax_checkjoint(L, 1);
|
Joint* joint = luax_checkjoint(L, 1);
|
||||||
float tightness = luax_checkfloat(L, 2);
|
float tightness = luax_checkfloat(L, 2);
|
||||||
|
lovrAssert(tightness >= 0, "Negative tightness factor causes simulation instability");
|
||||||
lovrBallJointSetTightness(joint, tightness);
|
lovrBallJointSetTightness(joint, tightness);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -206,6 +208,7 @@ static int l_lovrDistanceJointGetResponseTime(lua_State* L) {
|
||||||
static int l_lovrDistanceJointSetResponseTime(lua_State* L) {
|
static int l_lovrDistanceJointSetResponseTime(lua_State* L) {
|
||||||
Joint* joint = luax_checkjoint(L, 1);
|
Joint* joint = luax_checkjoint(L, 1);
|
||||||
float responseTime = luax_checkfloat(L, 2);
|
float responseTime = luax_checkfloat(L, 2);
|
||||||
|
lovrAssert(responseTime >= 0, "Negative response time causes simulation instability");
|
||||||
lovrDistanceJointSetResponseTime(joint, responseTime);
|
lovrDistanceJointSetResponseTime(joint, responseTime);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -220,6 +223,7 @@ static int l_lovrDistanceJointGetTightness(lua_State* L) {
|
||||||
static int l_lovrDistanceJointSetTightness(lua_State* L) {
|
static int l_lovrDistanceJointSetTightness(lua_State* L) {
|
||||||
Joint* joint = luax_checkjoint(L, 1);
|
Joint* joint = luax_checkjoint(L, 1);
|
||||||
float tightness = luax_checkfloat(L, 2);
|
float tightness = luax_checkfloat(L, 2);
|
||||||
|
lovrAssert(tightness >= 0, "Negative tightness factor causes simulation instability");
|
||||||
lovrDistanceJointSetTightness(joint, tightness);
|
lovrDistanceJointSetTightness(joint, tightness);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,7 @@ static int l_lovrWorldSetGravity(lua_State* L) {
|
||||||
static int l_lovrWorldGetTightness(lua_State* L) {
|
static int l_lovrWorldGetTightness(lua_State* L) {
|
||||||
World* world = luax_checktype(L, 1, World);
|
World* world = luax_checktype(L, 1, World);
|
||||||
float tightness = lovrWorldGetTightness(world);
|
float tightness = lovrWorldGetTightness(world);
|
||||||
|
lovrAssert(tightness >= 0, "Negative tightness factor causes simulation instability");
|
||||||
lua_pushnumber(L, tightness);
|
lua_pushnumber(L, tightness);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -211,6 +212,7 @@ static int l_lovrWorldGetResponseTime(lua_State* L) {
|
||||||
static int l_lovrWorldSetResponseTime(lua_State* L) {
|
static int l_lovrWorldSetResponseTime(lua_State* L) {
|
||||||
World* world = luax_checktype(L, 1, World);
|
World* world = luax_checktype(L, 1, World);
|
||||||
float responseTime = luax_checkfloat(L, 2);
|
float responseTime = luax_checkfloat(L, 2);
|
||||||
|
lovrAssert(responseTime >= 0, "Negative response time causes simulation instability");
|
||||||
lovrWorldSetResponseTime(world, responseTime);
|
lovrWorldSetResponseTime(world, responseTime);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue