reuse draw_camera() in axial variant

This commit is contained in:
veclavtalica 2025-02-10 14:42:30 +03:00
parent e9f8dbebbf
commit 1818532ec9

View File

@ -491,31 +491,19 @@ DrawCameraFromPrincipalAxesResult draw_camera_from_principal_axes(Vec3 position,
sincosf(yaw + (float)M_PI_2, &yaws, &yawc); sincosf(yaw + (float)M_PI_2, &yaws, &yawc);
sincosf(pitch, &pitchs, &pitchc); sincosf(pitch, &pitchs, &pitchc);
Camera const camera = { Vec3 const direction = vec3_norm(((Vec3){
.fov = fov, yawc * pitchc,
.pos = position, pitchs,
.target = vec3_norm(((Vec3){ yaws * pitchc,
yawc * pitchc, }));
pitchs,
yaws * pitchc,
})),
.up = (Vec3){0, 1, 0},
.viewbox = {
(Vec2){ 1/-zoom, 1/zoom },
(Vec2){ 1/zoom, 1/-zoom }
},
};
if (!orthographic) Vec3 const up = (Vec3){0, 1, 0};
camera_projection_matrix = camera_perspective(&camera);
else
camera_projection_matrix = camera_orthographic(&camera);
camera_look_at_matrix = camera_look_at(&camera); draw_camera(position, direction, up, fov, zoom);
return (DrawCameraFromPrincipalAxesResult) { return (DrawCameraFromPrincipalAxesResult) {
.direction = camera.target, .direction = direction,
.up = camera.up, .up = up,
}; };
} }