Fix for projectile splash when no emitter trails are defined
by Josh Moore · 09/30/2004 (7:47 pm) · 3 comments
In projectile.cc find this section of code:
and replace it with this:
else if (!fromWater && toWater && bool(mParticleEmitter) && bool(mParticleWaterEmitter)) // entering water
{
// cast the ray to get the surface point of the water
RayInfo rInfo;
if (gClientContainer.castRay(from, to, WaterObjectType, &rInfo))
{
MatrixF trans = getTransform();
trans.setPosition(rInfo.point);
Splash *splash = new Splash();
splash->onNewDataBlock(mDataBlock->splash);
splash->setTransform(trans);
splash->setInitialState(trans.getPosition(), Point3F(0.0, 0.0, 1.0));
if (!splash->registerObject())
{
delete splash;
splash = NULL;
}
// create an emitter for the particles out of water and the particles in water
mParticleEmitter->emitParticles(from, rInfo.point, axis, vel, ms);
mParticleWaterEmitter->emitParticles(rInfo.point, to, axis, vel, ms);
}
}
else if (fromWater && !toWater && bool(mParticleEmitter) && bool(mParticleWaterEmitter)) // leaving water
{
// cast the ray in the opposite direction since that point is out of the water, otherwise
// we hit water immediately and wont get the appropriate surface point
RayInfo rInfo;
if (gClientContainer.castRay(to, from, WaterObjectType, &rInfo))
{
MatrixF trans = getTransform();
trans.setPosition(rInfo.point);
Splash *splash = new Splash();
splash->onNewDataBlock(mDataBlock->splash);
splash->setTransform(trans);
splash->setInitialState(trans.getPosition(), Point3F(0.0, 0.0, 1.0));
if (!splash->registerObject())
{
delete splash;
splash = NULL;
}
// create an emitter for the particles out of water and the particles in water
mParticleEmitter->emitParticles(rInfo.point, to, axis, vel, ms);
mParticleWaterEmitter->emitParticles(from, rInfo.point, axis, vel, ms);
}
}and replace it with this:
else if (!fromWater && toWater )//&& bool(mParticleEmitter) && bool(mParticleWaterEmitter)) // entering water
{
// cast the ray to get the surface point of the water
RayInfo rInfo;
if (gClientContainer.castRay(from, to, WaterObjectType, &rInfo))
{
MatrixF trans = getTransform();
trans.setPosition(rInfo.point);
Splash *splash = new Splash();
splash->onNewDataBlock(mDataBlock->splash);
splash->setTransform(trans);
splash->setInitialState(trans.getPosition(), Point3F(0.0, 0.0, 1.0));
if (!splash->registerObject())
{
delete splash;
splash = NULL;
}
if(bool(mParticleEmitter) && bool(mParticleWaterEmitter))
{
// create an emitter for the particles out of water and the particles in water
mParticleEmitter->emitParticles(from, rInfo.point, axis, vel, ms);
mParticleWaterEmitter->emitParticles(rInfo.point, to, axis, vel, ms);
}
}
}
else if (fromWater && !toWater )//&& bool(mParticleEmitter) && bool(mParticleWaterEmitter)) // leaving water
{
// cast the ray in the opposite direction since that point is out of the water, otherwise
// we hit water immediately and wont get the appropriate surface point
RayInfo rInfo;
if (gClientContainer.castRay(to, from, WaterObjectType, &rInfo))
{
MatrixF trans = getTransform();
trans.setPosition(rInfo.point);
Splash *splash = new Splash();
splash->onNewDataBlock(mDataBlock->splash);
splash->setTransform(trans);
splash->setInitialState(trans.getPosition(), Point3F(0.0, 0.0, 1.0));
if (!splash->registerObject())
{
delete splash;
splash = NULL;
}
if(bool(mParticleEmitter) && bool(mParticleWaterEmitter))
{
// create an emitter for the particles out of water and the particles in water
mParticleEmitter->emitParticles(rInfo.point, to, axis, vel, ms);
mParticleWaterEmitter->emitParticles(from, rInfo.point, axis, vel, ms);
}
}
}About the author

Torque Owner Joseph Villard
Default Studio Name
Thanks, Joe