Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Ayumi, PeWi, Quad, VoroneTZ), 513 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Alternate c_trace mode #217492
07/23/08 12:11
07/23/08 12:11
Joined: Jan 2002
Posts: 300
Usa
Rich Offline OP
Senior Member
Rich  Offline 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 Offline
Expert
xXxGuitar511  Offline
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: xXxGuitar511] #217535
07/23/08 16:23
07/23/08 16:23
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
you can use the 'trace_hit' instead:
Quote:
trace_hit Nonzero if c_trace hit something, otherwise 0.
from the online manual

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 Offline OP
Senior Member
Rich  Offline 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: Rich] #217537
07/23/08 16:47
07/23/08 16:47
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Honestly, while already posting that your suggestion might be a good idea, I did a look into the manual and found this! wink

Re: Alternate c_trace mode [Re: Pappenheimer] #217689
07/24/08 11:57
07/24/08 11:57
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

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.:
Code:
// ct = col trace
// n = var
ct_nResult += (ct_nResult == 0) * ct_nDist;  //?



Re: Alternate c_trace mode [Re: tD_Datura_v] #218073
07/26/08 10:37
07/26/08 10:37
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
The distance if nothing was hit is simply the distance between the VECTOR* from and VECTOR* to .. isn't it?

Code:
result = c_trace(trace_from,trace_to,IGNORE_ME);
if(!result)
{
  distance = vec_dist(trace_from,trace_to);
}
else { distance = result; }


Re: Alternate c_trace mode [Re: Xarthor] #218126
07/26/08 16:20
07/26/08 16:20
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

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.
Code:
// 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.
Code:
distance = c_trace(trace_from, trace_to, trace_mode);
distance += (distance == 0) * vec_dist(trace_from, trace_to);  // wasteful



Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1