diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-01-13 19:15:30 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-01-17 19:35:23 +0300 |
commit | 4d10a46e6368f0b48a901325b94ebd43b672db32 (patch) | |
tree | da3a7e85d4a82f4d06b4852858dfc187a13c80c0 /intern/cycles/kernel/geom/motion_triangle_intersect.h | |
parent | a25cfc5db2625d147c4f2d89584e6d87748a47bb (diff) |
Cleanup: refactor BVH2 in preparation of self intersection skip
Move some logic out of triangle intersection functions and into BVH
traversal, so we can share logic between primitives.
Ref D12954
Diffstat (limited to 'intern/cycles/kernel/geom/motion_triangle_intersect.h')
-rw-r--r-- | intern/cycles/kernel/geom/motion_triangle_intersect.h | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/intern/cycles/kernel/geom/motion_triangle_intersect.h b/intern/cycles/kernel/geom/motion_triangle_intersect.h index 3bbb7be685d..cb6d210d90f 100644 --- a/intern/cycles/kernel/geom/motion_triangle_intersect.h +++ b/intern/cycles/kernel/geom/motion_triangle_intersect.h @@ -153,14 +153,12 @@ ccl_device_inline bool motion_triangle_intersect(KernelGlobals kg, float time, uint visibility, int object, + int prim, int prim_addr) { - /* Primitive index for vertex location lookup. */ - int prim = kernel_tex_fetch(__prim_index, prim_addr); - int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, prim_addr) : object; /* Get vertex locations for intersection. */ float3 verts[3]; - motion_triangle_vertices(kg, fobject, prim, time, verts); + motion_triangle_vertices(kg, object, prim, time, verts); /* Ray-triangle intersection, unoptimized. */ float t, u, v; if (ray_triangle_intersect(P, dir, tmax, verts[0], verts[1], verts[2], &u, &v, &t)) { @@ -175,8 +173,7 @@ ccl_device_inline bool motion_triangle_intersect(KernelGlobals kg, isect->u = u; isect->v = v; isect->prim = prim; - isect->object = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, prim_addr) : - object; + isect->object = object; isect->type = PRIMITIVE_MOTION_TRIANGLE; return true; } @@ -196,25 +193,15 @@ ccl_device_inline bool motion_triangle_intersect_local(KernelGlobals kg, float3 dir, float time, int object, - int local_object, + int prim, int prim_addr, float tmax, ccl_private uint *lcg_state, int max_hits) { - /* Only intersect with matching object, for instanced objects we - * already know we are only intersecting the right object. */ - if (object == OBJECT_NONE) { - if (kernel_tex_fetch(__prim_object, prim_addr) != local_object) { - return false; - } - } - - /* Primitive index for vertex location lookup. */ - int prim = kernel_tex_fetch(__prim_index, prim_addr); /* Get vertex locations for intersection. */ float3 verts[3]; - motion_triangle_vertices(kg, local_object, prim, time, verts); + motion_triangle_vertices(kg, object, prim, time, verts); /* Ray-triangle intersection, unoptimized. */ float t, u, v; if (!ray_triangle_intersect(P, dir, tmax, verts[0], verts[1], verts[2], &u, &v, &t)) { @@ -266,7 +253,7 @@ ccl_device_inline bool motion_triangle_intersect_local(KernelGlobals kg, isect->u = u; isect->v = v; isect->prim = prim; - isect->object = local_object; + isect->object = object; isect->type = PRIMITIVE_MOTION_TRIANGLE; /* Record geometric normal. */ |