solstice-solver

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

commit 3ad13eabb7d163ed1c82b48d636c85ec7782a602
parent 8e66ad810c8dbf887c746e0536db19b733098b4b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Mon, 19 Sep 2016 15:27:35 +0200

BugFix: difference between Debug and Release builds on solver test #4

Change the way self intersects are detected

Diffstat:
Msrc/ssol_scene.c | 13+++++++------
Msrc/ssol_solver.c | 10++++++++--
2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/ssol_scene.c b/src/ssol_scene.c @@ -298,13 +298,7 @@ hit_filter_function } seg->tmin = hit->distance; - /* Discard self intersection */ - seg->hit_front = f3_dot(hit->normal, dir) < 0; inst = *htable_instance_find(&rs->data.scene->instances_rt, &hit->prim.inst_id); - if (seg->self_instance == inst && seg->self_front != seg->hit_front) { - return 1; - } - shape = inst->object->shape; seg->on_punched = (shape->type == SHAPE_PUNCHED); switch (shape->type) { @@ -347,6 +341,13 @@ hit_filter_function } default: FATAL("Unreachable code.\n"); break; } + d3_normalize(seg->hit_normal, seg->hit_normal); + + /* Discard self intersection */ + seg->hit_front = d3_dot(seg->hit_normal, seg->dir) < 0; + if (seg->self_instance == inst && seg->self_front != seg->hit_front) { + return 1; + } if(seg->hit_front) { seg->hit_material = inst->object->mtl_front; diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -493,15 +493,21 @@ receive_sunlight(struct realisation* rs) } else { start->material = start->instance->object->mtl_back; - d3_muld(start->sampl_normal, start->sampl_normal, -1); } + /* normals must face the sun and cos must be positive */ if (start->geom_cos > 0) { d3_muld(start->rt_normal, start->rt_normal, -1); } else { start->geom_cos *= -1; } - start->cos_sun = fabs(d3_dot(start->sampl_normal, start->sundir)); + start->cos_sun = d3_dot(start->sampl_normal, start->sundir); + if (start->cos_sun > 0) { + d3_muld(start->sampl_normal, start->sampl_normal, -1); + } + else { + start->cos_sun *= -1; + } /* start must now be complete */ check_starting_point(start);