diff --git a/data/shaders/alphatest_particle.vert b/data/shaders/alphatest_particle.vert index 515a5f327..973ff77f8 100644 --- a/data/shaders/alphatest_particle.vert +++ b/data/shaders/alphatest_particle.vert @@ -19,7 +19,7 @@ in vec2 lifetime_and_size; in vec2 Texcoord; in vec2 quadcorner; -float anglespeed; +in float anglespeed; #endif out vec2 tc; diff --git a/data/shaders/simple_particle.vert b/data/shaders/simple_particle.vert index 9e5057c5c..4163f771a 100644 --- a/data/shaders/simple_particle.vert +++ b/data/shaders/simple_particle.vert @@ -19,7 +19,7 @@ in vec2 lifetime_and_size; in vec2 Texcoord; in vec2 quadcorner; -float anglespeed; +in float anglespeed; #endif out vec2 tc; diff --git a/src/graphics/stk_particle.cpp b/src/graphics/stk_particle.cpp index de7763444..bc74bf76d 100644 --- a/src/graphics/stk_particle.cpp +++ b/src/graphics/stk_particle.cpp @@ -255,16 +255,26 @@ void STKParticle::generate(std::vector* out) } Buffer->BoundingBox.reset(AbsoluteTransformation.getTranslation()); + int active_count = getEmitter()->getMaxLifeTime() * + getEmitter()->getMaxParticlesPerSecond() / 1000; if (m_first_execution) { m_previous_frame_matrix = AbsoluteTransformation; + for (int i = 0; i < (m_max_count > 5000 ? 5 : 100); i++) + { + if (m_hm != NULL) + { + stimulateHeightMap(i, active_count, NULL); + } + else + { + stimulateNormal(i, active_count, NULL); + } + } m_first_execution = false; } float dt = GUIEngine::getLatestDt() * 1000.f; - int active_count = getEmitter()->getMaxLifeTime() * - getEmitter()->getMaxParticlesPerSecond() / 1000; - if (m_hm != NULL) { stimulateHeightMap(dt, active_count, out); @@ -350,14 +360,15 @@ void STKParticle::stimulateHeightMap(float dt, unsigned int active_count, m_particles_generating[i].m_lifetime = new_lifetime; m_particles_generating[i].m_direction = new_particle_direction; m_particles_generating[i].m_size = new_size; - if (m_flips || new_size != 0.0f) + if (out != NULL) { - if (new_size != 0.0f) - { - Buffer->BoundingBox.addInternalPoint(new_particle_position); - } - if (out != NULL) + if (m_flips || new_size != 0.0f) { + if (new_size != 0.0f) + { + Buffer->BoundingBox.addInternalPoint + (new_particle_position); + } out->emplace_back(new_particle_position, m_color_from, m_color_to, new_lifetime, new_size); } @@ -455,14 +466,15 @@ void STKParticle::stimulateNormal(float dt, unsigned int active_count, m_particles_generating[i].m_lifetime = new_lifetime; m_particles_generating[i].m_direction = new_particle_direction; m_particles_generating[i].m_size = new_size; - if (m_flips || new_size != 0.0f) + if (out != NULL) { - if (new_size != 0.0f) - { - Buffer->BoundingBox.addInternalPoint(new_particle_position); - } - if (out != NULL) + if (m_flips || new_size != 0.0f) { + if (new_size != 0.0f) + { + Buffer->BoundingBox.addInternalPoint + (new_particle_position); + } out->emplace_back(new_particle_position, m_color_from, m_color_to, new_lifetime, new_size); } diff --git a/src/graphics/stk_particle.hpp b/src/graphics/stk_particle.hpp index 64d172623..220d7fe82 100644 --- a/src/graphics/stk_particle.hpp +++ b/src/graphics/stk_particle.hpp @@ -67,7 +67,7 @@ private: /** Previous frame particles emitter source matrix */ core::matrix4 m_previous_frame_matrix; - + /** Maximum count of particles. */ unsigned m_max_count;