Fix hotloading making models disappear.
The actors were always hotloaded because of a bad logic change in
76acc4e146
.
Fixes #6228
Differential Revision: https://code.wildfiregames.com/D4175
This was SVN commit r25805.
This commit is contained in:
parent
8c7d77a610
commit
a541f3a317
@ -157,10 +157,15 @@ void CObjectManager::UnloadObjects()
|
|||||||
|
|
||||||
Status CObjectManager::ReloadChangedFile(const VfsPath& path)
|
Status CObjectManager::ReloadChangedFile(const VfsPath& path)
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
// Mark old entries as outdated so we don't reload them from the cache
|
// Mark old entries as outdated so we don't reload them from the cache
|
||||||
for (std::pair<const ObjectKey, Hotloadable<CObjectEntry>>& object : m_Objects)
|
for (std::pair<const ObjectKey, Hotloadable<CObjectEntry>>& object : m_Objects)
|
||||||
if (!object.second.outdated && object.second.obj->m_Base->UsesFile(path))
|
if (!object.second.outdated && object.second.obj->m_Base->UsesFile(path))
|
||||||
|
{
|
||||||
object.second.outdated = true;
|
object.second.outdated = true;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
const CSimulation2::InterfaceListUnordered& cmps = m_Simulation.GetEntitiesWithInterfaceUnordered(IID_Visual);
|
const CSimulation2::InterfaceListUnordered& cmps = m_Simulation.GetEntitiesWithInterfaceUnordered(IID_Visual);
|
||||||
|
|
||||||
@ -168,15 +173,23 @@ Status CObjectManager::ReloadChangedFile(const VfsPath& path)
|
|||||||
for (std::pair<const CStrW, Hotloadable<CActorDef>>& actor : m_ActorDefs)
|
for (std::pair<const CStrW, Hotloadable<CActorDef>>& actor : m_ActorDefs)
|
||||||
{
|
{
|
||||||
if (!actor.second.outdated && actor.second.obj->UsesFile(path))
|
if (!actor.second.outdated && actor.second.obj->UsesFile(path))
|
||||||
|
{
|
||||||
actor.second.outdated = true;
|
actor.second.outdated = true;
|
||||||
|
changed = true;
|
||||||
|
|
||||||
// Slightly ugly hack: The graphics system doesn't preserve enough information to regenerate the
|
// Slightly ugly hack: The graphics system doesn't preserve enough information to regenerate the
|
||||||
// object with all correct variations, and we don't want to waste space storing it just for the
|
// object with all correct variations, and we don't want to waste space storing it just for the
|
||||||
// rare occurrence of hotloading, so we'll tell the component (which does preserve the information)
|
// rare occurrence of hotloading, so we'll tell the component (which does preserve the information)
|
||||||
// to do the reloading itself
|
// to do the reloading itself
|
||||||
for (CSimulation2::InterfaceListUnordered::const_iterator eit = cmps.begin(); eit != cmps.end(); ++eit)
|
for (CSimulation2::InterfaceListUnordered::const_iterator eit = cmps.begin(); eit != cmps.end(); ++eit)
|
||||||
static_cast<ICmpVisual*>(eit->second)->Hotload(actor.first);
|
static_cast<ICmpVisual*>(eit->second)->Hotload(actor.first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
// Trigger an interpolate call - needed because the game may be paused & if so, models disappear.
|
||||||
|
m_Simulation.Interpolate(0.f, 0.f, 0.f);
|
||||||
|
|
||||||
return INFO::OK;
|
return INFO::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user