From 54001263327fafb7be9abcee54bd63b7b1f7cabf Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 12 Jul 2011 01:48:14 +0000 Subject: [PATCH] - try bugfix for titi's verticle rotation - added deep copy for child particles --- source/glest_game/graphics/particle_type.cpp | 54 ++++++++++++++++++++ source/glest_game/graphics/particle_type.h | 8 ++- source/glest_game/type_instances/unit.cpp | 8 +-- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index b9095651..e1e56d6b 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -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 > > &loadedFileList, string parentLoader, string techtreePath) { diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index 5ebf89a4..ba6dc421 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -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 > > &loadedFileList, string parentLoader, string techtreePath); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 7c9879fa..b47e9001 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -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;