Inheritance: PageLoadableUnit
Esempio n. 1
0
        /// <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
        }
Esempio n. 2
0
 /// <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);
 }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
		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 );
				}
			}
		}
Esempio n. 5
0
        /// <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);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="page"></param>
 /// <param name="sync"></param>
 public void UnloadPage(Page page, bool sync)
 {
     UnloadPage(page.PageID, sync);
 }
Esempio n. 7
0
		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();
			}
		}
Esempio n. 8
0
			public override bool UnPrepareProcedualPage( Page page, PagedWorldSection section ) { return true; }
		internal virtual void NotifyAttached( Page page )
		{
			this.mParent = page;
		}
Esempio n. 10
0
			public PageRequest( Page p )
			{
				this.srcPage = p;
			}
Esempio n. 11
0
		internal bool UnloadProcedualPage( Page page, PagedWorldSection section )
		{
			bool generated = false;
			if ( this.mPageProvider != null )
			{
				generated = this.mPageProvider.UnloadProcedualPage( page, section );
			}

			return generated;
		}
Esempio n. 12
0
		public abstract void UpdateDebugDisplay( Page p, SceneNode sn );
Esempio n. 13
0
        /// <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;
        }
Esempio n. 14
0
        /// <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);
                    }
                }
            }
        }
Esempio n. 15
0
		public void UnloadPage( Page page )
		{
			UnloadPage( page.PageID, false );
		}
Esempio n. 16
0
 public Request(RequestType rt, Page p, PagedWorldSection s)
 {
     RequestType = rt;
     Page = p;
     Section = s;
 }
Esempio n. 17
0
		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;
		}
Esempio n. 18
0
        /// <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;
        }
Esempio n. 19
0
 /// <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;
 }
Esempio n. 20
0
 /// <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();
 }
Esempio n. 21
0
 /// <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;
 }
Esempio n. 22
0
        /// <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;
        }
Esempio n. 23
0
 /// <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);
 }
Esempio n. 24
0
 /// <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);
         }
     }
 }
Esempio n. 25
0
		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;
		}