void BVH4BuilderTopLevel::task_build_parallel(size_t threadIndex, size_t threadCount, size_t taskIndex, size_t taskCount, TaskScheduler::Event* event_i) { /* ignore meshes that need all threads */ size_t objectID = taskIndex; if (builders[objectID] && builders[objectID]->needAllThreads) return; /* build all other meshes */ BBox3f bounds = build(threadIndex,threadCount,objectID); if (!bounds.empty()) g_state->thread_bounds[threadIndex].extend(bounds); }
float BVH4i::sah (NodeRef& node, const BBox3f& bounds) { float f = bounds.empty() ? 0.0f : area(bounds); if (node.isNode()) { Node* n = node.node(nodePtr()); for (size_t c=0; c<4; c++) f += sah(n->child(c),n->bounds(c)); return f; } else { size_t num; node.leaf(triPtr(),num); return f*num; } }