public class ZoneManager
extends java.lang.Object
Object updates need to be done in the context of a 'frame' so that the updates can be properly grouped together. To do this, the game code that is reporting updates needs to call the ZoneManager methods using a specific life cycle:
Modifier and Type | Class and Description |
---|---|
protected class |
ZoneManager.DynamicZoneRange |
protected class |
ZoneManager.OctZoneRange
The original ZoneRange implementation that maxed out
at 8 zones, ie: 2x2x2.
|
protected static interface |
ZoneManager.ZoneRange |
Constructor and Description |
---|
ZoneManager(int zoneSize)
Creates a new ZoneManager with a ZoneGrid sized using zoneSize and
with a history backlog of 12 frames.
|
ZoneManager(ZoneGrid grid)
Creates a new ZoneManager with the specified grid representation and
with a history backlog of 12.
|
ZoneManager(ZoneGrid grid,
int historyBacklog)
Creates a new zone manager with the specified grid representation and
history backlog.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Long id)
Let's the zone manager know about a particular entity.
|
void |
beginUpdate(long time)
Starts history collection for a frame at the specified time.
|
void |
endUpdate()
Called to end update collection for the current 'frame'.
|
protected void |
enterZone(java.lang.Long id,
ZoneKey key) |
boolean |
getCollectHistory()
Returns true if the ZoneManager is currently collecting history, false otherwise.
|
int |
getFrameOverflowLimit() |
int |
getFrameUnderflowLimit() |
ZoneGrid |
getGrid()
Returns the current zone specification used for partioning space into
zones.
|
boolean |
getSupportLargeObjects() |
protected Zone |
getZone(ZoneKey key,
boolean create) |
protected ZoneManager.ZoneRange |
getZoneRange(java.lang.Long id,
boolean create) |
protected void |
leaveZone(java.lang.Long id,
ZoneKey key) |
static void |
main(java.lang.String... args) |
protected void |
objectWarped(java.lang.Long parent,
java.lang.Long id,
ZoneKey key) |
StateFrame[] |
purgeState()
Called by a state collection process to return all of the history that
has been collected since the last call to purgeState().
|
void |
remove(java.lang.Long id)
Removes the entity from the zone manager.
|
void |
setCollectHistory(boolean b)
Set to true if history should be collected or false if object updates
should be ignored.
|
void |
setFrameOverflowLimit(int frameOverflowLimit)
Sets frame overflow limit.
|
void |
setFrameRateLimits(int frameUnderflowLimit,
int frameOverflowLimit)
Sets frame update limits which are used to print warnings when ZoneManager update rate
goes under or over the specified value.
|
void |
setFrameUnderflowLimit(int frameUnderflowLimit)
Sets frame underflow limit.
|
void |
setSupportLargeObjects(boolean b)
Set to true to support objects that are larger than the grid spacing.
|
void |
updateEntity(java.lang.Long id,
boolean active,
com.simsilica.mathd.Vec3d p,
com.simsilica.mathd.Quatd orientation,
com.simsilica.mathd.AaBBox bounds)
Updates an entity's position in the zone space.
|
void |
updateEntity(java.lang.Long parent,
java.lang.Long child,
boolean active,
com.simsilica.mathd.Vec3d p,
com.simsilica.mathd.Quatd orientation,
com.simsilica.mathd.AaBBox bounds) |
protected void |
updateZoneObject(java.lang.Long parent,
java.lang.Long id,
com.simsilica.mathd.Vec3d p,
com.simsilica.mathd.Quatd orientation,
ZoneKey key)
Sends the object update to the specified zone.
|
public ZoneManager(int zoneSize)
public ZoneManager(ZoneGrid grid)
public ZoneManager(ZoneGrid grid, int historyBacklog)
grid
- The grid settings used for zone partitioning.historyBacklog
- Designates how many frames of history to keep
in each zone.public ZoneGrid getGrid()
public void setSupportLargeObjects(boolean b)
public boolean getSupportLargeObjects()
public void setCollectHistory(boolean b)
public boolean getCollectHistory()
public void setFrameRateLimits(int frameUnderflowLimit, int frameOverflowLimit)
java.lang.IllegalArgumentException
- if values are negative or underflow limit is larger than the overflow limit.public void setFrameUnderflowLimit(int frameUnderflowLimit)
java.lang.IllegalArgumentException
- if value is negative or larger than the overflow limit.public int getFrameUnderflowLimit()
public void setFrameOverflowLimit(int frameOverflowLimit)
java.lang.IllegalArgumentException
- if value is negative or less than the underflow limit.public int getFrameOverflowLimit()
protected ZoneManager.ZoneRange getZoneRange(java.lang.Long id, boolean create)
public void beginUpdate(long time)
public void updateEntity(java.lang.Long id, boolean active, com.simsilica.mathd.Vec3d p, com.simsilica.mathd.Quatd orientation, com.simsilica.mathd.AaBBox bounds)
id
- The ID of the object that has been moved.active
- Currently unused. Pass 'true' or the non-sleeping state of your object
if you care to be accurate for future changes.p
- The position of the object in world space.orientation
- The orientation of the object in world space.bounds
- The 3D bounds of the object in WORLD SPACE. This is why it's passed
every update and it allows it to change to be accurate as the object rotates and
so on. But more importantly, it pushes the updating of the bounds to the thing
actually controlling the position which might be able to more efficiently update
it than we could internally.public void updateEntity(java.lang.Long parent, java.lang.Long child, boolean active, com.simsilica.mathd.Vec3d p, com.simsilica.mathd.Quatd orientation, com.simsilica.mathd.AaBBox bounds)
public void endUpdate()
public StateFrame[] purgeState()
public void add(java.lang.Long id)
public void remove(java.lang.Long id)
protected void updateZoneObject(java.lang.Long parent, java.lang.Long id, com.simsilica.mathd.Vec3d p, com.simsilica.mathd.Quatd orientation, ZoneKey key)
protected void objectWarped(java.lang.Long parent, java.lang.Long id, ZoneKey key)
protected void enterZone(java.lang.Long id, ZoneKey key)
protected void leaveZone(java.lang.Long id, ZoneKey key)
public static void main(java.lang.String... args)