Page 1 of 1

Why is my bounding box null? How do I force an update?

Posted: Thu Apr 21, 2005 4:17 am
by srfnaked99
Looks like the problems I've been running into with collision detection aren't my fault. I have some code that goes as such:

Entity *ent = mSceneMgr->createEntity(...);
SceneNode *node = mSceneMgr->...->createChildSceneNode(entName);

do {
} while (collides(ent));

bool collides(SceneNode *ent) {
list<Entity*>::iterator itr;
AxisAlignedBox myBox = ent->getWorldBoundingBox(), theirBox;

for (itr = mEntList.begin(); itr != mEntList.end(); itr++) {
if ((*itr) == ent)

theirBox = (*itr)->getWorldBoundingBox();

if (myBox.intersects(theirBox))
return true;

return false;

The problem is that although the node's position is being updated, the bounding box of the entity isn't. I looked into it more and found that the bounding boxes for all my entities have mNull=true, even though they have been initialized to their default locations and sizes. This causes the myBox.intersects(...) test to be false regardless of whether the boxes are actually intersecting due to the following lines in OgreAxisAlignedBox.h:

// Early-fail for nulls
if (this->isNull() || b2.isNull())
return false;

I came across SceneNode::needUpdate() but that doesn't seem to fix the problem either. Is there a manual way to force the scene manager to update all the scene nodes and their respective entities/bounding boxes?

What causes a bounding box to be null and how to I change it?

Posted: Thu Apr 21, 2005 4:23 am
by srfnaked99
Never seems to fail. As soon as you make the post you find the solution. Calling node->_update() after setting the position made it work.