Beispiel #1
0
        public bool Subdivide()
        {
            float quarter_length = Length / 4.0f;

            int stop = 8;

            for (int x = -1; x <= 1; x += 2)
            {
                for (int y = -1; y <= 1; y += 2)
                {
                    for (int z = -1; z <= 1; z += 2)
                    {
                        VoxelizingOctreeCell newCell = new VoxelizingOctreeCell(Tree, Root,
                                                                                Center + new Vector3(x * quarter_length, y * quarter_length, z * quarter_length),
                                                                                quarter_length * 2.0f,
                                                                                Level + 1
                                                                                );

                        newCell.Parent = this;
                        newCell.EncloseTriangles(this);

                        if (newCell.IsOutsideMeshBounds())
                        {
                            newCell.Status = CellStatus.Outside;
                        }

                        if (!newCell.IsIntersecting)
                        {
                            stop--;
                        }

                        Children.Add(newCell);
                    }
                }
            }

            if (stop == 0)
            {
                //Debug.Assert(!IsIntersecting);
                if (IsIntersecting)
                {
                    //Debugger.Break();
                }

                Children.Clear();
            }

            return(stop != 0);
        }
        public bool Subdivide()
        {
            float quarter_length = Length / 4.0f;

            int stop = 8;
            for (int x = -1; x <= 1; x += 2)
            {
                for (int y = -1; y <= 1; y += 2)
                {
                    for (int z = -1; z <= 1; z += 2)
                    {
                        VoxelizingOctreeCell newCell = new VoxelizingOctreeCell(Tree, Root,
                            Center + new Vector3(x * quarter_length, y * quarter_length, z * quarter_length),
                            quarter_length * 2.0f,
                            Level + 1
                        );

                        newCell.Parent = this;
                        newCell.EncloseTriangles(this);

                        if (newCell.IsOutsideMeshBounds())
                            newCell.Status = CellStatus.Outside;

                        if (!newCell.IsIntersecting)
                            stop--;

                        Children.Add(newCell);
                    }
                }
            }

            if (stop == 0)
            {
                //Debug.Assert(!IsIntersecting);
                if (IsIntersecting)
                {
                    //Debugger.Break();
                }

                Children.Clear();
            }

            return stop != 0;
        }