v2 Mesh with name already exists, after clearing

Problems building or running the engine, queries about how to use features etc.
Post Reply
lib3d
Gnoblar
Posts: 4
Joined: Mon Nov 23, 2020 11:38 pm

v2 Mesh with name already exists, after clearing

Post by lib3d »

Ogre Version: 2.2.3
Operating System: linux
Render System: opengl3+

I'm clearing my scene using this code.

Code: Select all

        if (sceneManager) {
            sceneManager->clearScene(false, true);
            sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->
                removeAndDestroyAllChildren();
            sceneManager->destroyAllItems();
            sceneManager->destroyAllManualObjects();
        }
It does work, but when I try to recreate my object using createManual ...

Code: Select all

Ogre::MeshManager::getSingleton().createManual(obj.getName(),
            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
I get this error.

Code: Select all

terminate called after throwing an instance of 'Ogre::ItemIdentityException'
  what():  OGRE EXCEPTION(4:ItemIdentityException): v2 Mesh with name 'House1' already exists. in MeshManager::createManual at /home/dev/ogre-2.2/OgreMain/src/OgreMeshManager2.cpp (line 144)
Any idea?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: v2 Mesh with name already exists, after clearing

Post by dark_sylinc »

clearScene does not destroy meshes, as meshes are not part of any scene. They're resources.

If you wish to destroy them too, you'd need to call Ogre::MeshManager::getSingleton().remove() on each one of them
lib3d
Gnoblar
Posts: 4
Joined: Mon Nov 23, 2020 11:38 pm

Re: v2 Mesh with name already exists, after clearing

Post by lib3d »

I've called MeshManager::getSingleton().remove() on each mesh resource, but still get this error when recreating it.

Code: Select all

terminate called after throwing an instance of 'Ogre::ItemIdentityException'
  what():  OGRE EXCEPTION(4:ItemIdentityException): v2 Mesh with name 'House1' already exists. in MeshManager::createManual at /home/dev/ogre-2.2/OgreMain/src/OgreMeshManager2.cpp (line 144)
So, since it's a resource from the MeshManager, I tried to iterate all it's resources to remove them.

Code: Select all

Ogre::MeshManager *meshManager = Ogre::MeshManager::getSingletonPtr();

Ogre::ResourceManager::ResourceMapIterator mapIt =
    meshManager->getResourceIterator();

while (mapIt.hasMoreElements()) {
    Ogre::ResourcePtr resourcePtr = mapIt.getNext();

    meshManager->remove(resourcePtr);
}

// even this doesn't do it.
Ogre::MeshManager::getSingletonPtr()->removeAll();
But that doesn't do it. I'm at a loss on how to be able to recreate an object that I previously cleared. I've tried many things.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: v2 Mesh with name already exists, after clearing

Post by dark_sylinc »

What you're doing should work.

Either you're calling the methods from another thread (race condition) or you're accidentally creating the resource again shortly after being removed; and you didn't notice it.

Or Ogre has a really obscure bug. Try to see if you can repro this issue in any of the samples so I can take a look.

Cheers
Matias
Xonauqa
Gnoblar
Posts: 5
Joined: Thu Apr 22, 2021 4:34 am

Re: v2 Mesh with name already exists, after clearing

Post by Xonauqa »

Did you ever get to the bottom of this, have the same problem. The mesh is still in the ResourceManager when create is called.
Post Reply