diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-10-13 19:19:51 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-10-15 16:42:44 +0300 |
commit | 5d565062edc25575bbabf173a4e26f184103944b (patch) | |
tree | d0f41f75cbdf1260b3126f909ae2917a8ca52c2f /intern/cycles/kernel/geom/geom_motion_triangle.h | |
parent | 509b637d594f97ce1504c65430d0643ecb4c6f9a (diff) |
Cleanup: refactor OptiX shadow intersection for upcoming changes
Diffstat (limited to 'intern/cycles/kernel/geom/geom_motion_triangle.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_motion_triangle.h | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/intern/cycles/kernel/geom/geom_motion_triangle.h b/intern/cycles/kernel/geom/geom_motion_triangle.h index 161b358110d..547f03af47c 100644 --- a/intern/cycles/kernel/geom/geom_motion_triangle.h +++ b/intern/cycles/kernel/geom/geom_motion_triangle.h @@ -27,41 +27,12 @@ #pragma once +#include "kernel/bvh/bvh_util.h" + CCL_NAMESPACE_BEGIN /* Time interpolation of vertex positions and normals */ -ccl_device_inline int find_attribute_motion(ccl_global const KernelGlobals *kg, - int object, - uint id, - ccl_private AttributeElement *elem) -{ - /* todo: find a better (faster) solution for this, maybe store offset per object */ - uint attr_offset = object_attribute_map_offset(kg, object); - uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset); - - while (attr_map.x != id) { - if (UNLIKELY(attr_map.x == ATTR_STD_NONE)) { - if (UNLIKELY(attr_map.y == 0)) { - return (int)ATTR_STD_NOT_FOUND; - } - else { - /* Chain jump to a different part of the table. */ - attr_offset = attr_map.z; - } - } - else { - attr_offset += ATTR_PRIM_TYPES; - } - attr_map = kernel_tex_fetch(__attributes_map, attr_offset); - } - - *elem = (AttributeElement)attr_map.y; - - /* return result */ - return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : (int)attr_map.z; -} - ccl_device_inline void motion_triangle_verts_for_step(ccl_global const KernelGlobals *kg, uint4 tri_vindex, int offset, @@ -129,8 +100,7 @@ ccl_device_inline void motion_triangle_vertices( float t = time * maxstep - step; /* find attribute */ - AttributeElement elem; - int offset = find_attribute_motion(kg, object, ATTR_STD_MOTION_VERTEX_POSITION, &elem); + int offset = intersection_find_attribute(kg, object, ATTR_STD_MOTION_VERTEX_POSITION); kernel_assert(offset != ATTR_STD_NOT_FOUND); /* fetch vertex coordinates */ @@ -164,8 +134,7 @@ ccl_device_inline float3 motion_triangle_smooth_normal(ccl_global const KernelGl float t = time * maxstep - step; /* find attribute */ - AttributeElement elem; - int offset = find_attribute_motion(kg, object, ATTR_STD_MOTION_VERTEX_NORMAL, &elem); + int offset = intersection_find_attribute(kg, object, ATTR_STD_MOTION_VERTEX_NORMAL); kernel_assert(offset != ATTR_STD_NOT_FOUND); /* fetch normals */ |