Skip to content

Commit 1a7e5c8

Browse files
committed
assure raytrace always progress to prevent infinite loop
1 parent f796fa0 commit 1a7e5c8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/mesh.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,15 +989,17 @@ void StructuredMesh::raytrace_mesh(
989989
// For all directions outside the mesh, find the distance that we need
990990
// to travel to reach the next surface. Use the largest distance, as
991991
// only this will cross all outer surfaces.
992-
int k_max {0};
992+
int k_max {-1};
993993
for (int k = 0; k < n; ++k) {
994994
if ((ijk[k] < 1 || ijk[k] > shape_[k]) &&
995995
(distances[k].distance > traveled_distance)) {
996996
traveled_distance = distances[k].distance;
997997
k_max = k;
998998
}
999999
}
1000-
1000+
// Assure some distance is traveled
1001+
if (k_max == -1)
1002+
traveled_distance += TINY_BIT;
10011003
// If r1 is not inside the mesh, exit here
10021004
if (traveled_distance >= total_distance)
10031005
return;

0 commit comments

Comments
 (0)