コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: MeshBuilder.cs プロジェクト: Elizafur/FPS-Transfer
        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);
        }