Ejemplo n.º 1
0
        // TODO: hilbert sorting could be done on GPU while finding exposed voxels?
        public void hilbertSortVoxels()
        {
            int voxelCount = getShownVoxelCount();

            int[] voxels = new int[voxelCount];
            ShownVoxels.GetData(voxels, 0, 0, voxels.Length);


            List <IntVoxel3> voxVs = new List <IntVoxel3>(voxels.Length);

            foreach (int voxel in voxels)
            {
                voxVs.Add(new IntVoxel3(voxel, 0));
            }

            int bits = vGenConfig.hilbertBits;

            int[] hsorted = voxels.OrderBy(vox => IntVector3.FromVoxelInt(vox).ToUint3().CoordsToFlatHilbertIndex(bits)).ToArray();
            //IntVector3.FromVoxelInt(vox).ToUint3().HilbertIndexTransposed(bits).FlatHilbertIndex(bits)).ToArray();

            ShownVoxels.SetData(hsorted, 0, 0, hsorted.Length);

            //
            //
            SetLOD2HindicesCPUSide(hsorted);
        }
Ejemplo n.º 2
0
        public uint[] GetHilbertSortedVoxels()
        {
            int voxelCount = getShownVoxelCount();

            uint[] voxels = new uint[voxelCount];
            ShownVoxels.GetData(voxels, 0, 0, voxels.Length);

            int bits = vGenConfig.hilbertBits;

            return(voxels.OrderBy(vox => HilbertTables.XYZToHilbertIndex[IntVector3.FromVoxelInt((int)vox).ToFlatXYZIndex(vGenConfig.ChunkSize)]).ToArray());
        }
Ejemplo n.º 3
0
        void _draw(int[] voxels, float xOffset = 0f)
        {
            IntVector3 offset = IntVector3.right * xOffset;
            IntVector3 end;

            lr.positionCount = voxels.Length;

            if (voxels.Length == 0)
            {
                print("zero voxels");
            }
            for (int i = 0; i < voxels.Length; ++i)
            {
                end = IntVector3.FromVoxelInt(voxels[i]);
                lr.SetPosition(i, end + offset);
            }
        }
Ejemplo n.º 4
0
        public bool TestDisplayBufferFromSolidVoxels(uint[] uis, out MapDisplay.DisplayBuffers displayBuffers)
        {
            if (uis.Length == 0)
            {
                displayBuffers = new MapDisplay.DisplayBuffers();
                return(false);
            }
            var points = new List <IntVector3.IndexedIntVector3>(uis.Length);

            for (int i = 0; i < uis.Length; ++i)
            {
                points.Add(new IntVector3.IndexedIntVector3()
                {
                    index = i,
                    v     = IntVector3.FromVoxelInt((int)uis[i])
                });
            }

            displayBuffers = GenTestBuffers(_chunkSize, points);
            return(true);
        }