[Solved]Overflow in AABB and atan2f related?

efaj
Posts: 8
Joined: Sun Dec 09, 2012 12:30 pm

[Solved]Overflow in AABB and atan2f related?

Post by efaj »

Code: Select all

//std::cout<<atan2f(angleForceX, angleForceZ)<<std::endl;
After applying a force, I make a copy of it in angleForceX and Z so I later calculate the direction the character is looking at. Strangely, when I have that line uncommented, and apply a force with X and Z components, I have a high probability of triggering the Overflow error....

Unable to yet find the cause, and sceptic that calculating an arctan with 2 floats from a data object that merely has an index to a Component object that is loosely coupled to Bullet itself would be the cause.... I can only ask myself one thing:
Could some flags that atan2f set affect bullet in a way that it thinks there is such overflow?

--Using 2.81, and MinGW on Win7.

Edit: After some recompiles, and build type switches, and building Bullet in Debug too, the error vanished from all my configurations.... Is there a way to consistently debug this better? If it's really just an AABB overflow, I have no idea how I could be causing it since after initialization, I don't touch the shape at all.
EDit: Edit: Nevermind, it's still there...

Edit final: I was using

Code: Select all

applyForce(force, btVector3());
supposing btVector3() would init to 0,0,0, but that's not true. And that's why indeed there was an AABB overflow
CireNeikual
Posts: 19
Joined: Thu Jun 28, 2012 5:06 pm

Re: [Solved]Overflow in AABB and atan2f related?

Post by CireNeikual »

Heap corruption might be a possibility. Check your deletes, and throw out any primitive arrays (std::vector is pretty much always a better option).

http://www.efnetcpp.org/wiki/Heap_Corru ... k_Overflow
efaj
Posts: 8
Joined: Sun Dec 09, 2012 12:30 pm

Re: [Solved]Overflow in AABB and atan2f related?

Post by efaj »

CireNeikual wrote:Heap corruption might be a possibility. Check your deletes, and throw out any primitive arrays (std::vector is pretty much always a better option).

http://www.efnetcpp.org/wiki/Heap_Corru ... k_Overflow
Thanks for the help.
Indeed it was corrupted, but merely from assuming btVector3() gave a 0,0,0 vector. But, for optimization, it's uninitialized instead, and that's where the corruption came from. Simply changed btVector3() to btVector3(0,0,0) and presto.