[no bug]MeshCache bug?

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
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

[no bug]MeshCache bug?

Post by RdR »

Hello all,

I've encountered a weird problem manually adding meshes to the mesh cache.

I simplified my code to the following and still crashes when trying to get the mesh name of mesh2

Code: Select all

 
        scene::IMesh* mesh1 = smgr->getMesh("media/tank_armor.b3d");
        scene::SMesh* newMesh = new scene::SMesh();
        smgr->getMeshCache()->addMesh("randomName", (scene::IAnimatedMesh*) newMesh); // If i remove this line, everything works perferctly
 
        scene::IMesh* mesh2 = smgr->getMesh("media/tank_turret.b3d");
        smgr->getMeshCache()->getMeshName(mesh1);
        smgr->getMeshCache()->getMeshName(mesh2); // Crash here
 
What am i doing wrong here?

Testcase:

Code: Select all

 
#include <irrlicht.h>
#include "driverChoice.h"
 
using namespace irr;
 
int main() {
        // ask user for driver
        //video::E_DRIVER_TYPE driverType = driverChoiceConsole();
        video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
        if (driverType == video::EDT_COUNT)
                return 1;
 
        // create device with full flexibility over creation parameters
        // you can add more parameters if desired, check irr::SIrrlichtCreationParameters
        irr::SIrrlichtCreationParameters params;
        params.DriverType = driverType;
        params.WindowSize = core::dimension2d<u32>(1024, 768);
        params.Bits = 32;
        IrrlichtDevice* device = createDeviceEx(params);
 
        if (device == 0)
                return 1; // could not create selected driver.
 
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
        gui::IGUIEnvironment* env = device->getGUIEnvironment();
 
        // Some meshes
        scene::IMesh* mesh1 = smgr->getMesh("media/tank_armor.b3d");
        scene::SMesh* newMesh = new scene::SMesh();
        smgr->getMeshCache()->addMesh("randomName", (scene::IAnimatedMesh*) newMesh);
 
        scene::IMesh* mesh2 = smgr->getMesh("media/tank_turret.b3d");
        smgr->getMeshCache()->getMeshName(mesh1);
        smgr->getMeshCache()->getMeshName(mesh2); // Crash here
 
        while (device->run()) {
                if (device->isWindowActive()) {
                        driver->beginScene(true, true, 0);
 
                        smgr->drawAll();
 
                        env->drawAll();
 
                        driver->endScene();
                }
        }
 
        device->drop();
 
        return 0;
}
 
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: MeshCache bug?

Post by hybrid »

Will test later. Moving to bug reports for now.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: MeshCache bug?

Post by RdR »

hybrid wrote:Will test later. Moving to bug reports for now.
Oke will wait for that.
I think it has something to do with looping through the meshes in the MeshCache, that somehow the added mesh is null :?:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: MeshCache bug?

Post by hybrid »

Not really, it's just not an IAnimatedMesh. The mesh cache can only handle animated meshes. You cast the mesh to an animated mesh. But still, it's not such a mesh. Inside, the cache tries to call a method from the animated mesh class, which will obviously not work. If you want to store the mesh in the cache, add an animated mesh around it. There's a method in the MeshManipulator which automatically adds the proper class, or you do it manually.
Still, I'm currently thinking about a way to add both types to the cache, or make the class hierarchy integrating better here. Any ideas anyone?
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: MeshCache bug?

Post by RdR »

hybrid wrote:Not really, it's just not an IAnimatedMesh. The mesh cache can only handle animated meshes. You cast the mesh to an animated mesh. But still, it's not such a mesh. Inside, the cache tries to call a method from the animated mesh class, which will obviously not work. If you want to store the mesh in the cache, add an animated mesh around it. There's a method in the MeshManipulator which automatically adds the proper class, or you do it manually.
Still, I'm currently thinking about a way to add both types to the cache, or make the class hierarchy integrating better here. Any ideas anyone?
Thanks for replying, using createAnimatedMesh() from the MeshManipulator did the trick!
Post Reply