| 267 | } |
| 268 | |
| 269 | RTC_SYCL_INDIRECTLY_CALLABLE void sphereIntersectFunc(const RTCIntersectFunctionNArguments* args) |
| 270 | { |
| 271 | int* valid = args->valid; |
| 272 | void* ptr = args->geometryUserPtr; |
| 273 | Ray *ray = (Ray*)args->rayhit; |
| 274 | RTCHit* hit = (RTCHit *)&ray->Ng.x; |
| 275 | unsigned int primID = args->primID; |
| 276 | |
| 277 | assert(args->N == 1); |
| 278 | const Sphere* spheres = (const Sphere*)ptr; |
| 279 | const Sphere& sphere = spheres[primID]; |
| 280 | |
| 281 | if (!valid[0]) return; |
| 282 | valid[0] = 0; |
| 283 | |
| 284 | const Vec3fa v = ray->org-sphere.p; |
| 285 | const float A = dot(ray->dir,ray->dir); |
| 286 | const float B = 2.0f*dot(v,ray->dir); |
| 287 | const float C = dot(v,v) - sqr(sphere.r); |
| 288 | const float D = B*B - 4.0f*A*C; |
| 289 | if (D < 0.0f) return; |
| 290 | const float Q = sqrt(D); |
| 291 | const float rcpA = rcp(A); |
| 292 | const float t0 = 0.5f*rcpA*(-B-Q); |
| 293 | const float t1 = 0.5f*rcpA*(-B+Q); |
| 294 | |
| 295 | RTCHit potentialHit; |
| 296 | potentialHit.u = 0.0f; |
| 297 | potentialHit.v = 0.0f; |
| 298 | copyInstanceIdStack(args->context, potentialHit.instID); |
| 299 | potentialHit.geomID = sphere.geomID; |
| 300 | potentialHit.primID = primID; |
| 301 | |
| 302 | if ((ray->tnear() < t0) & (t0 < ray->tfar)) |
| 303 | { |
| 304 | int imask; |
| 305 | bool mask = 1; |
| 306 | { |
| 307 | imask = mask ? -1 : 0; |
| 308 | } |
| 309 | |
| 310 | const Vec3fa Ng = ray->org+t0*ray->dir-sphere.p; |
| 311 | potentialHit.Ng_x = Ng.x; |
| 312 | potentialHit.Ng_y = Ng.y; |
| 313 | potentialHit.Ng_z = Ng.z; |
| 314 | |
| 315 | RTCFilterFunctionNArguments fargs; |
| 316 | fargs.valid = (int*)&imask; |
| 317 | fargs.geometryUserPtr = ptr; |
| 318 | fargs.context = args->context; |
| 319 | fargs.ray = (RTCRayN *)args->rayhit; |
| 320 | fargs.hit = (RTCHitN*)&potentialHit; |
| 321 | fargs.N = 1; |
| 322 | |
| 323 | const float old_t = ray->tfar; |
| 324 | ray->tfar = t0; |
| 325 | #if USE_ARGUMENT_CALLBACKS |
| 326 | contextFilterFunction(&fargs); |
no test coverage detected