LoadPage() public méthode

Ask for a page to be loaded with the given (section-relative) PageID
public LoadPage ( PageID pageID ) : void
pageID PageID The page ID to load
Résultat void
Exemple #1
0
        public override void NotifyCamera(Camera cam, PagedWorldSection section)
        {
            var stratData = (Grid2DPageStrategyData)section.StrategyData;

            Vector3 pos     = cam.DerivedPosition;
            Vector2 gridpos = Vector2.Zero;

            stratData.ConvertWorldToGridSpace(pos, ref gridpos);
            int x, y;

            stratData.DetermineGridLocation(gridpos, out x, out y);

            Real loadRadius = stratData.LoadRadiusInCells;
            Real holdRadius = stratData.HoldRadiusInCells;
            //scan the whole hold range
            Real fxmin = (Real)x - holdRadius;
            Real fxmax = (Real)x + holdRadius;
            Real fymin = (Real)y - holdRadius;
            Real fymax = (Real)y + holdRadius;

            int xmin = stratData.CellRangeMinX;
            int xmax = stratData.CellRangeMaxX;
            int ymin = stratData.CellRangeMinY;
            int ymax = stratData.CellRangeMaxY;

            // Round UP max, round DOWN min
            xmin = fxmin < xmin ? xmin : (int)System.Math.Floor(fxmin);
            xmax = fxmax > xmax ? xmax : (int)System.Math.Ceiling(fxmax);
            ymin = fymin < ymin ? ymin : (int)System.Math.Floor(fymin);
            ymax = fymax > ymax ? ymax : (int)System.Math.Ceiling(fymax);
            // the inner, active load range
            fxmin = (Real)x - loadRadius;
            fxmax = (Real)x + loadRadius;
            fymin = (Real)y - loadRadius;
            fymax = (Real)y + loadRadius;
            // Round UP max, round DOWN min
            int loadxmin = fxmin < xmin ? xmin : (int)System.Math.Floor(fxmin);
            int loadxmax = fxmax > xmax ? xmax : (int)System.Math.Ceiling(fxmax);
            int loadymin = fymin < ymin ? ymin : (int)System.Math.Floor(fymin);
            int loadymax = fymax > ymax ? ymax : (int)System.Math.Ceiling(fymax);

            for (int cy = ymin; cy <= ymax; ++cy)
            {
                for (int cx = xmin; cx <= xmax; ++cx)
                {
                    PageID pageID = stratData.CalculatePageID(cx, cy);
                    if (cx >= loadxmin && cx <= loadxmax && cy >= loadymin && cy <= loadymax)
                    {
                        // in the 'load' range, request it
                        section.LoadPage(pageID);
                    }
                    else
                    {
                        // in the outer 'hold' range, keep it but don't actively load
                        section.HoldPage(pageID);
                    }
                    // other pages will by inference be marked for unloading
                }
            }
        }
		public override void NotifyCamera( Camera cam, PagedWorldSection section )
		{
			var stratData = (Grid2DPageStrategyData)section.StrategyData;

			Vector3 pos = cam.DerivedPosition;
			Vector2 gridpos = Vector2.Zero;
			stratData.ConvertWorldToGridSpace( pos, ref gridpos );
			int x, y;
			stratData.DetermineGridLocation( gridpos, out x, out y );

			Real loadRadius = stratData.LoadRadiusInCells;
			Real holdRadius = stratData.HoldRadiusInCells;
			//scan the whole hold range
			Real fxmin = (Real)x - holdRadius;
			Real fxmax = (Real)x + holdRadius;
			Real fymin = (Real)y - holdRadius;
			Real fymax = (Real)y + holdRadius;

			int xmin = stratData.CellRangeMinX;
			int xmax = stratData.CellRangeMaxX;
			int ymin = stratData.CellRangeMinY;
			int ymax = stratData.CellRangeMaxY;

			// Round UP max, round DOWN min
			xmin = fxmin < xmin ? xmin : (int)System.Math.Floor( fxmin );
			xmax = fxmax > xmax ? xmax : (int)System.Math.Ceiling( fxmax );
			ymin = fymin < ymin ? ymin : (int)System.Math.Floor( fymin );
			ymax = fymax > ymax ? ymax : (int)System.Math.Ceiling( fymax );
			// the inner, active load range
			fxmin = (Real)x - loadRadius;
			fxmax = (Real)x + loadRadius;
			fymin = (Real)y - loadRadius;
			fymax = (Real)y + loadRadius;
			// Round UP max, round DOWN min
			int loadxmin = fxmin < xmin ? xmin : (int)System.Math.Floor( fxmin );
			int loadxmax = fxmax > xmax ? xmax : (int)System.Math.Ceiling( fxmax );
			int loadymin = fymin < ymin ? ymin : (int)System.Math.Floor( fymin );
			int loadymax = fymax > ymax ? ymax : (int)System.Math.Ceiling( fymax );

			for ( int cy = ymin; cy <= ymax; ++cy )
			{
				for ( int cx = xmin; cx <= xmax; ++cx )
				{
					PageID pageID = stratData.CalculatePageID( cx, cy );
					if ( cx >= loadxmin && cx <= loadxmax && cy >= loadymin && cy <= loadymax )
					{
						// in the 'load' range, request it
						section.LoadPage( pageID );
					}
					else
					{
						// in the outer 'hold' range, keep it but don't actively load
						section.HoldPage( pageID );
					}
					// other pages will by inference be marked for unloading
				}
			}
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cam"></param>
        /// <param name="section"></param>
        public override void NotifyCamera(Camera cam, PagedWorldSection section)
        {
            Grid2DPageStrategyData stratData = (Grid2DPageStrategyData)section.StrategyData;

            Vector3 pos = cam.DerivedPosition;
            Vector2 gridpos = Vector2.Zero;
            stratData.ConvetWorldToGridSpace(pos, ref gridpos);
            int row = 0, col = 0;
            stratData.DetermineGridLocation(gridpos, ref row, ref col);

            float loadRadius = stratData.LoadRadiusInCells;
            float holdRadius = stratData.HoldRadiusInCells;
            //scan the whole hold range
            float frowmin = (float)row - holdRadius;
            float frowmax = (float)row + holdRadius;
            float fcolmin = (float)col - holdRadius;
            float fcolmax = (float)col + holdRadius;

            int clampRowAt = stratData.CellCountVert - 1;
            int clampColAt = stratData.CellCountHorz - 1;

            //round UP max, round DOWN min
            int rowmin = frowmin < 0 ? 0 : (int)System.Math.Floor(frowmin);
            int rowmax = frowmax > clampRowAt ? clampRowAt : (int)System.Math.Ceiling(frowmax);
            int colmin = fcolmin < 0 ? 0 : (int)System.Math.Floor(fcolmin);
            int colmax = fcolmax > clampColAt ? clampColAt : (int)System.Math.Ceiling(fcolmax);
            // the inner, active load range
            frowmin = (float)row - loadRadius;
            frowmax = (float)row + loadRadius;
            fcolmin = (float)col - loadRadius;
            fcolmax = (float)col + loadRadius;
            //round UP max, round DOWN min
            int loadrowmin = frowmin < 0 ? 0 : (int)System.Math.Floor(frowmin);
            int loadrowmax = frowmax > clampRowAt ? clampRowAt : (int)System.Math.Ceiling(frowmax);
            int loadcolmin = fcolmin < 0 ? 0 : (int)System.Math.Floor(fcolmin);
            int loadcolmax = fcolmax > clampColAt ? clampColAt : (int)System.Math.Ceiling(fcolmax);

            for (int r = rowmin; r <= rowmax; ++r)
            {
                for (int c = colmin; c <= colmax; ++c)
                {
                    PageID pageID = stratData.CalculatePageID(r, c);
                    if (r >= loadrowmin && r <= loadrowmax && c >= loadcolmin && c <= loadcolmax)
                    {
                        // int the 'load' range, request it
                        section.LoadPage(pageID);
                    }
                    else
                    {
                        // int the outer 'hold' range, keep it but don't actively load.
                        section.HoldPage(pageID);
                    }
                    // other paged will by inference be marked for unloading
                }
            }
        }