star-3d

Surface structuring for efficient 3D geometric queries
git clone git://git.meso-star.fr/star-3d.git
Log | Files | Refs | README | LICENSE

commit 215a38e4582089d2233842bcddf2cabc780fda44
parent 96a07e217c782b471045533813456c046d02dd93
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue, 19 Jan 2021 17:12:08 +0100

Manage an Embree bug (uv out of range).

Diffstat:
Msrc/s3d_scene_view_trace_ray.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/s3d_scene_view_trace_ray.c b/src/s3d_scene_view_trace_ray.c @@ -116,13 +116,13 @@ hit_setup ASSERT(hit->prim.shape__); ASSERT(((struct geometry*)hit->prim.shape__)->type == GEOM_MESH ||((struct geometry*)hit->prim.shape__)->type == GEOM_SPHERE); - - hit->uv[0] = ray_hit->hit.u; - hit->uv[1] = ray_hit->hit.v; + + /* Handle Embree returning uv out of range */ + hit->uv[0] = CLAMP(ray_hit->hit.u, 0, 1); + hit->uv[1] = CLAMP(ray_hit->hit.v, 0, 1); if(((struct geometry*)hit->prim.shape__)->type == GEOM_MESH) { w = 1.f - hit->uv[0] - hit->uv[1]; - ASSERT(w <= 1.f); /* This may not occurs */ if(w < 0.f) { /* Handle precision error */ if(hit->uv[0] > hit->uv[1]) hit->uv[0] += w; else hit->uv[1] += w;