diff --git a/include/Ray.h b/include/Ray.h index 03eb38d..64264c1 100644 --- a/include/Ray.h +++ b/include/Ray.h @@ -23,6 +23,9 @@ class Ray { // The 3d voxel position the ray is currently at sf::Vector3 voxel; + // The 2d pixel coordinate + sf::Vector2 pixel; + // Reference to the voxel map Map *map; diff --git a/src/Ray.cpp b/src/Ray.cpp index 7ccfb1c..f283056 100644 --- a/src/Ray.cpp +++ b/src/Ray.cpp @@ -13,6 +13,7 @@ Ray::Ray( sf::Vector3 camera_position, sf::Vector3 ray_direction) { + this->pixel = pixel; this->map = map; origin = camera_position; direction = ray_direction; @@ -46,6 +47,13 @@ sf::Color Ray::Cast() { fabsf((float) (1.0 / cartesian.z)) ); + //97, 25, 34 is an interesting example of the problems + // Ahhh, ya know what? This is a problem with how spherical coords + // work when approaching 0 on the chi axis as rotation about + // the theta axis is completely useless. A viewing frustum will + // be needed unfortunately + + // Intersection T is the collection of the next intersection points // for all 3 axis XYZ. @@ -59,6 +67,11 @@ sf::Color Ray::Cast() { delta_t.z + origin.z ); + if (pixel.x == 0){ + int i = 0; + i++; + } + int dist = 0; do { diff --git a/src/RayCaster.cpp b/src/RayCaster.cpp index a084559..0f1e69b 100644 --- a/src/RayCaster.cpp +++ b/src/RayCaster.cpp @@ -49,8 +49,8 @@ sf::Color* RayCaster::CastRays(sf::Vector3 camera_direction, sf::Vector3< //-resolution.y / 2 // Start the loop at the top left, scan right and work down - for (int x = 0; x < resolution.x; x++) { - for (int y = 0; y < resolution.y; y++) { + for (int y = 0; y < resolution.y; y++) { + for (int x = 0; x < resolution.x; x++) { // The direction the final ray will point. // First take a reference to the base direction to setup the viewport