遇到一个bug,是值的范围的问题,下面是解释。
怎么调试也不明白原因,即使google也没发现解决方法。原来自己不小心除以了一个0(在一定情况下),╮(╯▽╰)╭,大家写程序时一定要小心!!!!!
下面是官网描述 http://www.ogre3d.org/forums/viewtopic.php?f=5&t=70549
– OgreAxisAlignedBox.h:252 – OGRE CRASHES
回答者建议:
99% of the time this is caused by the user passing in bad values to ogre’s methods that transform scene nodes. If you give ogre a NAN (Not A Number, a floating point value made by doing bad things like dividing by zero) when moving, rotating or scaling a scene node, it will corrupt the transform matrix the node generates. This is then used to transform the bounding box, which now has NANs in it and triggers the exception.
The most common causes are:
– dividing by zero
– calling acos or asin with a number bigger than 1.0 or less than -1.0 (even a fraction outside that range is fatal. 1.0000001 will cause NANs)
The acos/asin stuff can be fixed by calling Ogre’s Math::ACos or Math::ASin instead, they protect against bad values.
Often acos is used with rotations. For example, you might normalise two vectors, get their dot product, then get the acos of that. The answer is the angle between them. That can be used to rotate an object to look at something. The dot product of two normalised vectors is theoretically between -1.0 and 1.0, but due to floating point errors if might be bigger or smaller by enough to break the acos, which then breaks the rotation, which then breaks the bounding box.
转自:点击打开链接