SceneZoneSpace

Engine/source/scene/zones/sceneZoneSpace.h

Abstract base class for an object that manages zones in a scene.

More...

Classes:

class

Link to another zone space.

Occluders

Zone spaces keep track of the occluders that get added to them so that during traversal, they can be taken on board as early as possible.

This allows traversals themselves to take occlusion into account.

Add the given object to the list of occluders in this zone space.

Remove the given object from the list of occluders in this zone space.

Register the occluders in this zone with the given culling state.

Occluders in this space.

Zone Space Connectivity

Disconnect all zone spaces currently connected to this space.

Hand the traversal over to connected zone spaces.

bool

Return true if the given zone space, which has crossed into this space, should be automatically connected.

List of zone spaces that this space is connected to.

Allocator for ZoneSpaceRefs.

SceneManager Notifications

These methods are called when SceneManager assigns or removes objects to/from our zones.

_onZoneAddObject(SceneObject * object, const U32 * zoneIDs, U32 numZones)

Called by the SceneManager when an object is added to one or more zones that are managed by this object.

Called by the SceneManager when an object that was previously added to one or more zones managed by this object is now removed.

Containment Tests

bool
getOverlappingZones(const Box3F & aabb, U32 * zones, U32 & numZones)
bool
getOverlappingZones(SceneObject * obj, U32 * outZones, U32 & outNumZones)

Find the zones in this object that obj is part of.

Returns the ID of the zone that are managed by this object that contains p.

Connectivity

Connect this zone space to the given zone space.

If the object is a zone space, then this method is called to instruct the object to remove any zone connectivity to zoneSpace.

Traversals

Traverse into the zones of this space.

traverseZones(SceneTraversalState * state, U32 startZoneId)

Traverse the zones in this space starting with the given zone.

Public Types

enum
_Anonymous_ {  InvalidZoneGroup = 0
}
enum
ZoneFlags {  ZoneFlag_IsClosedOffSpace = BIT( 0 )
}
Parent 

Protected Types

enum
_Anonymous_ {
  ZoneGroupMask = Parent::NextFreeMask << 0
  NextFreeMask = Parent::NextFreeMask << 1
}

Public Friends

Protected Attributes

The manager to which this zone space is registered.

Number of zones managed by #obj.

Group which the zone is assigned to.

ID of first zone defined by object.

Protected Functions

Called when this is removed from its current SceneManager.

Public Functions

dumpZoneState(bool update)

Dump a listing of all objects assigned to this zone space to the console as well as a list of all connected spaces.

bool

Get the ambient light color of the given zone in this space or return false if the given zone does not have an ambient light color assigned to it.

Return the zone group that this zone space belongs to.

Return the number of zones that are managed by this object.

Gets the index of the first zone this object manages in the collection of zones or 0xFFFFFFFF if the object is not managing zones.

bool

Return true if this is the outdoor zone.

packUpdate(NetConnection * conn, U32 mask, BitStream * stream)

Instructs this object to pack its state for transfer over the network.

Set the zone group of this zone space.

Instructs this object to read state data previously packed with packUpdate.

bool
writeField(StringTableEntry fieldname, const char * value)

Determine whether or not a field should be written.

Public Static Functions

Private Static Functions

bool
_setZoneGroup(void * object, const char * index, const char * data)

Detailed Description

Abstract base class for an object that manages zones in a scene.

This class adds the ability to SceneSpace to define and manage zones within the object's space. Zones are used to determine visibility in a scene.

Each zone space manages one or more zones in a scene. All the zones must be within the AABB of the zone space but within that AABB, the zone space is free to distribute and manage zones in arbitrary fashion.

For scene traversal, zone spaces are interconnected. By default, zone spaces get a chance to connect to each other when being moved into each other's zones. An exception to this is the root zone since it is both immobile and without position and (limited) extents. If a zone space wants to connect to the root zone, it must do so manually (same goes for disconnecting).

Occluders

Zone spaces keep track of the occluders that get added to them so that during traversal, they can be taken on board as early as possible.

This allows traversals themselves to take occlusion into account.

_addOccluder(SceneObject * object)

Add the given object to the list of occluders in this zone space.

_removeOccluder(SceneObject * object)

Remove the given object from the list of occluders in this zone space.

_addOccludersToCullingState(SceneCullingState * state)

Register the occluders in this zone with the given culling state.

Vector< SceneObject * > mOccluders 

Occluders in this space.

Every object that is assigned to this space and has the OccluderObjectType flag set, is added to this list.

Zone Space Connectivity

_disconnectAllZoneSpaces()

Disconnect all zone spaces currently connected to this space.

Reimplemented by: Portal

_traverseConnectedZoneSpaces(SceneTraversalState * state)

Hand the traversal over to connected zone spaces.

Reimplemented by: Portal

_automaticallyConnectZoneSpace(SceneZoneSpace * zoneSpace)

Return true if the given zone space, which has crossed into this space, should be automatically connected.

Note that event

ZoneSpaceRef * mConnectedZoneSpaces 

List of zone spaces that this space is connected to.

This is used for traversals.

ClassChunker< ZoneSpaceRef > smZoneSpaceRefChunker 

Allocator for ZoneSpaceRefs.

SceneManager Notifications

These methods are called when SceneManager assigns or removes objects to/from our zones.

_onZoneAddObject(SceneObject * object, const U32 * zoneIDs, U32 numZones)

Called by the SceneManager when an object is added to one or more zones that are managed by this object.

_onZoneRemoveObject(SceneObject * object)

