[no bug] Crash on calling IMeshSceneNode::setMesh

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

[no bug] Crash on calling IMeshSceneNode::setMesh

Post by 3DModelerMan »

I'm trying to run this code:

Code: Select all

 
irr::scene::IMesh* roomMesh = smgr->getMesh("Debug/room_mesh.b3d");
        if ( !roomMesh )
                return 1;
 
        CGameEntity* room = gameLogic->createEntity();
        Optional<IComponent*> meshComp = gameLogic->getComponentManager()->createComponent(CT_MESH_NODE);
        if ( !meshComp.isValid() )
                return 1;
 
        room->addComponent(meshComp);
        ((CMeshSceneNodeComponent*)meshComp.var)->setMesh(roomMesh);
 
Basically after going through my entity system it all boils down to a call to IMeshSceneNode::setMesh where it crashes. The setMesh function on my component class is basically just a wrapper for setMesh on the mesh scene node. I tried going around my component system and just doing:

Code: Select all

 
IMeshSceneNode* mesh = smgr->createMeshSceneNode(0);
mesh->setMesh(roomNode);
 
But it's still crashing. I think it's a bug in Irrlicht.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Crash on calling IMeshSceneNode::setMesh with valid data

Post by hybrid »

What is createMeshSceneNode? There's no such method in Irrlicht's API. If you use addMeshSceneNode instead, you have to set the boolean flag which ensures that even though the mesh is null, you get a valid scene node. Otherwise the return value is 0, which you obviously don't check for.
As said elsewhere, bugs in these simple and very basic methods are very unlikely. Better check for faults on your side first.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Re: Crash on calling IMeshSceneNode::setMesh with valid data

Post by 3DModelerMan »

Oh. I didn't see the flag on the last parameter. Thanks.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Post Reply