Class Pager<T>

  • Direct Known Subclasses:
    ChunkPager, PhysicsChunkPager

    public abstract class Pager<T>
    extends java.lang.Object
    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).
    • Field Detail

      • chunkManager

        @NonNull
        protected final @NonNull ChunkManager chunkManager
      • 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
      • centerPage

        protected com.simsilica.mathd.Vec3i centerPage
      • location

        protected com.jme3.math.Vector3f location
      • gridLowerBounds

        protected com.simsilica.mathd.Vec3i gridLowerBounds
      • gridUpperBounds

        protected com.simsilica.mathd.Vec3i gridUpperBounds
      • pagerListeners

        protected java.util.List<PagerListener<T>> pagerListeners
    • Constructor Detail

      • Pager

        public Pager()
    • Method Detail

      • initialize

        public void initialize()
      • update

        public void update()
      • cleanup

        public void cleanup()
      • addListener

        public void addListener​(@NonNull
                                @NonNull PagerListener<T> listener)
      • removeListener

        public void removeListener​(@NonNull
                                   @NonNull PagerListener<T> listener)
      • 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