From f8f18cc02611d1dadc63387fc2ee29986874d654 Mon Sep 17 00:00:00 2001 From: songchengjiang Date: Wed, 15 Apr 2015 12:44:03 +0800 Subject: [PATCH] enable users to clone PUParticleSystem3D --- extensions/Particle3D/PU/CCPUAffector.cpp | 3 +++ extensions/Particle3D/PU/CCPUEmitter.cpp | 4 ++++ extensions/Particle3D/PU/CCPUObserver.cpp | 1 + extensions/Particle3D/PU/CCPUParticleSystem3D.cpp | 8 +++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/Particle3D/PU/CCPUAffector.cpp b/extensions/Particle3D/PU/CCPUAffector.cpp index 9e941e671a..5cfadf4f18 100755 --- a/extensions/Particle3D/PU/CCPUAffector.cpp +++ b/extensions/Particle3D/PU/CCPUAffector.cpp @@ -187,10 +187,13 @@ float PUAffector::getMass() const void PUAffector::copyAttributesTo( PUAffector* affector ) { affector->setName(_name); + affector->setAffectorType(_affectorType); + affector->_position = _position; affector->_isEnabled = _isEnabled; affector->_particleSystem = _particleSystem; affector->_affectorScale = _affectorScale; affector->_affectSpecialisation = _affectSpecialisation; + affector->_excludedEmitters = _excludedEmitters; } void PUAffector::addEmitterToExclude( const std::string& emitterName ) diff --git a/extensions/Particle3D/PU/CCPUEmitter.cpp b/extensions/Particle3D/PU/CCPUEmitter.cpp index 8d4282394c..dd5f4edcb0 100755 --- a/extensions/Particle3D/PU/CCPUEmitter.cpp +++ b/extensions/Particle3D/PU/CCPUEmitter.cpp @@ -890,6 +890,10 @@ void PUEmitter::copyAttributesTo( PUEmitter* emitter ) emitter->setEmitterType(_emitterType); emitter->setEmitsName(_emitsName); emitter->setEmitsType(_emitsType); + emitter->_position = _position; + emitter->_isEnabled = _isEnabled; + emitter->_originEnabled = _originEnabled; + emitter->_originEnabledSet = _originEnabledSet; emitter->_particleDirection = _particleDirection; emitter->_originalParticleDirection = _originalParticleDirection; emitter->_particleOrientation = _particleOrientation; diff --git a/extensions/Particle3D/PU/CCPUObserver.cpp b/extensions/Particle3D/PU/CCPUObserver.cpp index 0212629cb6..971150d9e3 100644 --- a/extensions/Particle3D/PU/CCPUObserver.cpp +++ b/extensions/Particle3D/PU/CCPUObserver.cpp @@ -317,6 +317,7 @@ void PUObserver::copyAttributesTo( PUObserver* observer ) { // Copy attributes observer->setName(_name); + observer->setObserverType(_observerType); observer->_particleTypeToObserve = _particleTypeToObserve; observer->_particleTypeToObserveSet = _particleTypeToObserveSet; observer->_particleSystem = _particleSystem; diff --git a/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp b/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp index 893f2df8d6..9fe328a239 100755 --- a/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp +++ b/extensions/Particle3D/PU/CCPUParticleSystem3D.cpp @@ -1051,7 +1051,8 @@ void PUParticleSystem3D::copyAttributesTo( PUParticleSystem3D* system ) system->setName(_name); system->_state = _state; - system->setRender(static_cast(_render)->clone()); + if (_render) + system->setRender(static_cast(_render)->clone()); system->_particleQuota = _particleQuota; system->_blend = _blend; system->_keepLocal = _keepLocal; @@ -1102,6 +1103,11 @@ PUParticleSystem3D* PUParticleSystem3D::clone() { auto ps = PUParticleSystem3D::create(); copyAttributesTo(ps); + for (auto &iter : _children){ + PUParticleSystem3D *child = dynamic_cast(iter); + if (child) + ps->addChild(child->clone()); + } return ps; }