From 768c8b2caa01a0f631eacbe59913e84c4fc7f433 Mon Sep 17 00:00:00 2001 From: Li0n Date: Sat, 11 Nov 2023 01:17:17 +0100 Subject: [PATCH] =?UTF-8?q?*=20Align=20=E2=80=9Dright=E2=80=9D=20vector=20?= =?UTF-8?q?with=20the=20horizontal=20plane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The player's camera in Minetest has limited degrees of freedom: It can only rotate around the Y axis and look up and down. This means players can vary pitch and yaw, but never roll. This implies that the ”right” vector used to construct the lens must be aligned with the horizon. This constraint was not taken into account before this patch, so the in-game images rendered by xcam were often somehow tilted. This patch sets the Y component of the “right” vector to zero to align the “right” vector with the horizon: This makes the vector determined by its X and Z components only and thus aligned with any horizontal plane in Minetest's coordinate system. --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a2ed0b2..2a22869 100644 --- a/init.lua +++ b/init.lua @@ -110,7 +110,7 @@ local create_photo_pixels = function( player_name ) eye.y = eye.y + girl:get_properties().eye_height local dir = girl:get_look_dir() local right = vector.normalize( - vector.new( { x=dir.z, y=dir.y, z=-dir.x } ) + vector.new( { x=dir.z, y=0, z=-dir.x } ) ) local down = vector.normalize( dir:cross( right )