From f8f6d98df404fa9fb33e434cee2191551c5725d0 Mon Sep 17 00:00:00 2001 From: bjorn Date: Fri, 14 Jun 2019 15:04:17 -0700 Subject: [PATCH] Use better default for identity quat; --- src/api/l_quat.c | 2 +- src/resources/math.lua | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/l_quat.c b/src/api/l_quat.c index 7bc9bc2c..3e980b0f 100644 --- a/src/api/l_quat.c +++ b/src/api/l_quat.c @@ -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) { diff --git a/src/resources/math.lua b/src/resources/math.lua index 4eeb5f46..18ef9b4f 100644 --- a/src/resources/math.lua +++ b/src/resources/math.lua @@ -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