• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Why does/doesn't Polar Projection leak?

Status
Not open for further replies.
Level 8
Joined
Nov 27, 2004
Messages
251
and the answer is "It depends on the way you use polar projection"


if you say

JASS:
call SetUnitPositionLoc ( u , PolarProjectionBJ ( GetUnitLoc ( u ) , 600 , 0 ) )

it will lag a hell,because GetUnitLoc () will return a location that will not be removed , and PolarProjection will return another one that is not removed , so we have 2 location leaks.

but if you say
JASS:
local location l = GetUnitLoc ( u )
local location p = PolarProjectionBJ ( l , 600 , 0 )

call SetUnitPositionLoc ( u , p )


call RemoveLocation ( l )
call RemoveLocation ( p )
set l = null
set p = null


wont leak now ,but locations suck so the best way of using polar projections is

JASS:
local real x = GetUnitX ( u ) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY ( u ) + dist * Sin(angle * bj_DEGTORAD)

call SetUnitPosition ( u , x , y )

doesnt use locations and is way faster
 
Level 12
Joined
Apr 29, 2005
Messages
999
It also seems that most of the functions using units position uses coordinates instead of locations. Like many BJ functions that calls the real native function which uses coordinates. I also used locations before but Vexorian told me that it is better to use coordinates and I saw that he use coordinates in all his spells when ever possible. Leave the locations. :)
 
Status
Not open for further replies.
Top