Make CustomParticle_Render slightly faster

This commit is contained in:
UnknownShadow200 2020-02-23 00:24:12 +11:00
parent a5c3e296e9
commit 68639f9772
2 changed files with 5 additions and 6 deletions

View File

@ -322,9 +322,8 @@ static void CustomParticle_Render(struct CustomParticle* p, float t, VertexP3fT2
TextureRec rec = e->rec; TextureRec rec = e->rec;
int x, y, z; int x, y, z;
float frame_time = p->totalLifespan / e->frameCount; float time_lived = p->totalLifespan - p->base.lifetime;
float inverted_lifetime = Math_AbsF(p->base.lifetime - p->totalLifespan); int curFrame = Math_Floor(e->frameCount * (time_lived / p->totalLifespan));
int curFrame = Math_Floor(inverted_lifetime / frame_time);
float shiftU = curFrame * (rec.U2 - rec.U1); float shiftU = curFrame * (rec.U2 - rec.U1);
rec.U1 += shiftU;// * 0.0078125f; rec.U1 += shiftU;// * 0.0078125f;

View File

@ -26,10 +26,10 @@ struct CustomParticleEffect {
cc_bool fullBright; cc_bool fullBright;
float size; float size;
float sizeVariation; float sizeVariation;
float spread; //how far from the spawnpoint their location can vary float spread; /* how far from the spawnpoint their location can vary */
float speed; //how fast they move away/towards the origin float speed; /* how fast they move away/towards the origin */
float gravity; float gravity;
float baseLifetime; //how long (in seconds) the particle lives for float baseLifetime; /* how long (in seconds) the particle lives for */
float lifetimeVariation; float lifetimeVariation;
}; };