You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
But later on I call ISceneManager::saveScene(filename); and it saves the file alright... but the mesh property in xml has no filename. Everything else appears to save fine but not the mesh filename.
EDIT: oops! irrlicht svn revision 1574 is what I tested with
Last edited by aanderse on Sun Sep 21, 2008 5:35 pm, edited 1 time in total.
//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none.
const c8* CMeshCache::getMeshFilename(const IAnimatedMesh* const mesh) const
{
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh == mesh)
return Meshes[i].Name.c_str();
}
return 0;
}
//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none.
const c8* CMeshCache::getMeshFilename(const IMesh* const mesh) const
{
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
return Meshes[i].Name.c_str();
}
return 0;
}
So in the second function it compares Meshes.Mesh->getMesh(0) to the paramater you pass, mesh. I checked the pointers and Meshes.Mesh is the same value as the parameter mesh which means in my situation the second function should just be comparing Meshes.Mesh and mesh, not Meshes.Mesh->getMesh(0) and mesh (ie. more like the first function).
It could also be that whatever is calling this second function should instead be calling the first function- because if the first function was called it would work fine.
I guess that we need to refactor thw whole MeshCache to IMesh, now that IAnimatedMesh is derived from IMesh. This will also require the ability to check which type of mesh (animated, static, or one of the more specific types) this mesh is, i.e. move getMeshType from IAnimatedMesh to IMesh. Maybe we can also cleanup the mesh types here, because all the minor format types don't help that much, at least if there are no specific properties in a format.
This bug is already tracked, so it won't get lost. However, I'm not sure if it will be resolved until the 1.5 release.
//! Returns the filename of a loaded mesh, if there is any. Returns 0 if there is none.
const c8* CMeshCache::getMeshFilename(const IMesh* const mesh) const
{
for (u32 i=0; i<Meshes.size(); ++i)
{
// IMesh may actually be an IAnimatedMesh, so do a direct comparison
// as well as getting an IMesh from our stored IAnimatedMeshes
if (Meshes[i].Mesh && (Meshes[i].Mesh == mesh || Meshes[i].Mesh->getMesh(0) == mesh))
return Meshes[i].Name.c_str();
}
return 0;
}
We could have that in now, or wait while I investigate the consequences of making IMesh smarterer.
By the way, this is a great bug report, aanderse. I like being pointed at the solution.
Oh yes, the double check looks good for now. This would work for both the basic IMesh structures and those wrapped in an animated mesh. At least as a temporary workaround.