comparison Engine/Graphics/ParticleEngine.cpp @ 2496:5abd8fc8f1c6

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