mistergreen That's the whole point of my thread, invalid mathematical operations aren't raising any Errors
... So there is nothing to be caught ๐
2jfw Where does it occur / what variable is it / where is it defined in the library?
This is what I'm actually trying to answer with my investigations...
2jfw There could be a setter for it and you could simply add a breakpoint there and follow the callstack or you find the function where the value gets set and add a breakpoint there.
Using "Show Occurrences" (supported in most IDEs) on that var can help you track down the locations where the variable is set.
Unfortunately I can't because at some point Box2D enters in an infinite loop and when I stop the debugger I have NaN
pretty much everywhere... Those NaN
are pretty viral when you start doing mathematical operations. My goal is really to detect the first occurrence of NaN
. Looking at method usages doesn't help me since for example b2Vec2
is used in 1000+ locations.
Yep, that's first thing I did ๐
So finally I managed to find the root cause of it.
The trick I found was to create properties accessors in multiple places in Box2D with checks in them to detect any NaN
as early as possible. Here is an example for b2Vec2
x property:
public class b2Vec2
{
public var _x:Number;
public function get x():Number { return _x; }
public function set x(value:Number):void
{
_x = x;
if (isNaN(_x))
throw "Caramba!";
}
}
And step by step I narrow down the root cause which was in fact in my code ๐
Thanks for the help guys!