コード例 #1
0
ファイル: MyVoxelMap.cs プロジェクト: Bunni/Miner-Wars-2081
        void GetRenderElementsFromRenderCell(List<MyRender.MyRenderElement> renderElements, MyVoxelCacheCellRender renderCell)
        {      
            //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GetElementsFromRenderCell");

            //  Performance counters
            if (renderCell.CellHashType == MyLodTypeEnum.LOD1)
                MyPerformanceCounter.PerCameraDraw.RenderCellsInFrustum_LOD1++;
            else
                MyPerformanceCounter.PerCameraDraw.RenderCellsInFrustum_LOD0++;

            foreach (MyVoxelCacheCellRenderBatch batch in renderCell.Batches)
            {
                if (batch.IndexBuffer == null)
                    continue;

                MyRender.MyRenderElement renderElement;
                MyRender.AllocateRenderElement(out renderElement);
                //MyRender.AddRenderElement(renderElements, out renderElement);

                //renderElement.DebugName = this.Name;
                renderElement.Entity = this;
                renderElement.IndexBuffer = batch.IndexBuffer;
                renderElement.VertexDeclaration = MinerWars.AppCode.Game.Utils.VertexFormats.MyVertexFormatVoxelSingleMaterial.VertexDeclaration;
                renderElement.VertexStride = MinerWars.AppCode.Game.Utils.VertexFormats.MyVertexFormatVoxelSingleMaterial.Stride;
                renderElement.VertexCount = batch.VertexBufferCount;
                renderElement.VertexBuffer = batch.VertexBuffer;
                renderElement.IndexStart = 0;
                renderElement.TriCount = batch.IndexBufferCount / 3;
                renderElement.WorldMatrix = Matrix.CreateTranslation(PositionLeftBottomCorner);
                renderElement.DrawTechnique = MyMeshDrawTechnique.VOXEL_MAP;
                renderElement.Material = m_fakeVoxelMaterial;
                renderElement.VoxelBatch = batch;

                renderElements.Add(renderElement);

                MyPerformanceCounter.PerCameraDraw.VoxelTrianglesInFrustum += renderElement.TriCount;

            }
              
            //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
コード例 #2
0
ファイル: MyVoxelMap.cs プロジェクト: Bunni/Miner-Wars-2081
        static void AddRenderCellToSortingList(MyVoxelCacheCellRender cachedRenderCell)
        {
            //  If cell is empty, skip it (don't add to sorting list)
            if (cachedRenderCell.Batches.Count <= 0) return;

            //  Cell is in the frustum and isn't empty, so add to sorting list
            MyVoxelMaps.GetSortedRenderCells().Add(new MyRenderCellForSorting(cachedRenderCell));
        }