[closed][2.1] MeshManager::createManual() assert unique name

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
hyyou
Gremlin
Posts: 154
Joined: Wed Feb 03, 2016 2:24 am
x 2

[closed][2.1] MeshManager::createManual() assert unique name

Post by hyyou » Wed Jun 29, 2016 1:52 pm

I am using Ogre 2.1 version around April 2016.

I request a mini fool-proof feature that Ogre should crash when it detects non-unique name when call :-

Code: Select all

Ogre::MeshManager::getSingleton().createManual("must...be...a...unique..name..for..each..meshV2")
Because if I call this >1 times with exactly same name, issues can occur.

Situation that can cause issue

Assume that I have a blender model with embedded invalid material - named material.001.
I loaded it and converted it to V2 two times (to meshPtr & meshPtr2), using exactly same name - "AAA".
Then I reassign meshPtr2 to use another material - named DebugCube as followed:-

Code: Select all

 //this is pseudo code
meshV1 = ....
meshPtr = Ogre::MeshManager::getSingleton().createManual("AAA");   meshPtr ->importV1(meshV1);
meshPtr2 = Ogre::MeshManager::getSingleton().createManual("AAA");  meshPtr2 ->importV1(meshV1);
meshPtr2->getSubMesh(0)->setMaterialName("DebugCube");   
//^^^ Let's assume that DebugCube  is valid && meshPtr2 has only 1 subMesh
Ogre::Item* entity2 = this->mSceneMgr()->createItem(meshPtr2);  

According to my experiment, Ogre sometimes warns "Can't assign material" in the last line, while it should NOT!
Here is the stack when the warning "Can't assign material" occurs:

Code: Select all

OgreMain_d.dll!Ogre::Renderable::setMaterialName Line 156	
OgreMain_d.dll!Ogre::Renderable::setDatablockOrMaterialName Line 83	
OgreMain_d.dll!Ogre::Item::buildSubItems Line 277	
OgreMain_d.dll!Ogre::Item::_initialise Line 112	
OgreMain_d.dll!Ogre::Item::Item Line 71	
OgreMain_d.dll!Ogre::ItemFactory::createInstanceImpl Line 401	
OgreMain_d.dll!Ogre::MovableObjectFactory::createInstance Line 874	
OgreMain_d.dll!Ogre::SceneManager::createMovableObject Line 4871	
OgreMain_d.dll!Ogre::SceneManager::createItem Line 417	
OgreMain_d.dll!Ogre::SceneManager::createItem Line 424	
myCode.exe!Graphic_Factory::newBlenderGraphic Line 76
At the top of stack (OgreRenderable.cpp), here is the situation:-

Code: Select all

void Renderable::setMaterialName( const String& name, const String& groupName )    //<-- name = "Material.001" wrong!
    {
        MaterialPtr material = MaterialManager::getSingleton().getByName( name, groupName );
                  //^^^^^^^^^^ material = {pRep=0x00000000 <NULL> pInfo=0x00000000 <NULL> }
        if( material.isNull() )
        {
            //It output "Can't assign material " .........
In the above code, name should = DebugCube, not Material.001

Inside Ogre, OgreSceneManager.cpp shows that Ogre pass string-name of MeshPtr as parameter
(instead of passing mesh's pointer) :-

Code: Select all

Item* SceneManager::createItem( const MeshPtr& pMesh, SceneMemoryMgrTypes sceneType )
{
    return createItem(pMesh->getName(), pMesh->getGroup(), sceneType);    //<--- passing by string name
}
As a result, Ogre lost trace of meshPtr2 in my code, and retrieved (by some way like hash?) its internal mesh pointer - meshPtr from string-name instead.

In other words, there are 2 meshPtr with the same string-name, it pick-up a wrong one in this case.

This can cause minor hard-to-track bug for user code.
Last edited by hyyou on Fri Jul 01, 2016 11:58 am, edited 1 time in total.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3740
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 130
Contact:

Re: [2.1] MeshManager::createManual() should assert unique n

Post by dark_sylinc » Wed Jun 29, 2016 2:18 pm

I'm moving this to the 2.0+ forum. This is definitely a bug. Behavior should be what you said. Thanks for the report
0 x

Post Reply