Skip to content

Commit aa6e247

Browse files
committed
particle stepping fixes
1 parent 13c666b commit aa6e247

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/engine/renderparticles.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ VAR(IDF_PERSIST, particleglare, 0, 1, 100);
1717
// Automatically stops particles being emitted when paused or in reflective drawing
1818
VAR(IDF_PERSIST, emitmillis, 1, 20, VAR_MAX);
1919
static int lastemitframe = 0;
20-
static bool emit = false;
20+
static bool emit = false, canstep = false;
2121

2222
static bool canemitparticles()
2323
{
@@ -70,7 +70,7 @@ struct partrenderer
7070
}
7171

7272
//blend = 0 => remove it
73-
void calc(particle *p, int &blend, int &ts, float &size, bool lastpass = true)
73+
void calc(particle *p, int &blend, int &ts, float &size, bool step = true)
7474
{
7575
vec o = p->o;
7676
if(p->fade <= 5)
@@ -114,7 +114,7 @@ struct partrenderer
114114
v.z -= physics::gravityvel(&d)*secs;
115115
p->o.add(v);
116116
}
117-
if(p->collide && p->o.z < p->val && lastpass)
117+
if(step && p->collide && p->o.z < p->val)
118118
{
119119
if(p->collide >= 0)
120120
{
@@ -132,7 +132,7 @@ struct partrenderer
132132
}
133133
else p->m.add(vec(p->o).sub(o));
134134
}
135-
game::particletrack(p, type, ts, lastpass);
135+
game::particletrack(p, type, ts, step);
136136
}
137137

138138
const char *debuginfo()
@@ -273,17 +273,16 @@ struct listrenderer : partrenderer
273273
preload();
274274
startrender();
275275
if(tex) glBindTexture(GL_TEXTURE_2D, tex->id);
276-
bool lastpass = !reflecting && !refracting;
277276
for(T **prev = &list, *p = list; p; p = *prev)
278277
{
279278
int blend = 255, ts = 1;
280279
float size = 1;
281-
calc(p, blend, ts, size, lastpass);
280+
calc(p, blend, ts, size, canstep);
282281
if(blend > 0)
283282
{
284283
renderpart(p, blend, ts, size);
285284

286-
if(p->fade > 5 || !lastpass)
285+
if(p->fade > 5 || !canstep)
287286
{
288287
prev = &p->next;
289288
continue;
@@ -1145,6 +1144,7 @@ void debugparticles()
11451144

11461145
void renderparticles(bool mainpass)
11471146
{
1147+
canstep = mainpass;
11481148
//want to debug BEFORE the lastpass render (that would delete particles)
11491149
if(dbgparts && mainpass) loopi(sizeof(parts)/sizeof(parts[0])) parts[i]->debuginfo();
11501150

src/game/game.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ namespace game
20732073
return vec::hexcolor(pulsecols[c][n%PULSECOLOURS]).lerp(vec::hexcolor(pulsecols[c][n2%PULSECOLOURS]), (lastmillis%50)/50.0f);
20742074
}
20752075

2076-
void particletrack(particle *p, uint type, int &ts, bool lastpass)
2076+
void particletrack(particle *p, uint type, int &ts, bool step)
20772077
{
20782078
if(!p || !p->owner || !gameent::is(p->owner)) return;
20792079
gameent *d = (gameent *)p->owner;

src/shared/igame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace game
108108
extern int numdynents(bool all = false);
109109
extern vec getpalette(int palette, int index);
110110
extern void adddynlights();
111-
extern void particletrack(particle *p, uint type, int &ts, bool lastpass);
111+
extern void particletrack(particle *p, uint type, int &ts, bool step);
112112
extern bool mousemove(int dx, int dy, int x, int y, int w, int h);
113113
extern void project(int w, int h);
114114
extern void recomputecamera(int w, int h);

0 commit comments

Comments
 (0)