Cube  Diff

Differences From Artifact [dcdd211b54]:

To Artifact [41bd950ef0]:


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
68
69
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(const OFVector3D *o, const OFVector3D *d, int fade, int type)
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->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(const OFVector3D *r, const OFVector3D *u)
setorient(OFVector3D r, OFVector3D u)
{
	right = *r;
	up = *u;
	right = r;
	up = u;
}

void
render_particles(int time)
{
	if (demoplayback && demotracking) {
	if (demoplayback && demotracking)
		OFVector3D o = player1.origin;
		OFVector3D nom = OFMakeVector3D(0, 0, 0);
		newparticle(&o, &nom, 100000000, 8);
		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
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
163

164
165
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, const OFVector3D *p)
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);
		newparticle(p, d, rnd(fade * 3), type);
	}
}

void
particle_trail(int type, int fade, const OFVector3D *s, const OFVector3D *e)
particle_trail(int type, int fade, OFVector3D s, OFVector3D e)
{
	float d = OFDistanceOfVectors3D(*s, *e);
	OFVector3D v = OFSubtractVectors3D(*s, *e);
	float d = OFDistanceOfVectors3D(s, e);
	OFVector3D v = OFSubtractVectors3D(s, e);
	v = OFMultiplyVector3D(v, 1.0f / (d * 2 + 0.1f));
	OFVector3D p = *s;
	for (int i = 0; i < ((int)d * 2); i++) {
		p = OFAddVectors3D(p, v);
		s = OFAddVectors3D(s, v);
		OFVector3D d =
		    OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5);
		newparticle(&p, &d, rnd(fade) + fade, type);
		newparticle(s, d, rnd(fade) + fade, type);
	}
}