Code: Select all
// ISceneNode's constructor:
ISceneNode( ISceneNode* parent, ISceneManager* mgr, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
: RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale),
Parent(parent), ID(id), SceneManager(mgr), TriangleSelector(0),
AutomaticCullingState(EAC_BOX), IsVisible(true),
DebugDataVisible(EDS_OFF), IsDebugObject(false)
{
if (Parent)
Parent->addChild(this);
//...
}
My suggested solution is to change the constructor of ISceneNode as follows:
Code: Select all
ISceneNode( ISceneNode* parent, ISceneManager* mgr, s32 id=-1,
const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& rotation = core::vector3df(0,0,0),
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
: RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale),
Parent(NULL), ID(id), SceneManager(mgr), TriangleSelector(0),
AutomaticCullingState(EAC_BOX), IsVisible(true),
DebugDataVisible(EDS_OFF), IsDebugObject(false)
{
if (parent)
parent->addChild(this);
updateAbsolutePosition();
}
Code: Select all
virtual void addChild(ISceneNode* child)
{
if (child)
{
child->grab();
child->remove(); // remove from old parent
Children.push_back(child);
child->Parent = this;
}
}
Sorry if this suggestion is no longer relevant for ver. 1.4 but I don't have the time to check if it has changed in the new release.