comparison ParticleEngine.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children bcc051713d20
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
1 #include "ParticleEngine.h"
2 #include "Time.h"
3 #include "Render.h"
4 #include "Viewport.h"
5 #include "Outdoor.h"
6 #include "Game.h"
7 #include "IndoorCamera.h"
8 #include "Math.h"
9 #include "LOD.h"
10 #include "stru346.h"
11
12 #include "mm7_data.h"
13
14 //----- (0048AAC5) --------------------------------------------------------
15 ParticleEngine::ParticleEngine()
16 {
17 for (uint i = 0; i < 500; ++i)
18 memset(&pParticles[i], 0, sizeof(pParticles[i]));
19
20 ResetParticles();
21 }
22
23 //----- (0048AAF6) --------------------------------------------------------
24 void ParticleEngine::ResetParticles()
25 {
26 memset(pParticles, 0, 500 * sizeof(*pParticles));
27 uStartParticle = 500;
28 uEndParticle = 0;
29 uTimeElapsed = 0;
30 }
31
32 //----- (0048AB23) --------------------------------------------------------
33 void ParticleEngine::AddParticle(Particle_ *a2)
34 {
35 signed int v2; // eax@2
36 Particle *v3; // edx@2
37 Particle *v4; // esi@10
38 int v5; // ecx@10
39 char v6; // zf@10
40
41 if ( !pMiscTimer->bPaused )
42 {
43 v2 = 0;
44 v3 = (Particle *)this;
45 do
46 {
47 if ( !v3->bFree )
48 break;
49 ++v2;
50 ++v3;
51 }
52 while ( v2 < 500 );
53 if ( v2 < 500 )
54 {
55 if ( v2 < this->uStartParticle )
56 this->uStartParticle = v2;
57 if ( v2 > this->uEndParticle )
58 this->uEndParticle = v2;
59 v4 = &this->pParticles[v2];
60 v4->bFree = a2->bFree;
61 v4->x = a2->x;
62 v4->y = a2->y;
63 v4->z = a2->z;
64 v4->_x = a2->x;
65 v4->_y = a2->y;
66 v4->_z = a2->z;
67 v4->flt_10 = a2->flt_10;
68 v4->flt_14 = a2->flt_14;
69 v4->flt_18 = a2->flt_18;
70 v5 = a2->uDiffuse;
71 v4->uParticleColor = v5;
72 v4->uLightColor = v5;
73 v6 = (v4->bFree & 4) == 0;
74 v4->field_20 = a2->field_20;
75 v4->uTextureID = a2->uTextureID;
76 v4->flt_28 = a2->flt_28;
77 if ( v6 )
78 {
79 v4->field_38 = 0;
80 v4->_rotation = 0;
81 }
82 else
83 {
84 v4->field_38 = (unsigned __int8)rand() - 128;
85 v4->_rotation = rand();
86 }
87 }
88 }
89 }
90
91 //----- (0048ABF3) --------------------------------------------------------
92 void ParticleEngine::Draw()
93 {
94 ParticleEngine *v1; // esi@1
95
96 v1 = this;
97 v1->uTimeElapsed += pEventTimer->uTimeElapsed;
98 this->pLines.uNumLines = 0;
99 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
100 DrawParticles_BLV();
101 else
102 DrawParticles_ODM();
103 if ( pRenderer->pRenderD3D )
104 {
105 if ( v1->pLines.uNumLines )
106 {
107 pRenderer->pRenderD3D->pDevice->SetTexture(0, 0);
108 pRenderer->pRenderD3D->pDevice->DrawPrimitive(
109 D3DPT_LINELIST,
110 452,
111 v1->pLines.pLineVertices,
112 v1->pLines.uNumLines,
113 16);
114 }
115 }
116 }
117
118 //----- (0048AC65) --------------------------------------------------------
119 int ParticleEngine::UpdateParticles()
120 {
121 ParticleEngine *v1; // ebx@1
122 unsigned int time; // edi@1
123 int v3; // eax@1
124 int v4; // esi@2
125 int v5; // eax@3
126 char v6; // sf@4
127 float v7; // ST4C_4@11
128 double v8; // st7@12
129 int v9; // eax@12
130 double v10; // st7@14
131 float v11; // ST4C_4@14
132 float v12; // ST3C_4@14
133 double v13; // ST20_8@14
134 float v14; // ST3C_4@14
135 double v15; // ST18_8@14
136 float v16; // ST3C_4@14
137 double v17; // ST10_8@14
138 signed int result; // eax@19
139 signed int v19; // [sp+38h] [bp-14h]@1
140 int v20; // [sp+3Ch] [bp-10h]@1
141 unsigned int time_; // [sp+40h] [bp-Ch]@1
142 int v22; // [sp+44h] [bp-8h]@12
143 int v23; // [sp+48h] [bp-4h]@1
144
145 v20 = 0;
146 v1 = this;
147 time = pMiscTimer->bPaused == 0 ? pEventTimer->uTimeElapsed : 0;
148 v3 = this->uStartParticle;
149 v19 = 500;
150 time_ = pMiscTimer->bPaused == 0 ? pEventTimer->uTimeElapsed : 0;
151 v23 = this->uStartParticle;
152 if ( v3 <= this->uEndParticle )
153 {
154 v4 = (int)((char *)&this->pParticles[v3].uParticleColor + 1);
155 do
156 {
157 v5 = *(int *)(v4 - 0x1D);
158 if ( v5 )
159 {
160 v6 = ((*(int *)(v4 + 3) - time) & 0x80000000u) != 0;
161 *(int *)(v4 + 3) -= time;
162 if ( v6 )
163 {
164 *(int *)(v4 - 0x1D) = 0;
165 }
166 else
167 {
168 if ( BYTE1(v5) & 2 )
169 {
170 *(int *)(v4 + 15) = *(int *)(v4 - 25);
171 *(int *)(v4 + 19) = *(int *)(v4 - 21);
172 *(int *)(v4 + 23) = *(int *)(v4 - 17);
173 }
174 if ( v5 & 1 )
175 *(float *)(v4 - 5) = *(float *)(v4 - 5) - (double)(signed int)time_ * 5.0;
176 if ( v5 & 8 )
177 {
178 v7 = (double)(signed int)time_;
179 *(float *)(v4 - 25) = (double)(rand() % 5 - 2) * v7 * 0.0625 + *(float *)(v4 - 25);
180 *(float *)(v4 - 21) = (double)(rand() % 5 - 2) * v7 * 0.0625 + *(float *)(v4 - 21);
181 *(float *)(v4 - 17) = (double)(rand() % 5 + 4) * v7 * 0.0625 + *(float *)(v4 - 17);
182 }
183 v8 = (double)(signed int)time_ * 0.0078125;
184 v9 = (signed int)(time * *(int *)(v4 + 27)) / 16;
185 *(float *)(v4 - 25) = v8 * *(float *)(v4 - 13) + *(float *)(v4 - 25);
186 *(float *)(v4 - 21) = v8 * *(float *)(v4 - 9) + *(float *)(v4 - 21);
187 *(float *)(v4 - 17) = v8 * *(float *)(v4 - 5) + *(float *)(v4 - 17);
188 *(int *)(v4 + 31) += v9;
189 v22 = 2 * *(int *)(v4 + 3);
190 if ( 2 * *(int *)(v4 + 3) >= 255 )
191 v22 = 255;
192 v10 = (double)v22 * 0.0039215689;
193 v11 = v10;
194 v12 = (double)*(char *)(v4 + 1) * v10;
195 v13 = v12 + 6.7553994e15;
196 v14 = (double)*(char *)v4 * v11;
197 v15 = v14 + 6.7553994e15;
198 v16 = (double)(*(int *)(v4 - 1) & 0xFF) * v11;
199 v17 = v16 + 6.7553994e15;
200 *(int *)(v4 + 71) = LODWORD(v17) | ((LODWORD(v15) | (LODWORD(v13) << 8)) << 8);
201 if ( v23 < v19 )
202 v19 = v23;
203 if ( v23 > v20 )
204 v20 = v23;
205 }
206 }
207 ++v23;
208 v4 += 104;
209 }
210 while ( v23 <= v1->uEndParticle );
211 }
212 v1->uEndParticle = v20;
213 result = v19;
214 v1->uStartParticle = v19;
215 return result;
216 }
217
218 //----- (0048AE74) --------------------------------------------------------
219 bool ParticleEngine::ViewProject_TrueIfStillVisible(unsigned int uParticleID)
220 {
221 Particle *pParticle; // esi@1
222 double v56; // ST28_8@2
223 float v4; // eax@4
224 double v5; // ST34_8@4
225 signed __int64 v6; // qtt@4
226 double v7; // st7@4
227 float v8; // ST18_4@4
228 int v9; // ecx@4
229 int v10; // eax@4
230 double v11; // ST44_8@7
231 double v12; // ST4C_8@7
232 double v13; // ST4C_8@7
233 int v14; // ecx@7
234 signed __int64 v15; // qtt@7
235 int v16; // eax@7
236 int v17; // edx@7
237 float v18; // edx@7
238 int v19; // eax@7
239 int v20; // edx@7
240 int v21; // ST50_4@8
241 int v22; // ebx@8
242 int v23; // ecx@10
243 int v24; // edi@10
244 double v25; // ST44_8@12
245 double v26; // ST4C_8@12
246 int v27; // edi@12
247 int v28; // ST40_4@12
248 int v29; // ecx@12
249 signed __int64 v30; // qtt@12
250 int v31; // eax@12
251 int v32; // edx@12
252 float v33; // edx@12
253 int v34; // eax@12
254 int v35; // ecx@12
255 int v36; // ST38_4@13
256 int v37; // ST30_4@15
257 int v38; // eax@16
258 signed __int64 v40; // qtt@18
259 int v41; // eax@18
260 int v42; // ecx@18
261 int v43; // eax@18
262 unsigned __int64 v44; // qax@18
263 double v45; // st7@18
264 int v46; // ecx@18
265 float v47; // ST18_4@18
266 unsigned __int64 v48; // qax@18
267 double y_int_; // [sp+10h] [bp-40h]@2
268 int a2; // [sp+18h] [bp-38h]@10
269 int x_int; // [sp+20h] [bp-30h]@2
270 double z_int_; // [sp+24h] [bp-2Ch]@2
271 int z_int_4; // [sp+28h] [bp-28h]@8
272 int z; // [sp+3Ch] [bp-14h]@3
273 double a5; // [sp+40h] [bp-10h]@4
274 int a6; // [sp+48h] [bp-8h]@4
275 int y; // [sp+4Ch] [bp-4h]@3
276
277 pParticle = &this->pParticles[uParticleID];
278 if ( !pParticle->bFree )
279 return 0;
280 uParticleID = LODWORD(pParticle->x);
281 v56 = *(float *)&uParticleID + 6.7553994e15;
282 x_int = LODWORD(v56);
283 uParticleID = LODWORD(pParticle->y);
284 y_int_ = *(float *)&uParticleID + 6.7553994e15;
285 uParticleID = LODWORD(pParticle->z);
286 z_int_ = *(float *)&uParticleID + 6.7553994e15;
287 if ( !pRenderer->pRenderD3D )
288 {
289 if ( pBLVRenderParams->sPartyRotX )
290 {
291 if ( BYTE1(pParticle->bFree) & 2 )
292 {
293 v11 = pParticle->_x + 6.7553994e15;
294 uParticleID = (LODWORD(v11) - pBLVRenderParams->vPartyPos.x) << 16;
295 v12 = pParticle->_y + 6.7553994e15;
296 y = (LODWORD(v12) - pBLVRenderParams->vPartyPos.y) << 16;
297 z = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
298 HIDWORD(a5) = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
299 - z;
300 a6 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
301 v13 = pParticle->_z + 6.7553994e15;
302 uParticleID = (LODWORD(v13) - pBLVRenderParams->vPartyPos.z) << 16;
303 z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
304 - ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
305 v14 = z;
306 HIDWORD(v13) = (unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
307 HIDWORD(a5) = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16;
308 LODWORD(v15) = pBLVRenderParams->field_40 << 16;
309 HIDWORD(v15) = pBLVRenderParams->field_40 >> 16;
310 v16 = v15 / z;
311 v17 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
312 pParticle->field_58 = v16;
313 uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16;
314 LODWORD(v18) = pBLVRenderParams->uViewportCenterX
315 - ((signed int)((unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16) >> 16);
316 v19 = pParticle->field_58;
317 pParticle->field_48 = v18;
318 uParticleID = (unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16;
319 v20 = pBLVRenderParams->uViewportCenterY
320 - ((signed int)((unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16) >> 16);
321 pParticle->field_54 = v14;
322 pParticle->field_4C = v20;
323 }
324 uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
325 y = (LODWORD(y_int_) - pBLVRenderParams->vPartyPos.y) << 16;
326 HIDWORD(a5) = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
327 - ((unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
328 a6 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
329 HIDWORD(z_int_) = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
330 uParticleID = (LODWORD(z_int_) - pBLVRenderParams->vPartyPos.z) << 16;
331 v21 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
332 v22 = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v21;
333 z = ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v21;
334 if ( v22 < (signed int)0x40000u || v22 > (signed int)0x1F400000u )
335 return 0;
336 v23 = a6 + z_int_4;
337 a2 = a6 + z_int_4;
338 v24 = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16)
339 + ((unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sSineNegX) >> 16);
340 }
341 else
342 {
343 if ( BYTE1(pParticle->bFree) & 2 )
344 {
345 v25 = pParticle->_x + 6.7553994e15;
346 uParticleID = (LODWORD(v25) - pBLVRenderParams->vPartyPos.x) << 16;
347 v26 = pParticle->_y + 6.7553994e15;
348 y = (LODWORD(v26) - pBLVRenderParams->vPartyPos.y) << 16;
349 HIDWORD(v25) = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
350 v27 = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
351 - HIDWORD(v25);
352 z = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
353 - HIDWORD(v25);
354 v28 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
355 a5 = pParticle->_z + 6.7553994e15;
356 v29 = (LODWORD(a5) - pBLVRenderParams->vPartyPos.z) << 16;
357 LODWORD(v30) = pBLVRenderParams->field_40 << 16;
358 HIDWORD(v30) = pBLVRenderParams->field_40 >> 16;
359 v31 = v30 / z;
360 v32 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
361 pParticle->field_58 = v31;
362 uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16;
363 LODWORD(v33) = pBLVRenderParams->uViewportCenterX
364 - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16);
365 v34 = pParticle->field_58;
366 pParticle->field_48 = v33;
367 v35 = pBLVRenderParams->uViewportCenterY
368 - ((signed int)((unsigned __int64)(v34 * (signed __int64)v29) >> 16) >> 16);
369 pParticle->field_54 = v27;
370 pParticle->field_4C = v35;
371 }
372 uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
373 y = (LODWORD(y_int_) - pBLVRenderParams->vPartyPos.y) << 16;
374 v36 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
375 v22 = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v36;
376 z = ((unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v36;
377 if ( v22 < 262144 || v22 > 524288000 )
378 return 0;
379 v37 = (unsigned __int64)((signed int)uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16;
380 uParticleID = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
381 v23 = v37 + ((unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
382 a2 = v37 + ((unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
383 v24 = (LODWORD(z_int_) - pBLVRenderParams->vPartyPos.z) << 16;
384 }
385 uParticleID = abs(v23);
386 v38 = abs(v22);
387 if ( v38 >= (signed int)uParticleID )
388 {
389 LODWORD(v40) = pBLVRenderParams->field_40 << 16;
390 HIDWORD(v40) = pBLVRenderParams->field_40 >> 16;
391 v41 = v40 / z;
392 pParticle->field_58 = v41;
393 uParticleID = (unsigned __int64)(v41 * (signed __int64)a2) >> 16;
394 v42 = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v41 * (signed __int64)a2) >> 16) >> 16);
395 v43 = pParticle->field_58;
396 pParticle->uScreenSpaceX = v42;
397 v44 = v43 * (signed __int64)v24;
398 uParticleID = v44 >> 16;
399 v45 = pParticle->flt_28;
400 LODWORD(v44) = (signed int)(v44 >> 16) >> 16;
401 v46 = pBLVRenderParams->uViewportCenterY - v44;
402 pParticle->uScreenSpaceY = pBLVRenderParams->uViewportCenterY - v44;
403 v47 = v45;
404 v48 = _48B561_mess_with_scaling_along_z(/*v46, */v47) * (signed __int64)pParticle->field_58;
405 uParticleID = v48 >> 16;
406 pParticle->field_58 = v48 >> 16;
407 v10 = z;
408 goto LABEL_19;
409 }
410 return 0;
411 }
412 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
413 x_int,
414 SLODWORD(y_int_),
415 COERCE_UNSIGNED_INT64(*(float *)&uParticleID + 6.7553994e15),
416 (signed int *)&uParticleID,
417 &y,
418 &z,
419 1) )
420 return 0;
421 pGame->pIndoorCameraD3D->Project(uParticleID, y, z, (int *)&a5 + 1, &a6);
422 pParticle->flt_5C = pGame->pIndoorCameraD3D->flt_D0;
423 v4 = pParticle->flt_5C;
424 pParticle->flt_60 = pGame->pIndoorCameraD3D->flt_D4;
425 v5 = v4 + 6.7553994e15;
426 LODWORD(v6) = 0;
427 HIDWORD(v6) = SLOWORD(v5);
428 v7 = pParticle->flt_28;
429 pParticle->field_58 = v6 / (signed int)uParticleID;
430 v8 = v7;
431 pParticle->uScreenSpaceX = HIDWORD(a5);
432 pParticle->uScreenSpaceY = a6;
433 pParticle->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->field_58) >> 16;
434 v10 = uParticleID;
435 LABEL_19:
436 pParticle->field_50 = v10;
437 return 1;
438 }
439
440
441
442
443 //----- (0048B5B3) --------------------------------------------------------
444 bool ParticleEngine::_48B5B3(unsigned int uID)
445 {
446 ParticleEngine *v2; // ST18_4@1
447 int v3; // ebx@1
448 int v4; // edi@1
449 int v5; // ecx@1
450 Particle *v6; // esi@1
451 double v7; // ST14_8@2
452 double v8; // ST34_8@4
453 double v9; // ST3C_8@4
454 int v10; // ST50_4@4
455 int v11; // ST44_4@4
456 double v12; // ST48_8@4
457 signed __int64 v13; // qtt@4
458 int v14; // eax@4
459 int v15; // ST28_4@4
460 int v16; // edi@6
461 int v17; // eax@6
462 double v18; // ST2C_8@8
463 double v19; // ST34_8@8
464 int v20; // ST50_4@8
465 double v21; // ST34_8@8
466 signed __int64 v22; // qtt@8
467 int v23; // eax@8
468 int v24; // ST28_4@8
469 int v25; // edx@8
470 int v26; // edx@9
471 int v27; // eax@9
472 int v28; // ebx@12
473 signed __int64 v29; // qtt@13
474 int v30; // eax@13
475 int v31; // ST1C_4@13
476 double v32; // st7@13
477 signed int v33; // eax@13
478 int v34; // ecx@13
479 float v35; // ST04_4@13
480 int v36; // eax@13
481 int v37; // esi@15
482 double v39; // [sp+10h] [bp-40h]@2
483 int v40; // [sp+14h] [bp-3Ch]@12
484 int v41; // [sp+1Ch] [bp-34h]@2
485 double v42; // [sp+20h] [bp-30h]@2
486 int v43; // [sp+24h] [bp-2Ch]@5
487 int v44; // [sp+2Ch] [bp-24h]@1
488 int v45; // [sp+40h] [bp-10h]@5
489 int X_4; // [sp+48h] [bp-8h]@5
490 int v47; // [sp+4Ch] [bp-4h]@5
491 int v48; // [sp+4Ch] [bp-4h]@9
492 int uIDc; // [sp+58h] [bp+8h]@4
493 int uIDd; // [sp+58h] [bp+8h]@4
494 int uIDe; // [sp+58h] [bp+8h]@5
495 int uIDa; // [sp+58h] [bp+8h]@5
496 int uIDf; // [sp+58h] [bp+8h]@8
497 int uIDb; // [sp+58h] [bp+8h]@9
498
499 v2 = this;
500 v3 = stru_5C6E00->SinCos(pIndoorCamera->sRotationX);
501 v44 = stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi);
502 v4 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
503 v5 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
504 v6 = &v2->pParticles[uID];
505 if ( v6->bFree )
506 {
507 v7 = v6->x + 6.7553994e15;
508 v41 = LODWORD(v7);
509 v39 = v6->y + 6.7553994e15;
510 v42 = v6->z + 6.7553994e15;
511 if ( v3 )
512 {
513 if ( BYTE1(v6->bFree) & 2 )
514 {
515 v8 = v6->_x + 6.7553994e15;
516 uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16;
517 v9 = v6->_y + 6.7553994e15;
518 v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16;
519 v11 = ((unsigned __int64)(uIDc * (signed __int64)v4) >> 16)
520 + ((unsigned __int64)(v10 * (signed __int64)v5) >> 16);
521 HIDWORD(v8) = (unsigned __int64)(uIDc * (signed __int64)v5) >> 16;
522 v12 = v6->_z + 6.7553994e15;
523 uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16;
524 HIDWORD(v12) = ((unsigned __int64)(v11 * (signed __int64)v3) >> 16)
525 + ((unsigned __int64)(uIDd * (signed __int64)v44) >> 16);
526 LODWORD(v13) = 0;
527 HIDWORD(v13) = SLOWORD(pOutdoorCamera->int_fov_rad);
528 v14 = v13 / SHIDWORD(v12);
529 v6->field_58 = v14;
530 v15 = v6->field_58;
531 v6->uScreenSpaceX = pViewport->uScreenCenterX
532 - ((signed int)((unsigned __int64)(v14
533 * (signed __int64)(signed int)(((unsigned __int64)(v10 * (signed __int64)v4) >> 16)
534 - HIDWORD(v8))) >> 16) >> 16);
535 v6->uScreenSpaceY = pViewport->uScreenCenterY
536 - ((signed int)((unsigned __int64)(v15
537 * (signed __int64)(signed int)(((unsigned __int64)(uIDd * (signed __int64)v3) >> 16)
538 - ((unsigned __int64)(v11 * (signed __int64)v44) >> 16))) >> 16) >> 16);
539 v6->field_50 = HIDWORD(v12);
540 }
541 uIDe = (v41 - pIndoorCamera->pos.x) << 16;
542 v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16;
543 v45 = ((unsigned __int64)(uIDe * (signed __int64)v4) >> 16) + ((unsigned __int64)(v47 * (signed __int64)v5) >> 16);
544 HIDWORD(v42) = (unsigned __int64)(uIDe * (signed __int64)v5) >> 16;
545 uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16;
546 X_4 = ((unsigned __int64)(uIDa * (signed __int64)v44) >> 16)
547 + ((unsigned __int64)(v45 * (signed __int64)v3) >> 16);
548 if ( X_4 < 262144 )
549 return 0;
550 v16 = ((unsigned __int64)(v47 * (signed __int64)v4) >> 16) - v43;
551 v17 = ((unsigned __int64)(uIDa * (signed __int64)v3) >> 16)
552 - ((unsigned __int64)(v45 * (signed __int64)v44) >> 16);
553 }
554 else
555 {
556 if ( BYTE1(v6->bFree) & 2 )
557 {
558 v18 = v6->_x + 6.7553994e15;
559 uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16;
560 v19 = v6->_y + 6.7553994e15;
561 v20 = (LODWORD(v19) - pIndoorCamera->pos.y) << 16;
562 v21 = v6->_z + 6.7553994e15;
563 LODWORD(v22) = 0;
564 HIDWORD(v22) = SLOWORD(pOutdoorCamera->int_fov_rad);
565 v23 = v22
566 / (signed int)(((unsigned __int64)(v20 * (signed __int64)v5) >> 16)
567 + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16));
568 v6->field_58 = v23;
569 v24 = v6->field_58;
570 v6->uScreenSpaceX = pViewport->uScreenCenterX
571 - ((signed int)((unsigned __int64)(v23
572 * (signed __int64)(signed int)(((unsigned __int64)(v20 * (signed __int64)v4) >> 16)
573 - ((unsigned __int64)(uIDf * (signed __int64)v5) >> 16))) >> 16) >> 16);
574 v25 = pViewport->uScreenCenterY
575 - ((signed int)((unsigned __int64)(v24 * (signed __int64)SLODWORD(v21)) >> 16) >> 16);
576 v6->field_50 = ((unsigned __int64)(v20 * (signed __int64)v5) >> 16)
577 + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16);
578 v6->uScreenSpaceY = v25;
579 }
580 uIDb = (v41 - pIndoorCamera->pos.x) << 16;
581 v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16;
582 v26 = (unsigned __int64)(v48 * (signed __int64)v5) >> 16;
583 v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16);
584 X_4 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16);
585 if ( v27 < 262144 || v27 > (pOutdoorCamera->uPickDepth - 1000) << 16 )
586 return 0;
587 v17 = LODWORD(v42);
588 v16 = ((unsigned __int64)(v48 * (signed __int64)v4) >> 16) - ((unsigned __int64)(uIDb * (signed __int64)v5) >> 16);
589 }
590 v40 = v17;
591 v28 = abs(v16);
592 if ( abs(X_4) >= v28 )
593 {
594 LODWORD(v29) = 0;
595 HIDWORD(v29) = SLOWORD(pOutdoorCamera->int_fov_rad);
596 v30 = v29 / X_4;
597 v6->field_58 = v30;
598 v31 = v6->field_58;
599 v6->uScreenSpaceX = pViewport->uScreenCenterX
600 - ((signed int)((unsigned __int64)(v30 * (signed __int64)v16) >> 16) >> 16);
601 v32 = v6->flt_28;
602 v33 = (signed int)((unsigned __int64)(v31 * (signed __int64)v40) >> 16) >> 16;
603 v34 = pViewport->uScreenCenterY - v33;
604 v6->uScreenSpaceY = pViewport->uScreenCenterY - v33;
605 v35 = v32;
606 v6->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->field_58) >> 16;
607 v6->field_50 = X_4;
608 v36 = v6->uScreenSpaceX;
609 if ( v36 >= (signed int)pViewport->uViewportX )
610 {
611 if ( v36 < (signed int)pViewport->uViewportZ )
612 {
613 v37 = v6->uScreenSpaceY;
614 if ( v37 >= (signed int)pViewport->uViewportY )
615 {
616 if ( v37 < (signed int)pViewport->uViewportW )
617 return 1;
618 }
619 }
620 }
621 }
622 }
623 return 0;
624 }
625
626 //----- (0048BBA6) --------------------------------------------------------
627 void ParticleEngine::DrawParticles_BLV()
628 {
629 ParticleEngine *v1; // esi@1
630 int v2; // eax@1
631 unsigned __int8 v3; // zf@1
632 char v4; // sf@1
633 unsigned __int8 v5; // of@1
634 Render *v6; // ebx@2
635 char *v7; // edi@2
636 signed int v8; // ecx@7
637 int v9; // eax@10
638 signed int v10; // eax@12
639 int v11; // eax@18
640 int v12; // ecx@20
641 int v13; // edx@20
642 Particle *v14; // eax@28
643 RenderBillboardTransform_local0 v15; // [sp+Ch] [bp-58h]@1
644 int v16; // [sp+5Ch] [bp-8h]@5
645 int v17; // [sp+60h] [bp-4h]@1
646
647 v15.uParentBillboardID = -1;
648 v1 = this;
649 v2 = this->uStartParticle;
650 v5 = __OFSUB__(v2, this->uEndParticle);
651 v3 = v2 == this->uEndParticle;
652 v4 = v2 - this->uEndParticle < 0;
653 v17 = this->uStartParticle;
654 if ( (unsigned __int8)(v4 ^ v5) | v3 )
655 {
656 v6 = pRenderer;
657 v7 = (char *)&this->pParticles[v2].field_54 + 2;
658 do
659 {
660 if ( *(int *)(v7 - 86) )
661 {
662 if ( v1->ViewProject_TrueIfStillVisible(v2) )
663 {
664 v16 = *(int *)(v7 - 22);
665 if ( v16 >= (signed int)pBLVRenderParams->uViewportX )
666 {
667 if ( v16 < (signed int)pBLVRenderParams->uViewportZ )
668 {
669 v8 = *(int *)(v7 - 18);
670 if ( v8 >= (signed int)pBLVRenderParams->uViewportY )
671 {
672 if ( v8 < (signed int)pBLVRenderParams->uViewportW )
673 {
674 if ( pRenderer->pRenderD3D )
675 {
676 v9 = *(int *)(v7 - 86);
677 if ( BYTE1(v9) & 1 )
678 {
679 v14 = &v1->pParticles[v17];
680 v15.field_10 = v14->field_58 >> 2;
681 v15.field_14 = v14->field_58 >> 2;
682 v15.field_8 = v14->uScreenSpaceX;
683 v15.field_C = v14->uScreenSpaceY;
684 v15.field_28 = v14->field_50;
685 pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, v14->uLightColor, v14->_rotation);
686 return;
687 }
688 if ( BYTE1(v9) & 2 )
689 {
690 v10 = v1->pLines.uNumLines;
691 if ( v10 < 100 )
692 {
693 v1->pLines.pLineVertices[2 * v10].pos.x = (double)v16;
694 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.y = (double)*(signed int *)(v7 - 18);
695 v16 = *((short *)v7 - 2);
696 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.z = 1.0
697 - 1.0 / ((double)v16 * 0.061758894);
698 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].rhw = 1.0;
699 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].diffuse = *(int *)(v7 + 14);
700 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].specular = 0;
701 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].texcoord.x = 0.0;
702 *((float *)&v1->pParticles[0].bFree + 16 * (v1->pLines.uNumLines + 813)) = 0.0;
703 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 14);
704 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 10);
705 v16 = *(short *)v7;
706 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.z = 1.0
707 - 1.0 / ((double)v16 * 0.061758894);
708 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].rhw = 1.0;
709 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].diffuse = *(int *)(v7 + 14);
710 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].specular = 0;
711 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].texcoord.x = 0.0;
712 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines++ + 1].texcoord.y = 0.0;
713 }
714 }
715 if ( *(v7 - 85) & 4 )
716 {
717 v15.field_10 = *(int *)(v7 + 2);
718 v15.field_14 = *(int *)(v7 + 2);
719 v15.field_8 = *(int *)(v7 - 22);
720 v15.field_C = *(int *)(v7 - 18);
721 v15.field_28 = *(int *)(v7 - 6);
722 pRenderer->MakeParticleBillboardAndPush_BLV(
723 &v15,
724 pBitmaps_LOD->pHardwareTextures[*(int *)(v7 - 50)],
725 *(int *)(v7 + 14),
726 *(int *)(v7 - 26));
727 }
728 if ( *(v7 - 85) & 8 )
729 {
730 v15.field_10 = *(int *)(v7 + 2);
731 v15.field_14 = *(int *)(v7 + 2);
732 v15.field_8 = *(int *)(v7 - 22);
733 v15.field_C = *(int *)(v7 - 18);
734 v15.field_28 = *(int *)(v7 - 6);
735 pRenderer->MakeParticleBillboardAndPush_BLV(
736 &v15,
737 pSprites_LOD->pHardwareSprites[*(int *)(v7 - 50)].pTexture,
738 *(int *)(v7 + 14),
739 *(int *)(v7 - 26));
740 }
741 }
742 else
743 {
744 v11 = 13 * *(int *)(v7 + 2) >> 16;
745 if ( v11 > 30 )
746 v11 = 30;
747 v12 = v8 - v11;
748 v13 = v16 - (v11 >> 1);
749 if ( v13 + v11 < (signed int)pViewport->uViewportX
750 || v13 >= (signed int)pViewport->uViewportZ
751 || v12 + v11 < (signed int)pViewport->uViewportY
752 || v12 >= (signed int)pViewport->uViewportW )
753 {
754 v6 = pRenderer;
755 }
756 else
757 {
758 v6 = pRenderer;
759 pRenderer->_4A48E4(v13, v12, *(int *)(v7 - 6), *(int *)(v7 + 14), v11);
760 }
761 }
762 }
763 }
764 }
765 }
766 }
767 }
768 v7 += 104;
769 v2 = v17 + 1;
770 v5 = __OFSUB__(v17 + 1, v1->uEndParticle);
771 v3 = v17 + 1 == v1->uEndParticle;
772 v4 = v17++ + 1 - v1->uEndParticle < 0;
773 }
774 while ( (unsigned __int8)(v4 ^ v5) | v3 );
775 }
776 }
777
778 //----- (0048BEEF) --------------------------------------------------------
779 void ParticleEngine::DrawParticles_ODM()
780 {
781 ParticleEngine *v1; // esi@1
782 int v2; // eax@1
783 unsigned __int8 v3; // zf@1
784 char v4; // sf@1
785 unsigned __int8 v5; // of@1
786 Render *pRender; // ebx@2
787 char *v7; // edi@2
788 int v8; // eax@6
789 signed int v9; // eax@8
790 int v10; // eax@14
791 int v11; // ecx@16
792 int v12; // edx@16
793 Particle *v13; // eax@24
794 stru346 v14; // [sp+Ch] [bp-58h]@1
795 int v15; // [sp+5Ch] [bp-8h]@9
796 int v16; // [sp+60h] [bp-4h]@1
797
798 v14.uParentBillboardID = -1;
799 v1 = this;
800 v2 = this->uStartParticle;
801 v5 = __OFSUB__(v2, this->uEndParticle);
802 v3 = v2 == this->uEndParticle;
803 v4 = v2 - this->uEndParticle < 0;
804 v16 = this->uStartParticle;
805 if ( (unsigned __int8)(v4 ^ v5) | v3 )
806 {
807 pRender = pRenderer;
808 v7 = (char *)&this->pParticles[v2].field_50 + 2;
809 do
810 {
811 if ( *(int *)(v7 - 82) && v1->_48B5B3(v2) )
812 {
813 if ( pRenderer->pRenderD3D )
814 {
815 v8 = *(int *)(v7 - 82);
816 if ( BYTE1(v8) & 1 )
817 {
818 v13 = &v1->pParticles[v16];
819 v14.field_10 = v13->field_58 >> 2;
820 v14.field_14 = v13->field_58 >> 2;
821 v14.field_8 = v13->uScreenSpaceX;
822 v14.field_C = v13->uScreenSpaceY;
823 v14.field_28 = v13->field_50;
824 pRenderer->MakeParticleBillboardAndPush_ODM(
825 (RenderBillboardTransform_local0 *)&v14,
826 0,
827 v13->uLightColor,
828 v13->_rotation);
829 return;
830 }
831 if ( BYTE1(v8) & 2 )
832 {
833 v9 = v1->pLines.uNumLines;
834 if ( v9 < 100 )
835 {
836 v1->pLines.pLineVertices[2 * v9].pos.x = (double)*(signed int *)(v7 - 18);
837 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.y = (double)*(signed int *)(v7 - 14);
838 v15 = *(short *)v7;
839 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.z = 1.0
840 - 1.0
841 / ((double)v15
842 * 1000.0
843 / (double)pOutdoorCamera->shading_dist_mist);
844 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].rhw = 1.0;
845 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].diffuse = *(int *)(v7 + 18);
846 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].specular = 0;
847 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].texcoord.x = 0.0;
848 *((float *)&v1->pParticles[0].bFree + 16 * (v1->pLines.uNumLines + 813)) = 0.0;
849 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 10);
850 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 6);
851 v15 = *(short *)v7;
852 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.z = 1.0
853 - 1.0
854 / ((double)v15
855 * 1000.0
856 / (double)pOutdoorCamera->shading_dist_mist);
857 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].rhw = 1.0;
858 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].diffuse = *(int *)(v7 + 18);
859 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].specular = 0;
860 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].texcoord.x = 0.0;
861 v1->pLines.pLineVertices[2 * v1->pLines.uNumLines++ + 1].texcoord.y = 0.0;
862 }
863 }
864 if ( *(v7 - 81) & 4 )
865 {
866 v14.field_10 = *(int *)(v7 + 6);
867 v14.field_14 = *(int *)(v7 + 6);
868 v14.field_8 = *(int *)(v7 - 18);
869 v14.field_C = *(int *)(v7 - 14);
870 v14.field_28 = *(int *)(v7 - 2);
871 pRenderer->MakeParticleBillboardAndPush_ODM(
872 (RenderBillboardTransform_local0 *)&v14,
873 pBitmaps_LOD->pHardwareTextures[*(int *)(v7 - 46)],
874 *(int *)(v7 + 18),
875 *(int *)(v7 - 22));
876 }
877 if ( *(v7 - 81) & 8 )
878 {
879 v14.field_10 = *(int *)(v7 + 6);
880 v14.field_14 = *(int *)(v7 + 6);
881 v14.field_8 = *(int *)(v7 - 18);
882 v14.field_C = *(int *)(v7 - 14);
883 v14.field_28 = *(int *)(v7 - 2);
884 pRenderer->MakeParticleBillboardAndPush_ODM(
885 (RenderBillboardTransform_local0 *)&v14,
886 pSprites_LOD->pHardwareSprites[*(int *)(v7 - 46)].pTexture,
887 *(int *)(v7 + 18),
888 *(int *)(v7 - 22));
889 }
890 }
891 else
892 {
893 v10 = 13 * *(int *)(v7 + 6) >> 16;
894 if ( v10 > 30 )
895 v10 = 30;
896 v11 = *(int *)(v7 - 18) - (v10 >> 1);
897 v12 = *(int *)(v7 - 14) - v10;
898 if ( v11 + v10 < (signed int)pViewport->uViewportX
899 || v11 >= (signed int)pViewport->uViewportZ
900 || *(int *)(v7 - 14) < (signed int)pViewport->uViewportY
901 || v12 >= (signed int)pViewport->uViewportW )
902 {
903 pRender = pRenderer;
904 }
905 else
906 {
907 pRender = pRenderer;
908 pRenderer->_4A48E4(v11, v12, *(int *)(v7 - 2), *(int *)(v7 + 18), v10);
909 }
910 }
911 }
912 v7 += 104;
913 v2 = v16 + 1;
914 v5 = __OFSUB__(v16 + 1, v1->uEndParticle);
915 v3 = v16 + 1 == v1->uEndParticle;
916 v4 = v16++ + 1 - v1->uEndParticle < 0;
917 }
918 while ( (unsigned __int8)(v4 ^ v5) | v3 );
919 }
920 }