smgr->drawAll() crash
-
- Posts: 30
- Joined: Thu Mar 16, 2006 6:21 pm
smgr->drawAll() crash
Hello All -
Just a quick question - randomly I get a crash on the smgr->drawAll() line. I presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
Also (while I'm here I occassionally get a message in the console window saying 'Can not draw triangles, too many primitives'. My app rarely draws more than 5 cube nodes and maybe 10 billboards. Is that really enough to cause problems?
Thanks,
Mark.
Just a quick question - randomly I get a crash on the smgr->drawAll() line. I presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
Also (while I'm here I occassionally get a message in the console window saying 'Can not draw triangles, too many primitives'. My app rarely draws more than 5 cube nodes and maybe 10 billboards. Is that really enough to cause problems?
Thanks,
Mark.
Re: smgr->drawAll() crash
No.markanderson wrote: Just a quick question - randomly I get a crash on the smgr->drawAll() line. I presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
Because all people that able to read minds are have a vocation. So demonstration of the source code is highly recommended.
That's why I have no suggestions.
The best thing we could do for you would be to tell you to step into the source with the debugger. Most likely you are dropping something that you shouldn't be or you are removing something from a list while iterating over it.presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
Someone might be able to help you if you posted a stack, but you need to use the debugger to get that.
This happens when you have a mesh that has to many triangles. Most likely you have a really big mesh or terrain. If you are using a terrain scene node, you should use a 129x129 heightmap image. Anything bigger than 256 might fail with this message.I occassionally get a message in the console window saying 'Can not draw triangles, too many primitives'
Travis
-
- Posts: 30
- Joined: Thu Mar 16, 2006 6:21 pm
Thanks
My height map was 256x256 so I've reduced it. The terrain did sometimes flash on and off when the 'too many primitives' message was flashing now that I think of it.
Regarding the crash on smgr->drawAll() I did step through the debugger - and that's the line where it crashed. The call stack didn't help nor did the locales. I accept it's most likely my fault and was just trying to find out if it was indicative of any typical noob mistakes.
I'll go through me ->drop() statements as Travis suggested and see I can find. Thanks again,
Mark.
Regarding the crash on smgr->drawAll() I did step through the debugger - and that's the line where it crashed. The call stack didn't help nor did the locales. I accept it's most likely my fault and was just trying to find out if it was indicative of any typical noob mistakes.
I'll go through me ->drop() statements as Travis suggested and see I can find. Thanks again,
Mark.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
If the app fails at that verx line you either have a corrupted scene manager (quite unlikely, though, that it only happens occasionally) or it happens inside the method. Then you'd have to step inside the method to see where it crashes. So set a breakpoint at that statement and start single stepping.
-
- Posts: 30
- Joined: Thu Mar 16, 2006 6:21 pm
I will try rebuilding the dll in debug mode and stepping through it. That didn't occur to me, thanks vitek.
I'm using the a SVN build (618 I think) and do have a customscenenode Luben. I've pasted the class below, it's from the tutorials and only slightly modified. I've removed the comments for brevity.
I'm calling it like this:
I save the nodeid so that later I can beam->drop() later when I want to get rid of it.
Anything obviously wrong about the above?
I'm using the a SVN build (618 I think) and do have a customscenenode Luben. I've pasted the class below, it's from the tutorials and only slightly modified. I've removed the comments for brevity.
Code: Select all
class CSampleSceneNode : public scene::ISceneNode
{
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[4];
video::SMaterial Material;
public:
CSampleSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, core::vector3df pos_start, core::vector3df pos_end)
: scene::ISceneNode(parent, mgr, id)
{
Material.Wireframe = false;
Material.Lighting = false;
Vertices[0] = video::S3DVertex(pos_end.X,pos_end.Y,pos_end.Z, 1,0,0, video::SColor(255,255,255,255), 1, 1);
Vertices[1] = video::S3DVertex(pos_start.X,pos_start.Y+20,pos_start.Z, 0,1,1, video::SColor(255,255,255,255), 1, 0);
Vertices[2] = video::S3DVertex(pos_start.X+20,pos_start.Y-20,pos_start.Z+20, 0,0,1, video::SColor(255,255,255,255), 0, 0);
Vertices[3] = video::S3DVertex(pos_start.X-20,pos_start.Y-20,pos_start.Z-20, 1,1,0, video::SColor(255,255,255,255), 0, 1);
Box.reset(Vertices[0].Pos);
for (s32 i=1; i<4; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
virtual void OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 4);
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return Box;
}
virtual u32 getMaterialCount()
{
return 1;
}
virtual video::SMaterial& getMaterial(u32 i)
{
return Material;
}
};
Code: Select all
CSampleSceneNode *beam = new CSampleSceneNode(device->getSceneManager()->getRootSceneNode(), device->getSceneManager(), 666, core::vector3df(nodelist[srcnodeid].posx, nodelist[srcnodeid].posy, nodelist[srcnodeid].posz), core::vector3df(nodelist[dstnodeid].posx, nodelist[dstnodeid].posy, nodelist[dstnodeid].posz));
beam->setMaterialTexture(0, device->getVideoDriver()->getTexture("Media/laserbeam.bmp"));
beam->setMaterialFlag(video::EMF_LIGHTING, false);
beam->setID(sessionlist.size()-1+2000);
sessionlist[sessionlist.size()-1].id = (sessionlist.size()-1)+2000;
ISceneManager_assignTriangleSelectors(device->getSceneManager(), device->getFileSystem());
scene::IMetaTriangleSelector* meta = device->getSceneManager()->createMetaTriangleSelector();
ISceneManager_gatherTriangleSelectors(device->getSceneManager(), meta);
scene::ISceneNodeAnimator *anim = device->getSceneManager()->createCollisionResponseAnimator(meta, beam, core::vector3df(3,3,3), core::vector3df(0,0,0), core::vector3df(0,6,0));
beam->addAnimator(anim);
anim->drop();
Anything obviously wrong about the above?
-
- Posts: 30
- Joined: Thu Mar 16, 2006 6:21 pm
Update
I hope nobody minds me reigniting this thread but I have some more information which hopefully will lead to a fix.
I recompiled the Irrlicht DLL in debug mode so that I could walk the call stack when it crashes. The stack is as follows:
Does anyone have any idea what is going on? The crashes seem to happen randomly, usually when the camera is moving (FPS camera) but not when its in contact with any nodes. Although I'm not sure if camera movement is the culprit. I'd really appreciate any help because this is the last big stumbling block for my app.
Thanks,
Mark.
I recompiled the Irrlicht DLL in debug mode so that I could walk the call stack when it crashes. The stack is as follows:
The specific line that causes the crash in CTriangleBBSelector::getTriangles() is:main()
CSceneManager::drawAll()
ISceneNode::OnAnimate()
CCameraFPSSceneNode::OnAnimate()
CSceneNodeAnimatorCollisionResponse::animateNode()
CSceneCollisionManager::getCollisionResultPosition()
CSceneCollisionManager::collideEllipsoidWithWorld()
CSceneCollisionManager::collideWithWorld()
CMetaTriangleSelector::getTriangles()
CTriangleSelector::getTriangles()
CTriangleBBSelector::getTriangles()
Code: Select all
core::aabbox3d<f32> box = SceneNode->getBoundingBox();
Thanks,
Mark.
From the looks of it I'd guess that a scene node has been destroyed, but you haven't removed its triangle selector from the meta selector. This could happen if you removed a scene node from the scene graph, but didn't remove its selector. You can fix it in two ways. You can find the code that removes the node and add a line to remove the selector for that node just before you remove it...
The other option is to clear the meta selector after every render and rebuild it after running any code that may remove scene nodes. I have already posted some sample code here that shows how to do that. The modified gather function has the benefit that it only includes selectors for scene nodes that are near the camera so it avoids searching through many triangles that are nowhere near the camera.
Code: Select all
meta->removeTriangleSelector( node->getTriangleSelector() );
node->remove();
-
- Posts: 30
- Joined: Thu Mar 16, 2006 6:21 pm
Thanks so much!
Thanks vitek - that worked a treat. You're the man! ;]
I knew it would be something stupidly simple. I had no idea I had to remove a node's triangle selector from the meta selector. The irrlicht tutorials are great but they don't really give you a background in 3D development which would have helped. And I'm sure the other n00bs would benefit also.
I knew it would be something stupidly simple. I had no idea I had to remove a node's triangle selector from the meta selector. The irrlicht tutorials are great but they don't really give you a background in 3D development which would have helped. And I'm sure the other n00bs would benefit also.