diff --git a/src/orange/BoundingBoxUtils.hh b/src/orange/BoundingBoxUtils.hh index b18310fd47..0d15ed4e84 100644 --- a/src/orange/BoundingBoxUtils.hh +++ b/src/orange/BoundingBoxUtils.hh @@ -228,21 +228,21 @@ inline bool encloses(BoundingBox const& big, BoundingBox const& small) * intersection, the result will be inf. */ template -inline CELER_FUNCTION U calc_dist_to_inside(BoundingBox const& bbox, +inline CELER_FUNCTION T calc_dist_to_inside(BoundingBox const& bbox, Array const& pos, Array const& dir) { CELER_EXPECT(!is_inside(bbox, pos)); // Test if an intersection is outside the bbox for a given axis - auto out_of_bounds = [&bbox](U intersect, int ax) { + auto out_of_bounds = [&bbox](T intersect, int ax) { return !(intersect >= bbox.lower()[ax] && intersect <= bbox.upper()[ax]); }; // Check that the intersection point occurs within the region // bounded by the planes of the other two axes - auto in_bounds = [&](int ax, U dist) { + auto in_bounds = [&](int ax, T dist) { for (auto other_ax : range(to_int(Axis::size_))) { if (other_ax == ax) @@ -256,8 +256,8 @@ inline CELER_FUNCTION U calc_dist_to_inside(BoundingBox const& bbox, }; // Loop over all 6 planes to find the minimum intersection - U min_dist = numeric_limits::infinity(); - for (auto bound : range(to_int(Bound::size_))) + T min_dist = numeric_limits::infinity(); + for (auto bound : range(Bound::size_)) { for (auto ax : range(to_int(Axis::size_))) { @@ -267,10 +267,10 @@ inline CELER_FUNCTION U calc_dist_to_inside(BoundingBox const& bbox, continue; } - U dist = (bbox.point(static_cast(bound))[ax] - pos[ax]) + T dist = (bbox.point(static_cast(bound))[ax] - pos[ax]) / dir[ax]; - if (dist < 0) + if (dist <= 0) { // Short circut if the plane is behind us continue; diff --git a/src/orange/detail/BIHBuilder.hh b/src/orange/detail/BIHBuilder.hh index 87730643cb..2a5df4165d 100644 --- a/src/orange/detail/BIHBuilder.hh +++ b/src/orange/detail/BIHBuilder.hh @@ -36,6 +36,11 @@ namespace detail * node with all volumes in the stored inf_vols. This final case is useful in * the event that an ORANGE geometry is created via a method where volume * bounding boxes are not availible. + * + * Bounding boxes supplied to this builder should "bumped," i.e. expanded + * outward by at least floating-point epsilson from the volumes they bound. + * This eliminates the possiblity of accidently missing a volume during + * tracking. */ class BIHBuilder {