ParticleBuffer class
Struct-of-arrays storage for the live particles of an emitter.
All per-particle state lives in preallocated typed-data lists, so a running particle system performs no per-particle allocations and the simulation loop is a tight scan over contiguous memory.
The particles at indices 0 to length - 1 are alive. Removing a
particle swaps the last live particle into its slot, so iteration while
removing must not advance the index after a removal.
Constructors
- ParticleBuffer(int capacity)
-
Creates a buffer with room for
capacitysimultaneous particles.
Properties
- age → Float32List
-
Time in seconds since the particle spawned.
final
- baseSize → Float32List
-
The size the particle had when it spawned, in local units.
final
- capacity → int
-
The maximum number of simultaneous particles.
final
- color → Int32List
-
The current color as a 32-bit ARGB value.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- invLifespan → Float32List
-
The reciprocal of the particle's lifespan;
age[i] * invLifespan[i]is the life progress from 0 (spawn) to 1 (death).final - isFull → bool
-
Whether the buffer has reached capacity.
no setter
- length → int
-
The number of currently live particles.
no setter
- posX → Float32List
-
The x position, in the emitter's local coordinate system.
final
- posY → Float32List
-
The y position, in the emitter's local coordinate system.
final
- rotation → Float32List
-
The current rotation in radians.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → Float32List
-
The current rendered size (width and height) in local units.
final
- spin → Float32List
-
The angular velocity in radians per second.
final
- velX → Float32List
-
The x velocity, in local units per second.
final
- velY → Float32List
-
The y velocity, in local units per second.
final
Methods
-
clear(
) → void - Removes all live particles.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
progressAt(
int index) → double -
The life progress of the particle at
index, from 0 to 1. -
removeAt(
int index) → void -
Removes the particle at
indexby swapping the last live particle into its slot. -
spawn(
) → int - Activates one particle slot and returns its index, or -1 when the buffer is full. The caller is responsible for initializing every field at the returned index.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited