| 353 | } |
| 354 | |
| 355 | RTC_API void* rtcBuildBVH(const RTCBuildArguments* arguments) |
| 356 | { |
| 357 | BVH* bvh = (BVH*) arguments->bvh; |
| 358 | RTC_CATCH_BEGIN; |
| 359 | RTC_TRACE(rtcBuildBVH); |
| 360 | RTC_VERIFY_HANDLE(bvh); |
| 361 | RTC_VERIFY_HANDLE(arguments); |
| 362 | RTC_VERIFY_HANDLE(arguments->createNode); |
| 363 | RTC_VERIFY_HANDLE(arguments->setNodeChildren); |
| 364 | RTC_VERIFY_HANDLE(arguments->setNodeBounds); |
| 365 | RTC_VERIFY_HANDLE(arguments->createLeaf); |
| 366 | |
| 367 | if (arguments->primitiveArrayCapacity < arguments->primitiveCount) |
| 368 | throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"primitiveArrayCapacity must be greater or equal to primitiveCount") |
| 369 | |
| 370 | /* initialize the allocator */ |
| 371 | bvh->allocator.init_estimate(arguments->primitiveCount*sizeof(BBox3fa)); |
| 372 | bvh->allocator.reset(); |
| 373 | |
| 374 | /* switch between different builders based on quality level */ |
| 375 | if (arguments->buildQuality == RTC_BUILD_QUALITY_LOW) |
| 376 | return rtcBuildBVHMorton(arguments); |
| 377 | else if (arguments->buildQuality == RTC_BUILD_QUALITY_MEDIUM) |
| 378 | return rtcBuildBVHBinnedSAH(arguments); |
| 379 | else if (arguments->buildQuality == RTC_BUILD_QUALITY_HIGH) { |
| 380 | if (arguments->splitPrimitive == nullptr || arguments->primitiveArrayCapacity <= arguments->primitiveCount) |
| 381 | return rtcBuildBVHBinnedSAH(arguments); |
| 382 | else |
| 383 | return rtcBuildBVHSpatialSAH(arguments); |
| 384 | } |
| 385 | else |
| 386 | throw_RTCError(RTC_ERROR_INVALID_OPERATION,"invalid build quality"); |
| 387 | |
| 388 | /* if we are in dynamic mode, then do not clear temporary data */ |
| 389 | if (!(arguments->buildFlags & RTC_BUILD_FLAG_DYNAMIC)) |
| 390 | { |
| 391 | bvh->morton_src.clear(); |
| 392 | bvh->morton_tmp.clear(); |
| 393 | } |
| 394 | |
| 395 | RTC_CATCH_END(bvh->device); |
| 396 | return nullptr; |
| 397 | } |
| 398 | |
| 399 | RTC_API void* rtcThreadLocalAlloc(RTCThreadLocalAllocator localAllocator, size_t bytes, size_t align) |
| 400 | { |
no test coverage detected