@@ -1203,8 +1203,9 @@ std::pair<Position, Direction> RayTracePlot::get_pixel_ray(
1203
1203
double p1 = static_cast <double >(pixels_[1 ]);
1204
1204
double vert_fov_radians = horiz_fov_radians * p1 / p0;
1205
1205
1206
- // This can be changed to alter the perspective distortion effect.
1207
- // This is in units of cm. Most of the time does not need to be changed.
1206
+ // focal_plane_dist can be changed to alter the perspective distortion
1207
+ // effect. This is in units of cm. This seems to look good most of the
1208
+ // time. TODO let this variable be set through XML.
1208
1209
constexpr double focal_plane_dist = 10.0 ;
1209
1210
const double dx = 2.0 * focal_plane_dist * std::tan (0.5 * horiz_fov_radians );
1210
1211
const double dy = p1 / p0 * dx;
@@ -1551,36 +1552,18 @@ void PhongPlot::create_output() const
1551
1552
size_t height = pixels_[1 ];
1552
1553
ImageData data ({width, height}, not_found_);
1553
1554
1554
- #pragma omp parallel
1555
- {
1555
+ #pragma omp parallel for schedule(dynamic) collapse(2)
1556
+ for (int horiz=0 ; horiz<pixels_[0 ]; ++horiz) {
1557
+ for (int vert=0 ; vert<pixels_[1 ]; ++vert) {
1556
1558
1557
- #ifdef _OPENMP
1558
- const int n_threads = omp_get_max_threads ();
1559
- const int tid = omp_get_thread_num ();
1560
- #else
1561
- int n_threads = 1 ;
1562
- int tid = 0 ;
1563
- #endif
1559
+ // RayTracePlot implements camera ray generation
1560
+ std::pair<Position, Direction> ru = get_pixel_ray (horiz, vert);
1561
+ PhongRay ray (ru.first , ru.second , *this );
1564
1562
1565
- int vert = tid;
1566
- for (int iter = 0 ; iter <= pixels_[1 ] / n_threads; iter++) {
1567
- if (vert < pixels_[1 ]) {
1568
- for (int horiz = 0 ; horiz < pixels_[0 ]; ++horiz) {
1569
-
1570
- // RayTracePlot implements camera ray generation
1571
- std::pair<Position, Direction> ru = get_pixel_ray (horiz, vert);
1572
- PhongRay ray (ru.first , ru.second , *this );
1573
-
1574
- ray.trace ();
1575
- data (horiz, vert) = ray.result_color ();
1576
- }
1577
- } // end "if" vert in correct range
1578
-
1579
- // TODO: can maybe remove this barrier
1580
- #pragma omp barrier
1581
- vert += n_threads;
1563
+ ray.trace ();
1564
+ data (horiz, vert) = ray.result_color ();
1582
1565
}
1583
- } // end omp parallel
1566
+ }
1584
1567
1585
1568
#ifdef USE_LIBPNG
1586
1569
output_png (path_plot (), data);
0 commit comments