Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
fps related question #173182
12/16/07 22:52
12/16/07 22:52
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
if i have an action where i use the distance between the entity and another entity (using vec_dist(my.x,you.x) ... -- which is claimed as a fast operation in the manual)

i am talking about if conditions where certain distances cause different things

would it be wise to calculate the distance once per frame and save it in a skill for further usage, or doesnt it matter considering the framerate?

thanks for ypur opinions...

Re: fps related question [Re: ello] #173183
12/16/07 23:01
12/16/07 23:01
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
What vec dist does is sqrt(x*x+y*y+z*z), where x,y,z is the difference vector of the 2 vectors you passed in. So that's no problem at all for 1 calculation per frame. But the sqrt can become a problem when you call vec_dist a lot. It is most likely "worth it" in terms of performance to store it in a skill. But then again, why bother with the extra complexity when the performance gain is minimal? Only do it if you call vec_dist a lot. See if you can notice the difference in function execution time (F11 debug panel: fnc).

Another usefull trick you might want to consider is comparing squared distances. This leaves out the sqrt(by far the most costly operation of vec_dist), but it only works when COMPARING distances. When you need the actual distance you need a sqrt. But for example, if you want to check if an entity is within 500 quants from the origin, this works too: if(my.x*my.x+my.y*my.y+my.z*my.z < 500*500).

Re: fps related question [Re: Excessus] #173184
12/17/07 07:35
12/17/07 07:35
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
thanks for the indepth.. i guess since i use it three times i'll use a variable


www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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