Deleting the wrapper missed that it had a second job: being a type serialize.cpp could ignore by name, which a bare osg::Object parked in a user data container cannot be singled out for. Without it a scene dump hoists the entire template subtree into the user-data block and demotes the node's real children to bare UniqueID back-references, and no blunt filter can fix that because the same containers carry shaderPrefix, recordIndex and fileHash value objects that the dump should keep. TemplateMultiRef stays gone, the eight call sites still share one addTemplateRef helper that ignores a null template, and holding a ref_ptr<const osg::Object> means no call site needs a const_cast any more.
54 lines
2.0 KiB
C++
54 lines
2.0 KiB
C++
#ifndef OPENMW_COMPONENTS_SCENEUTIL_CLONE_H
|
|
#define OPENMW_COMPONENTS_SCENEUTIL_CLONE_H
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include <osg/CopyOp>
|
|
|
|
namespace osgParticle
|
|
{
|
|
class ParticleProcessor;
|
|
class ParticleSystem;
|
|
class ParticleSystemUpdater;
|
|
}
|
|
|
|
namespace SceneUtil
|
|
{
|
|
class Controller;
|
|
|
|
/// @par Defines the cloning behaviour we need:
|
|
/// * Assigns updated ParticleSystem pointers on cloned emitters and programs.
|
|
/// * Deep copies RigGeometry and MorphGeometry so they can animate without affecting clones.
|
|
/// @warning Avoid using this class directly. The safety of cloning operations depends on the copy flags and the
|
|
/// objects involved. Consider using SceneManager::cloneNode for additional safety.
|
|
/// @warning Do not use an object of this class for more than one copy operation.
|
|
class CopyOp : public osg::CopyOp
|
|
{
|
|
public:
|
|
CopyOp();
|
|
|
|
virtual osgParticle::ParticleSystem* operator()(const osgParticle::ParticleSystem* partsys) const;
|
|
virtual osgParticle::ParticleProcessor* operator()(const osgParticle::ParticleProcessor* processor) const;
|
|
|
|
osg::Node* operator()(const osg::Node* node) const override;
|
|
osg::Drawable* operator()(const osg::Drawable* drawable) const override;
|
|
osg::Callback* operator()(const osg::Callback* callback) const override;
|
|
|
|
osg::Node* getClonedNode(const osg::Node* original) const;
|
|
void remapControllerTargets() const;
|
|
|
|
private:
|
|
// maps new pointers to their old pointers
|
|
// a little messy, but I think this should be the most efficient way
|
|
mutable std::map<osgParticle::ParticleProcessor*, const osgParticle::ParticleSystem*> mProcessorToOldPs;
|
|
mutable std::map<osgParticle::ParticleSystemUpdater*, const osgParticle::ParticleSystem*> mUpdaterToOldPs;
|
|
mutable std::map<const osgParticle::ParticleSystem*, osgParticle::ParticleSystem*> mOldPsToNewPs;
|
|
mutable std::map<const osg::Node*, osg::Node*> mClonedNodes;
|
|
mutable std::vector<Controller*> mControllersToRemap;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|