Traceline speed

Discuss programming in the QuakeC language.
Post Reply
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Traceline speed

Post by Mexicouger »

Is it possible to control the speed of a traceline? Or are they instant point a, to point b?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Traceline speed

Post by Spike »

just look at the builtin definition. if you did, you'd realise that there's no way to specify a velocity/speed/time/etc.
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Re: Traceline speed

Post by Mexicouger »

Thanks. I was just making sure
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: Traceline speed

Post by gnounc »

you could always trace after a delay to imitate bullet travel speed
taniwha
Posts: 401
Joined: Thu Jan 14, 2010 7:11 am
Contact:

Re: Traceline speed

Post by taniwha »

Traceline is instant: it has to be because it's used (internally, but indirectly*) for collision detection of moving objects.

The way traceline is used is to do a trace for the distance the object will move in one frame. There is no speed limit in quake's physics**, so if you want to have a non-instant but very fast bullet, just set the bullet's speed to something appropriate and let the physics engine take care of everything (cloning the nail code is a good start).

The reason traceline is used for collision detection is to avoid the issue of a fast moving object missing just because its per-frame position never hits the target. Unfortunately, quake does not do it both ways, so two fast moving objects will miss even when they shouldn't, but for one fast and one slow (or both slow), it will work.

* Actually, traceline isn't used, but rather the code for which traceline is a wrapper is used, so it's effectively the same thing.

** Mostly. There is one, but it's caused by the precision of floats so it's pretty high.
Leave others their otherness.
http://quakeforge.net/
taniwha
Posts: 401
Joined: Thu Jan 14, 2010 7:11 am
Contact:

Re: Traceline speed

Post by taniwha »

BTW, it is possible to get the quake engine to handle collision between very fast objects, but it would take engine hacking and may not be worth the trouble (it might be too expensive):
  1. Create hulls representing the paths of traced by all moving objects for the current frame (ie, the hull for a moving object represents the path it traces in this frame). This hull would be clipped against the world.
  2. Test each pair of hulls for mutual intersection and for each intersection, find the times of "impact" of the two objects owning the hulls. There wil actually be two times for each object: the time where the first object first touches the second object's trace-hull, and the time where the first object last touches the second object's trace-hull.
  3. If the "impact" time spans overlap, then the objects collide, otherwise they miss. It should be possible to play with the time spans (along with other available information) to get the exact time of impact.
Part of the expense would come from collisions affecting other collisions. For three objects, A, B and C, all moving, both B and C might be on collision courses with A, but B colliding with A might prevent C from colling with A because A didn't reach the A-C collision. One way to handle it is to calculate the times for all intersecting pairs, sort the pairs by time, then work through each pair from earlies to latest.
Leave others their otherness.
http://quakeforge.net/
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Traceline speed

Post by ceriux »

once someone gave me some qc that made the nail gun work off of traces lines. maybe you could spawn a null entity and have the trace follow the front of it instead?
Post Reply