Functions in IMeshCache expecting IAnimatedMesh* parameters removed as similar functions with IMesh* can be used since a while. Fixes also problems when IAnimatedMesh* got upcasted to IMesh*. (thx @ Greenya for reporting)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3457 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2010-11-24 21:28:15 +00:00
parent 22e391f814
commit 1e69bb99bc
4 changed files with 11 additions and 130 deletions

View File

@ -1,5 +1,7 @@
Changes in 1.8 (??.0?.2010)
- Functions in IMeshCache expecting IAnimatedMesh* parameters removed as similar functions with IMesh* can be used since a while. Fixes also problems when IAnimatedMesh* got upcasted to IMesh*. (thx @ Greenya for reporting)
- The following functions will now use a "ISceneNode *" instead of a "const ISceneNode *":
ITriangleSelector::getSceneNodeForTriangle, ISceneNodeAnimatorCollisionResponse::getCollisionNode, ISceneCollisionManager::getCollisionPoint and ISceneCollisionManager::getCollisionResultPosition.
As collision functions often are followed by changing node positions users where so far forced to using const_casts (found by Greenya).

View File

@ -49,14 +49,7 @@ namespace scene
this name. */
virtual void addMesh(const io::path& name, IAnimatedMesh* mesh) = 0;
//! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be
removed from the cache using this method, freeing a lot of
memory.
\param mesh Pointer to the mesh which shall be removed. */
virtual void removeMesh(const IAnimatedMesh* const mesh) = 0;
//! Removes a mesh from the cache.
//! Removes the mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be
removed from the cache using this method, freeing a lot of
memory.
@ -71,12 +64,7 @@ namespace scene
\return Number of meshes in cache. */
virtual u32 getMeshCount() const = 0;
//! Returns current index number of the mesh, and -1 if it is not in the cache.
/** \param mesh Pointer to the mesh to search for.
\return Index of the mesh in the cache, or -1 if not found. */
virtual s32 getMeshIndex(const IAnimatedMesh* const mesh) const = 0;
//! Returns current index number of the mesh, and -1 if it is not in the cache.
//! Returns current index number of the mesh or -1 when not found.
/** \param mesh Pointer to the mesh to search for.
\return Index of the mesh in the cache, or -1 if not found. */
virtual s32 getMeshIndex(const IMesh* const mesh) const = 0;
@ -104,13 +92,6 @@ namespace scene
return getMeshName(index).getInternalName();
}
//! Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).
/** \deprecated Use getMeshName() instead. */
_IRR_DEPRECATED_ const io::path& getMeshFilename(const IAnimatedMesh* const mesh) const
{
return getMeshName(mesh).getInternalName();
}
//! Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).
/** \deprecated Use getMeshName() instead. */
_IRR_DEPRECATED_ const io::path& getMeshFilename(const IMesh* const mesh) const
@ -125,13 +106,6 @@ namespace scene
return renameMesh(index, filename);
}
//! Renames a loaded mesh.
/** \deprecated Use renameMesh() instead. */
_IRR_DEPRECATED_ bool setMeshFilename(const IAnimatedMesh* const mesh, const io::path& filename)
{
return renameMesh(mesh, filename);
}
//! Renames a loaded mesh.
/** \deprecated Use renameMesh() instead. */
_IRR_DEPRECATED_ bool setMeshFilename(const IMesh* const mesh, const io::path& filename)
@ -149,12 +123,7 @@ namespace scene
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(u32 index) const = 0;
//! Get the name of a loaded mesh, if there is any.
/** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(const IAnimatedMesh* const mesh) const = 0;
//! Get the name of a loaded mesh, if there is any.
//! Get the name of the loaded mesh if there is any.
/** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(const IMesh* const mesh) const = 0;
@ -168,16 +137,7 @@ namespace scene
\return True if mesh was renamed. */
virtual bool renameMesh(u32 index, const io::path& name) = 0;
//! Renames a loaded mesh.
/** Note that renaming meshes might change the ordering of the
meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change.
\param mesh Mesh to be renamed.
\param name New name for the mesh.
\return True if mesh was renamed. */
virtual bool renameMesh(const IAnimatedMesh* const mesh, const io::path& name) = 0;
//! Renames a loaded mesh.
//! Renames the loaded mesh
/** Note that renaming meshes might change the ordering of the
meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change.

View File

@ -32,23 +32,6 @@ void CMeshCache::addMesh(const io::path& filename, IAnimatedMesh* mesh)
}
//! Removes a mesh from the cache.
void CMeshCache::removeMesh(const IAnimatedMesh* const mesh)
{
if ( !mesh )
return;
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh == mesh)
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
return;
}
}
}
//! Removes a mesh from the cache.
void CMeshCache::removeMesh(const IMesh* const mesh)
{
@ -56,7 +39,7 @@ void CMeshCache::removeMesh(const IMesh* const mesh)
return;
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh))
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
@ -74,23 +57,11 @@ u32 CMeshCache::getMeshCount() const
//! Returns current number of the mesh
s32 CMeshCache::getMeshIndex(const IAnimatedMesh* const mesh) const
{
for (u32 i=0; i<Meshes.size(); ++i)
if (Meshes[i].Mesh == mesh)
return (s32)i;
return -1;
}
//! Returns current index number of the mesh, and -1 if it is not in the cache.
s32 CMeshCache::getMeshIndex(const IMesh* const mesh) const
{
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh))
return (s32)i;
}
@ -116,6 +87,7 @@ IAnimatedMesh* CMeshCache::getMeshByName(const io::path& name)
return (id != -1) ? Meshes[id].Mesh : 0;
}
//! Get the name of a loaded mesh, based on its index.
const io::SNamedPath& CMeshCache::getMeshName(u32 index) const
{
@ -125,20 +97,6 @@ const io::SNamedPath& CMeshCache::getMeshName(u32 index) const
return Meshes[index].NamedPath;
}
//! Get the name of a loaded mesh, if there is any.
const io::SNamedPath& CMeshCache::getMeshName(const IAnimatedMesh* const mesh) const
{
if(!mesh)
return emptyNamedPath;
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh == mesh)
return Meshes[i].NamedPath;
}
return emptyNamedPath;
}
//! Get the name of a loaded mesh, if there is any.
const io::SNamedPath& CMeshCache::getMeshName(const IMesh* const mesh) const
@ -148,9 +106,7 @@ const io::SNamedPath& CMeshCache::getMeshName(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))
if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh))
return Meshes[i].NamedPath;
}
@ -168,28 +124,13 @@ bool CMeshCache::renameMesh(u32 index, const io::path& name)
return true;
}
//! Renames a loaded mesh.
bool CMeshCache::renameMesh(const IAnimatedMesh* const mesh, const io::path& name)
{
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh == mesh)
{
Meshes[i].NamedPath.setPath(name);
Meshes.sort();
return true;
}
}
return false;
}
//! Renames a loaded mesh.
bool CMeshCache::renameMesh(const IMesh* const mesh, const io::path& name)
{
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh))
{
Meshes[i].NamedPath.setPath(name);
Meshes.sort();

View File

@ -32,11 +32,6 @@ namespace scene
\param mesh: Pointer to a mesh which will now be referenced by this name. */
virtual void addMesh(const io::path& filename, IAnimatedMesh* mesh);
//! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be removed from the cache
using this method, freeing a lot of memory. */
virtual void removeMesh(const IAnimatedMesh* const mesh);
//! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be removed from the cache
using this method, freeing a lot of memory. */
@ -48,9 +43,6 @@ namespace scene
removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */
virtual u32 getMeshCount() const;
//! Returns current index number of the mesh, and -1 if it is not in the cache.
virtual s32 getMeshIndex(const IAnimatedMesh* const mesh) const;
//! Returns current index number of the mesh, and -1 if it is not in the cache.
virtual s32 getMeshIndex(const IMesh* const mesh) const;
@ -70,11 +62,6 @@ namespace scene
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(u32 index) const;
//! Get the name of a loaded mesh, if there is any.
/** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(const IAnimatedMesh* const mesh) const;
//! Get the name of a loaded mesh, if there is any.
/** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */
@ -89,15 +76,6 @@ namespace scene
\return True if mesh was renamed. */
virtual bool renameMesh(u32 index, const io::path& name);
//! Renames a loaded mesh.
/** Note that renaming meshes might change the ordering of the
meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change.
\param mesh Mesh to be renamed.
\param name New name for the mesh.
\return True if mesh was renamed. */
virtual bool renameMesh(const IAnimatedMesh* const mesh, const io::path& name);
//! Renames a loaded mesh.
/** Note that renaming meshes might change the ordering of the
meshes, and so the index of the meshes as returned by