void EndSingleMaterial(MySingleMaterialHelper materialHelper) { //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); short[] indices = new short[materialHelper.IndexCount]; Array.Copy(materialHelper.Indices, indices, indices.Length); VRageRender.MyRenderProxy.UpdateRenderVoxelCell( VoxelMap.GetRenderObjectID(ref this.CellCoord), (VRageRender.MyLodTypeEnum)(int)CellHashType, vertices, indices, (int)materialHelper.Material.Index, -1, -1); } // Reset helper arrays, so we can start adding triangles to them again materialHelper.IndexCount = 0; materialHelper.VertexCount = 0; MyVoxelCacheCellRenderHelper.SingleMaterialIndicesLookupCount[(int)materialHelper.Material.Index]++; }
void EndMultiMaterial(MyMultiMaterialHelper helper) { if (helper.VertexCount > 0) { //Todo - is it possible without allocations? MyVertexFormatVoxelSingleData[] vertices = new MyVertexFormatVoxelSingleData[helper.VertexCount]; Array.Copy(helper.Vertices, vertices, vertices.Length); short[] indices = new short[helper.VertexCount]; for (short i = 0; i < indices.Length; i++) { indices[i] = i; } VRageRender.MyRenderProxy.UpdateRenderVoxelCell( VoxelMap.GetRenderObjectID(ref this.CellCoord), (VRageRender.MyLodTypeEnum)(int)CellHashType, vertices, indices, (int)helper.Material0.Index, (int)helper.Material1.Index, (int)helper.Material2.Index); } // Reset helper arrays, so we can start adding triangles to them again helper.VertexCount = 0; }