@@ -79,7 +79,6 @@ struct MortonPrimitive {
79
79
uint32_t mortonCode;
80
80
};
81
81
82
- inline uint32_t LeftShift3 (uint32_t x);
83
82
struct LBVHTreelet {
84
83
int startIndex, nPrimitives;
85
84
BVHBuildNode *buildNodes;
@@ -252,6 +251,10 @@ BVHBuildNode *BVHAccel::recursiveBuild(
252
251
return pi.centroid [dim] < pmid;
253
252
});
254
253
mid = midPtr - &primitiveInfo[0 ];
254
+ // For lots of prims with large overlapping bounding boxes, this
255
+ // may fail to partition; in that case don't break and fall
256
+ // through
257
+ // to EqualCounts.
255
258
if (mid != start && mid != end) break ;
256
259
}
257
260
case SplitMethod::EqualCounts: {
@@ -594,7 +597,7 @@ BVHBuildNode *BVHAccel::buildUpperSAH(MemoryArena &arena,
594
597
return node;
595
598
}
596
599
597
- int BVHAccel::flattenBVHTree (BVHBuildNode *node, int *offset, int depth ) {
600
+ int BVHAccel::flattenBVHTree (BVHBuildNode *node, int *offset) {
598
601
LinearBVHNode *linearNode = &nodes[*offset];
599
602
linearNode->bounds = node->bounds ;
600
603
int myOffset = (*offset)++;
@@ -607,9 +610,9 @@ int BVHAccel::flattenBVHTree(BVHBuildNode *node, int *offset, int depth) {
607
610
// Create interior flattened BVH node
608
611
linearNode->axis = node->splitAxis ;
609
612
linearNode->nPrimitives = 0 ;
610
- flattenBVHTree (node->children [0 ], offset, depth + 1 );
613
+ flattenBVHTree (node->children [0 ], offset);
611
614
linearNode->secondChildOffset =
612
- flattenBVHTree (node->children [1 ], offset, depth + 1 );
615
+ flattenBVHTree (node->children [1 ], offset);
613
616
}
614
617
return myOffset;
615
618
}
0 commit comments