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]++; }
// Remove cell - after voxels were changed, etc. public static void RemoveCell(MyVoxelMap voxelMap, ref Vector3I cellCoord, MyLodTypeEnum cellHashType) { Int64 key = MySession.Static.VoxelMaps.GetCellHashCode(voxelMap.VoxelMapId, ref cellCoord, cellHashType); // If cell is in cache, we remove it from dictionary and move it to the beginning of priority linked list LinkedListNode <MyVoxelCacheCellRender> ret; if (m_cellsByCoordinate.TryGetValue(key, out ret) == true) { m_cellsByCoordinate.Remove(key); ret.Value.Reset(); // Move it to the beginning of priority linked list Debug.Assert(Thread.CurrentThread == MySandboxGame.Static.UpdateThread); m_priority.Remove(ret); m_priority.AddFirst(ret); VRageRender.MyRenderProxy.InvalidateRenderVoxelCell(voxelMap.GetRenderObjectID(ref cellCoord), (VRageRender.MyLodTypeEnum)(int) cellHashType); } }