class RED::LayerSet

Use this class to build sets of layers. Layers are visibility masks that can be used to filter some parts of a scene from rendering. More...

#include <REDLayerSet.h>

Inherits: IChunkSaver and Object.

Public functions:

LayerSet ( )
~LayerSet ( )
RED_RCAddAllLayers ( )
RED_RCAddLayer ( unsigned int iLayer )
virtual const void *As ( const RED::CID & iCID ) const
template< class T_As > const T_As *As ( ) const
virtual void *As ( const RED::CID & iCID )
template< class T_As > T_As *As ( )
voidClearLayers ( )
RED_RCGetLayers ( RED::Vector< unsigned int > & oLayers ) const
RED::uint64GetMemorySize ( ) const
IMPLEMENT_CHUNKINTERPRETER ( )
boolIntersects ( const RED::LayerSet & iOther ) const
boolIsAllLayers ( ) const
boolIsEmpty ( ) const
booloperator< ( const RED::LayerSet & iOther ) const
RED_RCoperator= ( const RED::LayerSet & iSrc )
booloperator== ( const RED::LayerSet & iOther ) const
booloperator> ( const RED::LayerSet & iOther ) const
voidRemoveLayer ( unsigned int iLayer )
virtual RED_RCSave ( RED::IStream * iStream, StreamingPolicy & iPolicy, int iState = -1 ) const

Public static functions:

static RED::CIDGetClassID ( )

Public static variables:

static const RED::LayerSetALL_LAYERS

Protected functions:

LayerSet ( int iSize )

Protected variables:

RED::Vector< unsigned int >_layermask
int_size

Detailed description:

Use this class to build sets of layers. Layers are visibility masks that can be used to filter some parts of a scene from rendering.

A RED::LayerSet is a mask of bits. Each bit corresponds to a layer. During the rendering of a scene, the engine checks the layer set that is set on each rendered viewpoint, and based on this value and on the layer set values of the scene geometries and transforms, filtering may occur for the rendering.

Layer sets are inherited in a DAG in the same way materials are inherited: The last layer found on the path to access a shape instance is the layer set for that shape instance.

For RED::IShape instances, a shape is discarded from the rendering whenever its own layer set does not match any valid layer bit set in the viewpoint's layer set. Children are also discarded but if they overload their ancestor's layer set.

For RED::IMaterial instances, rules differ. A material is defined per layer configuration. A material always have a RED::LayerSet::ALL_LAYERS rendering configuration and may have alternative rendering configurations defined. These configurations are selected during the rendering only if the rendered viewpoint layer set exactly matches one of them, which differs from the shape's rule. Note that the RED::OPTIONS_MATERIAL_LAYER_INTERSECT may affect this behavior.

RED::LayerSet objects are also used by lights for the selection of light receivers, shadow casting geometries and shadow receiving geometries.

Functions documentation

LayerSet construction method.

The created layers set is empty.

LayerSet destruction method.

Internal construction method.

Parameters:

iSize:Initial size. Used to setup ALL_LAYERS.

Adds all known layers in the cluster explicitly to the mask.

This method generates a layerset whose contents are set to the explicit list of layers that are known to exist inside the cluster at the time of the call.

The value of a layerset setup using this method is NOT identical to RED::LayerSet::ALL_LAYERS. If a new layer is created after this call, then the layerset won't contain it whereas RED::LayerSet::ALL_LAYERS is always containing all layers. After a call to this method, it's possible to use the RED::LayerSet::RemoveLayer method, as we contain the list of all existing layers in our mask.

Returns:

RED_OK if the method has succeeded,
RED_ALLOC_FAILURE if an internal allocation has failed.
public RED_RC RED::LayerSet::AddLayer(unsigned intiLayer)

Adds a layer to the set.

