comparison ParticleEngine.cpp @ 0:9c0607679772

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