0
|
1 #include "stru10.h"
|
|
2 #include "Render.h"
|
|
3 #include "Indoor.h"
|
|
4 #include "Game.h"
|
|
5 #include "Party.h"
|
|
6
|
|
7 #include "mm7_data.h"
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12 //----- (0049CE9E) --------------------------------------------------------
|
|
13 void stru10::_49CE9E(BLVFace *pFace, RenderVertexSoft *a2, signed int a3, RenderVertexSoft *a4)
|
|
14 {
|
|
15 char *v5; // eax@1
|
|
16 signed int v6; // edx@1
|
|
17 unsigned int v7; // eax@3
|
|
18 signed int v8; // ecx@11
|
|
19 signed int v9; // esi@11
|
|
20 RenderVertexSoft *v10; // edx@12
|
|
21 double v11; // st6@14
|
|
22 RenderVertexSoft *v12; // edx@19
|
|
23 signed int v13; // ecx@19
|
|
24 signed int v14; // esi@19
|
|
25 RenderVertexSoft *v15; // edi@20
|
|
26 double v16; // st6@22
|
|
27 signed int v17; // ecx@27
|
|
28 signed int v18; // edi@27
|
|
29 char *v19; // esi@28
|
|
30 double v20; // st6@30
|
|
31 signed int v21; // ecx@35
|
|
32 signed int v22; // edi@35
|
|
33 char *v23; // esi@36
|
|
34 double v24; // st7@38
|
|
35 signed int v25; // ecx@45
|
|
36 signed int v26; // esi@45
|
|
37 RenderVertexSoft *v27; // edx@46
|
|
38 double v28; // st6@48
|
|
39 signed int v29; // ecx@53
|
|
40 signed int v30; // esi@53
|
|
41 RenderVertexSoft *v31; // edi@54
|
|
42 double v32; // st6@56
|
|
43 signed int v33; // ecx@61
|
|
44 signed int v34; // edi@61
|
|
45 char *v35; // esi@62
|
|
46 double v36; // st6@64
|
|
47 signed int v37; // edi@69
|
|
48 char *v38; // esi@70
|
|
49 double v39; // st7@72
|
|
50 RenderVertexSoft *v40; // esi@77
|
|
51 signed int v41; // ecx@79
|
|
52 signed int v42; // esi@79
|
|
53 char *v43; // edx@80
|
|
54 double v44; // st6@82
|
|
55 RenderVertexSoft *v45; // eax@87
|
|
56 signed int v46; // ecx@87
|
|
57 signed int v47; // edi@87
|
|
58 char *v48; // esi@88
|
|
59 double v49; // st6@90
|
|
60 signed int v50; // ecx@96
|
|
61 signed int v51; // edi@96
|
|
62 char *v52; // esi@97
|
|
63 double v53; // st6@99
|
|
64 signed int v54; // ecx@105
|
|
65 signed int v55; // edi@105
|
|
66 char *v56; // esi@106
|
|
67 double v57; // st7@108
|
|
68 RenderVertexSoft a2a[64]; // [sp+0h] [bp-C18h]@1
|
|
69 float v59; // [sp+C00h] [bp-18h]@4
|
|
70 float v60; // [sp+C04h] [bp-14h]@9
|
|
71 float v61; // [sp+C08h] [bp-10h]@4
|
|
72 float v62; // [sp+C0Ch] [bp-Ch]@9
|
|
73 float v63; // [sp+C10h] [bp-8h]@4
|
|
74 float v64; // [sp+C14h] [bp-4h]@4
|
|
75 float a1a; // [sp+C20h] [bp+8h]@11
|
|
76 float a1b; // [sp+C20h] [bp+8h]@19
|
|
77 float a1c; // [sp+C20h] [bp+8h]@27
|
|
78 float a1d; // [sp+C20h] [bp+8h]@35
|
|
79 float a1e; // [sp+C20h] [bp+8h]@45
|
|
80 float a1f; // [sp+C20h] [bp+8h]@53
|
|
81 float a1g; // [sp+C20h] [bp+8h]@61
|
|
82 float a1h; // [sp+C20h] [bp+8h]@69
|
|
83 float a1i; // [sp+C20h] [bp+8h]@79
|
|
84 float a1j; // [sp+C20h] [bp+8h]@87
|
|
85 float a1k; // [sp+C20h] [bp+8h]@96
|
|
86 float a1l; // [sp+C20h] [bp+8h]@105
|
|
87
|
|
88 v5 = (char *)&a2a[0].flt_2C;
|
|
89 v6 = 64;
|
|
90 do
|
|
91 {
|
|
92 *(float *)v5 = 0.0;
|
|
93 v5 += 48;
|
|
94 --v6;
|
|
95 }
|
|
96 while ( v6 );
|
|
97 stru10::CalcPolygonBoundingBox(pFace, a2a);
|
|
98 v7 = pFace->uAttributes;
|
|
99 if ( v7 & 0x100 )
|
|
100 {
|
|
101 v63 = a2a[0].vWorldPosition.x;
|
|
102 v59 = a2a[2].vWorldPosition.x;
|
|
103 v61 = a2a[1].vWorldPosition.y;
|
|
104 v64 = a2a[3].vWorldPosition.y;
|
|
105 goto LABEL_10;
|
|
106 }
|
|
107 if ( v7 & 0x200 )
|
|
108 {
|
|
109 v63 = a2a[0].vWorldPosition.x;
|
|
110 v59 = a2a[2].vWorldPosition.x;
|
|
111 }
|
|
112 else
|
|
113 {
|
|
114 if ( !(v7 & 0x400) )
|
|
115 goto LABEL_10;
|
|
116 v61 = a2a[0].vWorldPosition.y;
|
|
117 v64 = a2a[2].vWorldPosition.y;
|
|
118 }
|
|
119 v62 = a2a[1].vWorldPosition.z;
|
|
120 v60 = a2a[3].vWorldPosition.z;
|
|
121 LABEL_10:
|
|
122 if ( v7 & 0x100 )
|
|
123 {
|
|
124 v8 = -1;
|
|
125 a1a = 3.4028235e38;
|
|
126 v9 = 0;
|
|
127 if ( a3 > 0 )
|
|
128 {
|
|
129 v10 = a2;
|
|
130 do
|
|
131 {
|
|
132 if ( v10->vWorldPosition.x <= (double)v63 )
|
|
133 v11 = v63 - v10->vWorldPosition.x;
|
|
134 else
|
|
135 v11 = v10->vWorldPosition.x - v63;
|
|
136 if ( v11 < a1a )
|
|
137 {
|
|
138 a1a = v11;
|
|
139 v8 = v9;
|
|
140 }
|
|
141 ++v9;
|
|
142 ++v10;
|
|
143 }
|
|
144 while ( v9 < a3 );
|
|
145 }
|
|
146 v12 = a4;
|
|
147 a1b = 3.4028235e38;
|
|
148 memcpy(a4, &a2[v8], 0x30u);
|
|
149 v13 = -1;
|
|
150 v14 = 0;
|
|
151 if ( a3 > 0 )
|
|
152 {
|
|
153 v15 = a2;
|
|
154 do
|
|
155 {
|
|
156 if ( v15->vWorldPosition.x <= (double)v59 )
|
|
157 v16 = v59 - v15->vWorldPosition.x;
|
|
158 else
|
|
159 v16 = v15->vWorldPosition.x - v59;
|
|
160 if ( v16 < a1b )
|
|
161 {
|
|
162 a1b = v16;
|
|
163 v13 = v14;
|
|
164 }
|
|
165 ++v14;
|
|
166 ++v15;
|
|
167 }
|
|
168 while ( v14 < a3 );
|
|
169 }
|
|
170 a1c = 3.4028235e38;
|
|
171 memcpy(&a4[2], &a2[v13], sizeof(a4[2]));
|
|
172 v17 = -1;
|
|
173 v18 = 0;
|
|
174 if ( a3 > 0 )
|
|
175 {
|
|
176 v19 = (char *)&a2->vWorldPosition.y;
|
|
177 do
|
|
178 {
|
|
179 if ( *(float *)v19 <= (double)v61 )
|
|
180 v20 = v61 - *(float *)v19;
|
|
181 else
|
|
182 v20 = *(float *)v19 - v61;
|
|
183 if ( v20 < a1c )
|
|
184 {
|
|
185 a1c = v20;
|
|
186 v17 = v18;
|
|
187 }
|
|
188 ++v18;
|
|
189 v19 += 48;
|
|
190 }
|
|
191 while ( v18 < a3 );
|
|
192 }
|
|
193 a1d = 3.4028235e38;
|
|
194 memcpy(&a4[1], &a2[v17], sizeof(a4[1]));
|
|
195 v21 = -1;
|
|
196 v22 = 0;
|
|
197 if ( a3 > 0 )
|
|
198 {
|
|
199 v23 = (char *)&a2->vWorldPosition.y;
|
|
200 do
|
|
201 {
|
|
202 if ( *(float *)v23 <= (double)v64 )
|
|
203 v24 = v64 - *(float *)v23;
|
|
204 else
|
|
205 v24 = *(float *)v23 - v64;
|
|
206 if ( v24 < a1d )
|
|
207 {
|
|
208 a1d = v24;
|
|
209 v21 = v22;
|
|
210 }
|
|
211 ++v22;
|
|
212 v23 += 48;
|
|
213 }
|
|
214 while ( v22 < a3 );
|
|
215 }
|
|
216 LABEL_77:
|
|
217 v40 = &a2[v21];
|
|
218 goto LABEL_115;
|
|
219 }
|
|
220 if ( v7 & 0x200 )
|
|
221 {
|
|
222 v25 = -1;
|
|
223 a1e = 3.4028235e38;
|
|
224 v26 = 0;
|
|
225 if ( a3 > 0 )
|
|
226 {
|
|
227 v27 = a2;
|
|
228 do
|
|
229 {
|
|
230 if ( v27->vWorldPosition.x <= (double)v63 )
|
|
231 v28 = v63 - v27->vWorldPosition.x;
|
|
232 else
|
|
233 v28 = v27->vWorldPosition.x - v63;
|
|
234 if ( v28 < a1e )
|
|
235 {
|
|
236 a1e = v28;
|
|
237 v25 = v26;
|
|
238 }
|
|
239 ++v26;
|
|
240 ++v27;
|
|
241 }
|
|
242 while ( v26 < a3 );
|
|
243 }
|
|
244 v12 = a4;
|
|
245 a1f = 3.4028235e38;
|
|
246 memcpy(a4, &a2[v25], 0x30u);
|
|
247 v29 = -1;
|
|
248 v30 = 0;
|
|
249 if ( a3 > 0 )
|
|
250 {
|
|
251 v31 = a2;
|
|
252 do
|
|
253 {
|
|
254 if ( v31->vWorldPosition.x <= (double)v59 )
|
|
255 v32 = v59 - v31->vWorldPosition.x;
|
|
256 else
|
|
257 v32 = v31->vWorldPosition.x - v59;
|
|
258 if ( v32 < a1f )
|
|
259 {
|
|
260 a1f = v32;
|
|
261 v29 = v30;
|
|
262 }
|
|
263 ++v30;
|
|
264 ++v31;
|
|
265 }
|
|
266 while ( v30 < a3 );
|
|
267 }
|
|
268 a1g = 3.4028235e38;
|
|
269 memcpy(&a4[2], &a2[v29], sizeof(a4[2]));
|
|
270 v33 = -1;
|
|
271 v34 = 0;
|
|
272 if ( a3 > 0 )
|
|
273 {
|
|
274 v35 = (char *)&a2->vWorldPosition.z;
|
|
275 do
|
|
276 {
|
|
277 if ( *(float *)v35 <= (double)v62 )
|
|
278 v36 = v62 - *(float *)v35;
|
|
279 else
|
|
280 v36 = *(float *)v35 - v62;
|
|
281 if ( v36 < a1g )
|
|
282 {
|
|
283 a1g = v36;
|
|
284 v33 = v34;
|
|
285 }
|
|
286 ++v34;
|
|
287 v35 += 48;
|
|
288 }
|
|
289 while ( v34 < a3 );
|
|
290 }
|
|
291 a1h = 3.4028235e38;
|
|
292 memcpy(&a4[1], &a2[v33], sizeof(a4[1]));
|
|
293 v21 = -1;
|
|
294 v37 = 0;
|
|
295 if ( a3 > 0 )
|
|
296 {
|
|
297 v38 = (char *)&a2->vWorldPosition.z;
|
|
298 do
|
|
299 {
|
|
300 if ( *(float *)v38 <= (double)v60 )
|
|
301 v39 = v60 - *(float *)v38;
|
|
302 else
|
|
303 v39 = *(float *)v38 - v60;
|
|
304 if ( v39 < a1h )
|
|
305 {
|
|
306 a1h = v39;
|
|
307 v21 = v37;
|
|
308 }
|
|
309 ++v37;
|
|
310 v38 += 48;
|
|
311 }
|
|
312 while ( v37 < a3 );
|
|
313 }
|
|
314 goto LABEL_77;
|
|
315 }
|
|
316 if ( !(v7 & 0x400) )
|
|
317 return;
|
|
318 v41 = -1;
|
|
319 a1i = 3.4028235e38;
|
|
320 v42 = 0;
|
|
321 if ( a3 > 0 )
|
|
322 {
|
|
323 v43 = (char *)&a2->vWorldPosition.y;
|
|
324 do
|
|
325 {
|
|
326 if ( *(float *)v43 <= (double)v61 )
|
|
327 v44 = v61 - *(float *)v43;
|
|
328 else
|
|
329 v44 = *(float *)v43 - v61;
|
|
330 if ( v44 < a1i )
|
|
331 {
|
|
332 a1i = v44;
|
|
333 v41 = v42;
|
|
334 }
|
|
335 ++v42;
|
|
336 v43 += 48;
|
|
337 }
|
|
338 while ( v42 < a3 );
|
|
339 }
|
|
340 v45 = a2;
|
|
341 v12 = a4;
|
|
342 a1j = 3.4028235e38;
|
|
343 memcpy(a4, &a2[v41], 0x30u);
|
|
344 v46 = -1;
|
|
345 v47 = 0;
|
|
346 if ( a3 > 0 )
|
|
347 {
|
|
348 v48 = (char *)&a2->vWorldPosition.y;
|
|
349 do
|
|
350 {
|
|
351 if ( *(float *)v48 <= (double)v64 )
|
|
352 v49 = v64 - *(float *)v48;
|
|
353 else
|
|
354 v49 = *(float *)v48 - v64;
|
|
355 if ( v49 < a1j )
|
|
356 {
|
|
357 a1j = v49;
|
|
358 v46 = v47;
|
|
359 }
|
|
360 ++v47;
|
|
361 v48 += 48;
|
|
362 }
|
|
363 while ( v47 < a3 );
|
|
364 v45 = a2;
|
|
365 }
|
|
366 a1k = 3.4028235e38;
|
|
367 memcpy(&a4[2], &v45[v46], sizeof(a4[2]));
|
|
368 v50 = -1;
|
|
369 v51 = 0;
|
|
370 if ( a3 > 0 )
|
|
371 {
|
|
372 v52 = (char *)&v45->vWorldPosition.z;
|
|
373 do
|
|
374 {
|
|
375 if ( *(float *)v52 <= (double)v62 )
|
|
376 v53 = v62 - *(float *)v52;
|
|
377 else
|
|
378 v53 = *(float *)v52 - v62;
|
|
379 if ( v53 < a1k )
|
|
380 {
|
|
381 a1k = v53;
|
|
382 v50 = v51;
|
|
383 }
|
|
384 ++v51;
|
|
385 v52 += 48;
|
|
386 }
|
|
387 while ( v51 < a3 );
|
|
388 v45 = a2;
|
|
389 }
|
|
390 a1l = 3.4028235e38;
|
|
391 memcpy(&a4[1], &v45[v50], sizeof(a4[1]));
|
|
392 v54 = -1;
|
|
393 v55 = 0;
|
|
394 if ( a3 > 0 )
|
|
395 {
|
|
396 v56 = (char *)&v45->vWorldPosition.z;
|
|
397 do
|
|
398 {
|
|
399 if ( *(float *)v56 <= (double)v60 )
|
|
400 v57 = v60 - *(float *)v56;
|
|
401 else
|
|
402 v57 = *(float *)v56 - v60;
|
|
403 if ( v57 < a1l )
|
|
404 {
|
|
405 a1l = v57;
|
|
406 v54 = v55;
|
|
407 }
|
|
408 ++v55;
|
|
409 v56 += 48;
|
|
410 }
|
|
411 while ( v55 < a3 );
|
|
412 v45 = a2;
|
|
413 }
|
|
414 v40 = &v45[v54];
|
|
415 LABEL_115:
|
|
416 memcpy(&v12[3], v40, sizeof(v12[3]));
|
|
417 }
|
|
418
|
|
419 //----- (0049D379) --------------------------------------------------------
|
|
420 void stru10::CalcPolygonBoundingBox(BLVFace *pFace, RenderVertexSoft *pOutVertices)
|
|
421 {
|
|
422 struct
|
|
423 {
|
|
424 float x;
|
|
425 float y;
|
|
426 int c;
|
|
427 } v46[40]; //[sp+0C];
|
|
428
|
|
429 if (pFace->uAttributes & 0x0100)
|
|
430 {
|
|
431 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
432 {
|
|
433 v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
|
|
434 v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pYInterceptDisplacements[i];
|
|
435 v46[i].c = i;
|
|
436 }
|
|
437 }
|
|
438 if (pFace->uAttributes & 0x0200)
|
|
439 {
|
|
440 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
441 {
|
|
442 v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
|
|
443 v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pZInterceptDisplacements[i];
|
|
444 v46[i].c = i;
|
|
445 }
|
|
446 }
|
|
447 if (pFace->uAttributes & 0x0400)
|
|
448 {
|
|
449 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
450 {
|
|
451 v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pYInterceptDisplacements[i];
|
|
452 v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pZInterceptDisplacements[i];
|
|
453 v46[i].c = i;
|
|
454 }
|
|
455 }
|
|
456
|
|
457 float x_min = FLT_MAX;
|
|
458 uint x_min_idx = 0;
|
|
459
|
|
460 float x_max = FLT_MIN;
|
|
461 uint x_max_idx = 0;
|
|
462
|
|
463 float y_min = FLT_MAX;
|
|
464 uint y_min_idx = 0;
|
|
465
|
|
466 float y_max = FLT_MIN;
|
|
467 uint y_max_idx = 0;
|
|
468
|
|
469 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
470 {
|
|
471 if (v46[i].x < x_min)
|
|
472 {
|
|
473 x_min = v46[i].x;
|
|
474 x_min_idx = v46[i].c;
|
|
475 }
|
|
476 if (v46[i].x > x_max)
|
|
477 {
|
|
478 x_max = v46[i].x;
|
|
479 x_max_idx = v46[i].c;
|
|
480 }
|
|
481
|
|
482 if (v46[i].y < y_min)
|
|
483 {
|
|
484 y_min = v46[i].y;
|
|
485 y_min_idx = v46[i].c;
|
|
486 }
|
|
487 if (v46[i].y > y_max)
|
|
488 {
|
|
489 y_max = v46[i].y;
|
|
490 y_max_idx = v46[i].c;
|
|
491 }
|
|
492 }
|
|
493
|
|
494
|
|
495
|
|
496 auto p1 = &pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]];
|
|
497 RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24
|
|
498 v1.vWorldPosition.x = (float)p1->x;
|
|
499 v1.vWorldPosition.y = (float)p1->y;
|
|
500 v1.vWorldPosition.z = (float)p1->z;
|
|
501 memcpy(pOutVertices + 0, &v1, sizeof(RenderVertexSoft));
|
|
502
|
|
503 auto p2 = &pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]];
|
|
504 RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24
|
|
505 v2.vWorldPosition.x = (float)p2->x;
|
|
506 v2.vWorldPosition.y = (float)p2->y;
|
|
507 v2.vWorldPosition.z = (float)p2->z;
|
|
508 memcpy(pOutVertices + 1, &v2, sizeof(RenderVertexSoft));
|
|
509
|
|
510 auto p3 = &pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]];
|
|
511 RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24
|
|
512 v3.vWorldPosition.x = (float)p3->x;
|
|
513 v3.vWorldPosition.y = (float)p3->y;
|
|
514 v3.vWorldPosition.z = (float)p3->z;
|
|
515 memcpy(pOutVertices + 2, &v3, sizeof(RenderVertexSoft));
|
|
516
|
|
517 auto p4 = &pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]];
|
|
518 RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24
|
|
519 v4.vWorldPosition.x = (double)p4->x;
|
|
520 v4.vWorldPosition.y = (double)p4->y;
|
|
521 v4.vWorldPosition.z = (double)p4->z;
|
|
522 memcpy(pOutVertices + 3, &v4, sizeof(RenderVertexSoft));
|
|
523 }
|
|
524
|
|
525
|
|
526 //----- (0049C9E3) --------------------------------------------------------
|
|
527 bool stru10::_49C9E3(BLVFace *pFace, RenderVertexSoft *pFaceBounding, unsigned int uNumVertices, RenderVertexSoft *arg0)
|
|
528 {
|
|
529 //IndoorCameraD3D *v6; // edi@1
|
|
530 //PolygonType v7; // al@1
|
|
531 //unsigned int v8; // edx@7
|
|
532 //char v10; // zf@10
|
|
533 //float v13; // ST14_4@20
|
|
534 //stru10 *v15; // ecx@21
|
|
535 //RenderVertexSoft *v16; // ST0C_4@21
|
|
536 //bool result; // eax@21
|
|
537 //float v18; // ST14_4@24
|
|
538 //stru10 *v19; // edi@29
|
|
539 //float v20; // ST14_4@30
|
|
540 //float v21; // ST14_4@30
|
|
541 //float v22; // ST14_4@30
|
|
542 //float v23; // ST14_4@30
|
|
543 //float v24; // ST14_4@31
|
|
544 //RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
|
|
545 //RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
546 //IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
|
|
547 //stru10 *v31; // [sp+84h] [bp-1Ch]@1
|
|
548 float v32; // [sp+88h] [bp-18h]@8
|
|
549 Vec3_float_ a1; // [sp+8Ch] [bp-14h]@1
|
|
550 float v35; // [sp+9Ch] [bp-4h]@8
|
|
551
|
|
552 //auto a3 = pFace;
|
|
553 //auto arg4 = pFaceBounding;
|
|
554
|
|
555 //_ESI = a3;
|
|
556 //v31 = this;
|
|
557 //v6 = pGame->pIndoorCameraD3D;
|
|
558 //v7 = a3->uPolygonType;
|
|
559
|
|
560 a1.x = 0.0f;
|
|
561 a1.y = 0.0f;
|
|
562 a1.z = 0.0f;
|
|
563
|
|
564 float var_28;
|
|
565 float var_24;
|
|
566 if (pFace->uPolygonType == POLYGON_VerticalWall)
|
|
567 {
|
|
568 a1.x = -pFace->pFacePlane.vNormal.y;
|
|
569 a1.y = pFace->pFacePlane.vNormal.x;
|
|
570 a1.z = 0.0f;
|
|
571 a1.Normalize();
|
|
572
|
|
573 var_28 = 0;
|
|
574 var_24 = 1;
|
|
575 }
|
|
576 else if (pFace->uPolygonType == POLYGON_Floor ||
|
|
577 pFace->uPolygonType == POLYGON_Ceiling)
|
|
578 {
|
|
579 a1.x = 1;
|
|
580 a1.y = 0;
|
|
581 a1.z = 0.0f;
|
|
582
|
|
583 var_28 = 1;
|
|
584 var_24 = 0;
|
|
585 }
|
|
586
|
|
587
|
|
588 float arg_4;
|
|
589 float var_18;
|
|
590 float var_4;
|
|
591 float a3;
|
|
592 float var_8;
|
|
593 //v8 = _ESI->uAttributes;
|
|
594 //_ECX = pFaceBounding;
|
|
595 //__asm { fld 0.5 }
|
|
596 if (pFace->uAttributes & 0x0100)
|
|
597 {
|
|
598 arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
|
|
599 var_18 = (pFaceBounding[3].vWorldPosition.y + pFaceBounding[1].vWorldPosition.y) / 2;
|
|
600 var_4 = (pFaceBounding[0].vWorldPosition.z + pFaceBounding[2].vWorldPosition.z) / 2;
|
|
601
|
|
602 a3 = arg_4 - pFaceBounding[0].vWorldPosition.x;
|
|
603 var_8 = var_18 - pFaceBounding[1].vWorldPosition.y;
|
|
604 }
|
|
605 if (pFace->uAttributes & 0x0200)
|
|
606 {
|
|
607 arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
|
|
608 var_18 = (pFaceBounding[0].vWorldPosition.y + pFaceBounding[2].vWorldPosition.y) / 2;
|
|
609 var_4 = (pFaceBounding[1].vWorldPosition.z + pFaceBounding[3].vWorldPosition.z) / 2;
|
|
610
|
|
611 a3 = arg_4 - pFaceBounding[0].vWorldPosition.x;
|
|
612 var_8 = var_4 - pFaceBounding[1].vWorldPosition.z;
|
|
613
|
|
614 if (pFace->uPolygonType == POLYGON_VerticalWall)
|
|
615 a3 /= a1.x;
|
|
616 }
|
|
617 if (pFace->uAttributes & 0x0400)
|
|
618 {
|
|
619 arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
|
|
620 var_18 = (pFaceBounding[0].vWorldPosition.y + pFaceBounding[2].vWorldPosition.y) / 2;
|
|
621 var_4 = (pFaceBounding[1].vWorldPosition.z + pFaceBounding[3].vWorldPosition.z) / 2;
|
|
622
|
|
623 a3 = var_18 - pFaceBounding[0].vWorldPosition.y;
|
|
624 var_8 = var_4 - pFaceBounding[1].vWorldPosition.z;
|
|
625 // [0.5]
|
|
626 if (pFace->uPolygonType == POLYGON_VerticalWall)
|
|
627 {
|
|
628 if (a1.x != 1.0f)
|
|
629 a3 /= a1.y;
|
|
630 }
|
|
631 }
|
|
632
|
|
633
|
|
634 if ( byte_4D864C && pGame->uFlags & 8 )
|
|
635 {
|
|
636 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
637 v26.vWorldPosition.x = arg_4;
|
|
638 v26.vWorldPosition.y = v32;
|
|
639 v26.vWorldPosition.z = v35;
|
|
640
|
|
641 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(pFaceBounding, 0xFF00u, &v26, 0xFF0000u, 0, 0);
|
|
642 }
|
|
643
|
|
644 //_EBX = arg0;
|
|
645 //v15 = v31;
|
|
646 //v16 = arg0;
|
|
647 float var_20 = var_8 * var_24;
|
|
648 var_8 = a3 * a1.z;
|
|
649 float arg_0 = var_8 + var_4;
|
|
650
|
|
651 arg0[0].vWorldPosition.x = arg_4 - a3 * a1.x + var_8 * flt_4D84E8;
|
|
652 arg0[0].vWorldPosition.y = var_18 - a3 * a1.y + var_8 * var_28;
|
|
653 arg0[0].vWorldPosition.z = var_4 - var_8 + var_8 * var_24;
|
|
654 arg0[1].vWorldPosition.x = arg_4 - a3 * a1.x - var_8 * flt_4D84E8;
|
|
655 arg0[1].vWorldPosition.y = var_18 - a3 * a1.y - var_8 * var_28;
|
|
656 arg0[1].vWorldPosition.z = (var_4 - var_8) - var_8 * var_24;
|
|
657 arg0[2].vWorldPosition.x = a3 * a1.x + arg_4 - var_8 * flt_4D84E8;
|
|
658 arg0[2].vWorldPosition.y = a3 * a1.y + var_18 - var_8 * var_28;
|
|
659 arg0[2].vWorldPosition.z = var_8 + var_4 - var_20;
|
|
660 arg0[3].vWorldPosition.x = (a3 * a1.x + arg_4) + var_8 * flt_4D84E8;
|
|
661 arg0[3].vWorldPosition.y = a3 * a1.y + var_18 + var_8 * var_28;
|
|
662 arg0[3].vWorldPosition.z = arg_0 + var_20;
|
|
663
|
|
664 a3 = (var_4 - var_8);
|
|
665 a3 = (a3 * a1.x + arg_4);
|
|
666
|
|
667 a1.x = 0.0f;
|
|
668 a1.y = 0.0f;
|
|
669 a1.z = 0.0f;
|
|
670
|
|
671 if (!_49C8DC(arg0, &a1, &a3))
|
|
672 return false;
|
|
673
|
|
674
|
|
675 if ( byte_4D864C )
|
|
676 {
|
|
677 if ( pGame->uFlags & 8 )
|
|
678 {
|
|
679 RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
|
|
680 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
681
|
|
682 v25.vWorldPosition.x = arg_4;
|
|
683 v25.vWorldPosition.y = v32;
|
|
684 v25.vWorldPosition.z = v35;
|
|
685
|
|
686 v26.vWorldPosition.x = a1.x * 30.0f;
|
|
687 v26.vWorldPosition.y = a1.y * 30.0f;
|
|
688 v26.vWorldPosition.z = a1.z * 30.0f;
|
|
689
|
|
690 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, 0);
|
|
691 }
|
|
692 }
|
|
693
|
|
694
|
|
695 RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
|
|
696 memcpy(&v25, arg0, sizeof(RenderVertexSoft));
|
|
697
|
|
698 float _dp = (v25.vWorldPosition.x - pBLVRenderParams->vPartyPos.x) * a1.x +
|
|
699 (v25.vWorldPosition.y - pBLVRenderParams->vPartyPos.y) * a1.y +
|
|
700 (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z;
|
|
701 if (fabs(_dp) < 1e-6f)
|
|
702 {
|
|
703 memcpy(&v25, arg0 + 1, sizeof(RenderVertexSoft));
|
|
704 memcpy(arg0 + 1, arg0 + 3, sizeof(RenderVertexSoft));
|
|
705 memcpy(arg0 + 3, &v25, sizeof(RenderVertexSoft));
|
|
706 }
|
|
707
|
|
708 if ( byte_4D864C && pGame->uFlags & 8 )
|
|
709 {
|
|
710 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
711 if ( !LOBYTE(field_4) )
|
|
712 {
|
|
713 v26.vWorldPosition.x = pParty->vPosition.x;
|
|
714 v26.vWorldPosition.y = pParty->vPosition.y;
|
|
715 v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel;
|
|
716
|
|
717 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, arg0, 0xFF0000u, 0, 0);
|
|
718 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, arg0 + 1, 0xFF00u, 0, 0);
|
|
719 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, arg0 + 2, 0xFFu, 0, 0);
|
|
720 pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, arg0 + 3, 0xFFFFFFu, 0, 0);
|
|
721 LOBYTE(field_4) = 1;
|
|
722 }
|
|
723 pGame->pIndoorCameraD3D->debug_outline_sw(arg0, uNumVertices, 0x1EFF1Eu, 0.00019999999);
|
|
724 }
|
|
725 return true;
|
|
726 }
|
|
727
|
|
728
|
|
729
|
|
730 //----- (0049C5B0) --------------------------------------------------------
|
|
731 stru10::stru10()
|
|
732 {
|
|
733 LOBYTE(this->field_4) = 0;
|
|
734 }
|
|
735
|
|
736 //----- (0049C5BD) --------------------------------------------------------
|
|
737 stru10::~stru10()
|
|
738 {
|
|
739 }
|
|
740
|
|
741 //----- (0049C5DA) --------------------------------------------------------
|
|
742 char stru10::_49C5DA(BLVFace *a2, RenderVertexSoft *a3, int *a4, IndoorCameraD3D_Vec4 *a5, RenderVertexSoft *a6)
|
|
743 {
|
|
744 stru10 *v6; // edi@1
|
|
745 char *v7; // eax@1
|
|
746 signed int v8; // ecx@1
|
|
747 IndoorCameraD3D *v9; // esi@3
|
|
748 char result; // al@6
|
|
749 RenderVertexSoft a4a[4]; // [sp+Ch] [bp-C0h]@1
|
|
750
|
|
751 v6 = this;
|
|
752 v7 = (char *)&a4a[0].flt_2C;
|
|
753 v8 = 4;
|
|
754 do
|
|
755 {
|
|
756 *(float *)v7 = 0.0;
|
|
757 v7 += 48;
|
|
758 --v8;
|
|
759 }
|
|
760 while ( v8 );
|
|
761 v9 = pGame->pIndoorCameraD3D;
|
|
762 _49CE9E(a2, a3, *a4, a4a);
|
|
763 if ( byte_4D864C && pGame->uFlags & 8 )
|
|
764 pGame->pIndoorCameraD3D->debug_outline_sw(a4a, 4u, 0xFF1E1Eu, 0.000099999997);
|
|
765 result = _49C9E3(a2, a4a, 4u, a6);
|
|
766 if ( result )
|
|
767 result = _49C720(a6, a5);
|
|
768 return result;
|
|
769 }
|
|
770 // 4D864C: using guessed type char byte_4D864C;
|
|
771
|
|
772 //----- (0049C681) --------------------------------------------------------
|
|
773 char stru10::_49C681_DrawDebugStuff(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pArrayOf4)
|
|
774 {
|
|
775 RenderVertexSoft pBounding[4]; // [sp+Ch] [bp-C0h]@1
|
|
776
|
|
777 CalcPolygonBoundingBox(pFace, pBounding);
|
|
778 if ( byte_4D864C && pGame->uFlags & 8 )
|
|
779 pGame->pIndoorCameraD3D->debug_outline_sw(pBounding, 4, 0xFF1E1E, 0.000099999997);
|
|
780 if (_49C9E3(pFace, pBounding, 4, pArrayOf4))
|
|
781 return _49C720(pArrayOf4, a3);
|
|
782 return false;
|
|
783 }
|
|
784 // 4D864C: using guessed type char byte_4D864C;
|
|
785
|
|
786 //----- (0049C720) --------------------------------------------------------
|
|
787 char stru10::_49C720(RenderVertexSoft *a2, IndoorCameraD3D_Vec4 *a4)
|
|
788 {
|
|
789 char result; // al@2
|
|
790 Vec3_float_ a3; // [sp+4h] [bp-34h]@1
|
|
791 float v5; // [sp+30h] [bp-8h]@1
|
|
792 stru10 *thisa; // [sp+34h] [bp-4h]@1
|
|
793
|
|
794 v5 = 0.0;
|
|
795 a3.x = (double)pBLVRenderParams->vPartyPos.x;
|
|
796 a3.y = (double)pBLVRenderParams->vPartyPos.y;
|
|
797 thisa = this;
|
|
798 a3.z = (double)pBLVRenderParams->vPartyPos.z;
|
|
799 if ( _49C7C5(a2, a2 + 1, &a3, a4)
|
|
800 && _49C7C5(a2 + 1, a2 + 2, &a3, a4 + 1)
|
|
801 && _49C7C5(a2 + 2, a2 + 3, &a3, a4 + 2) )
|
|
802 result = _49C7C5(a2 + 3, a2, &a3, a4 + 3) != 0;
|
|
803 else
|
|
804 result = 0;
|
|
805 return result;
|
|
806 }
|
|
807
|
|
808 //----- (0049C7C5) --------------------------------------------------------
|
|
809 bool stru10::_49C7C5(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4)
|
|
810 {
|
|
811 double v5; // st7@1
|
|
812 double v6; // st6@1
|
|
813 double v7; // st5@1
|
|
814 Vec3_float_ *result; // eax@1
|
|
815 __int16 v9; // fps@3
|
|
816 char v10; // c0@3
|
|
817 char v11; // c2@3
|
|
818 char v12; // c3@3
|
|
819 float v13; // ecx@5
|
|
820 double v14; // st7@5
|
|
821 double v15; // st6@5
|
|
822 Vec3_float_ v1; // [sp+4h] [bp-48h]@1
|
|
823 Vec3_float_ v2; // [sp+10h] [bp-3Ch]@1
|
|
824 float v18; // [sp+20h] [bp-2Ch]@1
|
|
825 float v19; // [sp+24h] [bp-28h]@1
|
|
826 Vec3_float_ v20; // [sp+28h] [bp-24h]@1
|
|
827 Vec3_float_ v21; // [sp+34h] [bp-18h]@1
|
|
828 Vec3_float_ a1a; // [sp+40h] [bp-Ch]@1
|
|
829
|
|
830 a1a.x = 0.0;
|
|
831 a1a.y = 0.0;
|
|
832 a1a.z = 0.0;
|
|
833 v21.x = a3->x;
|
|
834 v21.y = a3->y;
|
|
835 v21.z = a3->z;
|
|
836 v5 = a1->vWorldPosition.x;
|
|
837 v6 = a1->vWorldPosition.y;
|
|
838 v2.z = a1->vWorldPosition.z;
|
|
839 v7 = a2->vWorldPosition.x;
|
|
840 v18 = a2->vWorldPosition.y;
|
|
841 v19 = a2->vWorldPosition.z;
|
|
842 v20.x = v5 - v21.x;
|
|
843 v20.y = v6 - v21.y;
|
|
844 v20.z = v2.z - v21.z;
|
|
845 LODWORD(v1.x) = (int)v20.x;
|
|
846 v1.y = v20.y;
|
|
847 v1.z = v20.z;
|
|
848 v20.x = v7 - v5;
|
|
849 v20.y = v18 - v6;
|
|
850 v20.z = v19 - v2.z;
|
|
851 result = Vec3_float_::Cross(&v1, &v2, v20.x, v20.y, v20.z);
|
|
852 a1a.x = result->x;
|
|
853 a1a.y = result->y;
|
|
854 a1a.z = result->z;
|
|
855 if ( a1a.x != 0.0
|
|
856 || a1a.y != 0.0
|
|
857 || (/*UNDEF(v9),*/ v10 = a1a.z < 0.0, v11 = 0, v12 = a1a.z == 0.0, BYTE1(result) = HIBYTE(v9), a1a.z != 0.0) )
|
|
858 {
|
|
859 a1a.Normalize();
|
|
860 result = (Vec3_float_ *)a4;
|
|
861 v13 = a1a.y;
|
|
862 a4->x = a1a.x;
|
|
863 v14 = v21.z * a1a.z;
|
|
864 v15 = v21.y * a1a.y;
|
|
865 a4->y = v13;
|
|
866 a4->z = a1a.z;
|
|
867 a4->dot = v14 + v15 + v21.x * a1a.x;
|
|
868 LOBYTE(result) = 1;
|
|
869 }
|
|
870 else
|
|
871 {
|
|
872 LOBYTE(result) = 0;
|
|
873 }
|
|
874 return (bool)result;
|
|
875 }
|
|
876
|
|
877 //----- (0049C8DC) --------------------------------------------------------
|
|
878 bool stru10::_49C8DC(RenderVertexSoft *arg0, Vec3_float_ *a2, float *a3)
|
|
879 {
|
|
880 double v4; // st7@1
|
|
881 double v5; // st6@1
|
|
882 double v6; // st5@1
|
|
883 Vec3_float_ *result; // eax@1
|
|
884 __int16 v8; // fps@3
|
|
885 char v9; // c0@3
|
|
886 char v10; // c2@3
|
|
887 char v11; // c3@3
|
|
888 float v12; // ecx@5
|
|
889 double v13; // st7@5
|
|
890 double v14; // st6@5
|
|
891 Vec3_float_ v1; // [sp+8h] [bp-3Ch]@1
|
|
892 Vec3_float_ v2; // [sp+14h] [bp-30h]@1
|
|
893 float v17; // [sp+24h] [bp-20h]@1
|
|
894 float v18; // [sp+28h] [bp-1Ch]@1
|
|
895 float v19; // [sp+2Ch] [bp-18h]@1
|
|
896 float v20; // [sp+30h] [bp-14h]@1
|
|
897 float v21; // [sp+34h] [bp-10h]@1
|
|
898 Vec3_float_ a1; // [sp+38h] [bp-Ch]@1
|
|
899
|
|
900 v19 = arg0->vWorldPosition.x;
|
|
901 v20 = arg0->vWorldPosition.y;
|
|
902 v21 = arg0->vWorldPosition.z;
|
|
903 v4 = arg0[1].vWorldPosition.x;
|
|
904 v5 = arg0[1].vWorldPosition.y;
|
|
905 v2.z = arg0[1].vWorldPosition.z;
|
|
906 v6 = arg0[2].vWorldPosition.x;
|
|
907 v17 = arg0[2].vWorldPosition.y;
|
|
908 v18 = arg0[2].vWorldPosition.z;
|
|
909 a1.x = v4 - v19;
|
|
910 a1.y = v5 - v20;
|
|
911 a1.z = v2.z - v21;
|
|
912 LODWORD(v1.x) = (int)a1.x;
|
|
913 v1.y = a1.y;
|
|
914 v1.z = a1.z;
|
|
915 a1.x = v6 - v4;
|
|
916 a1.y = v17 - v5;
|
|
917 a1.z = v18 - v2.z;
|
|
918 result = Vec3_float_::Cross(&v1, &v2, a1.x, a1.y, a1.z);
|
|
919 a1.x = result->x;
|
|
920 a1.y = result->y;
|
|
921 a1.z = result->z;
|
|
922 if ( a1.x != 0.0
|
|
923 || a1.y != 0.0
|
|
924 || (/*UNDEF(v8),*/ v9 = a1.z < 0.0, v10 = 0, v11 = a1.z == 0.0, /*BYTE1(result) = HIBYTE(v8),*/ a1.z != 0.0) )
|
|
925 {
|
|
926 a1.Normalize();
|
|
927 v12 = a1.y;
|
|
928 a2->x = a1.x;
|
|
929 v13 = v21 * a1.z;
|
|
930 v14 = v20 * a1.y;
|
|
931 a2->y = v12;
|
|
932 a2->z = a1.z;
|
|
933 result = (Vec3_float_ *)a3;
|
|
934 *a3 = -(v13 + v14 + v19 * a1.x);
|
|
935 return true;
|
|
936 }
|
|
937 return false;
|
|
938 }
|