Posts: 350
Threads: 18
Joined: Oct 2014
Thanks: 26
Given 54 thank(s) in 47 post(s)
I know that, but as the documentation for the Vector3d class says: Changes this vector so that it keeps current direction but is exactly 1 unit long. FIXME: Fails for a zero vector. If you set the coordinates for a vector, let's say, Direction. If you set each of Direction's coordinates to 0 then call Direction:Normalize(), the distance and each component become NaN when they should stay at 0.
Posts: 350
Threads: 18
Joined: Oct 2014
Thanks: 26
Given 54 thank(s) in 47 post(s)
I just feel that it should be handled by the server since it's a core function of a 3D vector. The API also says it's a "FIXME:." I'll probably look into making a patch or something, it should be really easy.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
I think you should guide the optimizer to remove the double call to Length(), by storing it in a temporary variable.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
(updated your post to use the correct code tag)
Basically, yes, but you don't want to compare to zero exactly, you want to compare to an epsilon (abs(Len) < EPS) to accommodate for numerical inaccuracy.