added IUnknown::getReferenceCount and IMeshCache::clearUnusedMeshes to flush unused meshes from the mesh cache.

Fixed CGUIModalScreen, which I broke with the IGUIElement changes. Also fixed a small bug with the tooltip appearing directly under the mouse cursor.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@760 dfc29bdd-3216-0410-991c-e03cc46cb475
master
bitplane 2007-07-05 11:20:03 +00:00
parent 9bd033b0a1
commit 64ea350e23
7 changed files with 43 additions and 3 deletions

View File

@ -1,5 +1,11 @@
Changes in version 1.4 (... 2007)
- Added IMeshCache::clearUnusedMeshes(). This allows the user to remove
meshes that are sitting in the mesh cache but aren't used by any scene nodes.
This is useful for example when changing levels.
- Added IUnknown::getReferenceCount()
- createDevice now reports errors if the driverType is unknown, previously it
created a window but populated it with a null driver without any warning.

View File

@ -112,8 +112,15 @@ namespace scene
//! Clears the whole mesh cache, removing all meshes.
/** All meshes will be reloaded completely when using ISceneManager::getMesh()
after calling this method. */
after calling this method.
Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh()
and you did not grab them, then they may become invalid. */
virtual void clear() = 0;
//! Clears all meshes that are held in the mesh cache but not used anywhere else.
/** Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh()
and you did not grab them, then they may become invalid. */
virtual void clearUnusedMeshes() = 0;
};

View File

@ -123,13 +123,19 @@ namespace irr
return false;
}
//! Returns the reference counter.
s32 getReferenceCount() const
{
return ReferenceCounter;
}
//! Returns the debug name of the object. The Debugname may only be set and
//! changed by the object itself. This method should only be used in Debug mode.
//! \return Returns a string, previously set by setDebugName();
const c8* getDebugName() const
{
return DebugName;
}
}
protected:

View File

@ -328,7 +328,7 @@ void CGUIEnvironment::OnPostRender( u32 time )
dim.Width += getSkin()->getSize(EGDS_TEXT_DISTANCE_X)*2;
dim.Height += getSkin()->getSize(EGDS_TEXT_DISTANCE_Y)*2;
pos.UpperLeftCorner.Y -= dim.Height-1;
pos.UpperLeftCorner.Y -= dim.Height+1;
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + dim.Height-1;
pos.LowerRightCorner.X = pos.UpperLeftCorner.X + dim.Width;

View File

@ -43,6 +43,9 @@ bool CGUIModalScreen::OnEvent(SEvent event)
MouseDownTime = os::Timer::getTime();
}
}
if (Parent)
Parent->OnEvent(event);
return true;
}

View File

@ -219,6 +219,21 @@ void CMeshCache::clear()
Meshes.clear();
}
//! Clears all meshes that are held in the mesh cache but not used anywhere else.
void CMeshCache::clearUnusedMeshes()
{
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh->getReferenceCount() == 1)
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
--i;
}
}
}
} // end namespace scene
} // end namespace irr

View File

@ -92,6 +92,9 @@ namespace scene
//! Clears the whole mesh cache, removing all meshes.
virtual void clear();
//! Clears all meshes that are held in the mesh cache but not used anywhere else.
virtual void clearUnusedMeshes();
protected:
struct MeshEntry