maxAge of particle is now halfAge and it lives for 5*halfAge time.

This commit is contained in:
Andreas Ortmann 2016-09-30 21:48:15 +02:00
parent a6b9078c21
commit 3a30a20043
5 changed files with 17 additions and 15 deletions

View file

@ -11,11 +11,11 @@ int getDivisorForIndex(int index)
}
namespace endofthejedi {
ParticleBatch::ParticleBatch(size_t id, size_t numParticles, float particleSize, float maxAge)
ParticleBatch::ParticleBatch(size_t id, size_t numParticles, float particleSize, float halfAge)
: m_id(id)
, m_numParticles(numParticles)
, m_particleRadius(particleSize)
, m_maxAge(maxAge)
, m_halfAge(halfAge)
, m_age(0.0)
, m_maxVelocity(1.0)
, m_center(glm::vec3(0.0f, 0.0f, 0.0f))
@ -137,7 +137,7 @@ namespace endofthejedi {
glUniform1f(m_shader.location("age"), m_age);
glUniform1f(m_shader.location("maxVelocity"), m_maxVelocity);
glUniform1f(m_shader.location("maxAge"), m_maxAge);
glUniform1f(m_shader.location("halfAge"), m_halfAge);
glUniform1f(m_shader.location("size"), m_particleRadius);
glUniform3f(m_shader.location("center"), m_center.x, m_center.y, m_center.z);
@ -206,6 +206,6 @@ namespace endofthejedi {
bool ParticleBatch::done() const
{
return m_age >= m_maxAge;
return m_age >= 5.0*m_halfAge;
}
}

View file

@ -10,7 +10,7 @@
namespace endofthejedi {
class ParticleBatch {
public:
ParticleBatch(size_t id, size_t numParticles, float particleRadius, float maxAge);
ParticleBatch(size_t id, size_t numParticles, float particleRadius, float halfAge);
// deallocate opengl stuff on destroy
~ParticleBatch();
@ -41,7 +41,7 @@ namespace endofthejedi {
size_t m_id;
size_t m_numParticles;
float m_particleRadius;
const float m_maxAge;
const float m_halfAge;
float m_age;
float m_maxVelocity;
glm::vec3 m_center;

View file

@ -119,7 +119,7 @@ namespace endofthejedi {
//glm::vec3 v = 0.5f*glm::vec3(sin(t), cos(t), util::randf_m1_1());
glm::vec3 v = glm::ballRand(maxVelocity);
v *= util::randf_0_1() + util::randf_0_1();
v *= util::randf_0_1() * util::randf_0_1();
batch->setParticle(i, glm::vec3(pos, 0.0) + glm::ballRand(explSize), v);
}