solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit 474abaa66b5f4a72147ca29078d17c1e8b4a1ae0
parent 14aaee803ec84a9df28fbfcf24f48f46f7954fae
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 31 Aug 2017 17:25:36 +0200

Fix the ray-tracing filter function for punched surfaces

Hits might be wrongly filtered when several punched surfaces were
regrouped in the same instance.

Diffstat:
Msrc/ssol_c.h | 3++-
Msrc/ssol_scene.c | 4+++-
Msrc/ssol_solver.c | 2++
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/ssol_c.h b/src/ssol_c.h @@ -34,6 +34,7 @@ struct ray_data { struct ssol_scene* scn; /* The scene into which the ray is traced */ struct s3d_primitive prim_from; /* Primitive from which the ray starts */ const struct ssol_instance* inst_from; /* Instance from which the ray starts */ + const struct shaded_shape* sshape_from; /* Shape from which the ray starts */ enum ssol_side_flag side_from; /* Primitive side from which the ray starts */ short discard_virtual_materials; /* Define if virtual materials are not RT */ short reversed_ray; /* Define if the ray direction is reversed */ @@ -45,7 +46,7 @@ struct ray_data { }; static const struct ray_data RAY_DATA_NULL = { - NULL, S3D_PRIMITIVE_NULL__, NULL, SSOL_INVALID_SIDE, 0, 0, 0, {0,0,0}, FLT_MAX + NULL, S3D_PRIMITIVE_NULL__, NULL, NULL, SSOL_INVALID_SIDE, 0, 0, 0, {0,0,0}, FLT_MAX }; diff --git a/src/ssol_scene.c b/src/ssol_scene.c @@ -491,7 +491,9 @@ hit_filter_function return 1; } hit_side = d3_dot(dir, N) < 0 ? SSOL_FRONT : SSOL_BACK; - if(inst == rdata->inst_from && hit_side != rdata->side_from) { + if(inst == rdata->inst_from + && sshape == rdata->sshape_from + && hit_side != rdata->side_from) { /* The intersected instance is the one from which the ray starts, * ensure that the ray does not intersect the opposite side of the * quadric diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -300,6 +300,7 @@ point_init ray_data.scn = scn; ray_data.prim_from = pt->prim; ray_data.inst_from = pt->inst; + ray_data.sshape_from = pt->sshape; ray_data.side_from = pt->side; ray_data.discard_virtual_materials = 1; /* Do not intersect virtual mtl */ ray_data.reversed_ray = 1; /* The ray direction is reversed */ @@ -841,6 +842,7 @@ trace_radiative_path ray_data.scn = scn; ray_data.prim_from = pt.prim; ray_data.inst_from = pt.inst; + ray_data.sshape_from = pt.sshape; ray_data.side_from = pt.side; ray_data.discard_virtual_materials = 0; ray_data.reversed_ray = 0;