From: <vin...@us...> - 2013-12-29 22:53:31
|
Revision: 14836 http://sourceforge.net/p/supertuxkart/code/14836 Author: vincentlj Date: 2013-12-29 22:53:28 +0000 (Sun, 29 Dec 2013) Log Message: ----------- GPUParticles: Properly handle parent for gpuparticles Modified Paths: -------------- main/trunk/src/graphics/gpuparticles.cpp main/trunk/src/graphics/gpuparticles.h main/trunk/src/graphics/particle_emitter.cpp main/trunk/src/graphics/particle_emitter.hpp Modified: main/trunk/src/graphics/gpuparticles.cpp =================================================================== --- main/trunk/src/graphics/gpuparticles.cpp 2013-12-29 22:53:17 UTC (rev 14835) +++ main/trunk/src/graphics/gpuparticles.cpp 2013-12-29 22:53:28 UTC (rev 14836) @@ -175,8 +175,8 @@ glUniform1i(location, textureUnit); } -GPUParticle::GPUParticle(scene::ISceneManager* mgr, ITexture *tex) - : scene::ISceneNode(mgr->getRootSceneNode(), mgr, -1) { +GPUParticle::GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr, ITexture *tex) + : scene::ISceneNode(parent, mgr, -1) { initGL(); fakemat.Lighting = false; fakemat.ZWriteEnable = false; @@ -206,7 +206,8 @@ #define COMPONENTCOUNT 8 -PointEmitter::PointEmitter(scene::ISceneManager* mgr, ITexture *tex, +PointEmitter::PointEmitter(scene::ISceneNode *parent, + scene::ISceneManager* mgr, ITexture *tex, const core::vector3df& direction, u32 minParticlesPerSecond, u32 maxParticlesPerSecond, @@ -216,7 +217,7 @@ s32 maxAngleDegrees // const core::dimension2df& minStartSize, // const core::dimension2df& maxStartSize -) : GPUParticle(mgr, tex) { +) : GPUParticle(parent, mgr, tex) { count = maxParticlesPerSecond; duration = lifeTimeMax; float initial_lifetime_incr = 1000.; @@ -296,6 +297,7 @@ void PointEmitter::draw() { + updateAbsolutePosition(); glDisable(GL_ALPHA_TEST); glDepthMask(GL_FALSE); glEnable(GL_BLEND); @@ -334,7 +336,7 @@ } RainNode::RainNode(scene::ISceneManager* mgr, ITexture *tex) - : GPUParticle(mgr, tex) + : GPUParticle(0, mgr, tex) { RenderProgram = LoadProgram(file_manager->getAsset("shaders/rain.vert").c_str(), file_manager->getAsset("shaders/rain.frag").c_str()); loc_screenw = glGetUniformLocation(RenderProgram, "screenw"); Modified: main/trunk/src/graphics/gpuparticles.h =================================================================== --- main/trunk/src/graphics/gpuparticles.h 2013-12-29 22:53:17 UTC (rev 14835) +++ main/trunk/src/graphics/gpuparticles.h 2013-12-29 22:53:28 UTC (rev 14836) @@ -20,7 +20,7 @@ virtual void simulate() = 0; virtual void draw() = 0; public: - GPUParticle(scene::ISceneManager* mgr, ITexture *tex); + GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr, ITexture *tex); virtual void render(); virtual void OnRegisterSceneNode(); }; @@ -40,7 +40,7 @@ virtual void simulate(); virtual void draw(); public: - PointEmitter( + PointEmitter(scene::ISceneNode *parent, scene::ISceneManager* mgr, ITexture *tex, const core::vector3df& dir, u32 minParticlesPerSecond, Modified: main/trunk/src/graphics/particle_emitter.cpp =================================================================== --- main/trunk/src/graphics/particle_emitter.cpp 2013-12-29 22:53:17 UTC (rev 14835) +++ main/trunk/src/graphics/particle_emitter.cpp 2013-12-29 22:53:28 UTC (rev 14836) @@ -233,6 +233,7 @@ m_particle_type = NULL; m_parent = parent; m_emission_decay_rate = 0; + PE = 0; setParticleType(type); assert(m_node != NULL); @@ -344,7 +345,9 @@ */ void ParticleEmitter::setPosition(const Vec3 &pos) { - m_node->setPosition(pos.toIrrVector()); + if (PE) + PE->setPosition(pos.toIrrVector()); + m_node->setPosition(pos.toIrrVector()); } // setPosition //----------------------------------------------------------------------------- @@ -447,7 +450,7 @@ m_particle_type->getAngleSpread() /* angle */ ); #ifdef GPUPARTICLE - PointEmitter *PE = new PointEmitter(irr_driver->getSceneManager(), m_node->getMaterial(0).getTexture(0), + PE = new PointEmitter(m_node->getParent(), irr_driver->getSceneManager(), m_node->getMaterial(0).getTexture(0), velocity, type->getMinRate(), type->getMaxRate(), type->getMinColor(), type->getMaxColor(), Modified: main/trunk/src/graphics/particle_emitter.hpp =================================================================== --- main/trunk/src/graphics/particle_emitter.hpp 2013-12-29 22:53:17 UTC (rev 14835) +++ main/trunk/src/graphics/particle_emitter.hpp 2013-12-29 22:53:28 UTC (rev 14836) @@ -49,6 +49,7 @@ /** Irrlicht's particle systems. */ scene::IParticleSystemSceneNode *m_node; + class PointEmitter *PE; Vec3 m_position; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |