- added code to be able to properly render attack particles when unit is not visible (turned off for now due to questions)

This commit is contained in:
Mark Vejvoda
2013-09-19 20:03:36 +00:00
parent b83e7dae90
commit 3126a10966
4 changed files with 23 additions and 0 deletions

View File

@@ -560,6 +560,8 @@ Unit::~Unit() {
Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame); Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame);
// Must set this to null of it will be used below in stopDamageParticles() // Must set this to null of it will be used below in stopDamageParticles()
Renderer::getInstance().cleanupParticleSystems(attackParticleSystems,rsGame);
if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) { if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) {
this->fire = NULL; this->fire = NULL;
} }
@@ -1252,6 +1254,10 @@ void Unit::setTargetPos(const Vec2i &targetPos) {
logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
} }
void Unit::addAttackParticleSystem(ParticleSystem *ps) {
attackParticleSystems.push_back(ps);
}
void Unit::setVisible(const bool visible) { void Unit::setVisible(const bool visible) {
this->visible = visible; this->visible = visible;
@@ -1279,6 +1285,17 @@ void Unit::setVisible(const bool visible) {
} }
} }
} }
if(attackParticleSystems.empty() == false) {
for(vector<ParticleSystem*>::iterator it= attackParticleSystems.begin(); it != attackParticleSystems.end(); ++it) {
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
// Not sure this is a good idea since the unit be not be visible but the attack particle might be.
// This means you won't see the attacking projectile until the unit moves into view.
//(*it)->setVisible(visible);
}
}
}
if(currentAttackBoostEffects.empty() == false) { if(currentAttackBoostEffects.empty() == false) {
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) { for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i]; UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];

View File

@@ -408,6 +408,7 @@ private:
vector<ParticleSystem*> fireParticleSystems; vector<ParticleSystem*> fireParticleSystems;
vector<UnitParticleSystem*> smokeParticleSystems; vector<UnitParticleSystem*> smokeParticleSystems;
vector<ParticleSystem*> attackParticleSystems;
CardinalDir modelFacing; CardinalDir modelFacing;
@@ -771,6 +772,8 @@ public:
void clearCaches(); void clearCaches();
bool showTranslatedTechTree() const; bool showTranslatedTechTree() const;
void addAttackParticleSystem(ParticleSystem *ps);
Checksum getCRC(); Checksum getCRC();
private: private:

View File

@@ -2299,6 +2299,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
psProj->setFactionColor(unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0)); psProj->setFactionColor(unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
} }
renderer.manageParticleSystem(psProj, rsGame); renderer.manageParticleSystem(psProj, rsGame);
unit->addAttackParticleSystem(psProj);
} }
else{ else{
hit(unit); hit(unit);
@@ -2316,6 +2317,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
if(pstProj!=NULL){ if(pstProj!=NULL){
psProj->link(psSplash); psProj->link(psSplash);
} }
unit->addAttackParticleSystem(psSplash);
} }
} }

View File

@@ -1470,6 +1470,7 @@ void ProjectileParticleSystem::link(SplashParticleSystem *particleSystem){
} }
void ProjectileParticleSystem::update(){ void ProjectileParticleSystem::update(){
//printf("Projectile particle system updating...\n");
if(state == sPlay){ if(state == sPlay){
lastPos= pos; lastPos= pos;