1 #ifndef OPENMW_COMPONENTS_SCENEUTIL_CLONE_H
2 #define OPENMW_COMPONENTS_SCENEUTIL_CLONE_H
3 
4 #include <map>
5 
6 #include <osg/CopyOp>
7 
8 namespace osgParticle
9 {
10     class ParticleProcessor;
11     class ParticleSystem;
12     class ParticleSystemUpdater;
13 }
14 
15 namespace SceneUtil
16 {
17 
18     /// @par Defines the cloning behaviour we need:
19     /// * Assigns updated ParticleSystem pointers on cloned emitters and programs.
20     /// * Deep copies RigGeometry and MorphGeometry so they can animate without affecting clones.
21     /// @warning Do not use an object of this class for more than one copy operation.
22     class CopyOp : public osg::CopyOp
23     {
24     public:
25         CopyOp();
26 
27         virtual osgParticle::ParticleSystem* operator() (const osgParticle::ParticleSystem* partsys) const;
28         virtual osgParticle::ParticleProcessor* operator() (const osgParticle::ParticleProcessor* processor) const;
29 
30         osg::Node* operator() (const osg::Node* node) const override;
31         osg::Drawable* operator() (const osg::Drawable* drawable) const override;
32 
33     private:
34         // maps new pointers to their old pointers
35         // a little messy, but I think this should be the most efficient way
36         mutable std::map<osgParticle::ParticleProcessor*, const osgParticle::ParticleSystem*> mProcessorToOldPs;
37         mutable std::map<osgParticle::ParticleSystemUpdater*, const osgParticle::ParticleSystem*> mUpdaterToOldPs;
38         mutable std::map<const osgParticle::ParticleSystem*, osgParticle::ParticleSystem*> mOldPsToNewPs;
39     };
40 
41 }
42 
43 #endif
44