| 38 | |
| 39 | template<int N> |
| 40 | typename BVHNStatistics<N>::Statistics BVHNStatistics<N>::statistics(NodeRef node, const double A, const BBox1f t0t1) |
| 41 | { |
| 42 | Statistics s; |
| 43 | assert(t0t1.size() > 0.0f); |
| 44 | double dt = max(0.0f,t0t1.size()); |
| 45 | if (node.isAABBNode()) |
| 46 | { |
| 47 | AABBNode* n = node.getAABBNode(); |
| 48 | s = s + parallel_reduce(0,N,Statistics(),[&] ( const int i ) { |
| 49 | if (n->child(i) == BVH::emptyNode) return Statistics(); |
| 50 | const double Ai = max(0.0f,halfArea(n->extend(i))); |
| 51 | Statistics s = statistics(n->child(i),Ai,t0t1); |
| 52 | s.statAABBNodes.numChildren++; |
| 53 | return s; |
| 54 | }, Statistics::add); |
| 55 | s.statAABBNodes.numNodes++; |
| 56 | s.statAABBNodes.nodeSAH += dt*A; |
| 57 | s.depth++; |
| 58 | } |
| 59 | else if (node.isOBBNode()) |
| 60 | { |
| 61 | OBBNode* n = node.ungetAABBNode(); |
| 62 | s = s + parallel_reduce(0,N,Statistics(),[&] ( const int i ) { |
| 63 | if (n->child(i) == BVH::emptyNode) return Statistics(); |
| 64 | const double Ai = max(0.0f,halfArea(n->extent(i))); |
| 65 | Statistics s = statistics(n->child(i),Ai,t0t1); |
| 66 | s.statOBBNodes.numChildren++; |
| 67 | return s; |
| 68 | }, Statistics::add); |
| 69 | s.statOBBNodes.numNodes++; |
| 70 | s.statOBBNodes.nodeSAH += dt*A; |
| 71 | s.depth++; |
| 72 | } |
| 73 | else if (node.isAABBNodeMB()) |
| 74 | { |
| 75 | AABBNodeMB* n = node.getAABBNodeMB(); |
| 76 | s = s + parallel_reduce(0,N,Statistics(),[&] ( const int i ) { |
| 77 | if (n->child(i) == BVH::emptyNode) return Statistics(); |
| 78 | const double Ai = max(0.0f,n->expectedHalfArea(i,t0t1)); |
| 79 | Statistics s = statistics(n->child(i),Ai,t0t1); |
| 80 | s.statAABBNodesMB.numChildren++; |
| 81 | return s; |
| 82 | }, Statistics::add); |
| 83 | s.statAABBNodesMB.numNodes++; |
| 84 | s.statAABBNodesMB.nodeSAH += dt*A; |
| 85 | s.depth++; |
| 86 | } |
| 87 | else if (node.isAABBNodeMB4D()) |
| 88 | { |
| 89 | AABBNodeMB4D* n = node.getAABBNodeMB4D(); |
| 90 | s = s + parallel_reduce(0,N,Statistics(),[&] ( const int i ) { |
| 91 | if (n->child(i) == BVH::emptyNode) return Statistics(); |
| 92 | const BBox1f t0t1i = intersect(t0t1,n->timeRange(i)); |
| 93 | assert(!t0t1i.empty()); |
| 94 | const double Ai = n->AABBNodeMB::expectedHalfArea(i,t0t1i); |
| 95 | Statistics s = statistics(n->child(i),Ai,t0t1i); |
| 96 | s.statAABBNodesMB4D.numChildren++; |
| 97 | return s; |
nothing calls this directly
no test coverage detected