Class RenderStorage

  • All Implemented Interfaces:
    com.badlogic.gdx.ai.msg.Telegraph


    public class RenderStorage
    extends java.lang.Object
    implements com.badlogic.gdx.ai.msg.Telegraph
    A RenderStorage is container which saves RenderChunks used for chunks storing rendering-data. It manages which Chunks must be transformed to RenderChunks.
    • Constructor Detail

      • RenderStorage

        public RenderStorage​()
        Creates a new renderstorage.
    • Method Detail

      • refreshCell

        public RenderCell refreshCell​(Coordinate coord,
                                      byte id,
                                      byte value)
        creates a new RenderCell instance at the coordinate
        Parameters:
        coord -
        id -
        value -
        Returns:
        the instance or null if the process failed
      • preUpdate

        public void preUpdate​(float dt)
        Parameters:
        dt -
      • update

        public void update​(float dt)
        Parameters:
        dt -
      • setLightFlag

        public void setLightFlag​(Coordinate coord)
        Marks this block as "dirty".
        Parameters:
        coord -
      • bakeChunks

        public void bakeChunks​()
        Clears the the content of the used RenderChunks then after refilling them calculates the renderdata (shadows, AO, occlusion culling). Very heavy operation.
      • getChunk

        public RenderChunk getChunk​(Coordinate coord)
        get the chunk where the coordinates are on. Worst case O(n). Average case O(1).
        Parameters:
        coord - not altered
        Returns:
        can return null if not loaded
      • getChunk

        public RenderChunk getChunk​(int chunkX,
                                    int chunkY)
        Get the chunk with the given chunk coords from the active pool.
        Runtime: O(c) c: amount of chunks -> O(1)
        Parameters:
        chunkX -
        chunkY -
        Returns:
        if not in memory returns null
      • getCell

        public RenderCell getCell​(int x,
                                  int y,
                                  int z)
        Returns a block without checking the parameters first. Good for debugging and also faster. O(n)
        Parameters:
        x - coordinate
        y - coordinate
        z - coordinate
        Returns:
        the single block you wanted
      • getCell

        public RenderCell getCell​(Point point)
        If the block can not be found returns null pointer.
        Parameters:
        point - transform safe
        Returns:
      • occlusionCulling

        public void occlusionCulling​(RenderChunk chunk)
        performs a simple clipping check by looking at the direct neighbours. O(n) where n is blocks in chunk
        Parameters:
        chunk -
      • getData

        public java.util.LinkedList<RenderChunk> getData​()
        Returns:
      • addCamera

        public void addCamera​(Camera camera)
        avoids duplicates
        Parameters:
        camera -
      • isClipped

        public boolean isClipped​(Coordinate coords)
        get if a coordinate is clipped
        Parameters:
        coords -
        Returns:
      • getZRenderingLimit

        public float getZRenderingLimit​()
        renders to this layer not including
        Returns:
        coordinate
      • setZRenderingLimit

        public void setZRenderingLimit​(float height)
        renders to this layer not including
        Parameters:
        height - game space
      • handleMessage

        public boolean handleMessage​(com.badlogic.gdx.ai.msg.Telegram msg)
        Specified by:
        handleMessage in interface com.badlogic.gdx.ai.msg.Telegraph
      • dispose

        public void dispose​()