From a7484f1748ddd17b8a9d7f7497ca02a2b0c7aa94 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Fri, 11 Oct 2024 13:30:47 +0200 Subject: [PATCH] chore: Move inverted logic to viewing_ray from main --- main.cpp | 4 +--- src/viewing_ray.cpp | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index c20ed74..6c8f830 100644 --- a/main.cpp +++ b/main.cpp @@ -87,9 +87,7 @@ int main(int argc, char * argv[]) // Compute viewing ray Ray ray; - /* NOTE I flipped the vertical axis of the pixels, because in computer graphics we assume the bottom left pixel - * is (0,0), while traditional jpg assumes (0,0) to be the upper left pixel. */ - viewing_ray(camera,height - i,j,width,height,ray); + viewing_ray(camera,i,j,width,height,ray); // Find first visible object hit by ray and its surface normal n double t; diff --git a/src/viewing_ray.cpp b/src/viewing_ray.cpp index 4a7218a..a643a9c 100644 --- a/src/viewing_ray.cpp +++ b/src/viewing_ray.cpp @@ -18,5 +18,7 @@ void viewing_ray( double v = 0 - camera.height / 2 + camera.height * (i + 0.5) / height; ray.origin = camera.e; - ray.direction = (0 - camera.d) * camera.w + u * camera.u + v * camera.v; + /* NOTE I flipped the vertical axis of the pixels, because in computer graphics we assume the bottom left pixel + * is (0,0), while traditional jpg assumes (0,0) to be the upper left pixel. */ + ray.direction = (0 - camera.d) * camera.w + u * camera.u - v * camera.v; }