Horde3D
http://horde3d.org/forums/

[solved] SceneManager::removeNode
http://horde3d.org/forums/viewtopic.php?f=3&t=56
Page 1 of 1

Author:  DarkAngel [ 28.03.2007, 09:39 ]
Post subject:  [solved] SceneManager::removeNode

removeNode always returns false, whereas the documentation says it's supposed to return true in case of success, otherwise false.

I just changed the second return statement to return true :wink:

I only noticed this recently when I added assert statements to my code to make sure that all my Horde calls were succeeding :)

Author:  marciano [ 29.03.2007, 10:56 ]
Post subject: 

Thank you! This will be fixed immediately :)

Author:  DarkAngel [ 30.03.2007, 09:18 ]
Post subject: 

One more thing :wink:

In SceneManager::removeNode, when the parent pointer is used it is check to make sure its not null:
Code:
   // Raise event
   if( sn->_parent != 0x0 )  sn->_parent->onDetach( *sn );
but then later in the same function the pointer is used without checking:
Code:
   sn->_parent->markDirty();
should that line actually be like this?:
Code:
   if( sn->_parent != 0x0 )  sn->_parent->markDirty();



----------------
Also, when I reported the "return" bug, I was using 0.8. I've just upgraded my engine to use 0.9, but now it's crashing in SceneManager::removeNode on the 'delete' statement on this line:
Code:
   // Delete node
   delete _nodes[id - 1]; _nodes[id - 1] = 0x0;

The stack trace says: 0x10096865 std::allocator<SceneNode*>::~allocator (C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/bits/allocator.h:103)

I was going to report this as a bug, but if I compile the "chicago" sample, this crash does not happen - it only happens in my code, so I guess I've made a mistake somewhere! I'll let you know when I find out more (I'm guessing I'm calling removeNode twice on the same ID or something like that...).

Author:  DarkAngel [ 31.03.2007, 05:44 ]
Post subject: 

This bug doesn't happen in the Chicago sample because it never calls removeNode!

If I add a member variable named _env to Application, and change this line:
Code:
   Horde3D::addNodes( RootNode, envRes );
to this:
   _env = Horde3D::addNodes( RootNode, envRes );

and then add this line to Application::release:
Code:
void Application::release()
{
   Horde3D::removeNode(_env);

then it crashes on the call to removeNode :cry:
again, the stack trace says std::allocator<SceneNode*>::~allocator and in the Horde code it crashes on the line:
// Delete node
delete _nodes[id - 1]; _nodes[id - 1] = 0x0;

Author:  marciano [ 02.04.2007, 08:35 ]
Post subject: 

Ok thanks. I will look into this issue and tell you when I find the problem. But this can still take some time since I am currently busy with restructuring the renderer.

Author:  marciano [ 05.04.2007, 10:38 ]
Post subject: 

I found the problem. The node to be deleted is not removed from the children list of its parent. Here is a quick fix for the problem. Just insert it between "Remove children" and "Mark dirty".

Code:
// Remove children
for( unsigned int i = 0; i < sn->_children.size(); ++i )
{
   removeNode( sn->_children[i]->_id );
}

// ++++++++++++++++++++++++++++++++++++++++++++++++
// Remove node from parent
if( sn->_parent != 0x0 )
{
   // Find child
   for( unsigned int i = 0; i < sn->_parent->_children.size(); ++i )
   {
      if( sn->_parent->_children[i] == sn )
      {
         sn->_parent->_children.erase(  sn->_parent->_children.begin() + i );
         break;
      }
   }
}
// ++++++++++++++++++++++++++++++++++++++++++++++++

// Mark dirty
if( sn->_parent != 0x0) sn->_parent->markDirty();

Author:  DarkAngel [ 13.04.2007, 04:06 ]
Post subject: 

thank you very much! :D

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/