From 7ab572f151100048431fb46415f1841b48a70529 Mon Sep 17 00:00:00 2001 From: Colby Klein Date: Sat, 30 Apr 2022 14:48:40 -0700 Subject: [PATCH] fix project/unproject --- modules/mat4.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/mat4.lua b/modules/mat4.lua index 4865cb6..2824358 100644 --- a/modules/mat4.lua +++ b/modules/mat4.lua @@ -661,6 +661,7 @@ function mat4.project(obj, mvp, viewport) local point = mat4.mul_vec3_perspective(vec3(), mvp, obj) point.x = point.x * 0.5 + 0.5 point.y = point.y * 0.5 + 0.5 + point.z = point.z * 0.5 + 0.5 point.x = point.x * viewport[3] + viewport[1] point.y = point.y * viewport[4] + viewport[2] return point @@ -681,6 +682,7 @@ function mat4.unproject(win, mvp, viewport) -- 0..1 -> -1..1 point.x = point.x * 2 - 1 point.y = point.y * 2 - 1 + point.z = point.z * 2 - 1 return mat4.mul_vec3_perspective(point, tmp:invert(mvp), point) end