[fixed] vector3d's normalize() doesn't handle null vector

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Piraaate
Posts: 18
Joined: Wed Feb 21, 2007 3:04 pm
Location: Valence, France
Contact:

[fixed] vector3d's normalize() doesn't handle null vector

Post by Piraaate »

Hi guys,
Well everything is pretty much in the title, I'm currently upgrading from my 1.4 version to the latest svn version and I searched for an entire day to discover this "bug".
The comment above the normalize() method is quite clear : "In case of the 0 vector the result is still 0" and now we get a -1.#IND000...

Bug tracker entry
(in my opinion it's a bug that needs a very quick fix)
ImageImage
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I guess returning NAN and returning 0 would both be correct. I'm not even sure what I would prefer here, probably 0 because that wouldn't change the old behaviour (otherwise I would prefer NAN). I just googled a little around and found some discussion on stackoverflow about this: http://stackoverflow.com/questions/7220 ... ero-vector

In any case code certainly should do as the documentation says - so one of both has to be changed.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

I think it should just do a simple check to see if the vector is zero and pass through the vector as is if the condition is true.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
Post Reply