void SetLOD2HindicesCPUSide(uint[] hsorted) { if (hsorted.Length == 0) { return; } lod2HindicesCPUSide = new List <int>(hsorted.Length / 8); lod2HindicesCPUSide.Add(0); int prev = (int)hsorted[0]; int next; for (int i = 0; i < hsorted.Length; ++i) { next = (int)hsorted[i]; if (TestHilbertIndices.isDifferentHilbertCube(prev, next, 2)) { lod2HindicesCPUSide.Add(i); prev = next; } } Debug.Log("hsorted: " + hsorted.Length); Debug.Log("LOD2 indices: " + lod2HindicesCPUSide.Count); List <int> lodTwoVoxels = new List <int>(lod2HindicesCPUSide.Count); foreach (int index in lod2HindicesCPUSide) { lodTwoVoxels.Add((int)hsorted[index]); } Debug.Log("lodTwoVoxels: " + lodTwoVoxels.Count); DebugDrawVoxelOrder.Draw(lodTwoVoxels.ToArray(), vGenConfig.ChunkSizeX + 1); //EditorApplication.isPaused = true; }
private static MapDisplay.DisplayBuffers GenerateMapBuffers(List <IntVector3.IndexedIntVector3> points) { List <uint> voxels = new List <uint>(points.Count); List <uint> hindices = new List <uint>(points.Count / 2); IntVector3 prevFour = points[0]; IntVector3 prevTwo = points[0]; hindices.Add(0); int hFourCount = 1; for (int i = 0; i < points.Count; ++i) { var iv = points[i]; voxels.Add(iv.v.ToVoxel()); if (TestHilbertIndices.isDifferentHilbertCube(iv.v, prevFour, 4)) { prevFour = iv.v; hindices.Add((uint)i); hFourCount++; } } for (int i = 0; i < points.Count; ++i) { var iv = points[i]; if (!TestHilbertIndices.isDifferentHilbertCube(iv.v, prevFour, 4)) { if (TestHilbertIndices.isDifferentHilbertCube(iv.v, prevTwo, 2)) { prevTwo = iv.v; hindices.Add((uint)i); } } else { prevFour = iv.v; } } uint[] hilbertRanges = new uint[] { (uint)points.Count, (uint)hindices.Count, (uint)hFourCount }; // (uint)hindices.Count }; MapDisplay.DisplayBuffers dbuffers = new MapDisplay.DisplayBuffers(); dbuffers.display = new ComputeBuffer(voxels.Count, sizeof(uint)); dbuffers.display.SetData(voxels.ToArray()); dbuffers.hilbertIndices = new ComputeBuffer(hindices.Count, sizeof(uint)); dbuffers.hilbertIndices.SetData(hindices.ToArray()); dbuffers.hilbertLODRanges = new ComputeBuffer(hilbertRanges.Length, sizeof(uint)); dbuffers.hilbertLODRanges.SetData(hilbertRanges); return(dbuffers); }