nCine::VelocityAffector class

Affector that animates the velocity of a particle.

Linearly interpolates a velocity offset between consecutive VelocityStep entries and adds the resulting amount to the particle's velocity each frame.

Base classes

class ParticleAffector
Base class for all particle affectors.

Public types

struct VelocityStep
A velocity offset keyed to a normalized particle age.

Constructors, destructors, conversion operators

VelocityAffector()
VelocityAffector(VelocityAffector&&) defaulted
Default move constructor.
VelocityAffector(const VelocityAffector& other) protected defaulted
Protected default copy constructor used to clone objects.

Public functions

auto operator=(VelocityAffector&&) -> VelocityAffector& defaulted
Default move assignment operator.
auto clone() const -> VelocityAffector
Returns a copy of this object.
void affect(Particle* particle, float normalizedAge) override
Affects a property of the specified particle using a precomputed normalized age.
void addVelocityStep(float age, float velX, float velY)
Appends a velocity step at the specified age.
void addVelocityStep(float age, Vector2f velocity)
Appends a vector velocity step at the specified age.
auto steps() -> SmallVectorImpl<VelocityStep>&
Returns the array of velocity steps.
auto steps() const -> const SmallVectorImpl<VelocityStep>&
Returns the array of velocity steps (read-only).

Function documentation

void nCine::VelocityAffector::affect(Particle* particle, float normalizedAge) override

Affects a property of the specified particle using a precomputed normalized age.

Parameters
particle Particle to mutate
normalizedAge Particle age mapped to the [0, 1] range, where 0 is birth and 1 is death

void nCine::VelocityAffector::addVelocityStep(float age, float velX, float velY)

Appends a velocity step at the specified age.

Steps must be added in ascending age order; an out-of-order step is rejected with a warning.