From 4e840b1c60dc550cc207efd1b0537ba660cb38cd Mon Sep 17 00:00:00 2001 From: bitplane Date: Thu, 6 Nov 2008 17:46:04 +0000 Subject: [PATCH] ISceneNode::addChild now recursively updates SceneManager pointers if the node was from another SceneManager. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1700 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 4 +++- include/ISceneNode.h | 15 +++++++++++++++ source/Irrlicht/CSceneManager.cpp | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index c52ae475..eb730ae6 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ Changes in version 1.5 (... 2008) + - ISceneNode::setParent and addChild now updates node SceneManager pointers if the node was from another SceneManager. + - Basic support for joystick input events on Windows, Linux and SDL devices. - Major API change: RTTs are now created via addRenderTargetTexture instead of createRenderTargetTexture, which allows to retrieve them from the texture cache, but also changes the way of removing the RTTs, and especially one must not drop the pointer anymore. @@ -1302,7 +1304,7 @@ Changes in version 0.14.0 (30 November 2005) - Lights now draw their bounding box and radius when debugdata is set to visible for them. -- Upgraded to irrXML 1.2. Thanks to some hints by Patrik Müller, irrXML, the XML parser used +- Upgraded to irrXML 1.2. Thanks to some hints by Patrik Mller, irrXML, the XML parser used by the Irrlicht Engine now has CDATA support and some other useful new features. - Support for VisualC++ (Express) 2005. Added a project file and a IrrlichtPropsVC2005.vsprops diff --git a/include/ISceneNode.h b/include/ISceneNode.h index e9e9e78b..741eb11c 100644 --- a/include/ISceneNode.h +++ b/include/ISceneNode.h @@ -248,6 +248,10 @@ namespace scene { if (child && (child != this)) { + // Change scene manager? + if (SceneManager != child->SceneManager) + child->setSceneManager(SceneManager); + child->grab(); child->remove(); // remove from old parent Children.push_back(child); @@ -717,6 +721,17 @@ namespace scene } } + //! Sets the new scene manager for this node and all children. + //! Called by addChild when moving nodes between scene managers + void setSceneManager(ISceneManager* newManager) + { + SceneManager = newManager; + + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->setSceneManager(newManager); + } + //! Name of the scene node. core::stringc Name; diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index 3acc7bcf..04e9a318 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -170,6 +170,9 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, ISceneNode::setDebugName("CSceneManager ISceneNode"); #endif + // root node's scene manager + SceneManager = this; + if (Driver) Driver->grab();