[SceneNode::_update] Intended behaviour?

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

[SceneNode::_update] Intended behaviour?

Post by Xavyiy »

Hi all!

I've been the whole day fighting with a strange bug in my engine, and after hours of debugging it's due an -extrange, dunno if intended- Ogre behaviour.
The fact is that if you follow the next steps, you'll get a visible scene node even if it's not in the scene graph:

Code: Select all

Ogre::Entity* e = mSceneMgr->createEntity("Test", Ogre::SceneManager::PT_SPHERE);
Ogre::SceneNode* sn = mSceneMgr->createSceneNode(); // Note that this node doesn't belong to the scene graph, it's just an unattached node
sn->attachObject(e);
sn->attachChild(...)
sn->setPosition(4,0,0);
sn->_update(true,false); // !!!
If you invoke _update(...), it'll update the children node tranforms but a side effect is that this unattached node associated geometry is going to be rendered like if it was a node attached to the root scene node.

My intention by calling _update(...) is to update the children global transforms in order to use them for some calcs.

Am I skipping something? Is this the expected behaviour? Because it looks a bad one to me.

Xavier
Last edited by Xavyiy on Thu Jun 14, 2012 4:14 pm, edited 1 time in total.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

Re: [SceneNode::_update] Intended behaviour?

Post by Klaim »

Looks like a bad merge to me...
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: [SceneNode::_update] Intended behaviour?

Post by Wolfmanfx »

Can you test this
File:OgreOctreeNode.cpp

Code: Select all

     //update the OctreeSceneManager that things might have moved.
     // if it hasn't been added to the octree, add it, and if has moved
     // enough to leave it's current node, we'll update it.
-    if ( ! mWorldAABB.isNull() )
+    if ( ! mWorldAABB.isNull() && mIsInSceneGraph)
     {
         static_cast < OctreeSceneManager * > ( mCreator ) -> _updateOctreeNode( this );
     }

User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: [SceneNode::_update] Intended behaviour?

Post by Xavyiy »

@Wolfmanfx
That does the trick! Thank a lot!
It'll be cool if you could make a pull request, I'm not a bitbucket member yet =)

Xavier
User avatar
m2codeGEN
Halfling
Posts: 52
Joined: Tue Apr 26, 2011 9:13 am
Location: Russia, Tver
x 2

Re: [SceneNode::_update] Intended behaviour?

Post by m2codeGEN »

May be best to rename topic to [OctreeSceneNode::_update] ?
Let`s paid attention to _findVisibleObjects implementation. In our engine we overload SceneManager and collect objects from root sceneNode
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: [SceneNode::_update] Intended behaviour?

Post by Wolfmanfx »

The problem is that _updateOctreeNode is adding the node to a octant without checking it (if its attached to the scenegraph) - but this was always the same :)
The best thing would if you make a bug entry so it do not get lost.
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: [SceneNode::_update] Intended behaviour?

Post by Xavyiy »

Well, I've tried for many times to submit a bug entry in mantis but I'm always getting the following error:

Code: Select all

APPLICATION ERROR #2800
Invalid form security token. Did you submit the form twice by accident?
And not, I'm not submitted the form twice ;)

I've tried in both Chrome and IE.

If someome is able to sumbit an entry, here are the relevant fields:

Summary

Code: Select all

OctreeSceneNode::_update bug
Description

Code: Select all

OctreeSceneNode::_update(...) works as expected but even if the node is not in the scene graph (the ultimate ancestor is not the root scene node, it's just unnatached) the associated geometry is going to be rendered like if it was a node attached to the root scene node.

(Fix included)

Forum thread: http://ogre3d.org/forums/viewtopic.php?f=4&t=70617
Additional Information

Code: Select all

File: OgreOctreeNode.cpp

-    if ( ! mWorldAABB.isNull() )
+    if ( ! mWorldAABB.isNull() && mIsInSceneGraph)
     {
         static_cast < OctreeSceneManager * > ( mCreator ) -> _updateOctreeNode( this );
     }
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: [SceneNode::_update] Intended behaviour?

Post by masterfalcon »

Thanks! I'll check this out sometime next week when I"m bug fixing.