How can OGRE3D SceneManager really find * any * SceneNode?

TL DR;

As SceneManageranyone can find, SceneNodeno matter where he is on the chart, when:

  • SceneManager::createSceneNode(...)Does the method explicitly state that the created nodes are not part of the graph? ¹ and
  • SceneNodecan create their own children without knowledge SceneManager?

¹ SM does not automatically turn the nodes of the scene that it creates into child nodes of other nodes (for example, root); you need to manually call addChildon node for this

² The client can simply write sceneManager->getRootSceneNode()->createChildSceneNode("Child");, and SM will not know about the existence of a new child


Background

OGRE3D SceneManager ( → < < emphasis added):

/** Retrieves a named SceneNode from the scene graph.
    @remarks
        If you chose to name a SceneNode as you created it, or if you
        happened to make a note of the generated name, you can look it
        up >>wherever it is in the scene graph<< using this method.
        @note Throws an exception if the named instance does not exist
*/
virtual SceneNode* getSceneNode(const String& name) const;

, :

SceneNode* SceneManager::getSceneNode(const String& name) const
{
    SceneNodeList::const_iterator i = mSceneNodes.find(name);

    if (i == mSceneNodes.end())
    {
        OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "SceneNode '" + name + "' not found.",
            "SceneManager::getSceneNode");
    }

    return i->second;
}

. , SM SceneNode SceneNodeList mSceneNodes. , , , , node, . SceneNode mSceneNodes SceneManager::createSceneNode(...). SM createSceneNode ( → < < ):

/** Creates an instance of a SceneNode with a given name.
    @remarks
        Note that this >>does not add the SceneNode to the scene hierarchy<<.
        This method is for convenience, since it allows an instance to
        be created for which the SceneManager is responsible for
        allocating and releasing memory, which is convenient in complex
        scenes.
    @par
        To include the returned SceneNode in the scene, use the addChild
        method of the SceneNode which is to be it parent.
    @par
        Note that this method takes a name parameter, which makes the node easier to
    retrieve directly again later.
*/
virtual SceneNode* createSceneNode(const String& name);

, SceneNode, createChild(const String& name, ...), SceneManager, :

SceneNode* SceneNode::createChildSceneNode(const Vector3& inTranslate,
    const Quaternion& inRotate)
{
    return static_cast<SceneNode*>(this->createChild(inTranslate, inRotate));
}
//-----------------------------------------------------------------------
SceneNode* SceneNode::createChildSceneNode(const String& name, const Vector3& inTranslate,
    const Quaternion& inRotate)
{
    return static_cast<SceneNode*>(this->createChild(name, inTranslate, inRotate));
}

, node.createChildSceneNode(...);, SceneManager node, AFAIK, .

, . BspSceneManager BspSceneNode, , - , .


/ :

commit 3b13abbdcce146b2813a6cc3bedf16d1d6084340
Author: mkultra333 <unknown>
Date:   Sun May 8 19:31:39 2016 +0800
+4
1

, , - . , .

, , , , : Node::createChild :

Node* newNode = createChildImpl( sceneType );
//...
return newNode;

createChildImpl ( "" ). , SceneNode .

SceneNode::createChildImpl, :

Node* SceneNode::createChildImpl(const String& name)
{
    return mCreator->_createSceneNode( name );
}

mCreator SceneManager. , : SceneManager , SceneNode createChildSceneNode.

, (, BspSceneNode BspSceneManager) createChildImpl SceneManager; .

SceneManager::_createSceneNode - .

+4

All Articles