public void AddRegionGeo(VoxGeo g) { lock(lckDraw) { var nl = new List<VoxGeo>(geos.Count + 1); for(int i = 0; i < geos.Count; i++) { if(geos[i].Region != g.Region) nl.Add(geos[i]); else geos[i].Dispose(); } geos = nl; geos.Add(g); } }
public void AddRegionGeo(VoxGeo g) { lock (lckDraw) { var nl = new List <VoxGeo>(geos.Count + 1); for (int i = 0; i < geos.Count; i++) { if (geos[i].Region != g.Region) { nl.Add(geos[i]); } else { geos[i].Dispose(); } } geos = nl; geos.Add(g); } }
public void DoWork() { var mFaces = RegionGreedyMesher.Mesh(region); var lVerts = new List<VertexVoxel>(128); var lInds = new List<int>(128); MeshedFace mf; for(int i = 0; i < mFaces.Count; i++) { mf = mFaces[i]; region.World.Atlas[(ushort)Math.Abs(mf.ID)].GeoProvider.Append(lVerts, lInds, ref mf); } // Build The Geometry if(lVerts.Count < 1) return; VoxGeo geo = new VoxGeo(); geo.Region = region; geo.VB = new VertexBuffer(renderer.G, VertexVoxel.Declaration, lVerts.Count, BufferUsage.WriteOnly); geo.VB.SetData(lVerts.ToArray()); geo.IB = new IndexBuffer(renderer.G, IndexElementSize.ThirtyTwoBits, lInds.Count, BufferUsage.WriteOnly); geo.IB.SetData(lInds.ToArray()); // TODO: Use The Geometry renderer.AddRegionGeo(geo); }