And now the funny part. Before the scenenode is rendered the first time i can change the mesh as often as i want without any problems. And when the app crashes it crashes with a assert error on irr::core::array it tells that the index accesed is to big. Btw this crash appears in ISceneManager::drawAll during the rendering of the registered scenenodes. The crash must be in one of the render functions of the scenenodes, probably in the one that changed the mesh. But i can't find the error.
Ok here is some code which reproduces the bug:
Edit: press a,s,d to change the mesh of last mesh
Code: Select all
#include <irrlicht.h>
using namespace irr;
class Events : public irr::IEventReceiver
{
public:
Events(irr::scene::IAnimatedMeshSceneNode* node, irr::scene::ISceneManager* mm)
{
Node = node;
smgr = mm;
}
bool OnEvent(const irr::SEvent& event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.Key == irr::KEY_KEY_A)
Node->setMesh(smgr->getMesh("show/Naruto.obj"));
else if (event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.Key == irr::KEY_KEY_S)
Node->setMesh(smgr->getMesh("show/Space.obj"));
else if (event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.Key == irr::KEY_KEY_D)
Node->setMesh(smgr->getMesh("show/Tyke.obj"));
Node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
return false;
}
irr::scene::IAnimatedMeshSceneNode* Node;
irr::scene::ISceneManager* smgr;
};
int main()
{
// start up the engine
IrrlichtDevice *device = createDevice(video::EDT_OPENGL,
core::dimension2d<s32>(640,480));
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* scenemgr = device->getSceneManager();
device->setWindowCaption(L"Hello World!");
// load and show quake2 .md2 model
scene::IAnimatedMeshSceneNode* node = scenemgr->addAnimatedMeshSceneNode(
scenemgr->getMesh("show/Naruto.3ds"));
node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
node = scenemgr->addAnimatedMeshSceneNode(
scenemgr->getMesh("show/Space.3ds"), NULL, -1, core::vector3df(50,0,0));
node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
node = scenemgr->addAnimatedMeshSceneNode(
scenemgr->getMesh("show/Tyke.3ds"), NULL, -1, core::vector3df(100,0,0));
node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
Events* events = new Events(node, scenemgr);
device->setEventReceiver(events);
// add a first person shooter style user controlled camera
scenemgr->addCameraSceneNodeFPS();
// draw everything
while(device->run() && driver)
{
driver->beginScene(true, true, video::SColor(255,0,0,255));
scenemgr->drawAll();
driver->endScene();
}
// delete device
device->drop();
return 0;
}
Download