Warnings and Asserts

Warnings and Asserts

neutrongames's picture

Hello,

when I use normalize3() on a hkVector3(0,0,0) the programm stops with an error but is resumable. In Release Configuration it does not even stop.

The same behaviour is found, when I use 0 or Pi(?) for RADIAN in

rigidBody->setPositionAndRotation(rigidBody->getPosition(), hkQuaternion(hkVector4(0, 0, 1), RADIAN));

How should I deal with this? Testing if a vectorlength is zero is possible, but sometimes I have to set 0 for the rotation and I wonder why there are this warnings, because the program does not crash but continue to work.

Are there any reasons to avoid these kind of warnings?

greetings

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
havok.yoav's picture

Hi,

We put asserts into the code to help catch bugs. These asserts are only activated when building in debug and fulldebug and will not appear in release (as you have already noted). These asserts should be addressed and should not be avoided.

When you need help with an assert, it is very helpful for us if you include the assert message and number, and a callstack.

Also, which version of TryHavok are you using, 6.1 or 6.5?

Thanks,

Yoav

neutrongames's picture
Hi,

I am using TryHavok 6.1 but I dont really need help with an assert at this moment.

But Im still curious why for example there is a problem with normalize3(hkvector(0,0,0)); if it runs perfect in release modus ? Is this assert for performance reasonse or because of something else ?

sean.thurston's picture

Hi,

normailize3(hkVector4(0,0,0)) doesn't really make sense. You can't normalize a zero vector. My bet is that in release mode you get garbage from the normalize call because you are going to do a division by 0.

Asserts are debug only tools. They let you know when you are doing something dangerous or if you have some bad data in your system. They cause the program to stop executing when you hit them. These get compiled out in release mode so that your program won't stop executing if you do hit one and so that there won't be extra validity checks slowing down execution. Does that make sense?

You don't want to try to normalize a 0 vector.

Cheers,
Sean

Developer Support Engineer Havok www.havok.com

Login to leave a comment.