Commit 1e69bb99 authored by cutealien's avatar cutealien

Functions in IMeshCache expecting IAnimatedMesh* parameters removed as similar...

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
parent 22e391f8
Changes in 1.8 (??.0?.2010) 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 *": - The following functions will now use a "ISceneNode *" instead of a "const ISceneNode *":
ITriangleSelector::getSceneNodeForTriangle, ISceneNodeAnimatorCollisionResponse::getCollisionNode, ISceneCollisionManager::getCollisionPoint and ISceneCollisionManager::getCollisionResultPosition. 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). As collision functions often are followed by changing node positions users where so far forced to using const_casts (found by Greenya).
......
...@@ -49,14 +49,7 @@ namespace scene ...@@ -49,14 +49,7 @@ namespace scene
this name. */ this name. */
virtual void addMesh(const io::path& name, IAnimatedMesh* mesh) = 0; virtual void addMesh(const io::path& name, IAnimatedMesh* 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.
\param mesh Pointer to the mesh which shall be removed. */
virtual void removeMesh(const IAnimatedMesh* const mesh) = 0;
//! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be /** After loading a mesh with getMesh(), the mesh can be
removed from the cache using this method, freeing a lot of removed from the cache using this method, freeing a lot of
memory. memory.
...@@ -71,12 +64,7 @@ namespace scene ...@@ -71,12 +64,7 @@ namespace scene
\return Number of meshes in cache. */ \return Number of meshes in cache. */
virtual u32 getMeshCount() const = 0; virtual u32 getMeshCount() 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 IAnimatedMesh* const mesh) 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. /** \param mesh Pointer to the mesh to search for.
\return Index of the mesh in the cache, or -1 if not found. */ \return Index of the mesh in the cache, or -1 if not found. */
virtual s32 getMeshIndex(const IMesh* const mesh) const = 0; virtual s32 getMeshIndex(const IMesh* const mesh) const = 0;
...@@ -104,13 +92,6 @@ namespace scene ...@@ -104,13 +92,6 @@ namespace scene
return getMeshName(index).getInternalName(); 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). //! Get the name of a loaded mesh, if there is any. (Name is often identical to the filename).
/** \deprecated Use getMeshName() instead. */ /** \deprecated Use getMeshName() instead. */
_IRR_DEPRECATED_ const io::path& getMeshFilename(const IMesh* const mesh) const _IRR_DEPRECATED_ const io::path& getMeshFilename(const IMesh* const mesh) const
...@@ -125,13 +106,6 @@ namespace scene ...@@ -125,13 +106,6 @@ namespace scene
return renameMesh(index, filename); 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. //! Renames a loaded mesh.
/** \deprecated Use renameMesh() instead. */ /** \deprecated Use renameMesh() instead. */
_IRR_DEPRECATED_ bool setMeshFilename(const IMesh* const mesh, const io::path& filename) _IRR_DEPRECATED_ bool setMeshFilename(const IMesh* const mesh, const io::path& filename)
...@@ -149,12 +123,7 @@ namespace scene ...@@ -149,12 +123,7 @@ namespace scene
\return The name if mesh was found and has a name, else the path is empty. */ \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; virtual const io::SNamedPath& getMeshName(u32 index) 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 IAnimatedMesh* const mesh) const = 0;
//! Get the name of a loaded mesh, if there is any.
/** \param mesh Pointer to mesh to query. /** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */ \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; virtual const io::SNamedPath& getMeshName(const IMesh* const mesh) const = 0;
...@@ -168,16 +137,7 @@ namespace scene ...@@ -168,16 +137,7 @@ namespace scene
\return True if mesh was renamed. */ \return True if mesh was renamed. */
virtual bool renameMesh(u32 index, const io::path& name) = 0; virtual bool renameMesh(u32 index, 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.
\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.
/** Note that renaming meshes might change the ordering of the /** Note that renaming meshes might change the ordering of the
meshes, and so the index of the meshes as returned by meshes, and so the index of the meshes as returned by
getMeshIndex() or taken by some methods will change. getMeshIndex() or taken by some methods will change.
......
...@@ -32,23 +32,6 @@ void CMeshCache::addMesh(const io::path& filename, IAnimatedMesh* mesh) ...@@ -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. //! Removes a mesh from the cache.
void CMeshCache::removeMesh(const IMesh* const mesh) void CMeshCache::removeMesh(const IMesh* const mesh)
{ {
...@@ -56,7 +39,7 @@ void CMeshCache::removeMesh(const IMesh* const mesh) ...@@ -56,7 +39,7 @@ void CMeshCache::removeMesh(const IMesh* const mesh)
return; return;
for (u32 i=0; i<Meshes.size(); ++i) 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[i].Mesh->drop();
Meshes.erase(i); Meshes.erase(i);
...@@ -74,23 +57,11 @@ u32 CMeshCache::getMeshCount() const ...@@ -74,23 +57,11 @@ u32 CMeshCache::getMeshCount() const
//! Returns current number of the mesh //! 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 s32 CMeshCache::getMeshIndex(const IMesh* const mesh) const
{ {
for (u32 i=0; i<Meshes.size(); ++i) 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; return (s32)i;
} }
...@@ -116,6 +87,7 @@ IAnimatedMesh* CMeshCache::getMeshByName(const io::path& name) ...@@ -116,6 +87,7 @@ IAnimatedMesh* CMeshCache::getMeshByName(const io::path& name)
return (id != -1) ? Meshes[id].Mesh : 0; return (id != -1) ? Meshes[id].Mesh : 0;
} }
//! Get the name of a loaded mesh, based on its index. //! Get the name of a loaded mesh, based on its index.
const io::SNamedPath& CMeshCache::getMeshName(u32 index) const const io::SNamedPath& CMeshCache::getMeshName(u32 index) const
{ {
...@@ -125,20 +97,6 @@ const io::SNamedPath& CMeshCache::getMeshName(u32 index) const ...@@ -125,20 +97,6 @@ const io::SNamedPath& CMeshCache::getMeshName(u32 index) const
return Meshes[index].NamedPath; 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. //! Get the name of a loaded mesh, if there is any.
const io::SNamedPath& CMeshCache::getMeshName(const IMesh* const mesh) const const io::SNamedPath& CMeshCache::getMeshName(const IMesh* const mesh) const
...@@ -148,9 +106,7 @@ 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) for (u32 i=0; i<Meshes.size(); ++i)
{ {
// IMesh may actually be an IAnimatedMesh, so do a direct comparison if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh))
// 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].NamedPath; return Meshes[i].NamedPath;
} }
...@@ -168,28 +124,13 @@ bool CMeshCache::renameMesh(u32 index, const io::path& name) ...@@ -168,28 +124,13 @@ bool CMeshCache::renameMesh(u32 index, const io::path& name)
return true; 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. //! Renames a loaded mesh.
bool CMeshCache::renameMesh(const IMesh* const mesh, const io::path& name) bool CMeshCache::renameMesh(const IMesh* const mesh, const io::path& name)
{ {
for (u32 i=0; i<Meshes.size(); ++i) 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[i].NamedPath.setPath(name);
Meshes.sort(); Meshes.sort();
......
...@@ -32,11 +32,6 @@ namespace scene ...@@ -32,11 +32,6 @@ namespace scene
\param mesh: Pointer to a mesh which will now be referenced by this name. */ \param mesh: Pointer to a mesh which will now be referenced by this name. */
virtual void addMesh(const io::path& filename, IAnimatedMesh* mesh); 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. //! Removes a mesh from the cache.
/** After loading a mesh with getMesh(), the mesh can be removed 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. */ using this method, freeing a lot of memory. */
...@@ -48,9 +43,6 @@ namespace scene ...@@ -48,9 +43,6 @@ namespace scene
removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */
virtual u32 getMeshCount() const; 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. //! Returns current index number of the mesh, and -1 if it is not in the cache.
virtual s32 getMeshIndex(const IMesh* const mesh) const; virtual s32 getMeshIndex(const IMesh* const mesh) const;
...@@ -70,11 +62,6 @@ namespace scene ...@@ -70,11 +62,6 @@ namespace scene
\return The name if mesh was found and has a name, else the path is empty. */ \return The name if mesh was found and has a name, else the path is empty. */
virtual const io::SNamedPath& getMeshName(u32 index) const; 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. //! Get the name of a loaded mesh, if there is any.
/** \param mesh Pointer to mesh to query. /** \param mesh Pointer to mesh to query.
\return The name if mesh was found and has a name, else the path is empty. */ \return The name if mesh was found and has a name, else the path is empty. */
...@@ -89,15 +76,6 @@ namespace scene ...@@ -89,15 +76,6 @@ namespace scene
\return True if mesh was renamed. */ \return True if mesh was renamed. */
virtual bool renameMesh(u32 index, const io::path& name); 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. //! Renames a loaded mesh.
/** Note that renaming meshes might change the ordering of the /** Note that renaming meshes might change the ordering of the
meshes, and so the index of the meshes as returned by meshes, and so the index of the meshes as returned by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment