Manual LOD mesh not found: FNFexception instead of assert

Minor issues with the Ogre API that can be trivial to fix
Post Reply
jonim8or
Goblin
Posts: 287
Joined: Mon Dec 08, 2008 4:49 pm

Manual LOD mesh not found: FNFexception instead of assert

Post by jonim8or » Wed Sep 28, 2011 10:12 am

I'm using manual LOD's for my meshes. Now that I am re-organizing my resources, I found out that if the path to the lower LOD meshes is not correct, an assertion fails. (due to an Ogre::SharedPtr that's being used while NULL)
The problem with assertion failures is that you can't catch them the way you catch exceptions. I suggest the following lines (175+) in OgreEntity.cpp to add a check for validity of the LOD mesh:

Code: Select all

	// Check if mesh is using manual LOD
		if (mMesh->isLodManual())
		{
			ushort i, numLod;
			numLod = mMesh->getNumLodLevels();
			// NB skip LOD 0 which is the original
			for (i = 1; i < numLod; ++i)
			{
				const MeshLodUsage& usage = mMesh->getLodLevel(i);
				if(usage.manualMesh.isNull())
				{
					OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND,
					            "ManualLOD file " + usage.manualName + " not found",
					            "Entity::_initialise");
				}
				else
				{
					// Manually create entity
					Entity* lodEnt = OGRE_NEW Entity(mName + "Lod" + StringConverter::toString(i),
						usage.manualMesh);
					mLodEntityList.push_back(lodEnt);
				}
			}
		}
0 x

Post Reply