/// <summary> /// Load a Page, for a given PagedWorldSection. /// </summary> /// <param name="page"></param> /// <param name="section"></param> /// <param name="forceSync"></param> public void LoadPage(Page page, PagedWorldSection section, bool forceSync) { // Prepare in the background Request req = new Request(RequestType.PreparePage, page, section); AddBackgroundRequest(req, forceSync); // load will happen in the main thread once preparation is complete }
/// <summary> /// Dispose of a page /// </summary> /// <param name="page"></param> /// <param name="section"></param> /// <param name="forceSync"></param> public void UnLoadPage(Page page, PagedWorldSection section, bool forceSync) { // unload in main thread, then unprepare in background Request req = new Request(RequestType.UnloadPage, page, section); AddRenderRequest(req, forceSync); }
/// <summary> /// Attach a page to this section. /// </summary> /// <param name="page"></param> public virtual void AttachPage(Page page) { if (mPages.ContainsKey(page.PageID)) { //page with this id allready in map Page existingPage; mPages.TryGetValue(page.PageID,out existingPage); if (existingPage != page) { Manager.Queue.CancelOperationsForPage(existingPage); mPages.Remove(existingPage.PageID); existingPage = null; } } page.NotifyAttached(this); }
public override void UpdateDebugDisplay( Page p, SceneNode sn ) { byte dbglvl = mManager.DebugDisplayLevel; if ( dbglvl != 0 ) { // we could try to avoid updating the geometry every time here, but this // wouldn't easily deal with paging parameter changes. There shouldn't // be that many pages anyway, and this is debug after all, so update every time int x, y; var stratData = (Grid2DPageStrategyData)p.ParentSection.StrategyData; stratData.CalculateCell( p.PageID, out x, out y ); var data = (Grid2DPageStrategyData)p.ParentSection.StrategyData; // Determine our centre point, we'll anchor here // Note that world points are initialised to ZERO since only 2 dimensions // are updated by the grid data (we could display this grid anywhere) Vector2 gridMidPoint = Vector2.Zero; Vector3 worldMidPoint = Vector3.Zero; data.GetMidPointGridSpace( x, y, ref gridMidPoint ); data.ConvertGridToWorldSpace( gridMidPoint, ref worldMidPoint ); sn.Position = worldMidPoint; var gridCorners = new Vector2[4]; var worldCorners = new Vector3[4]; data.GetCornersGridSpace( x, y, ref gridCorners ); for ( int i = 0; i < 4; ++i ) { worldCorners[ i ] = Vector3.Zero; data.ConvertGridToWorldSpace( gridCorners[ i ], ref worldCorners[ i ] ); // make relative to mid point worldCorners[ i ] -= worldMidPoint; } string matName = "Axiom/G2D/Debug"; var mat = (Material)MaterialManager.Instance.GetByName( matName ); if ( mat == null ) { mat = (Material)MaterialManager.Instance.Create( matName, ResourceGroupManager.DefaultResourceGroupName ); Pass pass = mat.GetTechnique( 0 ).GetPass( 0 ); pass.LightingEnabled = false; pass.VertexColorTracking = TrackVertexColor.Ambient; pass.DepthWrite = false; mat.Load(); } ManualObject mo = null; if ( sn.ChildCount == 0 ) { mo = p.ParentSection.SceneManager.CreateManualObject(); mo.Begin( matName, OperationType.LineStrip ); } else { mo = (ManualObject)sn.GetObject( 0 ); mo.BeginUpdate( 0 ); } ColorEx vcol = ColorEx.Green; for ( int i = 0; i < 5; ++i ) { mo.Position( worldCorners[ i%4 ] ); mo.Color( vcol ); } mo.End(); if ( sn.ObjectCount == 0 ) { sn.AttachObject( mo ); } } }
/// <summary> /// Called when the frame ends /// </summary> /// <param name="timeElapsed"></param> public virtual void FrameEnd(float timeElapsed) { mStrategy.FrameEnd(timeElapsed, this); ///copy to temporary array, to avoid exception Page[] temp = new Page[mPages.Count]; mPages.Values.CopyTo(temp, 0); for (int i = 0; i < temp.Length; i++) { if (!temp[i].IsHeld) UnloadPage(temp[i].PageID); else temp[i].FrameEnd(timeElapsed); } }
/// <summary> /// /// </summary> /// <param name="page"></param> /// <param name="sync"></param> public void UnloadPage(Page page, bool sync) { UnloadPage(page.PageID, sync); }
public virtual void LoadPage( PageID pageID, bool forceSynchronous ) { if ( !this.mParent.Manager.ArePagingOperationsEnabled ) { return; } if ( !this.mPages.ContainsKey( pageID ) ) { var page = new Page( pageID, this ); page.Load( forceSynchronous ); this.mPages.Add( pageID, page ); } else { this.mPages[ pageID ].Touch(); } }
public override bool UnPrepareProcedualPage( Page page, PagedWorldSection section ) { return true; }
internal virtual void NotifyAttached( Page page ) { this.mParent = page; }
public PageRequest( Page p ) { this.srcPage = p; }
internal bool UnloadProcedualPage( Page page, PagedWorldSection section ) { bool generated = false; if ( this.mPageProvider != null ) { generated = this.mPageProvider.UnloadProcedualPage( page, section ); } return generated; }
public abstract void UpdateDebugDisplay( Page p, SceneNode sn );
/// <summary> /// /// </summary> /// <param name="page"></param> /// <param name="section"></param> /// <returns></returns> public bool UnloadProcedualPage(Page page, PagedWorldSection section) { bool generated = false; if (mPageProvider != null) generated = mPageProvider.UnloadProcedualPage(page, section); return generated; }
/// <summary> /// Cancel any pending operations for a Page. /// </summary> /// <param name="page"></param> public void CancelOperationsForPage(Page page) { // cancel background { #warning TODO: lock background queue Request[] queue = mBackgroundQueue.ToArray(); foreach (Request r in queue) { if (r.Page == page) { mBackgroundQueue.Remove(r); } } } //cancel render { #warning TODO: render background queue Request[] queue = mRenderQueue.ToArray(); foreach (Request r in queue) { if (r.Page == page) { mRenderQueue.Remove(r); } } } }
public void UnloadPage( Page page ) { UnloadPage( page.PageID, false ); }
public Request(RequestType rt, Page p, PagedWorldSection s) { RequestType = rt; Page = p; Section = s; }
public virtual bool UnloadProcedualPage( Page page ) { bool generated = false; if ( this.mPageProvider != null ) { generated = this.mPageProvider.UnloadProcedualPage( page, this ); } if ( !generated ) { generated = this.mParent.UnloadProcedualPage( page, this ); } return generated; }
/// <summary> /// /// </summary> /// <param name="page"></param> /// <param name="section"></param> /// <returns></returns> public virtual bool UnPrepareProcedualPage(Page page, PagedWorldSection section) { bool generated = false; if (mPageProvider != null) generated = mPageProvider.UnPrepareProcedualPage(page, section); if (!generated) generated = mManger.UnPrepareProcedualPage(page, section); return generated; }
/// <summary> /// Give a provider the opportunity to load page content procedurally. /// </summary> /// <param name="page"></param> /// <param name="section"></param> /// <returns></returns> public virtual bool LoadProcedualPage(Page page, PagedWorldSection section) { return false; }
/// <summary> /// Ask for a page to be loaded with the given (section-relative) PageID /// </summary> /// <param name="pageID">The page ID to load</param> /// <param name="forceSynchronous">If true, the page will always be loaded synchronously</param> public virtual void LoadPage(PageID pageID, bool forceSynchronous) { Page page; if (!mPages.TryGetValue(pageID, out page)) { page = new Page(pageID); // attach page immediately, but notice that it's not loaded yet AttachPage(page); Manager.Queue.LoadPage(page, this, forceSynchronous); } else page.Touch(); }
/// <summary> /// Give a provider the opportunity to unprepare page content procedurally. /// </summary> /// <param name="page"></param> /// <param name="section"></param> /// <returns></returns> public bool UnPrepareProcedualPage(Page page, PagedWorldSection section) { return false; }
/// <summary> /// Give a section the opportunity to unprepare page content procedurally. /// </summary> /// <remarks> /// This method indicates that a page should be retained if it's already /// in memory, but if it's not then it won't trigger a load. This is useful /// for retaining pages that have just gone out of range, but which you /// don't want to unload just yet because it's quite possible they may come /// back into the active set again very quickly / easily. But at the same /// time, if they've already been purged you don't want to force them to load. /// This is the 'maybe' region of pages. /// </remarks> /// <param name="page"></param> /// <returns></returns> public virtual bool UnprepareProcedualPage(Page page) { bool generated = false; if (mPageProvider != null) generated = mPageProvider.UnPrepareProcedualPage(page, this); if (!generated) generated = mParent.UnPrepareProcedualPage(page, this); return generated; }
/// <summary> /// Load a Page, for a given PagedWorldSection. /// </summary> /// <param name="page"></param> /// <param name="section"></param> public void LoadPage(Page page, PagedWorldSection section) { LoadPage(page, section, false); }
/// <summary> /// Detach a page to this section. /// </summary> /// <param name="page"></param> public virtual void DetachPage(Page page) { Page pageFound; if (mPages.TryGetValue(page.PageID, out pageFound)) { if (page != pageFound) { mPages.Remove(pageFound.PageID); page.NotifyAttached(null); } } }
internal virtual bool UnPrepareProcedualPage( Page page, PagedWorldSection section ) { bool generated = false; if ( this.mPageProvider != null ) { generated = this.mPageProvider.UnPrepareProcedualPage( page, section ); } if ( !generated ) { generated = this.mManager.UnPrepareProcedualPage( page, section ); } return generated; }