* Align ”right” vector with the horizontal plane

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.
This commit is contained in:
Li0n 2023-11-11 01:17:17 +01:00 committed by Nils Dagsson Moskopp
parent 777f1a969d
commit 768c8b2caa
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 1 additions and 1 deletions

View File

@ -110,7 +110,7 @@ local create_photo_pixels = function( player_name )
eye.y = eye.y + girl:get_properties().eye_height eye.y = eye.y + girl:get_properties().eye_height
local dir = girl:get_look_dir() local dir = girl:get_look_dir()
local right = vector.normalize( 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( local down = vector.normalize(
dir:cross( right ) dir:cross( right )