Class Pager<T>

  • All Implemented Interfaces:
    BlocksManagerListener
    Direct Known Subclasses:
    ChunkPager, PhysicsChunkPager

    public abstract class Pager<T>
    extends java.lang.Object
    implements BlocksManagerListener
    An abstract implementation of a 3D pager. Based on the given center location (#setLocation(Vector3f) the pages around this center page in the grid are calculated. Each call to update() will: - detach one page that is outside the grid, if available - attach one new page that is inside the grid, if available - update a page inside the grid, if one is available. Implementing classes need to implement the methods to create, attach and detach pages. The boundaries of the grid can be set by setting #setGridLowerBounds(Vec3i) and #setGridUpperBounds(Vec3i).
    • Constructor Summary

      Constructors 
      Constructor Description
      Pager()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void attachPage​(T page)
      Attach the page.
      void cleanup()  
      protected abstract T createPage​(Chunk chunk)
      Creates and returns the page based on the passed chunk.
      protected abstract void detachPage​(T page)
      Detach the page.
      protected java.util.Set<com.simsilica.mathd.Vec3i> getPages()
      Calculates and returns the pages (chunks) in the grid, based on the gridSize and centerPageLocation in the grid.
      void initialize()  
      void onChunkAvailable​(Chunk chunk)
      Called when the chunk is available and the node and collision mesh are created.
      void update()  
      protected void updateQueues()
      Updates the queues of the Pager.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • blocksManager

        @NonNull
        protected final @NonNull BlocksManager blocksManager
      • attachedPages

        protected final java.util.Map<com.simsilica.mathd.Vec3i,​T> attachedPages
      • pagesToAttach

        protected final java.util.Queue<com.simsilica.mathd.Vec3i> pagesToAttach
      • pagesToDetach

        protected final java.util.Queue<com.simsilica.mathd.Vec3i> pagesToDetach
      • updatedPages

        protected final java.util.Queue<com.simsilica.mathd.Vec3i> updatedPages
      • requestedPages

        protected final java.util.Set<com.simsilica.mathd.Vec3i> requestedPages
      • gridSize

        protected com.simsilica.mathd.Vec3i gridSize
      • centerPageLocation

        protected com.simsilica.mathd.Vec3i centerPageLocation
      • location

        protected com.jme3.math.Vector3f location
      • gridLowerBounds

        protected com.simsilica.mathd.Vec3i gridLowerBounds
      • gridUpperBounds

        protected com.simsilica.mathd.Vec3i gridUpperBounds
    • Constructor Detail

      • Pager

        public Pager()
    • Method Detail

      • initialize

        public void initialize()
      • update

        public void update()
      • cleanup

        public void cleanup()
      • getPages

        protected java.util.Set<com.simsilica.mathd.Vec3i> getPages()
        Calculates and returns the pages (chunks) in the grid, based on the gridSize and centerPageLocation in the grid.
        Returns:
        the set of pages in the grid
      • updateQueues

        protected void updateQueues()
        Updates the queues of the Pager. This should be called when the gridSize or centerPageLocation has changed.
      • createPage

        protected abstract T createPage​(Chunk chunk)
        Creates and returns the page based on the passed chunk.
        Parameters:
        chunk -
        Returns:
        page of the chunk or null
      • detachPage

        protected abstract void detachPage​(T page)
        Detach the page.
        Parameters:
        page - to detach
      • attachPage

        protected abstract void attachPage​(T page)
        Attach the page.
        Parameters:
        page - to attach