commit 5fcd4f92c34ca4c5290daba21b0ed95aa75f0a48
parent 4282ebe01e3f81e7c81884ee52364408d1e37e88
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 24 Aug 2021 09:03:00 +0200
Discard "zero distance" intersections
Such intersections were already filtered but several traced rays do not
use filtering functions like the rays used to obtain the current medium
during a conductive random walk. But a zero intersection remains
invalid. To resolve this issue, this commit updates the range of these
radii to start from FLT_MIN rather than 0.
Diffstat:
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/sdis_heat_path_conductive_Xd.h b/src/sdis_heat_path_conductive_Xd.h
@@ -65,7 +65,7 @@ XD(sample_next_step)
/* Use the previously sampled direction to estimate the minimum distance from
* `pos' to the scene boundary */
- f2(range, 0.f, delta_solid*RAY_RANGE_MAX_SCALE);
+ f2(range, FLT_MIN, delta_solid*RAY_RANGE_MAX_SCALE);
SXD(scene_view_trace_ray(scn->sXd(view), pos, dirs[0], range, NULL, &hits[0]));
SXD(scene_view_trace_ray(scn->sXd(view), pos, dirs[1], range, NULL, &hits[1]));
if(SXD_HIT_NONE(&hits[0]) && SXD_HIT_NONE(&hits[1])) {
diff --git a/src/sdis_heat_path_convective_Xd.h b/src/sdis_heat_path_convective_Xd.h
@@ -115,7 +115,7 @@ XD(convective_path)
path_started_in_fluid = SXD_HIT_NONE(&rwalk->hit);
if(path_started_in_fluid) { /* The path begins in the fluid */
- const float range[2] = {0, FLT_MAX};
+ const float range[2] = {FLT_MIN, FLT_MAX};
float dir[DIM] = {0};
float org[DIM];
diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h
@@ -453,11 +453,12 @@ XD(hit_filter_function)
const struct sXd(hit)* hit_from = &filter_data->XD(hit);
(void)org, (void)dir, (void)global_data, (void)range;
- if(!ray_data || SXD_HIT_NONE(hit_from)) return 0; /* No filtering */
+ /* No user defined data. Do not filter */
+ if(!ray_data || SXD_HIT_NONE(hit_from)) return 0;
if(SXD_PRIMITIVE_EQ(&hit_from->prim, &hit->prim)) return 1;
- /* No displacement => assume self intersection */
+ /* No displacement => assume self intersection in all situations */
if(hit->distance <= 0) return 1;
if(eq_epsf(hit->distance, 0, (float)filter_data->epsilon)) {
@@ -1062,7 +1063,7 @@ XD(scene_get_medium)
struct sXd(attrib) attr;
struct sXd(primitive) prim;
size_t iprim2;
- const float range[2] = {0.f, FLT_MAX};
+ const float range[2] = {FLT_MIN, FLT_MAX};
float N[DIM], dir[DIM], cos_N_dir;
size_t istep = 0;
@@ -1187,7 +1188,7 @@ XD(scene_get_medium_in_closed_boundaries)
FOR_EACH(idir, 0, 2*DIM) {
struct sXd(hit) hit;
float N[DIM];
- const float range[2] = {0.f, FLT_MAX};
+ const float range[2] = {FLT_MIN, FLT_MAX};
float cos_N_dir;
/* Transform the directions to avoid to be aligned with the axis */
diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h
@@ -165,7 +165,7 @@ XD(sample_enclosure_position)
FOR_EACH(ichallenge, 0, MAX_NCHALLENGES) {
struct sXd(hit) hit = SXD_HIT_NULL;
const float dir[3] = {1,0,0};
- const float range[2] = {0, FLT_MAX};
+ const float range[2] = {FLT_MIN, FLT_MAX};
float org[DIM];
/* Generate an uniform position into the enclosure AABB */