Stream Set

StreamSets are a container holding 1 or more Streams, and potentially some binding logic to tie streams together. At their core they function like a hashtable containing streams referenced by the StreamKey which is a name and buffer usage type (Vertex, Index). This is the most common way to pass data around, and can be used to store arbitrarily complex sets of data.


Creating a basic stream set
// First we create the empty stream set
FRealtimeMeshStreamSet StreamSet;

// Then we can add whatever streams to it we want
FRealtimeMeshStream& PositionStream = StreamSet.AddStream<FVector3f>(FRealtimeMeshStreams::Position);
FRealtimeMeshStream& TangentsStream = StreamSet.AddStream<FRealtimeMeshTangentsNormalPrecision>(FRealtimeMeshStreams::Tangents);

// We can choose to add the streams to a link pool if we want to
StreamSet.AddStreamToLinkPool("Vertices", FRealtimeMeshStreams::Position, FRealtimeMeshStreamDefaultRowValue::Create(FVector3f::ZeroVector));
StreamSet.AddStreamToLinkPool("Vertices", FRealtimeMeshStreams::Tangents, FRealtimeMeshStreamDefaultRowValue::Create(
    FRealtimeMeshTangentsNormalPrecision(FVector3f::ZAxisVector, FVector3f::XAxisVector),
    TangentsStream.GetLayout()));

// Then we can bind the stream builds to the contained streams like a individual stream
TRealtimeMeshStreamBuilder<FVector3f> PositionStreamBuilder(StreamSet.FindChecked(FRealtimeMeshStreams::Position));

Copying stream sets

Stream Sets by default don’t allow simple copy through assignment. This is because this can be a heavy operation to copy all the stream data. If you actually want to copy a stream you should use the explicit copy constructor

// Use the explicit copy constructor as implicit copy and assignment are disallowed for performance reasons.
FRealtimeMeshStreamSet StreamSet2(StreamSet);

You can move to stream set around from one storage to another. This is far more efficient as it doesn’t duplicate the internal data but instead moves it from one owner to the next. This will reset the source streamset in the process

// Move assignment is fast because it does not duplicate the data and instead moves the ownership of it.
FRealtimeMeshStreamSet StreamSet2 = MoveTemp(StreamSet);