SOLVED Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

SOLVED Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I keep getting this error randomly when I run my app and move camera around...

OgreMain/include/OgreAxisAlignedBox.h:252: void Ogre::AxisAlignedBox::setExtents(const Ogre::Vector3&, const Ogre::Vector3&): Assertion `(min.x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum corner of the box must be less than or equal to maximum corner"' failed.

Sometimes I can move around for long time and sometimes not.

I had hoped this would disappear with 1.8, but I guess not.

Any suggestions to how this error can be avoided?
Last edited by OGREHEAD on Wed May 22, 2013 7:27 pm, edited 1 time in total.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7156
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 529

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by Kojack »

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.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I have traced this problem to the following.

I have a scenenode TheScenenode with a camera attached that I am moving and rotating with translate and pitch, yaw, roll.

I have a vector TheVector that I set to Ogre::Vector3::ZERO every frame before doing anything else.

I then do this for keypresses...
TheVector.x = DiferrentAmount;
TheVector.y = DifferentAmount;
TheVector.z = DifferentAmount;
DifferentAmount is between -100000 to 100000, but seems to crash more often at high values.

Then finally...
TheScenenode->translate( TheVector, Node::TS_LOCAL );

Now I get the crash when I hold key that influence z axis positively and I press any of the other keys like x and y negative and positive.
When I do any other combination I can move around as I want.
Only problem is when z axis positive is involved.

And event stranger...
Positive z axis works for a short period before crash it seems.
I have outputted TheVector just before a crash.
TheVector: Vector3(146151, 0, 146151)
TheVector: Vector3(145551, 0, 145551)
TheVector: Vector3(145901, 0, 145901)
TheVector: Vector3(146401, 0, 146401)
TheVector: Vector3(151551, 0, 151551)
TheVector: Vector3(147551, 0, 147551)
TheVector: Vector3(145851, 0, 145851)
TheVector: Vector3(145851, 0, 145851)
TheVector: Vector3(145451, 0, 145451)
TheVector: Vector3(146251, 0, 146251)
TheVector: Vector3(146151, 0, 146151)
TheVector: Vector3(145701, 0, 145701)
TheVector: Vector3(145201, 0, 145201)
TheVector: Vector3(145651, 0, 145651)
TheVector: Vector3(155151, 0, 155151)
TheVector: Vector3(146751, 0, 146751)
TheVector: Vector3(156501, 0, 156501)
TheVector: Vector3(178501, 0, 178501)
TheVector: Vector3(182351, 0, 182351)
TheVector: Vector3(145451, 0, 145451)
Then crash... OgreAxisAlignedBox.h:252: void Ogre::AxisAlignedBox::setExtents(const Ogre::Vector3&, const Ogre::Vector3&): Assertion `(min.x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum corner of the box must be less than or equal to maximum corner"' failed.

I simply do not understand why this would not work.
Anybody know how to solve this or have a better way to move a scenenode around?

I haven't even tested my scenenode rotate problem, but I think it is the same problem.

What am I doing wrong?
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

Does anybody know why the vector causes a crash and how to solve this?

I have the same setup as example framework...
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7156
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 529

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by Kojack »

moving and rotating with translate and pitch, yaw, roll.
How are you calculating the angles for the pitch, yaw and roll? asin and acos are used a lot with angles and they are the leading cause of the aabb assert.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

Rotate vector I have disabled for now, so only translate vector fails when when positive z key is pressed.
My translate vector does this...


MoveSpeed = 0.0002;

This is then done for every frame...

double FrameTIme; // Changes for every frame. Around 5000 every frame.
TranslateVector = Ogre::Vector3::ZERO;
Move = MoveSpeed * (float)FrameTIme;
TranslateVector.x = Move;
SceneManager1->getSceneNode( 'Camera1' )->translate( TranslateVector, Node::TS_LOCAL );
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I do not understand what I am doing wrong...

Moving a scenenode should be so simple, but I can not get this done without error...
Is it me or is it OGRE???
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by duststorm »

OGREHEAD wrote:double FrameTIme; // Changes for every frame. Around 5000 every frame.
TranslateVector = Ogre::Vector3::ZERO;
Move = MoveSpeed * (float)FrameTIme;
TranslateVector.x = Move;
SceneManager1->getSceneNode( 'Camera1' )->translate( TranslateVector, Node::TS_LOCAL );
I don't see anything wrong with that code. It should work. I quickly tested it and it does what it should do.
You must be passing some NAN values from somewhere else. Try debugging it where it goes wrong.
Developer @ MakeHuman.org
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7156
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 529

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by Kojack »

If you comment out just the translate line and leave everything else the same does it still cause the assert?

You could try adding some logging just before each frame is rendered, log out the position, scale and orientation of the camera node. On the log before the assert happens you should see one of the values being something like 1.#IND or 1.#INF. That's the NAN.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I will try what you suggest Kojack.

I have not logged the camera node position only the scenenode it is attached to.
And I am not doing any rotation at all right now, only translating.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

That gave a bit more clearity.

When I did not translate the scenenode but only changed my move vector, there was no crash.
So it is the scenenode position that causes crash it seems.
Then I outputted the vector AND camera position AND scenenode position.
Camera position is just 0,0,0 since I translate the scenenode camera is attached to.
Then the scenenode position only crashed when I moved large steps in vector.
Here is a scenenode position crash output...
SceneNodePosition: Vector3(-5.01512e+07, 5.01498e+07, 80)
When I do small steps in translate vector there is no crash.
So the larger steps influence the crash.
But even with large steps I can pres all keys except s which is Z Axis positive.
It would be nice to understand why only one axis cause the problem.

I do not see any 1.#IND or 1.#INF Kojack...

Perhaps duststorm you could try with 40 as MoveSpeed value and 5000 as FrameTime value...
double FrameTIme; // Changes for every frame. Around 5000 every frame.
TranslateVector = Ogre::Vector3::ZERO;
Move = 40 * (float)5000;
TranslateVector.x = Move;
SceneManager1->getSceneNode( 'Camera1' )->translate( TranslateVector, Node::TS_LOCAL );

And then start and just move positive z axis for a few seconds then probably crash...
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by duststorm »

I think I know what's happening.
You're feeding it way too large numbers, and your float position value overflows. That makes your minimum larger than your max.

Is there a reason your world or animation is such a large scale? I can't imagine a good reason why you would do it like that. My suggestion is to scale everything down.
Developer @ MakeHuman.org
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

OK, I think I have fixed the move vector.

And I do not think rotate vector crashes. It has not done yet.

But...
When I run in 1920x1200.
I can not keep moving mouse down...
It only sporadically responds.
Up left and right are fine, but down kind of freezes.

Is it a OIS bug or can I do something about this???

I use a lot of energy with stupid bugs like this, for something simple as moving a scenenode around in the world...
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

Small update:
When I run ogre samples the same bug appears.

It is very annoying not being able to use mouse correct in highest resolution...

Googled a bit and think this might be the problem.
http://www.wreckedgames.com/forum/index.php?topic=999.0

Anybody else have problems with mouse in high resolution or know a solution?
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I still get that axis aligned box error, just by moving my camera around.

This sucks.

I have checked my position is not very high any more.
This is the last five frames with my scenenode position before the crash...
Vector3(1082.62, 1902.77, -221.633)
Vector3(1083.46, 1903.33, -221.527)
Vector3(1084.27, 1903.88, -221.423)
Vector3(1085.54, 1904.72, -221.261)
Vector3(1086.39, 1905.29, -221.152)
This should be ok, I would say.

I am not moving anything else.

So there are two problems now...

This axis aligned error still for some object, can I somehow get more info on what object crashes?

And OIS mouse x11 bug I will make new thread for that.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

OK I think I figured out the problem.

When I load my scene file I do this...
x = strtod( Xposition );

Now in my scene file I have this...
<position y="0.000003" x="-0.000009" z="1.399937" />

Which put in to ogre with strtod becomes to this...
X -9e-06
Y 3e-06
Z 1.39994

This looks a lot like the error I get when moving a scenenode too far away.
So I guess I will have to get strtod to read the values correctly into ogre.
If anybody has some knowledge on the best way to get a position string converted to a double, I would find that interesting.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

Tried getting double and strtod to keep precision.

When I do this...
char str[] = "0.0009";
double num = atof(str);
Outputting num is 0.0009


char str[] = "0.00009";
double num = atof(str);
Outputting num is 9e-05

I want num to be 0.00009 as it is originally.

Why is double changed to 9e-05 when I have more than 4 decimals?
And how is this changed?
PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by PhilipLB »

That's a scientific notation and means the same.
9e-05 is 9 * 10^(-5) which is 0.0009
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I left 9e-05 as it was.

But I still get crashes.
Can it be because I parent lights to an object?

I can not seem to track which vector causes crashes.
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by duststorm »

OGREHEAD wrote:I can not seem to track which vector causes crashes.
Try debugging and tracing back a stacktrace when it crashes to find the source of the problem.

eg. it crashes at BoundingBox::setBounds()
find out what the parameters were from that call.
Going up, where did they come from, what is the old value and the new one, where did min become > max (probably somewhere at a very small number, deducted by another, causing an overflow).
Developer @ MakeHuman.org
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

How do I trace back a stacktrace?

Only error I get is in terminal, which is the axisaligned error.

I think it is when I make a light child to a object I move around.

But how else can I get more detail about what exactly causes crash other than terminal?
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by duststorm »

By learning to use a C++ debugger.
Developer @ MakeHuman.org
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

I finally managed to trace the problem.
When I export scene from blender my spot has this for inner outer
outer="0.8726648688316345" inner="0.7417651333054014"
But ogre expects this for setspotlightrange.
setSpotlightRange(Ogre::Degree(35), Ogre::Degree(50));

So how should I convert what blender produces?
What is blender's notation / measurement for inner outer?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by jacmoe »

Nice debugging - but: how do you get it out of Blender?
Your own exporter?
Or one provided by others?

If the latter, please submit a bug report so that they can fix it.
Even better: fix it and send in a patch.
This is something which needs to be fixed in the exporter.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Error - OgreAxisAlignedBox.h:252 - OGRE CRASHES

Post by OGREHEAD »

It is the blender2ogre plugin version 0.5.5...
It is when I create a spot light.
Inner / Outer range attribute in exported dotscene file becomes 0-1.
In blender it is only possible to choose angle, not inner / outer range, I think I was able to give that in earlier vesion.
In older blender and blender2ogre version I had it became like 30 - 90 or similar.
I will try newer blender2ogre version, I see there is one uploaded.
Post Reply