Fixed Projectile Particle Rendering
by Paul /*Wedge*/ DElia · 01/19/2006 (10:34 pm) · 9 comments
Download Code File
All this does is fix an issue where projectile trails start getting rendered late (or never at all if it collides soon enough) for a projectile object. It's a bit of an extensive to fix a minor visual glitch, but this can become very annoying and frequent if you start using higher velocity projectiles and more noticable particle trails. It checks for how much distance the client has missed when it gets the projectile from the server, and fills in the blanks in the particle rendering. There were several different cases I found where this could happen, but this should cover all of them. However, this of course does nothing to fix an offset you would have with the .dts shape of a projectile. Also this doesn't account for ballistic trajectories, but I don't think you can get offset/speed combinations where this would ever be noticable. The files are based off a clean 1.4. I tried posting the changes manually, but keep screwing it up, so just diff off the files if you need to.
All this does is fix an issue where projectile trails start getting rendered late (or never at all if it collides soon enough) for a projectile object. It's a bit of an extensive to fix a minor visual glitch, but this can become very annoying and frequent if you start using higher velocity projectiles and more noticable particle trails. It checks for how much distance the client has missed when it gets the projectile from the server, and fills in the blanks in the particle rendering. There were several different cases I found where this could happen, but this should cover all of them. However, this of course does nothing to fix an offset you would have with the .dts shape of a projectile. Also this doesn't account for ballistic trajectories, but I don't think you can get offset/speed combinations where this would ever be noticable. The files are based off a clean 1.4. I tried posting the changes manually, but keep screwing it up, so just diff off the files if you need to.
About the author
#2
01/20/2006 (8:14 am)
Great fix! Thanks
#3
-Jase
01/21/2006 (12:52 am)
Nice fix! I was wondering what was up with the particle trails not being quite right. Figured it was a server->client issue.-Jase
#4
Also, I was trying your fix to address the high muzzle speeds with the '3d Mesh Line Tracers for Torque' resource.
01/23/2006 (4:24 pm)
Anybody get this merged into the Torque Lighting Kit 1.4? I managed a compile without errors but, strange things happen...hehe, I'm not a coder/scripter so I probably merged this incorrectly? Also, I was trying your fix to address the high muzzle speeds with the '3d Mesh Line Tracers for Torque' resource.
#5
01/23/2006 (4:46 pm)
Have a problem patching it into TLK - I get "Invalid packet: GameBase::unpackUpdate()"
#6
01/24/2006 (4:36 pm)
I don't have TLK, so I'm afraid I can't help anyone with that. Anybody else fixes it please post though. Do remember you would have to merge the file changes over properly if you were using the lighting pack.
#7
looks like you added initial position twice to the packupdate message
this line was added right after the pos as added
mathWrite(*stream, mInitialPosition); //Wedge-
near the top of the packupdate function.
then later on you added
mathWrite(*stream, mInitialPosition);
mathWrite(*stream, mFinalVel);
but in unpack update you only have
mathRead(*stream, &pStart);
mathRead(*stream, &pVec);
your missing something like
mathRead(*stream, &pInitial); (or whatever variable you use).
otherwise your packs do not match!
so right around this line
stream->readCompressedPoint(&pos);
in unpackUpdate of projectile.cc
change this:
Point3F pos;
stream->readCompressedPoint(&pos);
if(stream->readFlag())
{
stream->readNormalVector(&mCurrVelocity, 10);
mCurrVelocity *= stream->readInt(13) / 32.0f;
}
else
mCurrVelocity.set(0, 0, 0);
mCurrDeltaBase = pos;
mCurrBackDelta = mCurrPosition - pos;
mCurrPosition = pos;
setPosition(mCurrPosition);
to something like this:
Point3F pos;
Point3F pInit;
stream->readCompressedPoint(&pos);
mathRead(*stream, &pInit);
if(stream->readFlag())
{
stream->readNormalVector(&mCurrVelocity, 10);
mCurrVelocity *= stream->readInt(13) / 32.0f;
}
else
mCurrVelocity.set(0, 0, 0);
mCurrDeltaBase = pos;
mCurrBackDelta = mCurrPosition - pos;
mCurrPosition = pos;
setPosition(mCurrPosition);
mInitialPosition = pInit;
02/04/2006 (7:53 pm)
Hey was looking at this and also getting the same error Invalid packet.looks like you added initial position twice to the packupdate message
this line was added right after the pos as added
mathWrite(*stream, mInitialPosition); //Wedge-
near the top of the packupdate function.
then later on you added
mathWrite(*stream, mInitialPosition);
mathWrite(*stream, mFinalVel);
but in unpack update you only have
mathRead(*stream, &pStart);
mathRead(*stream, &pVec);
your missing something like
mathRead(*stream, &pInitial); (or whatever variable you use).
otherwise your packs do not match!
so right around this line
stream->readCompressedPoint(&pos);
in unpackUpdate of projectile.cc
change this:
Point3F pos;
stream->readCompressedPoint(&pos);
if(stream->readFlag())
{
stream->readNormalVector(&mCurrVelocity, 10);
mCurrVelocity *= stream->readInt(13) / 32.0f;
}
else
mCurrVelocity.set(0, 0, 0);
mCurrDeltaBase = pos;
mCurrBackDelta = mCurrPosition - pos;
mCurrPosition = pos;
setPosition(mCurrPosition);
to something like this:
Point3F pos;
Point3F pInit;
stream->readCompressedPoint(&pos);
mathRead(*stream, &pInit);
if(stream->readFlag())
{
stream->readNormalVector(&mCurrVelocity, 10);
mCurrVelocity *= stream->readInt(13) / 32.0f;
}
else
mCurrVelocity.set(0, 0, 0);
mCurrDeltaBase = pos;
mCurrBackDelta = mCurrPosition - pos;
mCurrPosition = pos;
setPosition(mCurrPosition);
mInitialPosition = pInit;
#8
02/06/2006 (9:24 pm)
Yeeeah knew I'd have to miss something porting it over... that's fixed now in the download.
#9
02/09/2006 (6:34 pm)
Thank You! Works Excellent!! 
Torque 3D Owner KevinG
ZeroHourGames/ChronicLogic
Your efforts will save us a bunch of time!!
Cheers,
KevinG