Dev Guide: Particle Rendering
The RendererParticles
class is the root of a sub-tree responsible for rendering the particles as well as their bonds and circuits.
Since this is a very complex system with too many features to cover in detail, the next pages focus on the main components and roughly explain the other parts where they are relevant.

The class itself only manages its child renderers and some additional data, and forwards the render calls and other operations to the corresponding classes.
The purpose of the *_RenderBatch
classes is to render all objects that can be batched together, i.e., objects with the same visual properties like color or animation type.
To organize this, they define property block data structs that are used as keys for identifying the render batch indices.
For example, the RendererParticles_RenderBatch
class defines the RendererParticles_RenderBatch.PropertyBlockData
struct, which contains a color and the number of pins per side.
The RendererParticles
has a dictionary that maps instances of this struct to RendererParticles_RenderBatch
instances.
Whenever a particle is added to the render system, the RendererParticles
checks if a render batch for the particle's color and number of pins already exists and adds the particle to the batch.
If no batch exists yet, it creates a new batch and adds a new entry to the dictionary.
All future particles with the same color and number of pins will be rendered by that batch.
A similar approach is used for the circuit render batch classes, but the system is more complex.
This part is handled by a single RendererCircuitsAndBonds
instance that acts as the root of another sub-tree.
Because bonds are technically rendered the same way as circuits, it makes sense to handle these two components together.
In addition to the render batches, the RendererParticles
also keeps track of all particles that are registered in the render system.
They are stored in a dictionary that maps IParticleState
s to ParticleGraphicsAdapterImpl
s.
The IParticleState
interface is implemented by the particle class and allows the render system to read some general properties of the particles, such as its position, expansion state, compass direction and chirality, and even to change some of the properties.
The ParticleGraphicsAdapterImpl
is a class containing all visualization-specific data associated with a particle.
Every particle has one instance of this class that it can use to push visualization updates to the render system.
The RendererParticles
has methods for adding and removing particles that can be accessed through these interfaces.