Brunot
Loading...
Searching...
No Matches
ParticleBlock Class Referencefinal

A container for holding and updating particles that are all the same type. More...

#include <ParticleBlock.h>

Collaboration diagram for ParticleBlock:
[legend]

Public Member Functions

 ParticleBlock ()=default
 constructor for ParticleBlock.
auto addParticles (const std::vector< Particle > &particles) -> void
 Add a series of particles to the block.
auto update (float dt) -> void
auto render () const -> void
 renders the particles
auto showMenu () -> void
 draw a table with the stats of every particle
auto setTexture (gfx::Texture *texture) -> void
auto setShader (gfx::Shader *shader) -> void
auto setMesh (gfx::Mesh *mesh) -> void
auto setName (std::string newName) -> void
auto getName () const -> const std::string &
auto destroy () -> void
auto destroyed () const -> bool

Private Member Functions

auto activeParticles () const
 returns a list of the indices where there are active particles
auto addParticleAtPosition (const Particle &particle, unsigned pos) -> void
 helper function to add a particle at a specific point in the arrays
auto pushBackParticle (const Particle &particle) -> void
 helper function to add a particle to the ends of the arrays
auto updateAnimationForParticle (float dt, unsigned particlePosition) -> void
 helper function to run animation logic for a specific particle (called in loop for every particle)

Private Attributes

std::string name
 The name of the block of particles, for user reference. This name is set by the particleEmitter it's owned by.
bool isDestroyed = false
 whether the block has been destroyed, and should be discarded by sys::ParticleManager
unsigned particleCount = 0u
bool velocityChanges = false
bool colorChanges = false
bool scaleChanges = false
th::Bezier velocityCurve
th::Bezier colorCurve
th::Bezier scaleCurve
gfx::Texturetexture = th::Library::get<gfx::Texture>("Texture/The_House_Logo")
gfx::Shadershader = th::Library::get<gfx::Shader>("texture_shader")
gfx::Meshmesh = th::Library::get<gfx::Mesh>("Mesh/1x1_mesh")
unsigned totalFrames = texture->getFrames()
float frameTime = 0.f
bool loops = false
std::vector< Vector4Dposition
std::vector< Vector4Dvelocity
std::vector< Vector4DvelocityBegin
std::vector< Vector4DvelocityEnd
std::vector< Vector4Dscale
std::vector< Vector4DscaleBegin
std::vector< Vector4DscaleEnd
std::vector< float > rotation
std::vector< float > rotationalVelocity
std::vector< float > rotationalAcceleration
std::vector< Vector4Dcolor
std::vector< Vector4DcolorBegin
std::vector< Vector4DcolorEnd
std::vector< unsigned > frame
std::vector< float > frameCountdown
std::vector< float > lifetime
std::vector< float > timeLeft
 how long the particle has before it is dead, if less than 0, particle is inactive
std::vector< float > normalizedAge

Detailed Description

A container for holding and updating particles that are all the same type.

ParticleBlock used and owned by ParticleEmitter, and shared with sys::ParticleManager. Takes in particles as an Array of Structs, and stores them as a Struct of Arrays, for performance

Constructor & Destructor Documentation

◆ ParticleBlock()

ParticleBlock::ParticleBlock ( )
default

constructor for ParticleBlock.

creates an empty ParticleBlock

Here is the call graph for this function:

Member Function Documentation

◆ activeParticles()

auto ParticleBlock::activeParticles ( ) const
inlineprivate

returns a list of the indices where there are active particles

Here is the caller graph for this function:

◆ addParticleAtPosition()

auto ParticleBlock::addParticleAtPosition ( const Particle & particle,
unsigned pos )->void
private

helper function to add a particle at a specific point in the arrays

a local macro to simplify adding a particle to the arrays

Here is the caller graph for this function:

◆ addParticles()

auto ParticleBlock::addParticles ( const std::vector< Particle > & particles) ->void

Add a series of particles to the block.

Parameters
particlesa reference to a vector of particles to add
Here is the call graph for this function:

◆ destroy()

auto ParticleBlock::destroy ( ) ->void
Here is the caller graph for this function:

◆ destroyed()

auto ParticleBlock::destroyed ( ) const->bool
Here is the caller graph for this function:

◆ getName()

auto ParticleBlock::getName ( ) const->conststd::string &
Here is the caller graph for this function:

◆ pushBackParticle()

auto ParticleBlock::pushBackParticle ( const Particle & particle) ->void
private

