mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 05:15:33 +00:00
Make particle system cloning map names more sensible
This commit is contained in:
parent
f516178ec9
commit
6b874e397b
2 changed files with 15 additions and 15 deletions
|
@ -47,7 +47,7 @@ namespace SceneUtil
|
||||||
if (const osgParticle::ParticleSystemUpdater* updater = dynamic_cast<const osgParticle::ParticleSystemUpdater*>(node))
|
if (const osgParticle::ParticleSystemUpdater* updater = dynamic_cast<const osgParticle::ParticleSystemUpdater*>(node))
|
||||||
{
|
{
|
||||||
osgParticle::ParticleSystemUpdater* cloned = new osgParticle::ParticleSystemUpdater(*updater, osg::CopyOp::SHALLOW_COPY);
|
osgParticle::ParticleSystemUpdater* cloned = new osgParticle::ParticleSystemUpdater(*updater, osg::CopyOp::SHALLOW_COPY);
|
||||||
mMap2[cloned] = updater->getParticleSystem(0);
|
mUpdaterToOldPs[cloned] = updater->getParticleSystem(0);
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
return osg::CopyOp::operator()(node);
|
return osg::CopyOp::operator()(node);
|
||||||
|
@ -69,16 +69,16 @@ namespace SceneUtil
|
||||||
osgParticle::ParticleProcessor* CopyOp::operator() (const osgParticle::ParticleProcessor* processor) const
|
osgParticle::ParticleProcessor* CopyOp::operator() (const osgParticle::ParticleProcessor* processor) const
|
||||||
{
|
{
|
||||||
osgParticle::ParticleProcessor* cloned = osg::clone(processor, osg::CopyOp::DEEP_COPY_CALLBACKS);
|
osgParticle::ParticleProcessor* cloned = osg::clone(processor, osg::CopyOp::DEEP_COPY_CALLBACKS);
|
||||||
for (std::map<const osgParticle::ParticleSystem*, osgParticle::ParticleSystem*>::const_iterator it = mMap3.begin(); it != mMap3.end(); ++it)
|
for (const auto& oldPsNewPsPair : mOldPsToNewPs)
|
||||||
{
|
{
|
||||||
if (processor->getParticleSystem() == it->first)
|
if (processor->getParticleSystem() == oldPsNewPsPair.first)
|
||||||
{
|
{
|
||||||
cloned->setParticleSystem(it->second);
|
cloned->setParticleSystem(oldPsNewPsPair.second);
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mMap[cloned] = processor->getParticleSystem();
|
mProcessorToOldPs[cloned] = processor->getParticleSystem();
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,24 +86,24 @@ namespace SceneUtil
|
||||||
{
|
{
|
||||||
osgParticle::ParticleSystem* cloned = osg::clone(partsys, *this);
|
osgParticle::ParticleSystem* cloned = osg::clone(partsys, *this);
|
||||||
|
|
||||||
for (std::map<osgParticle::ParticleProcessor*, const osgParticle::ParticleSystem*>::const_iterator it = mMap.begin(); it != mMap.end(); ++it)
|
for (const auto& processorPsPair : mProcessorToOldPs)
|
||||||
{
|
{
|
||||||
if (it->second == partsys)
|
if (processorPsPair.second == partsys)
|
||||||
{
|
{
|
||||||
it->first->setParticleSystem(cloned);
|
processorPsPair.first->setParticleSystem(cloned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::map<osgParticle::ParticleSystemUpdater*, const osgParticle::ParticleSystem*>::const_iterator it = mMap2.begin(); it != mMap2.end(); ++it)
|
for (const auto& updaterPsPair : mUpdaterToOldPs)
|
||||||
{
|
{
|
||||||
if (it->second == partsys)
|
if (updaterPsPair.second == partsys)
|
||||||
{
|
{
|
||||||
osgParticle::ParticleSystemUpdater* updater = it->first;
|
osgParticle::ParticleSystemUpdater* updater = updaterPsPair.first;
|
||||||
updater->removeParticleSystem(updater->getParticleSystem(0));
|
updater->removeParticleSystem(updater->getParticleSystem(0));
|
||||||
updater->addParticleSystem(cloned);
|
updater->addParticleSystem(cloned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// In rare situations a particle processor may be placed after the particle system in the scene graph.
|
// In rare situations a particle processor may be placed after the particle system in the scene graph.
|
||||||
mMap3[partsys] = cloned;
|
mOldPsToNewPs[partsys] = cloned;
|
||||||
|
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ namespace SceneUtil
|
||||||
private:
|
private:
|
||||||
// maps new pointers to their old pointers
|
// maps new pointers to their old pointers
|
||||||
// a little messy, but I think this should be the most efficient way
|
// a little messy, but I think this should be the most efficient way
|
||||||
mutable std::map<osgParticle::ParticleProcessor*, const osgParticle::ParticleSystem*> mMap;
|
mutable std::map<osgParticle::ParticleProcessor*, const osgParticle::ParticleSystem*> mProcessorToOldPs;
|
||||||
mutable std::map<osgParticle::ParticleSystemUpdater*, const osgParticle::ParticleSystem*> mMap2;
|
mutable std::map<osgParticle::ParticleSystemUpdater*, const osgParticle::ParticleSystem*> mUpdaterToOldPs;
|
||||||
mutable std::map<const osgParticle::ParticleSystem*, osgParticle::ParticleSystem*> mMap3;
|
mutable std::map<const osgParticle::ParticleSystem*, osgParticle::ParticleSystem*> mOldPsToNewPs;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue