mirror of https://github.com/bjornbytes/lovr.git
quat:direction returns vec3;
This commit is contained in:
parent
97e90a8699
commit
b1b97ddb02
|
@ -1301,12 +1301,9 @@ static int l_lovrQuatNormalize(lua_State* L) {
|
||||||
|
|
||||||
static int l_lovrQuatDirection(lua_State* L) {
|
static int l_lovrQuatDirection(lua_State* L) {
|
||||||
quat q = luax_checkvector(L, 1, V_QUAT, NULL);
|
quat q = luax_checkvector(L, 1, V_QUAT, NULL);
|
||||||
float x, y, z;
|
vec3 v = luax_newtempvector(L, V_VEC3);
|
||||||
quat_getDirection(q, &x, &y, &z);
|
quat_getDirection(q, v);
|
||||||
lua_pushnumber(L, x);
|
return 1;
|
||||||
lua_pushnumber(L, y);
|
|
||||||
lua_pushnumber(L, z);
|
|
||||||
return 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_lovrQuatConjugate(lua_State* L) {
|
static int l_lovrQuatConjugate(lua_State* L) {
|
||||||
|
|
|
@ -184,10 +184,10 @@ MAF quat quat_normalize(quat q) {
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
MAF void quat_getDirection(quat q, float* x, float* y, float* z) {
|
MAF void quat_getDirection(quat q, vec3 v) {
|
||||||
*x = -2.f * q[0] * q[2] - 2.f * q[3] * q[1];
|
v[0] = -2.f * q[0] * q[2] - 2.f * q[3] * q[1];
|
||||||
*y = -2.f * q[1] * q[2] + 2.f * q[3] * q[0];
|
v[1] = -2.f * q[1] * q[2] + 2.f * q[3] * q[0];
|
||||||
*z = -1.f + 2.f * q[0] * q[0] + 2.f * q[1] * q[1];
|
v[2] = -1.f + 2.f * q[0] * q[0] + 2.f * q[1] * q[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
MAF quat quat_conjugate(quat q) {
|
MAF quat quat_conjugate(quat q) {
|
||||||
|
|
Loading…
Reference in New Issue