Hey ?
The way I find up_tmp in init_camera_axis() is not optimal because if my cam->vec is (1, 1, -1) I can't find the right up_tmp. I currently find (0, 0, 1) and it should be equal to (-1, 0, 1). I then use these vectors in the lookat method.
How to get the correct vector up_tmp ?
void init_camera_axis(t_camera *cam)
{
t_vec3 up_tmp;
up_tmp = (t_vec3){0,0,0};
cam->forward = get_normalised(invert(cam->vec));
if (fabs(cam->vec.y) > 0.7)
{
if (cam->vec.z <= 0)
up_tmp = (t_vec3){0, 0, 1};
else
up_tmp = (t_vec3){0, 0, -1};
}
else
up_tmp = (t_vec3){0, 1, 0};
cam->right = vec_cross(up_tmp, cam->forward);
cam->up = vec_cross(cam->forward, cam->right);
normalize(&cam->right);
normalize(&cam->up);
}