/// <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(); }
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]++; }
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(); }
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; }
/// <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(); }
internal void AddVertex(ref MyVertexFormatVoxelSingleData vertex, ref Vector3D positionUnnormalized, ref Vector3D positionMorphUnnormalized) { m_vertexHelper.Add(vertex); m_positionHelper.Add(MyTuple.Create(positionUnnormalized, positionMorphUnnormalized)); }