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
}
}
}
/// <summary>