2015-03-26 17:02:51 +00:00
# ifndef OPENMW_COMPONENTS_SCENEUTIL_CLONE_H
# define OPENMW_COMPONENTS_SCENEUTIL_CLONE_H
# include <map>
# include <osg/CopyOp>
namespace osgParticle
{
class ParticleProcessor ;
class ParticleSystem ;
class ParticleSystemUpdater ;
}
namespace SceneUtil
{
/// @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.
2021-10-23 08:31:46 +00:00
/// @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.
2015-03-26 17:02:51 +00:00
/// @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 ;
2020-10-16 18:18:54 +00:00
osg : : Node * operator ( ) ( const osg : : Node * node ) const override ;
osg : : Drawable * operator ( ) ( const osg : : Drawable * drawable ) const override ;
2015-03-26 17:02:51 +00:00
private :
2020-04-29 08:06:14 +00:00
// maps new pointers to their old pointers
2015-03-26 17:02:51 +00:00
// a little messy, but I think this should be the most efficient way
2020-04-29 09:25:52 +00:00
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 ;
2015-03-26 17:02:51 +00:00
} ;
}
# endif