diff --git a/bin/defocus.c b/bin/defocus.c index 344e23c..a7ada1c 100644 --- a/bin/defocus.c +++ b/bin/defocus.c @@ -32,9 +32,8 @@ int main(int argc, char **argv) { plane.img_p0_x = -aspect; plane.img_p0_y = -1.f; plane.img_p0_z = plane.base_z; - plane.img_p1_x = aspect; - plane.img_p1_y = 1.f; - plane.img_p1_z = plane.base_z; + plane.img_w = 2.f * aspect; + plane.img_h = 2.f; plane.img_ax0_x = 1.f; plane.img_ax0_y = 0.f; plane.img_ax0_z = 0.f; @@ -49,8 +48,7 @@ int main(int argc, char **argv) { df_trace_rays((df_trace_rays_settings){ .focal_length = 1.f, .image_width = image_width, - .image_height = image_height - + .image_height = image_height, }, spheres, 0, &plane, 1, diff --git a/include/defocus/defocus.h b/include/defocus/defocus.h index ce4e6aa..397935c 100644 --- a/include/defocus/defocus.h +++ b/include/defocus/defocus.h @@ -64,9 +64,8 @@ typedef struct float img_p0_x; float img_p0_y; float img_p0_z; - float img_p1_x; - float img_p1_y; - float img_p1_z; + float img_w; + float img_h; /* TODO(Kevin): These could be calculated from p0 and p1... */ float img_ax0_x; diff --git a/lib/raytracer.c b/lib/raytracer.c index d0b9f91..9795d94 100644 --- a/lib/raytracer.c +++ b/lib/raytracer.c @@ -224,11 +224,8 @@ static df_hit plane_test(float ray_origin_x, float img_p3_y = py - planes[i].img_p0_y; float img_p3_z = pz - planes[i].img_p0_z; - /* FIXME(Kevin): We would need to take plane rotation into account. - * Alternatively, just pass w & h into the plane and let the user - * (i.e. higher level code) worry about that */ - float w = planes[i].img_p1_x - planes[i].img_p0_x; - float h = planes[i].img_p1_y - planes[i].img_p0_y; + float w = planes[i].img_w; + float h = planes[i].img_h; result.img_u = img_p3_x * planes[i].img_ax0_x + img_p3_y * planes[i].img_ax0_y + img_p3_z * planes[i].img_ax0_z;