Pre-generate some particles if max count is small
This commit is contained in:
parent
a0c9ba2b8c
commit
c3a22ddcf7
@ -19,7 +19,7 @@ in vec2 lifetime_and_size;
|
|||||||
in vec2 Texcoord;
|
in vec2 Texcoord;
|
||||||
in vec2 quadcorner;
|
in vec2 quadcorner;
|
||||||
|
|
||||||
float anglespeed;
|
in float anglespeed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
out vec2 tc;
|
out vec2 tc;
|
||||||
|
@ -19,7 +19,7 @@ in vec2 lifetime_and_size;
|
|||||||
in vec2 Texcoord;
|
in vec2 Texcoord;
|
||||||
in vec2 quadcorner;
|
in vec2 quadcorner;
|
||||||
|
|
||||||
float anglespeed;
|
in float anglespeed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
out vec2 tc;
|
out vec2 tc;
|
||||||
|
@ -255,16 +255,26 @@ void STKParticle::generate(std::vector<CPUParticle>* out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Buffer->BoundingBox.reset(AbsoluteTransformation.getTranslation());
|
Buffer->BoundingBox.reset(AbsoluteTransformation.getTranslation());
|
||||||
|
int active_count = getEmitter()->getMaxLifeTime() *
|
||||||
|
getEmitter()->getMaxParticlesPerSecond() / 1000;
|
||||||
if (m_first_execution)
|
if (m_first_execution)
|
||||||
{
|
{
|
||||||
m_previous_frame_matrix = AbsoluteTransformation;
|
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;
|
m_first_execution = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dt = GUIEngine::getLatestDt() * 1000.f;
|
float dt = GUIEngine::getLatestDt() * 1000.f;
|
||||||
int active_count = getEmitter()->getMaxLifeTime() *
|
|
||||||
getEmitter()->getMaxParticlesPerSecond() / 1000;
|
|
||||||
|
|
||||||
if (m_hm != NULL)
|
if (m_hm != NULL)
|
||||||
{
|
{
|
||||||
stimulateHeightMap(dt, active_count, out);
|
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_lifetime = new_lifetime;
|
||||||
m_particles_generating[i].m_direction = new_particle_direction;
|
m_particles_generating[i].m_direction = new_particle_direction;
|
||||||
m_particles_generating[i].m_size = new_size;
|
m_particles_generating[i].m_size = new_size;
|
||||||
if (m_flips || new_size != 0.0f)
|
if (out != NULL)
|
||||||
{
|
{
|
||||||
if (new_size != 0.0f)
|
if (m_flips || new_size != 0.0f)
|
||||||
{
|
|
||||||
Buffer->BoundingBox.addInternalPoint(new_particle_position);
|
|
||||||
}
|
|
||||||
if (out != NULL)
|
|
||||||
{
|
{
|
||||||
|
if (new_size != 0.0f)
|
||||||
|
{
|
||||||
|
Buffer->BoundingBox.addInternalPoint
|
||||||
|
(new_particle_position);
|
||||||
|
}
|
||||||
out->emplace_back(new_particle_position, m_color_from,
|
out->emplace_back(new_particle_position, m_color_from,
|
||||||
m_color_to, new_lifetime, new_size);
|
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_lifetime = new_lifetime;
|
||||||
m_particles_generating[i].m_direction = new_particle_direction;
|
m_particles_generating[i].m_direction = new_particle_direction;
|
||||||
m_particles_generating[i].m_size = new_size;
|
m_particles_generating[i].m_size = new_size;
|
||||||
if (m_flips || new_size != 0.0f)
|
if (out != NULL)
|
||||||
{
|
{
|
||||||
if (new_size != 0.0f)
|
if (m_flips || new_size != 0.0f)
|
||||||
{
|
|
||||||
Buffer->BoundingBox.addInternalPoint(new_particle_position);
|
|
||||||
}
|
|
||||||
if (out != NULL)
|
|
||||||
{
|
{
|
||||||
|
if (new_size != 0.0f)
|
||||||
|
{
|
||||||
|
Buffer->BoundingBox.addInternalPoint
|
||||||
|
(new_particle_position);
|
||||||
|
}
|
||||||
out->emplace_back(new_particle_position, m_color_from,
|
out->emplace_back(new_particle_position, m_color_from,
|
||||||
m_color_to, new_lifetime, new_size);
|
m_color_to, new_lifetime, new_size);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user