private static unsafe int[] ProducedPrimitivesCountPerSubTree(BoundingVolumeHierarchy.Node *nodes, int nodeCount) { int[] primitivesPerNode = Enumerable.Repeat(0, nodeCount).ToArray(); for (int nodeIndex = nodeCount - 1; nodeIndex >= 0; nodeIndex--) { BoundingVolumeHierarchy.Node node = nodes[nodeIndex]; if (node.IsLeaf) { primitivesPerNode[nodeIndex] = node.NumValidChildren(); } else { primitivesPerNode[nodeIndex] = primitivesPerNode[node.Data[0]] + primitivesPerNode[node.Data[1]] + primitivesPerNode[node.Data[2]] + primitivesPerNode[node.Data[3]]; } } return(primitivesPerNode); }
private static unsafe NativeArray <int> ProducedPrimitivesCountPerSubTree(BoundingVolumeHierarchy.Node *nodes, int nodeCount) { var primitivesPerNode = new NativeArray <int>(nodeCount, Allocator.Temp); for (int nodeIndex = nodeCount - 1; nodeIndex >= 0; nodeIndex--) { BoundingVolumeHierarchy.Node node = nodes[nodeIndex]; if (node.IsLeaf) { primitivesPerNode[nodeIndex] = node.NumValidChildren(); } else { primitivesPerNode[nodeIndex] = primitivesPerNode[node.Data[0]] + primitivesPerNode[node.Data[1]] + primitivesPerNode[node.Data[2]] + primitivesPerNode[node.Data[3]]; } } return(primitivesPerNode); }