LayerSet
Fields
const LayerSet |
Functions
|
|
void |
|
void |
|
bool |
|
bool |
|
bool |
|
bool |
|
RED::uint64 |
|
bool |
|
bool |
Detailed Description
-
class LayerSet : public RED::Object, public RED::IChunkSaver
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.
@related Material Layersets, function RED::IShape::ApplyLayerSet, function RED::IViewpoint::ApplyLayerSet, class RED::IMaterial
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.
Public Functions
- SET_CID (CID_class_REDLayerSet) IMPLEMENT_AS()
-
IMPLEMENT_CHUNKINTERPRETER()
-
RED_RC operator=(const RED::LayerSet &iSrc)
Assignment operator.
- Parameters
iSrc – Source of our contents.
- Returns
RED_OK when the operation succeeded,
RED_ALLOC_FAILURE otherwise.
-
RED_RC AddLayer(unsigned int iLayer)
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.
-
RED_RC AddAllLayers()
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.
-
void RemoveLayer(unsigned int iLayer)
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.
-
inline void ClearLayers()
Clears all layers from the layer set.
-
inline bool 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.
-
inline bool operator==(const RED::LayerSet &iOther) const
Equality test operator.
- Returns
true if the two RED::LayerSet are equals, false otherwise.
-
inline bool IsEmpty() const
Gets the fill state of the layer set.
- Returns
true if the layers set is empty, false otherwise.
-
inline bool IsAllLayers() const
Tests whether the layerset is set to ALL_LAYERS or not.
- Returns
true if ‘this’ is equal to ALL_LAYERS, false otherwise.
-
RED_RC 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.
-
RED::uint64 GetMemorySize() const
Gets the memory size used by the class.
- Returns
The byte size consumed by this class.
-
virtual RED_RC Save(RED::IStream *iStream, StreamingPolicy &iPolicy, int iState = -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.
-
inline bool operator<(const RED::LayerSet &iOther) const
Sorting operator.
- Parameters
iOther – reference to another RED::LayerSet.
- Returns
true if ‘this’ precedes iOther, false otherwise.
-
inline bool operator>(const RED::LayerSet &iOther) const
Sorting operator.
- Parameters
iOther – reference to another RED::LayerSet.
- Returns
true if iOther precedes ‘this’, false otherwise.