Page 2 of 2

Posted: Sat May 22, 2010 8:24 pm
by BrianATSI
bitplane wrote:Sounds like you've found a bug, removing the mesh should work. We only added removeUnusedMeshes for people who have a huge scene and wanted to clear down their cache (it removes all meshes with a reference count of 1, ie, those which belong only to the mesh cache).

If the size of the mesh cache doesn't change after doing

Code: Select all

smgr->getMeshCache()->removeMesh(mesh1); 
then that must be a bug!
I have had similar issues. I think I found the problem, but not sure how I should approach the fix.

->removeMesh(mesh);

I drill down to the code in trace and notice it does a compare like this...

Code: Select all

		
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
		{
			Meshes[i].Mesh->drop();
			Meshes.erase(i);
			return;
		}
The problem is that it compares an IMesh* to the first frame of an SAnimatedMesh so it never removes the mesh, the address of the IMesh* and the pointer to the first frame of the SAnimatedMesh seems to be different. Does the mesh cache only contain SAnimatedMesh meshes?

Posted: Sat May 22, 2010 8:58 pm
by bitplane
No, the mesh cache can also contain other types of animated meshes.

I guess that this wrong usage anyway, trying to remove a mesh from the mesh cache but actually using the pointer to animMesh->getMesh(0) rather than the original animated mesh pointer. Perhaps not a bug after all, maybe a doc update is needed to prevent other people from making this mistake.

Posted: Sat May 22, 2010 9:10 pm
by BrianATSI
bitplane wrote:No, the mesh cache can also contain other types of animated meshes.

I guess that this wrong usage anyway, trying to remove a mesh from the mesh cache but actually using the pointer to animMesh->getMesh(0) rather than the original animated mesh pointer. Perhaps not a bug after all, maybe a doc update is needed to prevent other people from making this mistake.
So what would be proper way? If all I have is a pointer to an IMesh then I can't do ->removeMesh(imesh->getMesh(0)); because that function is only for SAnimatedMesh. Does CMeshCache not contain SMesh meshes?
I would have to recast based on mesh type, right?