Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_motion_triangle_intersect.h
| Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
| # endif | # endif | ||||
| float3 | float3 | ||||
| motion_triangle_refine_local(KernelGlobals *kg, | motion_triangle_refine_local(KernelGlobals *kg, | ||||
| ShaderData *sd, | ShaderData *sd, | ||||
| const Intersection *isect, | const Intersection *isect, | ||||
| const Ray *ray, | const Ray *ray, | ||||
| float3 verts[3]) | float3 verts[3]) | ||||
| { | { | ||||
| # ifdef __KERNEL_OPTIX__ | |||||
| /* isect->t is always in world space with OptiX. */ | |||||
| return motion_triangle_refine(kg, sd, isect, ray, verts); | |||||
| # else | |||||
| float3 P = ray->P; | float3 P = ray->P; | ||||
| float3 D = ray->D; | float3 D = ray->D; | ||||
| float t = isect->t; | float t = isect->t; | ||||
| # ifdef __INTERSECTION_REFINE__ | # ifdef __INTERSECTION_REFINE__ | ||||
| if (isect->object != OBJECT_NONE) { | if (isect->object != OBJECT_NONE) { | ||||
| # ifdef __OBJECT_MOTION__ | # ifdef __OBJECT_MOTION__ | ||||
| Transform tfm = sd->ob_itfm; | Transform tfm = sd->ob_itfm; | ||||
| # else | # else | ||||
| Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM); | Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM); | ||||
| # endif | # endif | ||||
| P = transform_point(&tfm, P); | P = transform_point(&tfm, P); | ||||
| D = transform_direction(&tfm, D); | D = transform_direction(&tfm, D); | ||||
| D = normalize(D); | D = normalize(D); | ||||
| } | } | ||||
| P = P + D * t; | P = P + D * t; | ||||
| /* compute refined intersection distance */ | /* compute refined intersection distance */ | ||||
| const float3 e1 = verts[0] - verts[2]; | const float3 e1 = verts[0] - verts[2]; | ||||
| const float3 e2 = verts[1] - verts[2]; | const float3 e2 = verts[1] - verts[2]; | ||||
| const float3 s1 = cross(D, e2); | const float3 s1 = cross(D, e2); | ||||
| const float invdivisor = 1.0f / dot(s1, e1); | const float invdivisor = 1.0f / dot(s1, e1); | ||||
| const float3 d = P - verts[2]; | const float3 d = P - verts[2]; | ||||
| const float3 s2 = cross(d, e1); | const float3 s2 = cross(d, e1); | ||||
| float rt = dot(e2, s2) * invdivisor; | float rt = dot(e2, s2) * invdivisor; | ||||
| P = P + D * rt; | P = P + D * rt; | ||||
| if (isect->object != OBJECT_NONE) { | if (isect->object != OBJECT_NONE) { | ||||
| # ifdef __OBJECT_MOTION__ | # ifdef __OBJECT_MOTION__ | ||||
| Transform tfm = sd->ob_tfm; | Transform tfm = sd->ob_tfm; | ||||
| # else | # else | ||||
| Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM); | Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM); | ||||
| # endif | # endif | ||||
| P = transform_point(&tfm, P); | P = transform_point(&tfm, P); | ||||
| } | } | ||||
| return P; | return P; | ||||
| # else /* __INTERSECTION_REFINE__ */ | # else /* __INTERSECTION_REFINE__ */ | ||||
| return P + D * t; | return P + D * t; | ||||
| # endif /* __INTERSECTION_REFINE__ */ | # endif /* __INTERSECTION_REFINE__ */ | ||||
| # endif | |||||
| } | } | ||||
| #endif /* __BVH_LOCAL__ */ | #endif /* __BVH_LOCAL__ */ | ||||
| /* Ray intersection. We simply compute the vertex positions at the given ray | /* Ray intersection. We simply compute the vertex positions at the given ray | ||||
| * time and do a ray intersection with the resulting triangle. | * time and do a ray intersection with the resulting triangle. | ||||
| */ | */ | ||||
| ccl_device_inline bool motion_triangle_intersect(KernelGlobals *kg, | ccl_device_inline bool motion_triangle_intersect(KernelGlobals *kg, | ||||
| ▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines | |||||