Example #1
0
        public void DoFragmentation()
        {
            this.currentState = PhysicsState.Fragmanatation;

            VoxelIngameBuildTask ingameBuildTask = container.ingameBuildTask;

            ThreadPool.QueueUserWorkItem(FragmentationThread, ingameBuildTask);
        }
Example #2
0
        private List <List <Voxel> > GetAggregations(VoxelIngameBuildTask ingameBuildTask)
        {
            List <List <Voxel> > resultset            = new List <List <Voxel> >();
            List <Voxel>         listOfUnListedVoxels = new List <Voxel>(this.container.voxels.Values);

            if (ingameBuildTask != null)
            {
                foreach (Voxel curVoxel in ingameBuildTask.voxelsToRemove)
                {
                    listOfUnListedVoxels.Remove(curVoxel);
                }
            }

            HashSet <Vector3> curAggregatePos = new HashSet <Vector3>();

            while (listOfUnListedVoxels.Count > 0)
            {
                List <Voxel> curAggregate = new List <Voxel>();
                GetSurroundingVoxels(listOfUnListedVoxels[0], ref curAggregate, ref curAggregatePos);
                if (curAggregate.Count >= this.minAggregatedVoxelCount)
                {
                    resultset.Add(curAggregate);
                }
                else
                {
                    foreach (Voxel curVoxel in curAggregate)
                    {
                        this.container.RemoveVoxel(curVoxel, true);
                    }
                }
                foreach (Voxel curVoxel in curAggregate)
                {
                    listOfUnListedVoxels.Remove(curVoxel);
                }
            }
            return(resultset);
        }