2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Alternate c_trace mode
#217492
07/23/08 12:11
07/23/08 12:11
|
Joined: Jan 2002
Posts: 300 Usa
Rich
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 300
Usa
|
Hi,
I wanted to suggest an alternate mode for c_trace, activated by flag, that could return the distance of the trace if nothing was hit (the old trace behavior).
An example where this would be useful would be a gravity script, where you trace below the object. Tracing -5000 below the object with USE_BOX set eats up a lot more resources than a trace of say -50. (-5000 is the value I most see used in examples for gravity).
So if I am tracing -50 below the entities location, and nothing is hit, than the result would be 50, not 0.
Thanks.
Last edited by Rich; 07/23/08 12:16.
A8 com / A7 free
|
|
|
Re: Alternate c_trace mode
[Re: Rich]
#217519
07/23/08 14:49
07/23/08 14:49
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
I think it's easier to use trace results when it returns zero. Gives you a little more control...
xXxGuitar511 - Programmer
|
|
|
Re: Alternate c_trace mode
[Re: Pappenheimer]
#217536
07/23/08 16:37
07/23/08 16:37
|
Joined: Jan 2002
Posts: 300 Usa
Rich
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 300
Usa
|
Thanks Pappenheimer,
That will do it, but it doesn't return the distance, just 1 or 0. Though combining the result and this trace hit would work (example: if trace_hit = 1 and result < 1, the object is on the ground). I can honestly say that the last time I looked at c_trace I missed that.
A8 com / A7 free
|
|
|
Re: Alternate c_trace mode
[Re: Pappenheimer]
#217689
07/24/08 11:57
07/24/08 11:57
|
Joined: Dec 2005
Posts: 116
tD_Datura_v
Member
|
Member
Joined: Dec 2005
Posts: 116
|
I have seen planned traces of -999999, but if that is absurd, it is well placed here. Instead of hard coded amounts, trace distances can be based on the actors size, min_z, max_z - min_z, etc. multiples. Ignore this. It is erroneous.:
// ct = col trace
// n = var
ct_nResult += (ct_nResult == 0) * ct_nDist; //?
|
|
|
Re: Alternate c_trace mode
[Re: Xarthor]
#218126
07/26/08 16:20
07/26/08 16:20
|
Joined: Dec 2005
Posts: 116
tD_Datura_v
Member
|
Member
Joined: Dec 2005
Posts: 116
|
I should think so. In the case of the overused gravity down trace, I believe something near enough to the distance is usually already available. Doubly erroneous. Ignore x2.
// C-Script
var ct_nResult = 0;
var ct_nDist = 0;
var ct_nDistD = 2; // default in ENTITY units
var ct_nMode = 0;
//...
// set ct_nMode ?
vec_set(temp, my.x);
ct_nDist = (my.max_z - my.min_z) * ct_nDistD;
temp.z -= ct_nDist;
ct_nResult = c_trace(my.x, temp, ct_nMode);
ct_nResult += (ct_nResult == 0) * ct_nDist; // without if construct
If ignoring properly, this shouldn't be seen.
distance = c_trace(trace_from, trace_to, trace_mode);
distance += (distance == 0) * vec_dist(trace_from, trace_to); // wasteful
|
|
|
|