star-gs

Literate program for a geometric sensitivity calculation
git clone git://git.meso-star.fr/star-gs.git
Log | Files | Refs | README | LICENSE

commit 7985740bc0e077494428ef1de1d2abd9f12fe81d
parent 6e99b8586a6dbc78ede4f64a901ac012a28bad0e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 26 Apr 2021 18:57:00 +0200

Add the sgs_geometry_trace_ray API function

Diffstat:
Msrc/sgs_geometry.c | 33+++++++++++++++++++++++++++++++++
Msrc/sgs_geometry.h | 10++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/sgs_geometry.c b/src/sgs_geometry.c @@ -225,6 +225,39 @@ sgs_geometry_ref_put(struct sgs_geometry* geom) ref_put(&geom->ref, release_geometry); } +void +sgs_geometry_trace_ray + (const struct sgs_geometry* geom, + const double ray_org[3], + const double ray_dir[3], + const double ray_range[2], + const struct s3d_hit* hit_from, + struct s3d_hit* hit) +{ + struct hit_filter_context filter_ctx = HIT_FILTER_CONTEXT_NULL; + float org[3]; + float dir[3]; + float range[2]; + ASSERT(geom && ray_org && ray_dir && ray_range && hit); + + /* Convert ray data to single precision */ + f3_set_d3(org, ray_org); + f3_set_d3(dir, ray_dir); + f2_set_d2(range, ray_range); + + /* Ensure the normalization of the ray direction after its conversion to + * single precision */ + f3_normalize(dir, dir); + + /* Setup the hit filter data */ + filter_ctx.range[0] = range[0]; + filter_ctx.range[1] = range[1]; + filter_ctx.hit_from = hit_from ? *hit_from : S3D_HIT_NULL; + + /* Trace the ray */ + S3D(scene_view_trace_ray(geom->view_rt, org, dir, range, &filter_ctx, hit)); +} + res_T sgs_geometry_dump_vtk(const struct sgs_geometry* geom, FILE* stream) { diff --git a/src/sgs_geometry.h b/src/sgs_geometry.h @@ -115,6 +115,7 @@ static const struct sgs_geometry_step_args SGS_GEOMETRY_STEP_ARGS_DEFAULT = SGS_GEOMETRY_STEP_ARGS_DEFAULT__; /* Forward declaration */ +struct s3d_hit; struct sgs; struct sgs_geometry; @@ -147,6 +148,15 @@ extern LOCAL_SYM void sgs_geometry_ref_put (struct sgs_geometry* geom); +extern LOCAL_SYM void +sgs_geometry_trace_ray + (const struct sgs_geometry* geom, + const double ray_org[3], + const double ray_dir[3], + const double ray_range[2], + const struct s3d_hit* hit_from, /* May be NULL */ + struct s3d_hit* hit); + extern LOCAL_SYM res_T sgs_geometry_dump_vtk (const struct sgs_geometry* geom,