htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit c1e0c6fc21e575d1a024e1fbfed06651bcecff0b
parent ee741359dc23ec048e0335a3f70ac8f6502c0428
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  8 Jun 2020 18:10:16 +0200

Fix a possible infinite loop in the compute_radiance_sw

A traced ray must be explicitly stopped whenever the traversal distance
without any scattering event is too high. This occurs when the maximum
scattering coefficient has a very small value in a voxel whose length is
[quasi] infinite along the propagation direction.

Diffstat:
Msrc/htrdr_compute_radiance_sw.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/htrdr_compute_radiance_sw.c b/src/htrdr_compute_radiance_sw.c @@ -109,6 +109,13 @@ scattering_hit_filter ASSERT(ctx->traversal_dst >= hit->distance[0]); ASSERT(ctx->traversal_dst <= hit->distance[1]); + /* Stop the ray whenever the traversal distance without any scattering + * event is too high. It means the maximum scattering coefficient has a + * very small value, and the returned radiance is null. This can only + * happen when the voxel has a [quasi] infinite length in the propagation + * direction. */ + if(ctx->traversal_dst > 1e9) break; + /* Compute the world space position where a collision may occur */ pos[0] = org[0] + ctx->traversal_dst * dir[0]; pos[1] = org[1] + ctx->traversal_dst * dir[1];