- try bugfix for titi's verticle rotation

- added deep copy for child particles
This commit is contained in:
Mark Vejvoda 2011-07-12 01:48:14 +00:00
parent 94e0fca857
commit 5400126332
3 changed files with 65 additions and 5 deletions

View File

@ -52,6 +52,25 @@ ParticleSystemType::ParticleSystemType() {
minmaxIsPercent=false;
}
ParticleSystemType::ParticleSystemType(const ParticleSystemType &src) {
if(checkMemory) {
printf("++ Create ParticleSystemType #2 [%p]\n",this);
memoryObjectList[this]++;
}
copyAll(src);
}
ParticleSystemType & ParticleSystemType::operator=(const ParticleSystemType &src) {
if(checkMemory) {
printf("++ Create ParticleSystemType #3 [%p]\n",this);
memoryObjectList[this]++;
}
copyAll(src);
return *this;
}
ParticleSystemType::~ParticleSystemType() {
if(checkMemory) {
printf("-- Delete ParticleSystemType [%p] type = [%s]\n",this,type.c_str());
@ -62,6 +81,41 @@ ParticleSystemType::~ParticleSystemType() {
delete *it;
}
void ParticleSystemType::copyAll(const ParticleSystemType &src) {
this->type = src.type;
this->texture = src.texture;
this->model = src.model;
this->modelCycle = src.modelCycle;
this->primitive = src.primitive;
this->offset = src.offset;
this->color = src.color;
this->colorNoEnergy = src.colorNoEnergy;
this->size = src.size;
this->sizeNoEnergy = src.sizeNoEnergy;
this->speed = src.speed;
this->gravity = src.gravity;
this->emissionRate = src.emissionRate;
this->energyMax = src.energyMax;
this->energyVar = src.energyVar;
this->mode = src.mode;
this->teamcolorNoEnergy = src.teamcolorNoEnergy;
this->teamcolorEnergy = src.teamcolorEnergy;
this->alternations = src.alternations;
for(Children::iterator it = children.begin(); it != children.end(); it++) {
UnitParticleSystemType *child = *it;
// Deep copy the child particles
UnitParticleSystemType *newCopy = new UnitParticleSystemType();
*newCopy = *child;
children.push_back(newCopy);
}
this->minmaxEnabled = src.minmaxEnabled;
this->minHp = src.minHp;
this->maxHp = src.maxHp;
this->minmaxIsPercent = src.minmaxIsPercent;
}
void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader, string techtreePath) {

View File

@ -77,9 +77,15 @@ protected:
int maxHp;
bool minmaxIsPercent;
void copyAll(const ParticleSystemType &src);
public:
ParticleSystemType();
ParticleSystemType();
virtual ~ParticleSystemType();
ParticleSystemType & operator=(const ParticleSystemType &src);
ParticleSystemType(const ParticleSystemType &src);
void load(const XmlNode *particleSystemNode, const string &dir,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader, string techtreePath);

View File

@ -252,10 +252,10 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType
usePathfinderExtendedMaxNodes = false;
this->currentAttackBoostOriginatorEffect.skillType = NULL;
float targetRotationZ=.0f;
float targetRotationX=.0f;
float rotationZ=.0f;
float rotationX=.0f;
targetRotationZ=.0f;
targetRotationX=.0f;
rotationZ=.0f;
rotationX=.0f;
RandomGen random;