Create a dynamic list of structs or BaseContainers
-
I need to create a dynamic list of data that will be populated with a variable number of elements, in the InitRender method of a shader.
I need to store a few Float values, an Int32 and a Matrix, so, I can use a struct of a BaseContainer.
Maybe the BaseContainer is the best method as I can add to the BaseContainer another BaseContainer, creating a hierarchy that I can travel through, starting with the parent Container.
What do you guys think? Am I thinking correctly? -
Why not just use a BaseArray of the data structures you want to use? Re-initialise this every time InitRender is called then you can iterate through it when needed (presumably in the Output function?).
You’ll also need to implement CopyTo() to make sure the data is available when rendering to the picture viewer.
Steve
-
@spedler said in Create a dynamic list of structs or BaseContainers:
Why not just use a BaseArray of the data structures you want to use? Re-initialise this every time InitRender is called then you can iterate through it when needed (presumably in the Output function?).
You’ll also need to implement CopyTo() to make sure the data is available when rendering to the picture viewer.
Steve
That could be a good option but I need a list to different types of values. I could create an array of structs but I believe the BaseContainer already has everything I need.
If I create the BaseContainer as a public variable inside my plugin shader class, it will be available to the Output function? -
Hi @rui_mac,
As long as it fits your needs there's nothing to add against using BaseContainers in your case. However, if you don't need to store hierarchical data, the simpler approach of using BaseArray can sometimes end up in a cleaner implementation.
You can use the generic Data type to handle values of different types.
Cheers,
Ilia