Пример #1
0
    // This will pack all remaining triangles into the current node, or create more
    private void Pack(P3D_Node node, int min, int max)
    {
        var count = max - min;

        node.TriangleIndex = min;
        node.TriangleCount = count;
        node.Split         = count >= 5;

        node.CalculateBound(triangles);

        // Split this node?
        if (node.Split == true)
        {
            var mid = (min + max) / 2;

            SortTriangles(min, max);

            // Split node along pivot
            node.PositiveIndex = nodes.Count; var positiveNode = P3D_Node.Spawn(); nodes.Add(positiveNode); Pack(positiveNode, min, mid);
            node.NegativeIndex = nodes.Count; var negativeNode = P3D_Node.Spawn(); nodes.Add(negativeNode); Pack(negativeNode, mid, max);
        }
    }
Пример #2
0
    private void Pack(P3D_Node node, int min, int max)
    {
        int num = max - min;

        node.TriangleIndex = min;
        node.TriangleCount = num;
        node.Split         = num >= 5;
        node.CalculateBound(this.triangles);
        if (node.Split)
        {
            int num2 = (min + max) / 2;
            this.SortTriangles(min, max);
            node.PositiveIndex = this.nodes.Count;
            P3D_Node item = P3D_Node.Spawn();
            this.nodes.Add(item);
            this.Pack(item, min, num2);
            node.NegativeIndex = this.nodes.Count;
            P3D_Node node3 = P3D_Node.Spawn();
            this.nodes.Add(node3);
            this.Pack(node3, num2, max);
        }
    }