Created
February 23, 2017 13:38
-
-
Save HybridDog/76eee7890a439e6984aa4ca45c1e04e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function fine_pointed(pos, camera_pos, pos_off, look_dir) | |
local offset, nc | |
local oc = {} | |
for c,v in pairs(pos_off) do | |
if v == 0 then | |
oc[#oc + 1] = c | |
else | |
offset = v | |
nc = c | |
end | |
end | |
local fine_pos = {[nc] = pos[nc] + offset} | |
camera_pos.y = camera_pos.y + 1.625 | |
local f = (pos[nc] + offset - camera_pos[nc]) / look_dir[nc] | |
for i = 1,#oc do | |
fine_pos[oc[i]] = camera_pos[oc[i]] + look_dir[oc[i]] * f | |
end | |
camera_pos.y = camera_pos.y - 1.625 | |
return fine_pos | |
end | |
function minetest.fine_pointed_position(player, pt) | |
return fine_pointed( | |
pt.under, | |
player:getpos(), | |
vector.multiply(vector.subtract(pt.above, pt.under), 0.5), | |
player:get_look_dir() | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When listening to an UNIX shell, one can hear the C.