Commit 23986b2c authored by hybrid's avatar hybrid

Fixed two things from a previous commit that were not working. Some minor comment changes.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@680 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c4ec0b52
...@@ -207,7 +207,7 @@ struct SEvent ...@@ -207,7 +207,7 @@ struct SEvent
}; };
//! Interface of an object wich can receive events. //! Interface of an object which can receive events.
class IEventReceiver class IEventReceiver
{ {
public: public:
......
...@@ -20,7 +20,7 @@ namespace scene ...@@ -20,7 +20,7 @@ namespace scene
//! The mesh cache stores already loaded meshes and provides an interface to them. //! The mesh cache stores already loaded meshes and provides an interface to them.
/** You can access it using ISceneManager::getMeshCache(). All existing scene managers /** You can access it using ISceneManager::getMeshCache(). All existing scene managers
will return a pointer to the same mesh cache, because it is shared between them. With will return a pointer to the same mesh cache, because it is shared between them. With
this interface, it is possible to manually add new loaded meshes (if this interface, it is possible to manually add new loaded meshes (if
ISceneManager::getMesh() is not sufficient), to remove them and to iterate through ISceneManager::getMesh() is not sufficient), to remove them and to iterate through
already loaded meshes. */ already loaded meshes. */
...@@ -29,7 +29,7 @@ namespace scene ...@@ -29,7 +29,7 @@ namespace scene
public: public:
//! destructor //! destructor
virtual ~IMeshCache() = 0; virtual ~IMeshCache() {};
//! Adds a mesh to the internal list of loaded meshes. //! Adds a mesh to the internal list of loaded meshes.
/** Usually, ISceneManager::getMesh() is called to load a mesh from a file. /** Usually, ISceneManager::getMesh() is called to load a mesh from a file.
...@@ -39,9 +39,9 @@ namespace scene ...@@ -39,9 +39,9 @@ namespace scene
has been loaded. This method can be used for example by mesh loaders who need to has been loaded. This method can be used for example by mesh loaders who need to
load more than one mesh with one call. They can add additional meshes with this load more than one mesh with one call. They can add additional meshes with this
method to the scene manager. The COLLADA loader for example uses this method. method to the scene manager. The COLLADA loader for example uses this method.
\param filename: Filename of the mesh. When called ISceneManager::getMesh() with this \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this
parameter, the method will return the mesh parameter given with this method. parameter, the method will return the mesh parameter given with this method.
\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 c8* filename, IAnimatedMesh* mesh) = 0; virtual void addMesh(const c8* filename, IAnimatedMesh* mesh) = 0;
//! Removes a mesh from the cache. //! Removes a mesh from the cache.
...@@ -55,7 +55,7 @@ namespace scene ...@@ -55,7 +55,7 @@ namespace scene
virtual void removeMesh(const IMesh* const mesh) = 0; virtual void removeMesh(const IMesh* const mesh) = 0;
//! Returns amount of loaded meshes in the cache. //! Returns amount of loaded meshes in the cache.
/** You can load new meshes into the cache using getMesh() and addMesh(). /** You can load new meshes into the cache using getMesh() and addMesh().
If you ever need to access the internal mesh cache, you can do this using If you ever need to access the internal mesh cache, you can do this using
removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */
virtual u32 getMeshCount() const = 0; virtual u32 getMeshCount() const = 0;
...@@ -67,7 +67,7 @@ namespace scene ...@@ -67,7 +67,7 @@ namespace scene
virtual s32 getMeshIndex(const IMesh* const mesh) const = 0; virtual s32 getMeshIndex(const IMesh* const mesh) const = 0;
//! Returns a mesh based on its index number. //! Returns a mesh based on its index number.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1. /** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
Note that this number is only valid until a new mesh is loaded or removed * Note that this number is only valid until a new mesh is loaded or removed *
\return Returns pointer to the mesh or 0 if there is none with this number. */ \return Returns pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByIndex(u32 index) = 0; virtual IAnimatedMesh* getMeshByIndex(u32 index) = 0;
...@@ -76,8 +76,8 @@ namespace scene ...@@ -76,8 +76,8 @@ namespace scene
/** \return Returns pointer to the mesh or 0 if there is none with this number. */ /** \return Returns pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByFilename(const c8* filename) = 0; virtual IAnimatedMesh* getMeshByFilename(const c8* filename) = 0;
//! Returns name of a mesh based on its index number. //! Returns name of a mesh based on its index number.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1. /** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
Note that this is only valid until a new mesh is loaded */ Note that this is only valid until a new mesh is loaded */
virtual const c8* getMeshFilename(u32 index) const = 0; virtual const c8* getMeshFilename(u32 index) const = 0;
...@@ -107,11 +107,11 @@ namespace scene ...@@ -107,11 +107,11 @@ namespace scene
getMeshIndex() or taken by some methods will change. */ getMeshIndex() or taken by some methods will change. */
virtual bool setMeshFilename(const IMesh* const mesh, const c8* filename) = 0; virtual bool setMeshFilename(const IMesh* const mesh, const c8* filename) = 0;
//! returns if a mesh already was loaded //! returns if a mesh already was loaded
virtual bool isMeshLoaded(const c8* filename); virtual bool isMeshLoaded(const c8* filename) = 0;
//! Clears the whole mesh cache, removing all meshes. //! Clears the whole mesh cache, removing all meshes.
/** All meshes will be reloaded completely when using ISceneManager::getMesh() /** All meshes will be reloaded completely when using ISceneManager::getMesh()
after calling this method. */ after calling this method. */
virtual void clear() = 0; virtual void clear() = 0;
}; };
......
...@@ -2071,14 +2071,13 @@ namespace irr ...@@ -2071,14 +2071,13 @@ namespace irr
namespace video namespace video
{ {
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
//! creates a video driver //! creates a video driver
IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWND window, IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWND window,
u32 bits, bool fullscreen, bool stencilbuffer, u32 bits, bool fullscreen, bool stencilbuffer,
io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU,
bool vsync, bool antiAlias) bool vsync, bool antiAlias)
{ {
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
CD3D8Driver* dx8 = new CD3D8Driver(screenSize, window, fullscreen, CD3D8Driver* dx8 = new CD3D8Driver(screenSize, window, fullscreen,
stencilbuffer, io, pureSoftware); stencilbuffer, io, pureSoftware);
...@@ -2090,14 +2089,8 @@ IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWN ...@@ -2090,14 +2089,8 @@ IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWN
} }
return dx8; return dx8;
#else
return 0;
#endif // _IRR_COMPILE_WITH_DIRECT3D_8_
} }
#endif // _IRR_WINDOWS_API_ #endif // _IRR_COMPILE_WITH_DIRECT3D_8_
} // end namespace video } // end namespace video
} // end namespace irr } // end namespace irr
......
...@@ -2170,14 +2170,13 @@ namespace irr ...@@ -2170,14 +2170,13 @@ namespace irr
namespace video namespace video
{ {
#if defined(_IRR_WINDOWS_) #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
//! creates a video driver //! creates a video driver
IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWND window, IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWND window,
u32 bits, bool fullscreen, bool stencilbuffer, u32 bits, bool fullscreen, bool stencilbuffer,
io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU,
bool vsync, bool antiAlias) bool vsync, bool antiAlias)
{ {
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
CD3D9Driver* dx9 = new CD3D9Driver(screenSize, window, fullscreen, stencilbuffer, io, pureSoftware); CD3D9Driver* dx9 = new CD3D9Driver(screenSize, window, fullscreen, stencilbuffer, io, pureSoftware);
if (!dx9->initDriver(screenSize, window, bits, fullscreen, pureSoftware, highPrecisionFPU, vsync, antiAlias)) if (!dx9->initDriver(screenSize, window, bits, fullscreen, pureSoftware, highPrecisionFPU, vsync, antiAlias))
{ {
...@@ -2186,14 +2185,8 @@ IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWN ...@@ -2186,14 +2185,8 @@ IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWN
} }
return dx9; return dx9;
#else
return 0;
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
} }
#endif #endif // _IRR_COMPILE_WITH_DIRECT3D_9_
} // end namespace video } // end namespace video
} // end namespace irr } // end namespace irr
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace irr namespace irr
{ {
//! Interface for logging messages, warnings and errors //! Class for logging messages, warnings and errors to stdout
class CLogger : public ILogger class CLogger : public ILogger
{ {
public: public:
......
...@@ -32,35 +32,48 @@ void CMeshCache::addMesh(const c8* filename, IAnimatedMesh* mesh) ...@@ -32,35 +32,48 @@ void CMeshCache::addMesh(const c8* filename, IAnimatedMesh* mesh)
} }
//! Returns amount of loaded meshes //! Removes a mesh from the cache.
u32 CMeshCache::getMeshCount() const void CMeshCache::removeMesh(const IAnimatedMesh* const mesh)
{ {
return Meshes.size(); if ( !mesh )
return;
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh == mesh)
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
return;
}
}
} }
//! Returns a mesh based on its index number //! Removes a mesh from the cache.
IAnimatedMesh* CMeshCache::getMeshByIndex(u32 number) void CMeshCache::removeMesh(const IMesh* const mesh)
{ {
if (number >= Meshes.size()) if ( !mesh )
return 0; return;
for (u32 i=0; i<Meshes.size(); ++i)
return Meshes[number].Mesh; {
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
return;
}
}
} }
//! Returns a mesh based on its file name. //! Returns amount of loaded meshes
IAnimatedMesh* CMeshCache::getMeshByFilename(const c8* filename) u32 CMeshCache::getMeshCount() const
{ {
MeshEntry e; return Meshes.size();
e.Name = filename;
e.Name.make_lower();
s32 id = Meshes.binary_search(e);
return (id != -1) ? Meshes[id].Mesh : 0;
} }
//! Returns current number of the mesh //! Returns current number of the mesh
s32 CMeshCache::getMeshIndex(const IAnimatedMesh* const mesh) const s32 CMeshCache::getMeshIndex(const IAnimatedMesh* const mesh) const
{ {
for (u32 i=0; i<Meshes.size(); ++i) for (u32 i=0; i<Meshes.size(); ++i)
...@@ -85,6 +98,27 @@ s32 CMeshCache::getMeshIndex(const IMesh* const mesh) const ...@@ -85,6 +98,27 @@ s32 CMeshCache::getMeshIndex(const IMesh* const mesh) const
} }
//! Returns a mesh based on its index number
IAnimatedMesh* CMeshCache::getMeshByIndex(u32 number)
{
if (number >= Meshes.size())
return 0;
return Meshes[number].Mesh;
}
//! Returns a mesh based on its file name.
IAnimatedMesh* CMeshCache::getMeshByFilename(const c8* filename)
{
MeshEntry e;
e.Name = filename;
e.Name.make_lower();
s32 id = Meshes.binary_search(e);
return (id != -1) ? Meshes[id].Mesh : 0;
}
//! Returns name of a mesh based on its index number //! Returns name of a mesh based on its index number
const c8* CMeshCache::getMeshFilename(u32 number) const const c8* CMeshCache::getMeshFilename(u32 number) const
{ {
...@@ -123,47 +157,6 @@ const c8* CMeshCache::getMeshFilename(const IMesh* const mesh) const ...@@ -123,47 +157,6 @@ const c8* CMeshCache::getMeshFilename(const IMesh* const mesh) const
//! returns if a mesh already was loaded
bool CMeshCache::isMeshLoaded(const c8* filename)
{
return getMeshByFilename(filename) != 0;
}
//! 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)
{
if ( !mesh )
return;
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
return;
}
}
}
//! Renames a loaded mesh, if possible. //! Renames a loaded mesh, if possible.
bool CMeshCache::setMeshFilename(u32 index, const c8* filename) bool CMeshCache::setMeshFilename(u32 index, const c8* filename)
{ {
...@@ -209,6 +202,14 @@ bool CMeshCache::setMeshFilename(const IMesh* const mesh, const c8* filename) ...@@ -209,6 +202,14 @@ bool CMeshCache::setMeshFilename(const IMesh* const mesh, const c8* filename)
return false; return false;
} }
//! returns if a mesh already was loaded
bool CMeshCache::isMeshLoaded(const c8* filename)
{
return getMeshByFilename(filename) != 0;
}
//! Clears the whole mesh cache, removing all meshes. //! Clears the whole mesh cache, removing all meshes.
void CMeshCache::clear() void CMeshCache::clear()
{ {
......
...@@ -27,9 +27,9 @@ namespace scene ...@@ -27,9 +27,9 @@ namespace scene
has been loaded. This method can be used for example by mesh loaders who need to has been loaded. This method can be used for example by mesh loaders who need to
load more than one mesh with one call. They can add additional meshes with this load more than one mesh with one call. They can add additional meshes with this
method to the scene manager. The COLLADA loader for example uses this method. method to the scene manager. The COLLADA loader for example uses this method.
\param filename: Filename of the mesh. When called ISceneManager::getMesh() with this \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this
parameter, the method will return the mesh parameter given with this method. parameter, the method will return the mesh parameter given with this method.
\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 c8* filename, IAnimatedMesh* mesh); virtual void addMesh(const c8* filename, IAnimatedMesh* mesh);
//! Removes a mesh from the cache. //! Removes a mesh from the cache.
...@@ -43,7 +43,7 @@ namespace scene ...@@ -43,7 +43,7 @@ namespace scene
virtual void removeMesh(const IMesh* const mesh); virtual void removeMesh(const IMesh* const mesh);
//! Returns amount of loaded meshes in the cache. //! Returns amount of loaded meshes in the cache.
/** You can load new meshes into the cache using getMesh() and addMesh(). /** You can load new meshes into the cache using getMesh() and addMesh().
If you ever need to access the internal mesh cache, you can do this using If you ever need to access the internal mesh cache, you can do this using
removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */
virtual u32 getMeshCount() const; virtual u32 getMeshCount() const;
...@@ -55,7 +55,7 @@ namespace scene ...@@ -55,7 +55,7 @@ namespace scene
virtual s32 getMeshIndex(const IMesh* const mesh) const; virtual s32 getMeshIndex(const IMesh* const mesh) const;
//! Returns a mesh based on its index number. //! Returns a mesh based on its index number.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1. /** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
Note that this number is only valid until a new mesh is loaded or removed * Note that this number is only valid until a new mesh is loaded or removed *
\return Returns pointer to the mesh or 0 if there is none with this number. */ \return Returns pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByIndex(u32 index); virtual IAnimatedMesh* getMeshByIndex(u32 index);
...@@ -64,8 +64,8 @@ namespace scene ...@@ -64,8 +64,8 @@ namespace scene
/** \return Returns pointer to the mesh or 0 if there is none with this number. */ /** \return Returns pointer to the mesh or 0 if there is none with this number. */
virtual IAnimatedMesh* getMeshByFilename(const c8* filename); virtual IAnimatedMesh* getMeshByFilename(const c8* filename);
//! Returns name of a mesh based on its index number. //! Returns name of a mesh based on its index number.
/** \param index: Index of the mesh, number between 0 and getMeshCount()-1. /** \param index: Index of the mesh, number between 0 and getMeshCount()-1.
Note that this is only valid until a new mesh is loaded */ Note that this is only valid until a new mesh is loaded */
virtual const c8* getMeshFilename(u32 index) const; virtual const c8* getMeshFilename(u32 index) const;
......
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