GPUParticles: Properly handle parent for gpuparticles
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14836 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -175,8 +175,8 @@ void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUni
|
||||
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 @@ void GPUParticle::OnRegisterSceneNode() {
|
||||
|
||||
#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 @@ PointEmitter::PointEmitter(scene::ISceneManager* mgr, ITexture *tex,
|
||||
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::simulate()
|
||||
|
||||
void PointEmitter::draw()
|
||||
{
|
||||
updateAbsolutePosition();
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
@@ -334,7 +336,7 @@ void PointEmitter::draw()
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
@@ -20,7 +20,7 @@ protected:
|
||||
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 @@ protected:
|
||||
virtual void simulate();
|
||||
virtual void draw();
|
||||
public:
|
||||
PointEmitter(
|
||||
PointEmitter(scene::ISceneNode *parent,
|
||||
scene::ISceneManager* mgr, ITexture *tex,
|
||||
const core::vector3df& dir,
|
||||
u32 minParticlesPerSecond,
|
||||
|
||||
@@ -233,6 +233,7 @@ ParticleEmitter::ParticleEmitter(const ParticleKind* type,
|
||||
m_particle_type = NULL;
|
||||
m_parent = parent;
|
||||
m_emission_decay_rate = 0;
|
||||
PE = 0;
|
||||
|
||||
setParticleType(type);
|
||||
assert(m_node != NULL);
|
||||
@@ -344,7 +345,9 @@ int ParticleEmitter::getCreationRate()
|
||||
*/
|
||||
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 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
||||
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(),
|
||||
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
|
||||
/** Irrlicht's particle systems. */
|
||||
scene::IParticleSystemSceneNode *m_node;
|
||||
class PointEmitter *PE;
|
||||
|
||||
Vec3 m_position;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user