Called by the SceneManager when an object that was previously added to one or more zones managed by this object is now removed.

Containment Tests

getOverlappingZones(const Box3F & aabb, U32 * zones, U32 & numZones)

Reimplemented by: ScenePolyhedralZone, SceneRootZone, SceneSimpleZone

getOverlappingZones(SceneObject * obj, U32 * outZones, U32 & outNumZones)

Find the zones in this object that obj is part of.

Parameters:

obj

Object in question.

outZones

Indices of zones containing the object. Must have at least as many entries as there as zones in this object or SceneObject::MaxObjectZones, whichever is smaller. Note that implementations should never write more than SceneObject::MaxObjectZones entries.

outNumZones

Number of elements in the returned array.

return:

Return true if the world box of obj is fully contained within the zones of this object or false if it is at least partially outside of them.

getPointZone(const Point3F & p)

Returns the ID of the zone that are managed by this object that contains p.

Parameters:

p

Point to test.

return:

ID of the zone containing p or InvalidZoneId if none of the zones defined by this object contain the point.

Reimplemented by: SceneSimpleZone

Connectivity

connectZoneSpace(SceneZoneSpace * zoneSpace)

Connect this zone space to the given zone space.

Parameters:

zoneSpace

A zone space.

note:

Connectivity is reset when a zone space is moved!

Reimplemented by: Portal

disconnectZoneSpace(SceneZoneSpace * zoneSpace)

If the object is a zone space, then this method is called to instruct the object to remove any zone connectivity to zoneSpace.

Parameters:

zoneSpace

A zone space which had previously been passed to connectZoneSpace().

Reimplemented by: Portal

Traversals

traverseZones(SceneTraversalState * state)

Traverse into the zones of this space.

Set the render states of those zones and add the frustums that lead into them.

The traversal stack is expected to not be empty and the topmost entry on the stack should be the zone of another manager from which traversal is handed over to this manager.

Parameters:

state

Scene traversal state.

note:

If the zone's of a zone space are reached via different traversal paths, this method will be called multiple times on the same space.

Reimplemented by: SceneSimpleZone

traverseZones(SceneTraversalState * state, U32 startZoneId)

Traverse the zones in this space starting with the given zone.

Where appropriate, traversal should be handed off to connected spaces.

Parameters:

state

State which should be updated by the traversal.

startZoneId

ID of zone in this manager in which to start traversal.

Reimplemented by: SceneSimpleZone, Portal

Public Types

@161

Enumerator

InvalidZoneGroup = 0
ZoneFlags

Enumerator

ZoneFlag_IsClosedOffSpace = BIT( 0 )

Whether this zoning space is "closed off" or not.

When connections between zoning spaces are established, by default only spaces that are closed off are connected to those that are not and vice versa. This defines a natural progression where spaces that explicitly want to propagate traversals are connected to those that want to contain it.

This flag is set by default.

typedef SceneSpace Parent 

Protected Types

@162

Enumerator

ZoneGroupMask = Parent::NextFreeMask << 0
NextFreeMask = Parent::NextFreeMask << 1

Public Friends

Protected Attributes

SceneZoneSpaceManager * mManager 

The manager to which this zone space is registered.

U32 mNumZones 

Number of zones managed by #obj.

IDs are consecutive starting with mZoneRangeStart.

BitSet32 mZoneFlags 
U32 mZoneGroup 

Group which the zone is assigned to.

Zone spaces that would normally not connect do connect if they are assigned the same zone group. O to disable (default).

U32 mZoneRangeStart 

ID of first zone defined by object.

Protected Functions

onSceneRemove()

Reimplemented from: SceneObject

Reimplemented by: SceneRootZone, Portal

Public Functions

SceneZoneSpace()

~SceneZoneSpace()

dumpZoneState(bool update)

Dump a listing of all objects assigned to this zone space to the console as well as a list of all connected spaces.

Parameters:

update

Whether to update the zone contents before dumping. Since the zoning states of SceneObjects are updated lazily, the contents of a zone can be outdated.

getZoneAmbientLightColor(U32 zone, LinearColorF & outColor)

Get the ambient light color of the given zone in this space or return false if the given zone does not have an ambient light color assigned to it.

Reimplemented by: SceneSimpleZone

getZoneGroup()

Return the zone group that this zone space belongs to.

0 by default which means the zone space is not allocated to a specific zone group.

getZoneRange()

Return the number of zones that are managed by this object.

getZoneRangeStart()

Gets the index of the first zone this object manages in the collection of zones or 0xFFFFFFFF if the object is not managing zones.

isRootZone()

Return true if this is the outdoor zone.

packUpdate(NetConnection * conn, U32 mask, BitStream * stream)

Reimplemented from: SceneSpace

Reimplemented by: SceneSimpleZone, Portal, SceneAmbientSoundObject, ScenePolyhedralObject

setZoneGroup(U32 group)

Set the zone group of this zone space.

Zone spaces in the same group will connect even if not connecting by default. Set to 0 to deactivate.

unpackUpdate(NetConnection * conn, BitStream * stream)

Reimplemented from: SceneSpace

Reimplemented by: SceneSimpleZone, Portal, SceneAmbientSoundObject, ScenePolyhedralObject

writeField(StringTableEntry fieldname, const char * value)

Reimplemented from: SceneObject

Reimplemented by: Portal, ScenePolyhedralObject

Public Static Functions

initPersistFields()

Private Static Functions

_setZoneGroup(void * object, const char * index, const char * data)