/// <summary> /// Multimaterial vertices are not removing duplicities using indices. /// They just add indexing on top of duplicating vertices. /// </summary> private void EndMultiMaterial(MultiMaterialHelper helper, List<MyClipmapCellBatch> outBatches) { if (helper.Vertices.Count > 0) { //Todo - is it possible without allocations? MyVertexFormatVoxelSingleData[] vertices = new MyVertexFormatVoxelSingleData[helper.Vertices.Count]; Array.Copy(helper.Vertices.GetInternalArray(), vertices, vertices.Length); uint[] indices = new uint[helper.Vertices.Count]; for (ushort i = 0; i < indices.Length; i++) { indices[i] = i; } outBatches.Add(new MyClipmapCellBatch { Vertices = vertices, Indices = indices, Material0 = helper.Material0, Material1 = helper.Material1, Material2 = helper.Material2, }); } // Reset helper arrays, so we can start adding triangles to them again helper.Vertices.Clear(); }
private void EndSingleMaterial(SingleMaterialHelper materialHelper, List<MyClipmapCellBatch> outBatches) { //Synchronize to VRage render if (materialHelper.IndexCount > 0 && materialHelper.VertexCount > 0) { //Todo - is it possible without allocations? MyVertexFormatVoxelSingleData[] vertices = new MyVertexFormatVoxelSingleData[materialHelper.VertexCount]; Array.Copy(materialHelper.Vertices, vertices, vertices.Length); uint[] indices = new uint[materialHelper.IndexCount]; Array.Copy(materialHelper.Indices, indices, indices.Length); outBatches.Add(new MyClipmapCellBatch() { Vertices = vertices, Indices = indices, Material0 = materialHelper.Material, Material1 = -1, Material2 = -1, }); } // Reset helper arrays, so we can start adding triangles to them again materialHelper.IndexCount = 0; materialHelper.VertexCount = 0; SM_BatchLookups[materialHelper.Material].ResetBatch(); }