ConstructNodes() public méthode

public ConstructNodes ( int &v_index, List vertices, int grid_size ) : bool
v_index int
vertices List
grid_size int
Résultat bool
Exemple #1
0
        public bool ConstructNodes(ref int v_index, List <VertexPositionColorNormal> vertices, int grid_size)
        {
            if (size == 1)
            {
                return(ConstructLeaf(ref v_index, vertices, grid_size));
            }

            int  child_size   = size / 2;
            bool has_children = false;

            for (int i = 0; i < 4; i++)
            {
                Vector2      offset = new Vector2(i / 2, i % 2);
                QuadtreeNode child  = new QuadtreeNode();
                child.size     = child_size;
                child.position = position + offset * (float)child_size;
                child.type     = QuadtreeNodeType.Internal;

                if (child.ConstructNodes(ref v_index, vertices, grid_size))
                {
                    has_children = true;
                }
                children[i] = child;
            }

            if (!has_children)
            {
                type = QuadtreeNodeType.Leaf;
                return(false);
            }

            type = QuadtreeNodeType.Internal;
            return(true);
        }
Exemple #2
0
        public bool ConstructNodes(ref int v_index, List<VertexPositionColorNormal> vertices, int grid_size)
        {
            if (size == 1)
            {
                return ConstructLeaf(ref v_index, vertices, grid_size);
            }

            int child_size = size / 2;
            bool has_children = false;
            for (int i = 0; i < 4; i++)
            {
                Vector2 offset = new Vector2(i / 2, i % 2);
                QuadtreeNode child = new QuadtreeNode();
                child.size = child_size;
                child.position = position + offset * (float)child_size;
                child.type = QuadtreeNodeType.Internal;

                if (child.ConstructNodes(ref v_index, vertices, grid_size))
                    has_children = true;
                children[i] = child;
            }

            if (!has_children)
            {
                type = QuadtreeNodeType.Leaf;
                return false;
            }

            type = QuadtreeNodeType.Internal;
            return true;
        }