commit cefd6ab2094b9f74efe2c33a00b8ead8d4a12024
parent c5bd1beb8c19c9ff4504e9a72d2dc902d46aa429
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 18 Oct 2018 21:03:36 +0200
Update the API htrdr_slab_trace_ray function
Add a "max_steps" argument defining the maximum number of cells that a
ray can traversed until to consider that nothing is intersected.
Diffstat:
4 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/htrdr_ground.c b/src/htrdr_ground.c
@@ -298,7 +298,7 @@ htrdr_ground_trace_ray
d3_set_f3(upp, ground->upper);
res = htrdr_slab_trace_ray(ground->htrdr, org, dir, range, low, upp,
- trace_ground, &slab_ctx);
+ trace_ground, 32, &slab_ctx);
if(res != RES_OK) goto error;
}
diff --git a/src/htrdr_sky.c b/src/htrdr_sky.c
@@ -2193,7 +2193,8 @@ htrdr_sky_trace_ray
slab_ctx.hit = hit;
res = htrdr_slab_trace_ray(sky->htrdr, org, dir, cloud_range,
- sky->htcp_desc.lower, sky->htcp_desc.upper, trace_cloud, &slab_ctx);
+ sky->htcp_desc.lower, sky->htcp_desc.upper, trace_cloud, SIZE_MAX,
+ &slab_ctx);
if(res != RES_OK) goto error;
if(!SVX_HIT_NONE(hit)) goto exit; /* Collision */
diff --git a/src/htrdr_slab.c b/src/htrdr_slab.c
@@ -31,6 +31,7 @@ htrdr_slab_trace_ray
const double cell_low[2],
const double cell_upp[2],
htrdr_trace_cell_T trace_cell,
+ const size_t max_steps,
void* trace_cell_context)
{
double pos[2];
@@ -39,6 +40,7 @@ htrdr_slab_trace_ray
double cell_upp_ws[3]; /* Cell upper bound in world space */
double cell_sz[3]; /* Size of a cell */
double t_max[3], t_delta[2], t_min_z;
+ size_t istep;
int xy[2]; /* 2D index of the repeated cell */
int incr[2]; /* Index increment */
res_T res = RES_OK;
@@ -90,7 +92,7 @@ htrdr_slab_trace_ray
ASSERT(t_delta[0] >= 0 && t_delta[1] >= 0);
org_cs[2] = org[2];
- for(;;) {
+ FOR_EACH(istep, 0, max_steps) {
int iaxis;
int hit;
diff --git a/src/htrdr_slab.h b/src/htrdr_slab.h
@@ -39,6 +39,7 @@ htrdr_slab_trace_ray
const double cell_low[2],
const double cell_upp[2],
htrdr_trace_cell_T trace_cell,
+ const size_t max_steps, /* Max traversed cell */
void* trace_cell_context);
#endif /* HTRDR_SLAB_H */