update particles garbage collection scheme

This commit is contained in:
MihailRis
2024-11-02 22:15:26 +03:00
parent cee214754b
commit 1974298c82
5 changed files with 50 additions and 21 deletions
+12
View File
@@ -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;
};