Use better default for identity quat;

This commit is contained in:
bjorn 2019-06-14 15:04:17 -07:00
parent 9e42fe295a
commit f8f6d98df4
2 changed files with 5 additions and 2 deletions

View File

@ -44,7 +44,7 @@ static int l_lovrQuatUnpack(lua_State* L) {
int l_lovrQuatSet(lua_State* L) {
quat q = luax_checkmathtype(L, 1, MATH_QUAT, NULL);
if (lua_isnoneornil(L, 2)) {
quat_set(q, 0.f, 0.f, 0.f, 0.f);
quat_set(q, 0.f, 0.f, 0.f, 1.f);
} else if (lua_type(L, 2) == LUA_TNUMBER) {
float x = lua_tonumber(L, 2);
if (lua_type(L, 3) == LUA_TNUMBER) {

View File

@ -284,7 +284,10 @@ local quat = {
set = function(q, x, y, z, w, raw)
checkquat(q)
if type(x) == 'number' then
if x == nil then
q.x, q.y, q.z = 0, 0, 0
q.w = 1
elseif type(x) == 'number' then
if type(y) == 'number' then
if raw then
q.x, q.y, q.z, q.w = x, y, z, w