Horde3D

Next-Generation Graphics Engine
It is currently 23.11.2024, 04:43

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 28.03.2007, 09:39 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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 :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 29.03.2007, 10:56 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Thank you! This will be fixed immediately :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 30.03.2007, 09:18 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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...).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 31.03.2007, 05:44 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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;


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 02.04.2007, 08:35 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 05.04.2007, 10:38 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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();


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 13.04.2007, 04:06 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
thank you very much! :D


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group