Bug 3642 - Trail System: trails with a fadeOutTime don't fade
Status: REOPENED
Alias: None
Product: Tremulous
Classification: Unclassified
Component: Misc
Version: SVN HEAD
Hardware: PC Linux
: P3 normal
Assignee: Tim Angus
QA Contact: Tremulous Bugs
URL:
Depends on:
Blocks:
 
Reported: 2008-05-10 13:37 EDT by JPL
Modified: 2011-04-24 22:23:31 EDT
1 user (show)

See Also:


Attachments
patch for cgame/cg_trails.c (1.72 KB, patch)
2008-05-10 13:38 EDT, JPL
updated patch with fixed fadeOutTime and proper garbage collection for single-attachment trails. (855 bytes, patch)
2008-05-26 21:52 EDT, JPL

Description JPL 2008-05-10 13:37:18 EDT
I'm working on a standalone game based on ioQuake3 and I've merged in the Tremulous particle and trail systems.  Everything works great, except for the "fadeOutTime" parameter that allows trail systems that are attached to something at both ends to fade out over time ( http://tremmapping.pbwiki.com/Trail+System ).

I confirmed that this also didn't work in unmodified Tremulous, and went digging around in the code.  I found that fadeOutTime depends on destroyTime being greater than zero, but trails with a >0 destroyTime never get populated with beam nodes.  Also, the code where a vert's alpha is calculated based on lifetime and fadeOutTime is all integers, so you'll only ever see full or zero alpha.

I've created a patch with these changes... they work fine in my project, but I haven't tested them with Tremulous.  Not sure if this would be considered a fix or merely an "enhancement" given that none of Tremulous's FX content (that I could find) makes use of fadeOutTime.  Take it or leave it.

Forum topic that led me here: http://tremulous.net/forum/index.php?topic=8057.0
Comment 1 JPL 2008-05-10 13:38:01 EDT
Created attachment 1756 [details]
patch for cgame/cg_trails.c
Comment 2 JPL 2008-05-26 21:48:02 EDT
Comment on attachment 1756 [details]
patch for cgame/cg_trails.c

This patch causes another bug, obsoleted.
Comment 3 JPL 2008-05-26 21:51:25 EDT
Just recently I discovered a bug that my last patch inadvertently caused, namely that trail systems didn't get garbage collected when their attached client entities.  The new fix ended up being even simpler.  Patch is attached.
Comment 4 JPL 2008-05-26 21:52:26 EDT
Created attachment 1772 [details]
updated patch with fixed fadeOutTime and proper garbage collection for single-attachment trails.
Comment 5 Tim Angus 2009-10-17 18:55:41 EDT
Fixed in r1808.
Comment 6 Ben Millwood 2011-04-24 22:23:31 EDT
I'm pretty sure that this patch started Stannum's new trail systems misbehaving. I don't want to just revert the patch because I think it fixes a legitimate bug, so I think there's something else going wrong.

As it stands, trails with a fadeOutTime just don't die. At all. This isn't hard to fix. The condition in the patch:

> +  if( ( ts->destroyTime <= 0 ) || ( btb->fadeOutTime > 0 ) )

should probably be something like:

> +  if( ts->destroyTime <= 0 || ( cg.time - ts->destroyTime ) < btb->fadeOutTime )

But even with that change applied, I still don't observe any actual fading. It looks like the alpha parameter on the trailBeamNode is being set correctly, but in-game there is no visible effect.