Skip to content

Commit

Permalink
Don't change the z value when calling screen_to_world
Browse files Browse the repository at this point in the history
Fixes #34
  • Loading branch information
britzl committed Feb 5, 2021
1 parent a089e88 commit 80f3260
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions orthographic/camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -656,15 +656,15 @@ function M.project(view, projection, world)
local v4 = projection * view * v4_tmp
world.x = ((v4.x + 1) / 2) * DISPLAY_WIDTH
world.y = ((v4.y + 1) / 2) * DISPLAY_HEIGHT
world.z = ((v4.z + 1) / 2)
world.z = ((v4.z + 0) / 2)
return world
end


local function unproject_xyz(inverse_view_projection, x, y, z)
x = (2 * x / DISPLAY_WIDTH) - 1
y = (2 * y / DISPLAY_HEIGHT) - 1
z = (2 * z) - 1
z = (2 * z)
local inv = inverse_view_projection
local x1 = x * inv.m00 + y * inv.m01 + z * inv.m02 + inv.m03
local y1 = x * inv.m10 + y * inv.m11 + z * inv.m12 + inv.m13
Expand Down

0 comments on commit 80f3260

Please sign in to comment.