PCZSceneManager is missing destroySceneNode() by pointer

Minor issues with the Ogre API that can be trivial to fix
noorus
Halfling
Posts: 75
Joined: Wed Apr 20, 2011 9:55 pm
Location: Helsinki, Finland
x 3

PCZSceneManager is missing destroySceneNode() by pointer

Post by noorus »

I know PCZSM has it's own forum, but since it's still part of the official repository, and since this is clearly a papercut, I decided to post here.

PCZSM implements SceneManager's destroySceneNode(const String& name), but not the direct destroySceneNode(SceneNode* sn).
This is quite annoying, since when you manage your nodes by pointer, you'll have to do pScene->destroySceneNode(pNode->getName()) when you want to destroy one.

And here is the bugtracker entry.
Creator of Nice Input Library, for your advanced input needs.
Image
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: PCZSceneManager is missing destroySceneNode() by pointer

Post by masterfalcon »

Are you building from source? Try making these changes.

In OgrePCZSceneManager.cpp:

Code: Select all

    // Destroy a Scene Node by name.
    void PCZSceneManager::destroySceneNode( const String &name )
    {
        SceneNode * on = ( getSceneNode( name ) );

        if ( on != 0 )
		{
            // destroy the node
            destroySceneNode( on );
		}
    }
    
    // Destroy a scene node
    void PCZSceneManager::destroySceneNode(SceneNode* sn)
    {
        if ( sn != 0 )
		{
			// remove references to the node from zones
            removeSceneNode( sn );
		}
        
		// destroy the node
        SceneManager::destroySceneNode( sn );
    }
In OgrePCZSceneManager.h:

Code: Select all

        /** Deletes a scene node & corresponding PCZSceneNode */
        virtual void destroySceneNode(SceneNode* sn);
noorus
Halfling
Posts: 75
Joined: Wed Apr 20, 2011 9:55 pm
Location: Helsinki, Finland
x 3

Re: PCZSceneManager is missing destroySceneNode() by pointer

Post by noorus »

masterfalcon wrote:Are you building from source? Try making these changes.
Yes, I have actually written the method myself locally, and was thinking of rolling up a patch for the bugtracker entry.
Isn't the null-pointer check pretty pointless, though? I mean in the removeSceneNode part.
Creator of Nice Input Library, for your advanced input needs.
Image
noorus
Halfling
Posts: 75
Joined: Wed Apr 20, 2011 9:55 pm
Location: Helsinki, Finland
x 3

Re: PCZSceneManager is missing destroySceneNode() by pointer

Post by noorus »

So this is fixed now in the 1.8 branch (except for that 0-pointer check). Do changes from the v1-8 branch get periodically merged to the trunk, or how does that work?
Creator of Nice Input Library, for your advanced input needs.
Image
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: PCZSceneManager is missing destroySceneNode() by pointer

Post by masterfalcon »

I left the null pointer check in there because it is important. But yes, on occasion changes are merged back from 1.8 into trunk.