GPUParticles: This should fix boxemitters.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@15017 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
vincentlj 2014-01-12 19:49:23 +00:00
parent 795ac13c95
commit c5edf82a6c
3 changed files with 20 additions and 29 deletions

View File

@ -22,7 +22,9 @@ out float new_size;
void main(void)
{
float updated_lifetime = lifetime + (float(dt)/lifetime_initial);
if ((updated_lifetime > 1.) && (gl_VertexID <= level))
if (updated_lifetime > 1.)
{
if (gl_VertexID <= level)
{
float dt_from_last_frame = fract(updated_lifetime) * lifetime_initial;
vec4 updated_initialposition = sourcematrix * vec4(particle_position_initial, 1.0);
@ -33,6 +35,12 @@ void main(void)
new_size = mix(size_initial, size_initial * size_increase_factor, fract(updated_lifetime));
}
else
{
new_lifetime = fract(updated_lifetime);
new_size = 0;
}
}
else
{
new_particle_position = particle_position + particle_velocity.xyz * float(dt);
new_particle_velocity = particle_velocity;

View File

@ -4,6 +4,7 @@
#include "config/user_config.hpp"
#include <ICameraSceneNode.h>
#include <IParticleSystemSceneNode.h>
#include "guiengine/engine.hpp"
GLuint getTextureGLuint(irr::video::ITexture *tex) {
return static_cast<irr::video::COpenGLTexture*>(tex)->getOpenGLTextureName();
@ -432,7 +433,6 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
// Pass a fake material type to force irrlicht to update its internal states on rendering
setMaterialType(irr_driver->getShader(ES_RAIN));
setAutomaticCulling(0);
LastEmitTime = 0;
count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
switch (emitter->getType())
@ -465,15 +465,7 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
void ParticleSystemProxy::simulateHeightmap()
{
unsigned time = os::Timer::getTime();
if (LastEmitTime == 0)
{
LastEmitTime = time;
return;
}
u32 timediff = time - LastEmitTime;
LastEmitTime = time;
int timediff = GUIEngine::getLatestDt() * 1000.;
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
core::matrix4 matrix = getAbsoluteTransformation();
glUseProgram(HeightmapSimulationShader::Program);
@ -527,16 +519,7 @@ void ParticleSystemProxy::simulateHeightmap()
void ParticleSystemProxy::simulateNoHeightmap()
{
unsigned time = os::Timer::getTime();
if (LastEmitTime == 0)
{
LastEmitTime = time;
return;
}
u32 timediff = time - LastEmitTime;
LastEmitTime = time;
int timediff = GUIEngine::getLatestDt() * 1000.;
int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000;
core::matrix4 matrix = getAbsoluteTransformation();
glUseProgram(SimpleSimulationShader::Program);

View File

@ -34,7 +34,7 @@ protected:
static GLuint quad_vertex_buffer;
GLuint texture, normal_and_depth;
unsigned duration, count, LastEmitTime;
unsigned count;
void simulateHeightmap();
void simulateNoHeightmap();