Changing model during run time?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
BrianATSI
Posts: 23
Joined: Thu Jan 10, 2008 9:00 pm

Post 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?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
BrianATSI
Posts: 23
Joined: Thu Jan 10, 2008 9:00 pm

Post 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?
Post Reply