Example #1
0
        void Add(SceneNode node, Octree octree, int depth)
        {
            if (depth < MaxDepth && octree.IsTwiceSize(ref node.BoxWorld))
            {
                // 指定された八分木のサイズがノードの二倍以上ならば、
                // 子に対してノードを追加。

                int x;
                int y;
                int z;
                octree.GetChildIndex(ref node.BoxWorld, out x, out y, out z);

                if (octree[x, y, z] == null)
                {
                    // 子がまだ存在しないなら生成。
                    AllocateChildOctree(octree, x, y, z);
                }

                Add(node, octree[x, y, z], ++depth);
            }
            else
            {
                octree.Nodes.Add(node);
            }
        }