Cube  Diff

Differences From Artifact [4855ce96c9]:

To Artifact [d554171715]:


1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16
17
18
19

20
21
22
23
24
25
26
1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
26







-
+










-
+







// renderparticles.cpp

#include "cube.h"

const int MAXPARTICLES = 10500;
const int NUMPARTCUTOFF = 20;
struct particle {
	vec o, d;
	OFVector3D o, d;
	int fade, type;
	int millis;
	particle *next;
};
particle particles[MAXPARTICLES], *parlist = NULL, *parempty = NULL;
bool parinit = false;

VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);

void
newparticle(vec &o, vec &d, int fade, int type)
newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
{
	if (!parinit) {
		loopi(MAXPARTICLES)
		{
			particles[i].next = parempty;
			parempty = &particles[i];
		};
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
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







-
+


-
+



-
+





-
+

-
+







		parlist = p;
	};
};

VAR(demotracking, 0, 0, 1);
VARP(particlesize, 20, 100, 500);

vec right, up;
OFVector3D right, up;

void
setorient(vec &r, vec &u)
setorient(OFVector3D &r, OFVector3D &u)
{
	right = r;
	up = u;
};
}

void
render_particles(int time)
{
	if (demoplayback && demotracking) {
		vec nom = {0, 0, 0};
		OFVector3D nom = OFMakeVector3D(0, 0, 0);
		newparticle(player1->o, nom, 100000000, 8);
	};
	}

	glDepthMask(GL_FALSE);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
	glDisable(GL_FOG);

	struct parttype {
114
115
116
117
118
119
120
121

122
123
124
125
126
127


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
163
164


114
115
116
117
118
119
120

121
122
123
124
125


126
127
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


163
164







-
+




-
-
+
+







-
+










-
+

-
-
-
+
+
+

-
+



-
+



-
-
+
+

-
-
+
+
			*pp = p->next;
			p->next = parempty;
			parempty = p;
		} else {
			if (pt->gr)
				p->o.z -= ((lastmillis - p->millis) / 3.0f) *
				          curtime / (pt->gr * 10000);
			vec a = p->d;
			OFVector3D a = p->d;
			vmul(a, time);
			vdiv(a, 20000.0f);
			vadd(p->o, a);
			pp = &p->next;
		};
	};
		}
	}

	glEnable(GL_FOG);
	glDisable(GL_BLEND);
	glDepthMask(GL_TRUE);
};

void
particle_splash(int type, int num, int fade, vec &p)
particle_splash(int type, int num, int fade, OFVector3D &p)
{
	loopi(num)
	{
		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);
		vec d = {(float)x, (float)y, (float)z};
		OFVector3D d = OFMakeVector3D(x, y, z);
		newparticle(p, d, rnd(fade * 3), type);
	};
};

	}
}

void
particle_trail(int type, int fade, vec &s, vec &e)
particle_trail(int type, int fade, OFVector3D &s, OFVector3D &e)
{
	vdist(d, v, s, e);
	vdiv(v, d * 2 + 0.1f);
	vec p = s;
	OFVector3D p = s;
	loopi((int)d * 2)
	{
		vadd(p, v);
		vec d = {
		    float(rnd(11) - 5), float(rnd(11) - 5), float(rnd(11) - 5)};
		OFVector3D d =
		    OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5);
		newparticle(p, d, rnd(fade) + fade, type);
	};
};
	}
}