Differences From Artifact [dcdd211b54]:
- File src/renderparticles.m — part of check-in [6259424802] at 2025-03-23 21:31:55 on branch trunk — Remove vdist (user: js, size: 4160) [annotate] [blame] [check-ins using]
To Artifact [41bd950ef0]:
- File
src/renderparticles.m
— part of check-in
[304230c1e1]
at
2025-03-23 21:52:54
on branch trunk
— Avoid pointless pointers
Passing OFVector3D by reference is annoying and is worse at passing via registers. (user: js, size: 4036) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
14 15 16 17 18 19 20 | }; struct particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL; bool parinit = false; VARP(maxparticles, 100, 2000, MAXPARTICLES - 500); static void | | | | | | | | < < | < > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | }; struct particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL; bool parinit = false; VARP(maxparticles, 100, 2000, MAXPARTICLES - 500); static void newparticle(OFVector3D o, OFVector3D d, int fade, int type) { if (!parinit) { for (int i = 0; i < MAXPARTICLES; i++) { particles[i].next = parempty; parempty = &particles[i]; } parinit = true; } if (parempty) { struct particle *p = parempty; parempty = p->next; p->o = o; p->d = d; p->fade = fade; p->type = type; p->millis = lastmillis; p->next = parlist; parlist = p; } } VAR(demotracking, 0, 0, 1); VARP(particlesize, 20, 100, 500); OFVector3D right, up; void setorient(OFVector3D r, OFVector3D u) { right = r; up = u; } void render_particles(int time) { if (demoplayback && demotracking) newparticle( player1.origin, OFMakeVector3D(0, 0, 0), 100000000, 8); glDepthMask(GL_FALSE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); glDisable(GL_FOG); struct parttype { |
︙ | ︙ | |||
130 131 132 133 134 135 136 | glEnable(GL_FOG); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } void | | | | | | < | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | glEnable(GL_FOG); glDisable(GL_BLEND); glDepthMask(GL_TRUE); } void particle_splash(int type, int num, int fade, OFVector3D p) { for (int i = 0; i < num; i++) { const int radius = type == 5 ? 50 : 150; int x, y, z; do { x = rnd(radius * 2) - radius; y = rnd(radius * 2) - radius; z = rnd(radius * 2) - radius; } while (x * x + y * y + z * z > radius * radius); OFVector3D d = OFMakeVector3D(x, y, z); newparticle(p, d, rnd(fade * 3), type); } } void particle_trail(int type, int fade, OFVector3D s, OFVector3D e) { float d = OFDistanceOfVectors3D(s, e); OFVector3D v = OFSubtractVectors3D(s, e); v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f)); for (int i = 0; i < ((int)d * 2); i++) { s = OFAddVectors3D(s, v); OFVector3D d = OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5); newparticle(s, d, rnd(fade) + fade, type); } } |