Ejemplo n.º 1
0
        public override void DoWork()
        {
            ProfilerShort.Begin("MyPrecalcJobRender.DoWork");
            try
            {
                if (m_isCancelled)
                {
                    return;
                }

                m_metadata.Cell      = m_args.Cell;
                m_metadata.LocalAabb = BoundingBox.CreateInvalid();

                var cellSize = MyVoxelCoordSystems.RenderCellSizeInLodVoxels(m_args.Cell.Lod);
                var min      = m_args.Cell.CoordInLod * cellSize;
                var max      = min + cellSize - 1
                               + 1 // overlap to neighbor so geometry is stitched together within same LOD
                               + 1 // extra overlap so there are more vertices for mapping to parent LOD
                               + 1 // for eg. 9 vertices in row we need 9 + 1 samples (voxels)
                ;

                MyIsoMesh highResMesh = MyPrecalcComponent.IsoMesher.Precalc(m_args.Storage, m_args.Cell.Lod, min, max, true, true);

                if (m_isCancelled || highResMesh == null)
                {
                    return;
                }

                MyIsoMesh lowResMesh = null;

                // Less detailed mesh for vertex morph targets
                min >>= 1;
                max >>= 1;
                min  -= 1;
                max  += 1;
                // lowResMesh = MyPrecalcComponent.IsoMesher.Precalc(m_args.Storage, m_args.Cell.Lod + 1, min, max, true, true);

                if (m_isCancelled)
                {
                    return;
                }

                RenderCellBuilder.BuildCell(m_args, highResMesh, lowResMesh, m_batches, out m_metadata);
            }
            finally
            {
                ProfilerShort.End();
            }
        }
Ejemplo n.º 2
0
        public override void DoWork()
        {
            ProfilerShort.Begin("MyPrecalcJobRender.DoWork");
            try
            {
                if (m_isCancelled)
                {
                    return;
                }

                var min = m_args.Cell.CoordInLod * MyVoxelConstants.RENDER_CELL_SIZE_IN_VOXELS;
                var max = min + MyVoxelConstants.RENDER_CELL_SIZE_IN_VOXELS - 1
                          + 1  // overlap to neighbor so geometry is stitched together within same LOD
                          + 1  // extra overlap so there are more vertices for mapping to parent LOD
                          + 1; // for eg. 9 vertices in row we need 9 + 1 samples (voxels)
                var highResMesh = MyPrecalcComponent.IsoMesher.Precalc(m_args.Storage, m_args.Cell.Lod, min, max, true);

                if (m_isCancelled || highResMesh == null)
                {
                    return;
                }

                // Less detailed mesh for vertex morph targets
                min >>= 1;
                max >>= 1;
                min  -= 1;
                max  += 1;
                var lowResMesh = MyPrecalcComponent.IsoMesher.Precalc(m_args.Storage, m_args.Cell.Lod + 1, min, max, true);

                if (m_isCancelled)
                {
                    return;
                }

                RenderCellBuilder.BuildCell(m_args, highResMesh, lowResMesh, m_batches, out m_positionOffset, out m_positionScale, out m_localBoundingBox);
            }
            finally
            {
                ProfilerShort.End();
            }
        }
Ejemplo n.º 3
0
        public override void DoWork()
        {
            ProfilerShort.Begin("MyPrecalcJobRender.DoWork");
            try
            {
                if (m_isCancelled)
                {
                    return;
                }

                m_metadata.Cell      = m_args.Cell;
                m_metadata.LocalAabb = BoundingBox.CreateInvalid();

                var cellSize = MyVoxelCoordSystems.RenderCellSizeInLodVoxels(m_args.Cell.Lod);
                var min      = m_args.Cell.CoordInLod * cellSize - 1;
                var max      = min + cellSize - 1
                               + 1  // overlap to neighbor so geometry is stitched together within same LOD
                               + 1  // extra overlap so there are more vertices for mapping to parent LOD
                               + 1; // for eg. 9 vertices in row we need 9 + 1 samples (voxels)
                //    + 1 // why not
                //  + 1 // martin kroslak approved

                var       clipmapCellId = MyCellCoord.GetClipmapCellHash(m_args.ClipmapId, m_args.Cell.PackId64());
                MyIsoMesh highResMesh   = IsoMeshCache.Read(clipmapCellId);

                if (highResMesh == null)
                {
                    highResMesh = MyPrecalcComponent.IsoMesher.Precalc(m_args.Storage, m_args.Cell.Lod, min, max, true, MyFakes.ENABLE_VOXEL_COMPUTED_OCCLUSION);
                    if (UseIsoCache && highResMesh != null)
                    {
                        IsoMeshCache.Write(clipmapCellId, highResMesh);
                    }
                }

                if (m_isCancelled || highResMesh == null)
                {
                    return;
                }

                MyIsoMesh lowResMesh = null;

                if (m_args.Cell.Lod < 15 && MyFakes.ENABLE_VOXEL_LOD_MORPHING)
                {
                    var nextLodCell = m_args.Cell;
                    nextLodCell.Lod++;
                    clipmapCellId = MyCellCoord.GetClipmapCellHash(m_args.ClipmapId, nextLodCell.PackId64());

                    lowResMesh = IsoMeshCache.Read(clipmapCellId);

                    if (lowResMesh == null)
                    {
                        // Less detailed mesh for vertex morph targets
                        min >>= 1;
                        max >>= 1;
                        min  -= 1;
                        max  += 2;

                        lowResMesh = MyPrecalcComponent.IsoMesher.Precalc(m_args.Storage, m_args.Cell.Lod + 1, min, max, true, MyFakes.ENABLE_VOXEL_COMPUTED_OCCLUSION);

                        if (UseIsoCache && lowResMesh != null)
                        {
                            IsoMeshCache.Write(clipmapCellId, lowResMesh);
                        }
                    }
                }

                if (m_isCancelled)
                {
                    return;
                }

                RenderCellBuilder.BuildCell(m_args, highResMesh, lowResMesh, m_batches, out m_metadata);
            }
            finally
            {
                ProfilerShort.End();
            }
        }