Commit e08839f4 authored by Daniil Rastorguev's avatar Daniil Rastorguev
Browse files

got rid of nestedness (but personally I actually like that more than early returns etc)

parent 95159f28
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -84,8 +84,11 @@ namespace allpix {

        auto intersect = LiangBarskyIntersectionDistances(direction, position, box);

        if(!intersect) {
            return std::nullopt;
        }
        // The intersection is a point P + t * D. Return closest impact point if positive (i.e. in direction of the motion)
        if(intersect) {

        auto [t0, t1] = intersect.value();
        if(t0 > 0 && t1 > 0) {
            return (position + std::min(t0, t1) * direction);
@@ -94,7 +97,6 @@ namespace allpix {
        } else if(t1 > 0) {
            return (position + t1 * direction);
        }
        }

        // Otherwise: The line does not intersect the box.
        return std::nullopt;