Class RenderStorage
- java.lang.Object
-
- com.bombinggames.wurfelengine.core.map.rendering.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 savesRenderChunk
s used for chunks storing rendering-data. It manages whichChunk
s must be transformed toRenderChunk
s.
-
-
Constructor Summary
Constructors Constructor Description RenderStorage()
Creates a new renderstorage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCamera(Camera camera)
avoids duplicatesvoid
bakeChunks()
Clears the the content of the usedRenderChunk
s then after refilling them calculates the renderdata (shadows, AO, occlusion culling).void
dispose()
RenderCell
getCell(int x, int y, int z)
Returns a block without checking the parameters first.RenderCell
getCell(Coordinate coord)
If the cell can not be found returnsRenderChunk.CELLOUTSIDE
.RenderCell
getCell(Point point)
If the block can not be found returns null pointer.RenderChunk
getChunk(int chunkX, int chunkY)
Get the chunk with the given chunk coords from the active pool.RenderChunk
getChunk(Coordinate coord)
get the chunk where the coordinates are on.java.util.LinkedList<RenderChunk>
getData()
float
getZRenderingLimit()
renders to this layer not includingboolean
handleMessage(com.badlogic.gdx.ai.msg.Telegram msg)
boolean
isClipped(Coordinate coords)
get if a coordinate is clippedvoid
occlusionCulling(RenderChunk chunk)
performs a simple clipping check by looking at the direct neighbours.void
preUpdate(float dt)
RenderCell
refreshCell(Coordinate coord, byte id, byte value)
creates a newRenderCell
instance at the coordinatevoid
setLightFlag(Coordinate coord)
Marks this block as "dirty".void
setZRenderingLimit(float height)
renders to this layer not includingvoid
update(float dt)
-
-
-
Method Detail
-
refreshCell
public RenderCell refreshCell(Coordinate coord, byte id, byte value)
creates a newRenderCell
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 usedRenderChunk
s 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
- coordinatey
- coordinatez
- coordinate- Returns:
- the single block you wanted
-
getCell
public RenderCell getCell(Coordinate coord)
If the cell can not be found returnsRenderChunk.CELLOUTSIDE
.- Parameters:
coord
- transform safe- Returns:
-
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 interfacecom.badlogic.gdx.ai.msg.Telegraph
-
dispose
public void dispose()
-
-