Adding a layer to a RED::LayerSet whose value is ALL_LAYERS has no effect. Adding a layer to a layer set is an operation that can cause a memory allocation and therefore, there's a multi-threading securization mutex that takes place during the operation, so this may cost a bit of time, specially if several threads create layersets in parallel.

Parameters:

iLayer:Index of the layer to add.

Returns:

RED_OK when the layer could be added,
RED_ALLOC_FAILURE if an internal allocation has failed.
public virtual const void * RED::LayerSet::As(const RED::CID &iCID) const

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::Object::As.

template< class T_As > public const T_As * RED::LayerSet::As() const

Template version of the as const method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to a const instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

public virtual void * RED::LayerSet::As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::Object::As.

template< class T_As > public T_As * RED::LayerSet::As()

Template version of the as method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to an instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

Clears all layers from the layer set.

public RED_RC RED::LayerSet::GetLayers(RED::Vector< unsigned int > &oLayers) const

Gets the IDs of the layers in the set.

Parameters:

oLayers:Reference to the returned list of layers.

Returns:

RED_OK on success,
RED_FAIL otherwise.

Gets the memory size used by the class.

Returns:

The byte size consumed by this class.
public bool RED::LayerSet::Intersects(const RED::LayerSet &iOther) const

Layer inclusion test.

Layer interference tests are:

  • If this is empty, then it does not interfere with iOther.
  • If this is RED::LayerSet::ALL_LAYERS:
    • if iOther is empty, then intersection does not exist.
    • Otherwise intersection exists.
  • For all other cases, the intersection exists if iOther has at least one layer bit that matches a layer bit in this.

Returns:

true if iOther has at least one layer that matches a layer bit in this, false otherwise.
public bool RED::LayerSet::IsAllLayers() const

Tests whether the layerset is set to ALL_LAYERS or not.

Returns:

true if this is equal to ALL_LAYERS, false otherwise.
public bool RED::LayerSet::IsEmpty() const

Gets the fill state of the layer set.

Returns:

true if the layers set is empty, false otherwise.
public bool RED::LayerSet::operator<(const RED::LayerSet &iOther) const

Sorting operator.

Parameters:

iOther:reference to another RED::LayerSet.

Returns:

true if this precedes iOther, false otherwise.

Assignment operator.

Parameters:

iSrc:Source of our contents.

Returns:

RED_OK when the operation succeeded,
RED_ALLOC_FAILURE otherwise.
public bool RED::LayerSet::operator==(const RED::LayerSet &iOther) const

Equality test operator.

Returns:

true if the two RED::LayerSet are equals, false otherwise.
public bool RED::LayerSet::operator>(const RED::LayerSet &iOther) const

Sorting operator.

Parameters:

iOther:reference to another RED::LayerSet.

Returns:

true if iOther precedes this, false otherwise.
public void RED::LayerSet::RemoveLayer(unsigned intiLayer)

Removes a layer from the set.

Removing a layer from a layer whose value is RED::LayerSet::ALL_LAYERS is ignored.

Parameters:

iLayer:Index of the layer to remove.
public virtual RED_RC RED::LayerSet::Save(RED::IStream *iStream,
StreamingPolicy &iPolicy,
intiState = -1
)const

Saves the object content as one or more chunks in the given stream.

Parameters:

iStream:Pointer to the stream where the data must be saved.
iPolicy:Reference to the streaming policy to be used.
iState:Optional state number parameter at which the data to be saved must be retrieved. Default is set to 0 (for current state).

Returns:

RED_OK on success,
RED_FILE_WRITE_ERROR on a file write error (if iStream is a file stream),
RED_ALLOC_FAILURE on a memory allocation error,
RED_FAIL otherwise.

Implements: RED::IChunkSaver::Save.

Variables documentation

Built-in layer set: include every layer.

Layer bits field. Each bit corresponds to a layer: if set to 1 the shape belongs to the layer, if set to 0 it does not.

Number of layers into the set: -1: ALL_LAYERS. >= 0: Number of layer bits in the layerset.