i try to make a simple LOD - System for a small Tech Demo using Irrlicht and i run into a huge problem.
I defined 3 LOD-Stages and to achieve the goal, i have to iterate through the SceneNodes and set the Visible-Flag to true or false. So i let me gave the RootSceneNode from the SceneManager, but when the iteration on one Level comes to an end, the destructor off the core::list is called and i don't know why . So i tried to hold the start of the SceneNodes, which are interesting for me in my program, but this didn't helped.
When I run the program, i get a "Debug Assertion Failed", by Debugging the prog i come to the following code, which throws this Assertion
Code: Select all
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
Code: Select all
bool COrionProjekt::setLOD(LevelOfDetail newLevel) {
// still to complete
if (newLevel == m_detail)
return false;
m_detail = newLevel;
if (!m_galaxyRootSceneNode)
return false;
// When I created the SceneNodes, from my Galaxy Data, i created one RootNode for the hole Galaxy. It is an EmptySceneNode, but this problem also accurs, if i get the RootSceneNode from the SceneManager.
core::list<scene::ISceneNode*> galChildList = m_galaxyRootSceneNode->getChildren();
core::list<scene::ISceneNode*>::Iterator galChildIt = galChildList.begin();
for (; galChildIt != galChildList.end(); ++galChildIt) {
// Did we found a System?
if ((*galChildIt)->getID() & EGOT_SYSTEM) {
// GalaxyStructure:
// m_galaxyRootSceneNode---------------------------------------+
// | .... |
// +----------------------SystemNode1-------------------------+ .... SystemNodeX
// | | ...
// +----------StarRootNode--------+ +----------+--- PlanetRootNode
// | | | | ... |
// Star(3D-Model) StarLight StarCorona Planet1 ... PlanetX
// |
// +-----+------+
// | ... |
// Moon1 ... MoonX
switch (m_detail) {
// In the Galaxyview, all Lights of the Stars have to been turned off,
// because i think DirectX supports only 8 LightSources in 1 Scene.
// Also all Planets must be invisible, because there are just too many of them.
case ELOD_GALAXY : {
// iterate through the Childs of this System
// search for the StarLight and the PlanetRootNode, because we want to turn them invisible
core::list<scene::ISceneNode*> sysChildlist = (*galChildIt)->getChildren();
core::list<scene::ISceneNode*>::Iterator sysChildIt = sysChildlist.begin();
for (; sysChildIt != sysChildlist.end(); ++sysChildIt) {
if ((*sysChildIt)->getID() & ERNT_STAR) {
// turn the light off, by calling a function,
// which iterate through the Childs of the StarRootNode
// and if the StarLightNode is found the visible flag is set to false
setStarLight((*sysChildIt), false);
} else if ((*sysChildIt)->getID() & ERNT_PLANET) {
// Because if a Node is invisible, his Childs are also Invisible,
// we need only make the PlanetRootNode invisble
(*sysChildIt)->setVisible(false);
}
}// for SystemChilds
break;
} // case
....
Code: Select all
void COrionProjekt::setStarLight(scene::ISceneNode* node, bool state) {
// Zum Sternenlicht durchhangeln
core::list<scene::ISceneNode*> list = node->getChildren();
core::list<scene::ISceneNode*>::Iterator it = list.begin();
for (; it != list.end(); ++it) {
// Check ob es sich um das Licht handelt
if ((*it)->getID() & ERNT_STAR_LIGHT) {
(*it)->setVisible(state);
return;
}
}
}
Did anyone know what i do wrong? Has someone a suggestion?
Sorry for my bad english , but i hope you understand what my problem is and that someone can help me .
so long
Joe[/code]