Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh.h
| Show First 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | |||||
| # else /* __KERNEL_OPTIX__ */ | # else /* __KERNEL_OPTIX__ */ | ||||
| if (!scene_intersect_valid(ray)) { | if (!scene_intersect_valid(ray)) { | ||||
| local_isect->num_hits = 0; | local_isect->num_hits = 0; | ||||
| return false; | return false; | ||||
| } | } | ||||
| # ifdef __EMBREE__ | # ifdef __EMBREE__ | ||||
| if (kernel_data.bvh.scene) { | if (kernel_data.bvh.scene) { | ||||
| CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SSS); | const bool has_bvh = !(kernel_tex_fetch(__object_flag, local_object) & | ||||
| SD_OBJECT_TRANSFORM_APPLIED); | |||||
| CCLIntersectContext ctx( | |||||
| kg, has_bvh ? CCLIntersectContext::RAY_SSS : CCLIntersectContext::RAY_LOCAL); | |||||
| ctx.lcg_state = lcg_state; | ctx.lcg_state = lcg_state; | ||||
| ctx.max_hits = max_hits; | ctx.max_hits = max_hits; | ||||
| ctx.ss_isect = local_isect; | ctx.local_isect = local_isect; | ||||
| local_isect->num_hits = 0; | local_isect->num_hits = 0; | ||||
| ctx.sss_object_id = local_object; | ctx.local_object_id = local_object; | ||||
| IntersectContext rtc_ctx(&ctx); | IntersectContext rtc_ctx(&ctx); | ||||
| RTCRay rtc_ray; | RTCRay rtc_ray; | ||||
| kernel_embree_setup_ray(*ray, rtc_ray, PATH_RAY_ALL_VISIBILITY); | kernel_embree_setup_ray(*ray, rtc_ray, PATH_RAY_ALL_VISIBILITY); | ||||
| /* Get the Embree scene for this intersection. */ | /* If this object has its own BVH, use it. */ | ||||
| if (has_bvh) { | |||||
| RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 2); | RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 2); | ||||
| if (geom) { | if (geom) { | ||||
| float3 P = ray->P; | float3 P = ray->P; | ||||
| float3 dir = ray->D; | float3 dir = ray->D; | ||||
| float3 idir = ray->D; | float3 idir = ray->D; | ||||
| const int object_flag = kernel_tex_fetch(__object_flag, local_object); | |||||
| if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { | |||||
| Transform ob_itfm; | Transform ob_itfm; | ||||
| rtc_ray.tfar = bvh_instance_motion_push( | rtc_ray.tfar = bvh_instance_motion_push( | ||||
| kg, local_object, ray, &P, &dir, &idir, ray->t, &ob_itfm); | kg, local_object, ray, &P, &dir, &idir, ray->t, &ob_itfm); | ||||
| /* bvh_instance_motion_push() returns the inverse transform but | /* bvh_instance_motion_push() returns the inverse transform but | ||||
| * it's not needed here. */ | * it's not needed here. */ | ||||
| (void)ob_itfm; | (void)ob_itfm; | ||||
| rtc_ray.org_x = P.x; | rtc_ray.org_x = P.x; | ||||
| rtc_ray.org_y = P.y; | rtc_ray.org_y = P.y; | ||||
| rtc_ray.org_z = P.z; | rtc_ray.org_z = P.z; | ||||
| rtc_ray.dir_x = dir.x; | rtc_ray.dir_x = dir.x; | ||||
| rtc_ray.dir_y = dir.y; | rtc_ray.dir_y = dir.y; | ||||
| rtc_ray.dir_z = dir.z; | rtc_ray.dir_z = dir.z; | ||||
| } | |||||
| RTCScene scene = (RTCScene)rtcGetGeometryUserData(geom); | RTCScene scene = (RTCScene)rtcGetGeometryUserData(geom); | ||||
| kernel_assert(scene); | |||||
| if (scene) { | if (scene) { | ||||
| rtcOccluded1(scene, &rtc_ctx.context, &rtc_ray); | rtcOccluded1(scene, &rtc_ctx.context, &rtc_ray); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray); | |||||
| } | |||||
| return local_isect->num_hits > 0; | return local_isect->num_hits > 0; | ||||
| } | } | ||||
| # endif /* __EMBREE__ */ | # endif /* __EMBREE__ */ | ||||
| # ifdef __OBJECT_MOTION__ | # ifdef __OBJECT_MOTION__ | ||||
| if (kernel_data.bvh.have_motion) { | if (kernel_data.bvh.have_motion) { | ||||
| return bvh_intersect_local_motion(kg, ray, local_isect, local_object, lcg_state, max_hits); | return bvh_intersect_local_motion(kg, ray, local_isect, local_object, lcg_state, max_hits); | ||||
| ▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines | |||||