Entity Distance Speed

Blitz3D Forums/Blitz3D Programming/Entity Distance Speed

NTense(Posted 2003) [#1]
Does anyone know if EntityDistance is very processor intensive? I'm experiencing a bug I can't seem to solve (ie: my collision Bug post, same forum), and after extensive debugging, I haven't been able to solve it and fear it may be internal to Blitz. So I was going to write my own collision code using entityDistance but didn't know if it would be overly expensive or if there's a better way to do it?


Bot Builder(Posted 2003) [#2]
uh,
xd#=EntityX(ent1,1)-EntityX(ent2,1)
yd#=EntityY(ent1,1)-EntityY(ent2,1)
zd#=EntityZ(ent1,1)-EntityZ(ent2,1)
dist#=Sqr(xd#*xd#+yd#*yd#+zd#*zd#)



Ken Lynch(Posted 2003) [#3]
No, it's fast. There's no real difference in speed between bot builders code and EntityDistance, except it's much quicker to type entity distance!

Make sure if you do it bot's way that you don't replace xd#*xd# with xd#^2 as that does slow things down a bit (but still hardly noticable unless you are doing thousands of calculations each loop)


NTense(Posted 2003) [#4]
Hey Thanks. I've implemented it (just using EntityDistance), and seems to be working fine (I did notice a tiny drop in FPS, but not enough to worry about).