为什么将 sceneManager 设置为 sceneNode 的父级会在 Irrlicht 中抛出错误?

Why setting the sceneManager as parent of a sceneNode throws error in Irrlicht?

我在 Irrlicht 中创建了一个 IAnimatedMeshSceneNode,我在使用场景管理器的 addAnimatedMeshSceneNode 函数创建它时设置了空指针。

如愿,动画网格创建成功。当我使用函数 setParent(ISceneNode* parent) 更改此动画节点的父级时,它在父级指向现有节点时起作用。

但是当我再次将 SceneManager 指针设置为动画节点的父级时,或者如果我将其设置为 null 父级时,应用程序崩溃并且我知道执行会在 setParent(mySceneManager) 上抛出错误。

当我的动画节点已经创建时,如何将根节点 (sceneManager) 设置为父节点?

您可以像这样设置 IAnimatedMeshSceneNode 的父节点:

        node->setParent(smgr->getRootSceneNode());

在这种情况下,IAnimatedMeshSceneNode 和 smgr 节点是我的 ISceneManager。

:)