helper function to add a particle to the ends of the arrays

A local macro to simply the duplicate code of adding values to particles

Here is the caller graph for this function:

◆ render()

auto ParticleBlock::render ( ) const->void

renders the particles

Here is the call graph for this function:

◆ setMesh()

auto ParticleBlock::setMesh ( gfx::Mesh * mesh) ->void
Here is the caller graph for this function:

◆ setName()

auto ParticleBlock::setName ( std::string newName) ->void
Here is the caller graph for this function:

◆ setShader()

auto ParticleBlock::setShader ( gfx::Shader * shader) ->void
Here is the caller graph for this function:

◆ setTexture()

auto ParticleBlock::setTexture ( gfx::Texture * texture) ->void
Here is the caller graph for this function:

◆ showMenu()

auto ParticleBlock::showMenu ( ) ->void

draw a table with the stats of every particle

Here is the caller graph for this function:

◆ update()

auto ParticleBlock::update ( float dt) ->void
Parameters
dttime in seconds that have passed
Here is the call graph for this function:

◆ updateAnimationForParticle()

auto ParticleBlock::updateAnimationForParticle ( float dt,
unsigned particlePosition )->void
private

helper function to run animation logic for a specific particle (called in loop for every particle)

Here is the caller graph for this function:

Member Data Documentation

◆ color

std::vector<Vector4D> ParticleBlock::color
private

◆ colorBegin

std::vector<Vector4D> ParticleBlock::colorBegin
private

◆ colorChanges

bool ParticleBlock::colorChanges = false
private

◆ colorCurve

th::Bezier ParticleBlock::colorCurve
private

◆ colorEnd

std::vector<Vector4D> ParticleBlock::colorEnd
private

◆ frame

std::vector<unsigned> ParticleBlock::frame
private

◆ frameCountdown

std::vector<float> ParticleBlock::frameCountdown
private

◆ frameTime

float ParticleBlock::frameTime = 0.f
private

◆ isDestroyed

bool ParticleBlock::isDestroyed = false
private

whether the block has been destroyed, and should be discarded by sys::ParticleManager

◆ lifetime

std::vector<float> ParticleBlock::lifetime
private

◆ loops

bool ParticleBlock::loops = false
private

◆ mesh

gfx::Mesh* ParticleBlock::mesh = th::Library::get<gfx::Mesh>("Mesh/1x1_mesh")
private

◆ name

std::string ParticleBlock::name
private

The name of the block of particles, for user reference. This name is set by the particleEmitter it's owned by.

◆ normalizedAge

std::vector<float> ParticleBlock::normalizedAge
private

◆ particleCount

unsigned ParticleBlock::particleCount = 0u
private

◆ position

std::vector<Vector4D> ParticleBlock::position
private

◆ rotation

std::vector<float> ParticleBlock::rotation
private

◆ rotationalAcceleration

std::vector<float> ParticleBlock::rotationalAcceleration
private

◆ rotationalVelocity

std::vector<float> ParticleBlock::rotationalVelocity
private

◆ scale

std::vector<Vector4D> ParticleBlock::scale
private

◆ scaleBegin

std::vector<Vector4D> ParticleBlock::scaleBegin
private

◆ scaleChanges

bool ParticleBlock::scaleChanges = false
private

◆ scaleCurve

th::Bezier ParticleBlock::scaleCurve
private

◆ scaleEnd

std::vector<Vector4D> ParticleBlock::scaleEnd
private

◆ shader

gfx::Shader* ParticleBlock::shader = th::Library::get<gfx::Shader>("texture_shader")
private

◆ texture

gfx::Texture* ParticleBlock::texture = th::Library::get<gfx::Texture>("Texture/The_House_Logo")
private

◆ timeLeft

std::vector<float> ParticleBlock::timeLeft
private

how long the particle has before it is dead, if less than 0, particle is inactive

◆ totalFrames

unsigned ParticleBlock::totalFrames = texture->getFrames()
private

◆ velocity

std::vector<Vector4D> ParticleBlock::velocity
private

◆ velocityBegin

std::vector<Vector4D> ParticleBlock::velocityBegin
private

◆ velocityChanges

bool ParticleBlock::velocityChanges = false
private

◆ velocityCurve

th::Bezier ParticleBlock::velocityCurve
private

◆ velocityEnd

std::vector<Vector4D> ParticleBlock::velocityEnd
private

The documentation for this class was generated from the following files: