Improvements against http://code.google.com/p/wagic/issues/detail?id=50, Mana animation slows PSP down.
Two things: 1) there was an extremely inefficient implementation in the particle system of a queue where, when particles expired, each expired element would be copied over(replaced) by one at the rear of the container. Depending on the performance of the update, this could range anywhere from 100 to 500 (the max particle count) memcpy operations per update loop. I replaced the flat array with a std::list, and simply pop the unneeded elements when they expire now. This seems to shave ~30% off the time spent in the Update() call. 2) Hardcoded the number of emitters for the mana particles to 60 (the default in the psi file seems to be around 114). This reduces the amount of iterations per tapped mana by just over half, which also helps the performance, and it's not really noticeable - the glow effect is a *tiny* bit more muted, but chances are, if you didn't read this comment, you probably wouldn't have noticed. I've gone from having my psp start lagging noticeably at 8 tapped mana to about 12 - at this point, I think the bigger remaining lag is the fact that when there's a cache miss for a card image, we're doing synchronous i/o on the main thread - the framerate drop this causes is far more noticable than the mana particle lag.
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
#include "hgecolor.h"
|
#include "hgecolor.h"
|
||||||
#include "hgerect.h"
|
#include "hgerect.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
class JQuad;
|
class JQuad;
|
||||||
|
|
||||||
#define MAX_PARTICLES 500
|
#define MAX_PARTICLES 500
|
||||||
@@ -109,27 +111,28 @@ public:
|
|||||||
float GetAge() const { return fAge; }
|
float GetAge() const { return fAge; }
|
||||||
void GetPosition(float *x, float *y) const { *x=vecLocation.x; *y=vecLocation.y; }
|
void GetPosition(float *x, float *y) const { *x=vecLocation.x; *y=vecLocation.y; }
|
||||||
void GetTransposition(float *x, float *y) const { *x=fTx; *y=fTy; }
|
void GetTransposition(float *x, float *y) const { *x=fTx; *y=fTy; }
|
||||||
hgeRect* GetBoundingBox(hgeRect *rect) const { memcpy(rect, &rectBoundingBox, sizeof(hgeRect)); return rect; }
|
hgeRect* GetBoundingBox(hgeRect *rect) const { memcpy(rect, &rectBoundingBox, sizeof(hgeRect)); return rect; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hgeParticleSystem();
|
hgeParticleSystem();
|
||||||
|
|
||||||
//static HGE *hge;
|
//static HGE *hge;
|
||||||
|
|
||||||
float fAge;
|
float fAge;
|
||||||
float fEmissionResidue;
|
float fEmissionResidue;
|
||||||
|
|
||||||
hgeVector vecPrevLocation;
|
hgeVector vecPrevLocation;
|
||||||
hgeVector vecLocation;
|
hgeVector vecLocation;
|
||||||
float fTx, fTy;
|
float fTx, fTy;
|
||||||
|
|
||||||
int nParticlesAlive;
|
int nParticlesAlive;
|
||||||
hgeRect rectBoundingBox;
|
hgeRect rectBoundingBox;
|
||||||
bool bUpdateBoundingBox;
|
bool bUpdateBoundingBox;
|
||||||
|
|
||||||
hgeParticle particles[MAX_PARTICLES];
|
typedef std::list<hgeParticle> ParticleBuffer;
|
||||||
|
ParticleBuffer mParticleBuffer;
|
||||||
|
|
||||||
float mTimer;
|
float mTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class hgeParticleManager
|
class hgeParticleManager
|
||||||
|
|||||||
Binary file not shown.
+173
-179
@@ -29,20 +29,20 @@ unsigned int g_seed=0;
|
|||||||
|
|
||||||
void Random_Seed(int seed)
|
void Random_Seed(int seed)
|
||||||
{
|
{
|
||||||
if(!seed) g_seed=JGE::GetInstance()->GetTime();
|
if(!seed) g_seed=JGE::GetInstance()->GetTime();
|
||||||
else g_seed=seed;
|
else g_seed=seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Random_Int(int min, int max)
|
int Random_Int(int min, int max)
|
||||||
{
|
{
|
||||||
g_seed=214013*g_seed+2531011;
|
g_seed=214013*g_seed+2531011;
|
||||||
return min+(g_seed ^ g_seed>>15)%(max-min+1);
|
return min+(g_seed ^ g_seed>>15)%(max-min+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Random_Float(float min, float max)
|
float Random_Float(float min, float max)
|
||||||
{
|
{
|
||||||
g_seed=214013*g_seed+2531011;
|
g_seed=214013*g_seed+2531011;
|
||||||
return min+(g_seed>>16)*(1.0f/65535.0f)*(max-min);
|
return min+(g_seed>>16)*(1.0f/65535.0f)*(max-min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,19 +50,19 @@ float Random_Float(float min, float max)
|
|||||||
|
|
||||||
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
|
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
|
||||||
{
|
{
|
||||||
//void *psi;
|
//void *psi;
|
||||||
//hgeParticleSystemInfo psi;
|
//hgeParticleSystemInfo psi;
|
||||||
|
|
||||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||||
//hge=hgeCreate(HGE_VERSION);
|
//hge=hgeCreate(HGE_VERSION);
|
||||||
|
|
||||||
//psi=hge->Resource_Load(filename);
|
//psi=hge->Resource_Load(filename);
|
||||||
if (!fileSys->OpenFile(filename)) return;
|
if (!fileSys->OpenFile(filename)) return;
|
||||||
|
|
||||||
//if(!psi) return;
|
//if(!psi) return;
|
||||||
|
|
||||||
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
||||||
//hge->Resource_Free(psi);
|
//hge->Resource_Free(psi);
|
||||||
|
|
||||||
// Skip reading the pointer as it may be larger than 4 bytes in the structure
|
// Skip reading the pointer as it may be larger than 4 bytes in the structure
|
||||||
void *dummyPointer;
|
void *dummyPointer;
|
||||||
@@ -73,240 +73,234 @@ hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
|
|||||||
fileSys->ReadFile(&(info.nEmission), sizeof(hgeParticleSystemInfo));
|
fileSys->ReadFile(&(info.nEmission), sizeof(hgeParticleSystemInfo));
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile();
|
||||||
|
|
||||||
info.sprite=sprite;
|
info.sprite=sprite;
|
||||||
// info.fGravityMin *= 100;
|
// info.fGravityMin *= 100;
|
||||||
// info.fGravityMax *= 100;
|
// info.fGravityMax *= 100;
|
||||||
// info.fSpeedMin *= 100;
|
// info.fSpeedMin *= 100;
|
||||||
// info.fSpeedMax *= 100;
|
// info.fSpeedMax *= 100;
|
||||||
|
|
||||||
vecLocation.x=vecPrevLocation.x=0.0f;
|
vecLocation.x=vecPrevLocation.x=0.0f;
|
||||||
vecLocation.y=vecPrevLocation.y=0.0f;
|
vecLocation.y=vecPrevLocation.y=0.0f;
|
||||||
fTx=fTy=0;
|
fTx=fTy=0;
|
||||||
|
|
||||||
fEmissionResidue=0.0f;
|
fEmissionResidue=0.0f;
|
||||||
nParticlesAlive=0;
|
nParticlesAlive=0;
|
||||||
fAge=-2.0;
|
fAge=-2.0;
|
||||||
mTimer = 0.0f;
|
mTimer = 0.0f;
|
||||||
|
|
||||||
rectBoundingBox.Clear();
|
rectBoundingBox.Clear();
|
||||||
bUpdateBoundingBox=false;
|
bUpdateBoundingBox=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
|
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
|
||||||
{
|
{
|
||||||
//hge=hgeCreate(HGE_VERSION);
|
//hge=hgeCreate(HGE_VERSION);
|
||||||
|
|
||||||
memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
||||||
|
|
||||||
vecLocation.x=vecPrevLocation.x=0.0f;
|
vecLocation.x=vecPrevLocation.x=0.0f;
|
||||||
vecLocation.y=vecPrevLocation.y=0.0f;
|
vecLocation.y=vecPrevLocation.y=0.0f;
|
||||||
fTx=fTy=0;
|
fTx=fTy=0;
|
||||||
|
|
||||||
fEmissionResidue=0.0f;
|
fEmissionResidue=0.0f;
|
||||||
nParticlesAlive=0;
|
nParticlesAlive=0;
|
||||||
fAge=-2.0;
|
fAge=-2.0;
|
||||||
mTimer = 0.0f;
|
mTimer = 0.0f;
|
||||||
|
|
||||||
rectBoundingBox.Clear();
|
rectBoundingBox.Clear();
|
||||||
bUpdateBoundingBox=false;
|
bUpdateBoundingBox=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hgeParticleSystem::hgeParticleSystem(const hgeParticleSystem &ps)
|
hgeParticleSystem::hgeParticleSystem(const hgeParticleSystem &ps)
|
||||||
{
|
{
|
||||||
memcpy(this, &ps, sizeof(hgeParticleSystem));
|
memcpy(this, &ps, sizeof(hgeParticleSystem));
|
||||||
//hge=hgeCreate(HGE_VERSION);
|
//hge=hgeCreate(HGE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgeParticleSystem::Update(float fDeltaTime)
|
void hgeParticleSystem::Update(float fDeltaTime)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float ang;
|
float ang;
|
||||||
hgeParticle *par;
|
hgeVector vecAccel, vecAccel2;
|
||||||
hgeVector vecAccel, vecAccel2;
|
|
||||||
|
|
||||||
if(fAge >= 0)
|
if(fAge >= 0)
|
||||||
{
|
{
|
||||||
fAge += fDeltaTime;
|
fAge += fDeltaTime;
|
||||||
if(fAge >= info.fLifetime) fAge = -2.0f;
|
if(fAge >= info.fLifetime) fAge = -2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimer += fDeltaTime;
|
mTimer += fDeltaTime;
|
||||||
if (mTimer < 0.01f)
|
if (mTimer < 0.01f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fDeltaTime = mTimer;
|
fDeltaTime = mTimer;
|
||||||
mTimer = 0.0f;
|
mTimer = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
// update all alive particles
|
// update all alive particles
|
||||||
|
|
||||||
if(bUpdateBoundingBox) rectBoundingBox.Clear();
|
if(bUpdateBoundingBox) rectBoundingBox.Clear();
|
||||||
par=particles;
|
|
||||||
|
|
||||||
for(i=0; i<nParticlesAlive; i++)
|
ParticleBuffer::iterator particle = mParticleBuffer.begin();
|
||||||
{
|
while(particle != mParticleBuffer.end())
|
||||||
par->fAge += fDeltaTime;
|
{
|
||||||
if(par->fAge >= par->fTerminalAge)
|
particle->fAge += fDeltaTime;
|
||||||
{
|
if(particle->fAge >= particle->fTerminalAge)
|
||||||
nParticlesAlive--;
|
{
|
||||||
if (par != &particles[nParticlesAlive])
|
nParticlesAlive--;
|
||||||
memcpy(par, &particles[nParticlesAlive], sizeof(hgeParticle));
|
++particle;
|
||||||
i--;
|
mParticleBuffer.pop_front();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vecAccel = par->vecLocation-vecLocation;
|
vecAccel = particle->vecLocation-vecLocation;
|
||||||
vecAccel.Normalize();
|
vecAccel.Normalize();
|
||||||
vecAccel2 = vecAccel;
|
vecAccel2 = vecAccel;
|
||||||
vecAccel *= par->fRadialAccel;
|
vecAccel *= particle->fRadialAccel;
|
||||||
|
|
||||||
// vecAccel2.Rotate(M_PI_2);
|
// vecAccel2.Rotate(M_PI_2);
|
||||||
// the following is faster
|
// the following is faster
|
||||||
ang = vecAccel2.x;
|
ang = vecAccel2.x;
|
||||||
vecAccel2.x = -vecAccel2.y;
|
vecAccel2.x = -vecAccel2.y;
|
||||||
vecAccel2.y = ang;
|
vecAccel2.y = ang;
|
||||||
|
|
||||||
vecAccel2 *= par->fTangentialAccel;
|
vecAccel2 *= particle->fTangentialAccel;
|
||||||
par->vecVelocity += (vecAccel+vecAccel2)*fDeltaTime;
|
particle->vecVelocity += (vecAccel+vecAccel2)*fDeltaTime;
|
||||||
par->vecVelocity.y += par->fGravity*fDeltaTime;
|
particle->vecVelocity.y += particle->fGravity*fDeltaTime;
|
||||||
|
|
||||||
//par->vecVelocity.y = 0.1f;
|
//par->vecVelocity.y = 0.1f;
|
||||||
par->vecLocation += par->vecVelocity;
|
particle->vecLocation += particle->vecVelocity;
|
||||||
|
|
||||||
par->fSpin += par->fSpinDelta*fDeltaTime;
|
particle->fSpin += particle->fSpinDelta*fDeltaTime;
|
||||||
par->fSize += par->fSizeDelta*fDeltaTime;
|
particle->fSize += particle->fSizeDelta*fDeltaTime;
|
||||||
par->colColor += par->colColorDelta*fDeltaTime;
|
particle->colColor += particle->colColorDelta*fDeltaTime;
|
||||||
|
|
||||||
if(bUpdateBoundingBox) rectBoundingBox.Encapsulate(par->vecLocation.x, par->vecLocation.y);
|
if(bUpdateBoundingBox) rectBoundingBox.Encapsulate(particle->vecLocation.x, particle->vecLocation.y);
|
||||||
|
|
||||||
par++;
|
++particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate new particles
|
// generate new particles
|
||||||
|
|
||||||
if(fAge != -2.0f)
|
if(fAge != -2.0f)
|
||||||
{
|
{
|
||||||
float fParticlesNeeded = info.nEmission*fDeltaTime + fEmissionResidue;
|
float fParticlesNeeded = info.nEmission*fDeltaTime + fEmissionResidue;
|
||||||
int nParticlesCreated = (unsigned int)fParticlesNeeded;
|
int nParticlesCreated = (unsigned int)fParticlesNeeded;
|
||||||
fEmissionResidue=fParticlesNeeded-nParticlesCreated;
|
fEmissionResidue=fParticlesNeeded-nParticlesCreated;
|
||||||
|
|
||||||
par=&particles[nParticlesAlive];
|
for(i=0; i<nParticlesCreated; i++)
|
||||||
|
{
|
||||||
|
if(nParticlesAlive>=MAX_PARTICLES) break;
|
||||||
|
|
||||||
for(i=0; i<nParticlesCreated; i++)
|
hgeParticle newParticle;
|
||||||
{
|
newParticle.fAge = 0.0f;
|
||||||
if(nParticlesAlive>=MAX_PARTICLES) break;
|
newParticle.fTerminalAge = Random_Float(info.fParticleLifeMin, info.fParticleLifeMax);
|
||||||
|
|
||||||
par->fAge = 0.0f;
|
newParticle.vecLocation = vecPrevLocation+(vecLocation-vecPrevLocation)*Random_Float(0.0f, 1.0f);
|
||||||
par->fTerminalAge = Random_Float(info.fParticleLifeMin, info.fParticleLifeMax);
|
newParticle.vecLocation.x += Random_Float(-2.0f, 2.0f);
|
||||||
|
newParticle.vecLocation.y += Random_Float(-2.0f, 2.0f);
|
||||||
|
|
||||||
par->vecLocation = vecPrevLocation+(vecLocation-vecPrevLocation)*Random_Float(0.0f, 1.0f);
|
ang=info.fDirection-M_PI_2+Random_Float(0,info.fSpread)-info.fSpread/2.0f;
|
||||||
par->vecLocation.x += Random_Float(-2.0f, 2.0f);
|
if(info.bRelative) ang += (vecPrevLocation-vecLocation).Angle()+M_PI_2;
|
||||||
par->vecLocation.y += Random_Float(-2.0f, 2.0f);
|
newParticle.vecVelocity.x = cosf(ang);
|
||||||
|
newParticle.vecVelocity.y = sinf(ang);
|
||||||
|
newParticle.vecVelocity *= Random_Float(info.fSpeedMin, info.fSpeedMax);
|
||||||
|
|
||||||
ang=info.fDirection-M_PI_2+Random_Float(0,info.fSpread)-info.fSpread/2.0f;
|
newParticle.fGravity = Random_Float(info.fGravityMin, info.fGravityMax);
|
||||||
if(info.bRelative) ang += (vecPrevLocation-vecLocation).Angle()+M_PI_2;
|
newParticle.fRadialAccel = Random_Float(info.fRadialAccelMin, info.fRadialAccelMax);
|
||||||
par->vecVelocity.x = cosf(ang);
|
newParticle.fTangentialAccel = Random_Float(info.fTangentialAccelMin, info.fTangentialAccelMax);
|
||||||
par->vecVelocity.y = sinf(ang);
|
|
||||||
par->vecVelocity *= Random_Float(info.fSpeedMin, info.fSpeedMax);
|
|
||||||
|
|
||||||
par->fGravity = Random_Float(info.fGravityMin, info.fGravityMax);
|
newParticle.fSize = Random_Float(info.fSizeStart, info.fSizeStart+(info.fSizeEnd-info.fSizeStart)*info.fSizeVar);
|
||||||
par->fRadialAccel = Random_Float(info.fRadialAccelMin, info.fRadialAccelMax);
|
newParticle.fSizeDelta = (info.fSizeEnd-newParticle.fSize) / newParticle.fTerminalAge;
|
||||||
par->fTangentialAccel = Random_Float(info.fTangentialAccelMin, info.fTangentialAccelMax);
|
|
||||||
|
|
||||||
par->fSize = Random_Float(info.fSizeStart, info.fSizeStart+(info.fSizeEnd-info.fSizeStart)*info.fSizeVar);
|
newParticle.fSpin = Random_Float(info.fSpinStart, info.fSpinStart+(info.fSpinEnd-info.fSpinStart)*info.fSpinVar);
|
||||||
par->fSizeDelta = (info.fSizeEnd-par->fSize) / par->fTerminalAge;
|
newParticle.fSpinDelta = (info.fSpinEnd-newParticle.fSpin) / newParticle.fTerminalAge;
|
||||||
|
|
||||||
par->fSpin = Random_Float(info.fSpinStart, info.fSpinStart+(info.fSpinEnd-info.fSpinStart)*info.fSpinVar);
|
newParticle.colColor.r = Random_Float(info.colColorStart.r, info.colColorStart.r+(info.colColorEnd.r-info.colColorStart.r)*info.fColorVar);
|
||||||
par->fSpinDelta = (info.fSpinEnd-par->fSpin) / par->fTerminalAge;
|
newParticle.colColor.g = Random_Float(info.colColorStart.g, info.colColorStart.g+(info.colColorEnd.g-info.colColorStart.g)*info.fColorVar);
|
||||||
|
newParticle.colColor.b = Random_Float(info.colColorStart.b, info.colColorStart.b+(info.colColorEnd.b-info.colColorStart.b)*info.fColorVar);
|
||||||
|
newParticle.colColor.a = Random_Float(info.colColorStart.a, info.colColorStart.a+(info.colColorEnd.a-info.colColorStart.a)*info.fAlphaVar);
|
||||||
|
|
||||||
par->colColor.r = Random_Float(info.colColorStart.r, info.colColorStart.r+(info.colColorEnd.r-info.colColorStart.r)*info.fColorVar);
|
newParticle.colColorDelta.r = (info.colColorEnd.r-newParticle.colColor.r) / newParticle.fTerminalAge;
|
||||||
par->colColor.g = Random_Float(info.colColorStart.g, info.colColorStart.g+(info.colColorEnd.g-info.colColorStart.g)*info.fColorVar);
|
newParticle.colColorDelta.g = (info.colColorEnd.g-newParticle.colColor.g) / newParticle.fTerminalAge;
|
||||||
par->colColor.b = Random_Float(info.colColorStart.b, info.colColorStart.b+(info.colColorEnd.b-info.colColorStart.b)*info.fColorVar);
|
newParticle.colColorDelta.b = (info.colColorEnd.b-newParticle.colColor.b) / newParticle.fTerminalAge;
|
||||||
par->colColor.a = Random_Float(info.colColorStart.a, info.colColorStart.a+(info.colColorEnd.a-info.colColorStart.a)*info.fAlphaVar);
|
newParticle.colColorDelta.a = (info.colColorEnd.a-newParticle.colColor.a) / newParticle.fTerminalAge;
|
||||||
|
|
||||||
par->colColorDelta.r = (info.colColorEnd.r-par->colColor.r) / par->fTerminalAge;
|
if(bUpdateBoundingBox) rectBoundingBox.Encapsulate(newParticle.vecLocation.x, newParticle.vecLocation.y);
|
||||||
par->colColorDelta.g = (info.colColorEnd.g-par->colColor.g) / par->fTerminalAge;
|
|
||||||
par->colColorDelta.b = (info.colColorEnd.b-par->colColor.b) / par->fTerminalAge;
|
|
||||||
par->colColorDelta.a = (info.colColorEnd.a-par->colColor.a) / par->fTerminalAge;
|
|
||||||
|
|
||||||
if(bUpdateBoundingBox) rectBoundingBox.Encapsulate(par->vecLocation.x, par->vecLocation.y);
|
mParticleBuffer.push_back(newParticle);
|
||||||
|
++nParticlesAlive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nParticlesAlive++;
|
vecPrevLocation=vecLocation;
|
||||||
par++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vecPrevLocation=vecLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgeParticleSystem::MoveTo(float x, float y, bool bMoveParticles)
|
void hgeParticleSystem::MoveTo(float x, float y, bool bMoveParticles)
|
||||||
{
|
{
|
||||||
int i;
|
float dx,dy;
|
||||||
float dx,dy;
|
|
||||||
|
|
||||||
if(bMoveParticles)
|
if(bMoveParticles)
|
||||||
{
|
{
|
||||||
dx=x-vecLocation.x;
|
dx=x-vecLocation.x;
|
||||||
dy=y-vecLocation.y;
|
dy=y-vecLocation.y;
|
||||||
|
|
||||||
for(i=0;i<nParticlesAlive;i++)
|
ParticleBuffer::iterator particle = mParticleBuffer.begin();
|
||||||
{
|
for (; particle != mParticleBuffer.end(); ++particle)
|
||||||
particles[i].vecLocation.x += dx;
|
{
|
||||||
particles[i].vecLocation.y += dy;
|
particle->vecLocation.x += dx;
|
||||||
}
|
particle->vecLocation.y += dy;
|
||||||
|
}
|
||||||
|
|
||||||
vecPrevLocation.x=vecPrevLocation.x + dx;
|
vecPrevLocation.x=vecPrevLocation.x + dx;
|
||||||
vecPrevLocation.y=vecPrevLocation.y + dy;
|
vecPrevLocation.y=vecPrevLocation.y + dy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(fAge==-2.0) { vecPrevLocation.x=x; vecPrevLocation.y=y; }
|
if(fAge==-2.0) { vecPrevLocation.x=x; vecPrevLocation.y=y; }
|
||||||
else { vecPrevLocation.x=vecLocation.x; vecPrevLocation.y=vecLocation.y; }
|
else { vecPrevLocation.x=vecLocation.x; vecPrevLocation.y=vecLocation.y; }
|
||||||
}
|
}
|
||||||
|
|
||||||
vecLocation.x=x;
|
vecLocation.x=x;
|
||||||
vecLocation.y=y;
|
vecLocation.y=y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgeParticleSystem::FireAt(float x, float y)
|
void hgeParticleSystem::FireAt(float x, float y)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
MoveTo(x,y);
|
MoveTo(x,y);
|
||||||
Fire();
|
Fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgeParticleSystem::Fire()
|
void hgeParticleSystem::Fire()
|
||||||
{
|
{
|
||||||
mTimer = 0.0f;
|
mTimer = 0.0f;
|
||||||
|
|
||||||
if(info.fLifetime==-1.0f) fAge=-1.0f;
|
if(info.fLifetime==-1.0f) fAge=-1.0f;
|
||||||
else fAge=0.0f;
|
else fAge=0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgeParticleSystem::Stop(bool bKillParticles)
|
void hgeParticleSystem::Stop(bool bKillParticles)
|
||||||
{
|
{
|
||||||
fAge=-2.0f;
|
fAge=-2.0f;
|
||||||
if(bKillParticles)
|
if(bKillParticles)
|
||||||
{
|
{
|
||||||
nParticlesAlive=0;
|
nParticlesAlive=0;
|
||||||
rectBoundingBox.Clear();
|
mParticleBuffer.clear();
|
||||||
}
|
rectBoundingBox.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hgeParticleSystem::Render()
|
void hgeParticleSystem::Render()
|
||||||
{
|
{
|
||||||
int i;
|
ParticleBuffer::iterator particle = mParticleBuffer.begin();
|
||||||
// DWORD col;
|
for (;particle != mParticleBuffer.end(); ++particle)
|
||||||
hgeParticle *par=particles;
|
{
|
||||||
|
info.sprite->SetColor(particle->colColor.GetHWColor());
|
||||||
//col=info.sprite->GetColor();
|
JRenderer::GetInstance()->RenderQuad(
|
||||||
|
info.sprite,
|
||||||
for(i=0; i<nParticlesAlive; i++)
|
particle->vecLocation.x+fTx, particle->vecLocation.y+fTy,
|
||||||
{
|
particle->fSpin * particle->fAge,
|
||||||
info.sprite->SetColor(par->colColor.GetHWColor());
|
particle->fSize, particle->fSize);
|
||||||
JRenderer::GetInstance()->RenderQuad(info.sprite, par->vecLocation.x+fTx, par->vecLocation.y+fTy, par->fSpin*par->fAge, par->fSize, par->fSize);
|
}
|
||||||
par++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//info.sprite->SetColor(col);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,9 @@ ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) : Pos(
|
|||||||
else
|
else
|
||||||
particleSys = NEW hgeParticleSystem(psi); //Cache will clean psi up later.
|
particleSys = NEW hgeParticleSystem(psi); //Cache will clean psi up later.
|
||||||
|
|
||||||
|
// if we want to throttle the amount of particles for mana,
|
||||||
|
// here's where to do it - this is hardcoded to something like 114 in the psi file
|
||||||
|
particleSys->info.nEmission = 60;
|
||||||
icon = manaIcons[color];
|
icon = manaIcons[color];
|
||||||
|
|
||||||
particleSys->FireAt(x, y);
|
particleSys->FireAt(x, y);
|
||||||
@@ -252,15 +254,15 @@ void GuiMana::RenderStatic(){
|
|||||||
|
|
||||||
void GuiMana::Render()
|
void GuiMana::Render()
|
||||||
{
|
{
|
||||||
|
|
||||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||||
(*it)->Render();
|
(*it)->Render();
|
||||||
|
|
||||||
if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number)
|
if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number)
|
||||||
RenderStatic();
|
RenderStatic();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool remove_dead(ManaIcon* m) { return ManaIcon::DEAD != m->mode; }
|
bool remove_dead(ManaIcon* m) { return ManaIcon::DEAD != m->mode; }
|
||||||
|
|
||||||
void GuiMana::Update(float dt)
|
void GuiMana::Update(float dt)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user