File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -342,31 +342,47 @@ void VoxelLayer::raytraceFreespace(
342
342
double b = wpy - oy;
343
343
double c = wpz - oz;
344
344
double t = 1.0 ;
345
+ bool wp_outside = false ;
345
346
346
347
// we can only raytrace to a maximum z height
347
348
if (wpz > map_end_z) {
348
349
// we know we want the vector's z value to be max_z
349
350
t = std::max (0.0 , std::min (t, (map_end_z - 0.01 - oz) / c));
351
+ wp_outside = true ;
350
352
} else if (wpz < origin_z_) {
351
353
// and we can only raytrace down to the floor
352
354
// we know we want the vector's z value to be 0.0
353
355
t = std::min (t, (origin_z_ - oz) / c);
356
+ wp_outside = true ;
354
357
}
355
358
356
359
// the minimum value to raytrace from is the origin
357
360
if (wpx < origin_x_) {
358
361
t = std::min (t, (origin_x_ - ox) / a);
362
+ wp_outside = true ;
359
363
}
360
364
if (wpy < origin_y_) {
361
365
t = std::min (t, (origin_y_ - oy) / b);
366
+ wp_outside = true ;
362
367
}
363
368
364
369
// the maximum value to raytrace to is the end of the map
365
370
if (wpx > map_end_x) {
366
371
t = std::min (t, (map_end_x - ox) / a);
372
+ wp_outside = true ;
367
373
}
368
374
if (wpy > map_end_y) {
369
375
t = std::min (t, (map_end_y - oy) / b);
376
+ wp_outside = true ;
377
+ }
378
+
379
+ constexpr double wp_epsilon = 1e-5 ;
380
+ if (wp_outside) {
381
+ if (t > 0.0 ) {
382
+ t -= wp_epsilon;
383
+ } else if (t < 0.0 ) {
384
+ t += wp_epsilon;
385
+ }
370
386
}
371
387
372
388
wpx = ox + a * t;
You can’t perform that action at this time.
0 commit comments