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