public sealed class ParticleBufferOne system's particles, one array per attribute.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Struct of arrays, because every operation is a sweep. Gravity reads and writes velocity and touches nothing else; ageing touches age and lifetime. An array of particle structs would pull a whole particle into cache to change four bytes of it, and would defeat the vectoriser on every one of them. This is the same argument the ECS makes for chunk storage and the renderer makes for RenderDataHolder, one level further down.
An attribute a graph does not declare has no memory at all. Not a zeroed array, not a null check on every access — no allocation. A graph that never rotates its particles is a graph whose rotation array is Empty, and the operations that would have read it are not in the compiled list to begin with.
The alive set is a prefix, not a mask. Particles live in [0, Count) and a dead one is removed by copying the last live particle over it. That keeps every sweep a dense loop with no branch per particle, at the cost of the order changing as particles die — which nothing here promises and only a depth sort would care about, and a depth sort re-orders anyway.
Fields and properties (15)
public VfxAttribute AttributesWhich attributes have storage.
public int CapacityThe most particles that can be alive at once.
public int CountHow many are alive. They occupy [0, Count).
public int FreeHow many more could be spawned before the buffer is full.
public uint NextIdentifierHow many particles have ever been spawned, which is where the next identifier comes from.
public Span<Vector3> PositionWhere the particles are.
public Span<Vector3> VelocityHow they are moving.
public Span<float> SizeHow big they are.
public Span<Vector4> ColourWhat colour they are.
public Span<float> LifetimeHow long they live.
public Span<float> AgeHow long they have lived.
public Span<float> RotationTheir roll.
public Span<float> AngularVelocityHow fast that roll is changing.
public Span<uint> IdentifierTheir identifiers.
public int CustomCountHow many custom attributes this buffer has storage for.
Methods (10)
public ParticleBuffer(VfxAttribute attributes, int capacity, ReadOnlySpan<VfxCustomAttribute> declared = default(ReadOnlySpan<VfxCustomAttribute>))Allocates storage for a declared set of attributes.
public bool Has(VfxAttribute attribute)Whether an attribute has storage.
public int Lanes(int slot)How many floats one particle occupies in a custom slot.
public Span<float> Custom(int slot)One custom attribute's storage, as a flat run of lanes.
public int Spawn(int count, out int first)Adds particles, and says where they landed.
public void RemoveAt(int index)Removes a particle by moving the last live one into its place.
public int Reap()Removes every particle whose age has reached its lifetime.
public int Reap(Span<Vector3> graveyard)Removes every particle whose age has reached its lifetime, noting where they were.
public void Clear()Removes every particle, keeping the storage.
public void Dispose()Frees the storage.
Used by (27)
- ComparisonVixen.Vfx.Gpu.Tests
- ComparisonVixen.Vfx.Gpu.Tests
- ComparisonVixen.Vfx.Gpu.Tests
- ParticleLightsVixen.Rendering
- ParticleRenderFeatureTestsVixen.Rendering.Tests
- SweepVixen.Vfx
- VfxAgreementTestsVixen.Vfx.Gpu.Tests
- VfxCollisionTestsVixen.Vfx.Tests
- VfxCompiledGraphTestsVixen.Vfx.Tests
- VfxCustomAttributeTestsVixen.Vfx.Tests
- VfxExtractionTestsVixen.Rendering.Tests
- VfxForceTestsVixen.Vfx.Tests
- VfxGeometryBuilderVixen.Vfx
- VfxGeometryTestsVixen.Vfx.Tests
- VfxGpuSimulationVixen.Rendering
- VfxParallelTestsVixen.Vfx.Tests
- VfxReapTestsVixen.Vfx.Gpu.Tests
- VfxRibbonTestsVixen.Vfx.Tests
- VfxShaderPackingVixen.Vfx
- VfxSimulationVixen.Vfx
- VfxSortTestsVixen.Vfx.Gpu.Tests
- VfxSubEmitterVixen.Vfx
- VfxSubEmitterTestsVixen.Vfx.Tests
- VfxSystemVixen.Vfx
- VfxSystemTestsVixen.Vfx.Tests
- VfxGraphCompilerTestsVixen.Editor.VfxGraph.Tests
- VfxPreviewViewVixen.Editor.AssetEditors