diff --git a/src/plot.cpp b/src/plot.cpp index 03c9ff3f6e9..14fd7dac1ea 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -1659,6 +1659,13 @@ void Ray::trace() if (stop_) return; + // There are no more intersections to process + // if we hit the edge of the model, so stop + // the particle in that case: + if (dist_.distance == INFTY || dist_.distance == INFINITY) { + return; + } + // Advance particle, prepare for next intersection for (int lev = 0; lev < n_coord(); ++lev) { coord(lev).r += dist_.distance * coord(lev).u;