mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
update particles garbage collection scheme
This commit is contained in:
parent
cee214754b
commit
1974298c82
5 changed files with 50 additions and 21 deletions
|
|
@ -8,10 +8,19 @@
|
|||
|
||||
#include "maths/UVRegion.hpp"
|
||||
|
||||
class Emitter;
|
||||
|
||||
struct Particle {
|
||||
/// @brief Pointer used to access common behaviour.
|
||||
/// Emitter must be utilized after all related particles despawn.
|
||||
Emitter* emitter;
|
||||
/// @brief Global position
|
||||
glm::vec3 position;
|
||||
/// @brief Linear velocity
|
||||
glm::vec3 velocity;
|
||||
/// @brief Remaining life time
|
||||
float lifetime;
|
||||
/// @brief UV region
|
||||
UVRegion region;
|
||||
};
|
||||
|
||||
|
|
@ -43,6 +52,7 @@ public:
|
|||
int count
|
||||
);
|
||||
|
||||
/// @return Emitter particles texture
|
||||
const Texture* getTexture() const;
|
||||
|
||||
/// @brief Update emitter and spawn particles
|
||||
|
|
@ -50,7 +60,9 @@ public:
|
|||
/// @param particles destination particles vector
|
||||
void update(float delta, std::vector<Particle>& particles);
|
||||
|
||||
/// @brief Set initial random velocity magitude
|
||||
void setExplosion(const glm::vec3& magnitude);
|
||||
|
||||
/// @return true if the emitter has spawned all particles
|
||||
bool isDead() const;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue