comparison stru9.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children 0f4ed4f0f472
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
1 #include "stru9.h"
2 #include "IndoorCameraD3D.h"
3
4 #include "mm7_data.h"
5
6
7
8 //----- (00498377) --------------------------------------------------------
9 bool stru9::_498377(struct RenderVertexSoft *a1, unsigned int uNumVertices, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices)
10 {
11 bool result; // eax@7
12 unsigned int *v7; // ebx@7
13 char *v8; // esi@8
14 RenderVertexSoft *v9; // ecx@9
15 double v10; // st7@12
16 double v11; // st6@12
17 RenderVertexSoft *v12; // esi@13
18 int v13; // ecx@25
19 VertexBuffer *v14; // edx@26
20 char *v15; // eax@26
21 unsigned int i; // ecx@26
22 bool v17; // [sp+0h] [bp-28h]@9
23 char *v18; // [sp+10h] [bp-18h]@8
24 RenderVertexSoft *v19; // [sp+14h] [bp-14h]@0
25 RenderVertexSoft *v20; // [sp+18h] [bp-10h]@0
26 signed int v21; // [sp+1Ch] [bp-Ch]@7
27 RenderVertexSoft *a2; // [sp+20h] [bp-8h]@8
28 stru9 *thisa; // [sp+24h] [bp-4h]@1
29 signed int a3a; // [sp+38h] [bp+10h]@12
30 int a3b; // [sp+38h] [bp+10h]@25
31
32 thisa = this;
33
34 static RenderVertexSoft static_AE3FB4;
35 static bool __init_flag1 = false;
36 if (!__init_flag1)
37 {
38 __init_flag1 = true;
39
40 static_AE3FB4.flt_2C = 0.0;
41 }
42
43 static stru312 static_AE3FA4; // idb
44 static bool __init_flag2 = false;
45 if (!__init_flag2)
46 {
47 __init_flag2 = true;
48
49 //stru312::stru312(&static_AE3FA4);
50 }
51
52 static VertexBuffer static_AE33A0; // idb
53 static bool __init_flag3 = false;
54 if (!__init_flag3)
55 {
56 __init_flag3 = true;
57
58 //VertexBuffer::VertexBuffer(&static_AE33A0);
59 }
60
61 result = 0;
62 v7 = pOutNumVertices;
63 v21 = 0;
64 if ( (signed int)uNumVertices <= 0 )
65 goto LABEL_32;
66 a2 = a1;
67 v8 = (char *)&a3->y;
68 v18 = (char *)&a3->y;
69 do
70 {
71 v17 = result + 1;
72 v9 = &a1[(result + 1) % (signed int)uNumVertices];
73 if ( a2->vWorldPosition.x != v9->vWorldPosition.x
74 || a2->vWorldPosition.y != v9->vWorldPosition.y
75 || a2->vWorldPosition.z != v9->vWorldPosition.z )
76 {
77 v10 = *((float *)v8 + 1);
78 v11 = *(float *)v8;
79 ++v21;
80 result = 0;
81 static_AE3FA4.flt_0 = *((float *)v8 - 1);
82 static_AE33A0.uNumVertices = 0;
83 a3a = 0;
84 static_AE3FA4.flt_4 = v11;
85 static_AE3FA4.flt_8 = v10;
86 if ( (signed int)*v7 <= 0 )
87 goto LABEL_32;
88 do
89 {
90 v12 = &pVertices[result];
91 if ( result )
92 {
93 if ( _4989E1(v20, &pVertices[result], a2, &static_AE3FA4)
94 && _498774(v20, v12, a2, &static_AE3FA4, &static_AE3FB4) )
95 AddVertex(&static_AE33A0, &static_AE3FB4);
96 }
97 else
98 {
99 v19 = &pVertices[result];
100 }
101 v20 = v12;
102 if ( _49895A(v12, a2, &static_AE3FA4) )
103 AddVertex(&static_AE33A0, v12);
104 v7 = pOutNumVertices;
105 result = a3a++ + 1;
106 }
107 while ( a3a < (signed int)*pOutNumVertices );
108 if ( !static_AE33A0.uNumVertices )
109 goto LABEL_32;
110 if ( _4989E1(v12, v19, a2, &static_AE3FA4)
111 && _498774(v12, v19, a2, &static_AE3FA4, &static_AE3FB4) )
112 AddVertex(&static_AE33A0, &static_AE3FB4);
113 v13 = static_AE33A0.uNumVertices;
114 a3b = 0;
115 if ( static_AE33A0.uNumVertices > 0 )
116 {
117 v14 = &static_AE33A0;
118 v15 = (char *)&pVertices->vWorldPosition.y;
119 for ( i = (char *)&static_AE33A0.pVertices[0].vWorldPosition.y - (char *)pVertices;
120 ;
121 i = (char *)&static_AE33A0.pVertices[0].vWorldPosition.y - (char *)pVertices )
122 {
123 ++a3b;
124 *((int *)v15 - 1) = *(unsigned int *)(&v14->pVertices[0].vWorldPosition.x);
125 v14 = (VertexBuffer *)((char *)v14 + 48);
126 *(float *)v15 = *(float *)&v15[(char *)&static_AE33A0 - (char *)pVertices];
127 *((float *)v15 + 1) = *(float *)&v15[i];
128 *((float *)v15 + 8) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].flt_20 - (char *)pVertices];
129 *((float *)v15 + 9) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].u - (char *)pVertices];
130 v13 = static_AE33A0.uNumVertices;
131 v15 += 48;
132 if ( a3b >= static_AE33A0.uNumVertices )
133 break;
134 }
135 }
136 v7 = pOutNumVertices;
137 v8 = v18;
138 *pOutNumVertices = v13;
139 }
140 result = v17;
141 ++a2;
142 v8 += 24;
143 v18 = v8;
144 }
145 while ( v17 < (signed int)uNumVertices );
146 if ( v21 < 3 )
147 LABEL_32:
148 *v7 = 0;
149 return 1;
150 }
151 // AE3FE4: using guessed type char static_init_flag__AE3FB4_bit1__AE3FA4_bit2__AE33A0_bit3;
152
153 //----- (004985FB) --------------------------------------------------------
154 bool stru9::_4985FB(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *a3, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused)
155 {
156 RenderVertexSoft *v9; // ecx@1
157 Vec3_float_ *v10; // esi@1
158 char *v11; // ebx@1
159 RenderVertexSoft *v12; // edi@1
160 double v13; // st7@1
161 bool result; // eax@4
162 signed int v15; // edx@9
163 RenderVertexSoft *v16; // ecx@9
164 double v17; // st7@9
165 double v18; // st6@12
166 signed int v19; // [sp+Ch] [bp-Ch]@7
167 float v20; // [sp+10h] [bp-8h]@1
168 bool v21; // [sp+14h] [bp-4h]@2
169
170 v9 = a1;
171 v10 = a5;
172 v11 = (char *)&a1->vWorldPosition.z;
173 v12 = a3;
174 v13 = a1->vWorldPosition.y * a5->y + a5->x * a1->vWorldPosition.x + a1->vWorldPosition.z * a5->z;
175 v20 = v13;
176 v21 = v13 >= a6;
177 result = 0;
178 *pOutNumVertices = 0;
179 if ( a2 <= 0 )
180 goto LABEL_19;
181 while ( 1 )
182 {
183 v19 = result + 1;
184 if ( v21 )
185 {
186 ++a3;
187 memcpy(v12, v11 - 8, 0x30u);
188 ++*pOutNumVertices;
189 v10 = a5;
190 v12 = a3;
191 v9 = a1;
192 }
193 v15 = 0;
194 v16 = &v9[(result + 1) % a2];
195 v17 = v16->vWorldPosition.z * v10->z + v16->vWorldPosition.y * v10->y + v10->x * v16->vWorldPosition.x;
196 if ( v17 >= a6 )
197 v15 = 1;
198 if ( v21 != v15 )
199 {
200 v18 = (a6 - v20) / (v17 - v20);
201 v12->vWorldPosition.x = (v16->vWorldPosition.x - *((float *)v11 - 2)) * v18 + *((float *)v11 - 2);
202 ++v12;
203 a3 = v12;
204 *((float *)v12 - 11) = (v16->vWorldPosition.y - *((float *)v11 - 1)) * v18 + *((float *)v11 - 1);
205 *((float *)v12 - 10) = (v16->vWorldPosition.z - *(float *)v11) * v18 + *(float *)v11;
206 *((float *)v12 - 3) = (v16->u - *((float *)v11 + 7)) * v18 + *((float *)v11 + 7);
207 *((float *)v12 - 2) = (v16->v - *((float *)v11 + 8)) * v18 + *((float *)v11 + 8);
208 ++*pOutNumVertices;
209 *a7 = 1;
210 }
211 ++result;
212 v11 += 48;
213 v21 = v15;
214 v20 = v17;
215 if ( v19 >= a2 )
216 break;
217 v9 = a1;
218 }
219 result = (bool)pOutNumVertices;
220 if ( (signed int)*pOutNumVertices >= 3 )
221 LOBYTE(result) = 1;
222 else
223 LABEL_19:
224 LOBYTE(result) = 0;
225 return result;
226 }
227
228 //----- (00498737) --------------------------------------------------------
229 void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex)
230 {
231 RenderVertexSoft *v3; // eax@1
232
233 v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices];
234 v3->vWorldPosition.x = pVertex->vWorldPosition.x;
235 v3->vWorldPosition.y = pVertex->vWorldPosition.y;
236 v3->vWorldPosition.z = pVertex->vWorldPosition.z;
237 v3->u = pVertex->u;
238 v3->v = pVertex->v;
239 ++pVertexBuffer->uNumVertices;
240 }
241
242 //----- (00498774) --------------------------------------------------------
243 bool stru9::_498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5)
244 {
245 RenderVertexSoft *v6; // ecx@5
246 bool result; // eax@5
247 double v8; // st7@5
248 __int16 v9; // fps@5
249 double v10; // st7@6
250 double v11; // st6@8
251 double v12; // st6@18
252 char v13; // c0@24
253 char v14; // c2@24
254 char v15; // c3@24
255 float a1a; // [sp+10h] [bp+8h]@5
256
257 static stru312 static_AE3388;
258 /*if ( !(static_init_flag__AE3388_bit1__AE3378_bit2 & 1) )
259 {
260 static_init_flag__AE3388_bit1__AE3378_bit2 |= 1u;
261 stru312::stru312(&static_AE3388);
262 atexit(nullsub_16);
263 }*/
264 static stru312 static_AE3378;
265 /*if ( !(static_init_flag__AE3388_bit1__AE3378_bit2 & 2) )
266 {
267 static_init_flag__AE3388_bit1__AE3378_bit2 |= 2u;
268 stru312::stru312(&static_AE3378);
269 atexit(nullsub_15);
270 }*/
271 v6 = a1;
272 static_AE3378.flt_0 = a1->vWorldPosition.x - a3->vWorldPosition.x;
273 static_AE3378.flt_4 = a1->vWorldPosition.y - a3->vWorldPosition.y;
274 HIWORD(result) = HIWORD(a4);
275 static_AE3378.flt_8 = a1->vWorldPosition.z - a3->vWorldPosition.z;
276 static_AE3388.flt_0 = a2->vWorldPosition.x - a1->vWorldPosition.x;
277 static_AE3388.flt_4 = a2->vWorldPosition.y - a1->vWorldPosition.y;
278 static_AE3388.flt_8 = a2->vWorldPosition.z - a1->vWorldPosition.z;
279 a1a = static_AE3388.flt_0 * a4->flt_0 + static_AE3388.flt_8 * a4->flt_8 + static_AE3388.flt_4 * a4->flt_4;
280 v8 = static_AE3378.flt_0 * a4->flt_0 + static_AE3378.flt_8 * a4->flt_8 + static_AE3378.flt_4 * a4->flt_4;
281 //UNDEF(v9);
282 if ( a1a != 0.0 )
283 {
284 v10 = -(v8 / a1a);
285 if ( a1a <= 0.0 )
286 {
287 if ( v10 <= 0.0 )
288 v12 = 0.0;
289 else
290 v12 = v10;
291 if ( v12 <= 1.0 )
292 {
293 if ( v10 <= 0.0 )
294 v10 = (float)0.0;
295 }
296 else
297 {
298 v10 = 1.0;
299 }
300 }
301 else
302 {
303 if ( v10 >= 1.0 )
304 v11 = 1.0;
305 else
306 v11 = v10;
307 if ( v11 >= 0.0 )
308 {
309 if ( v10 >= 1.0 )
310 v10 = (float)1.0;
311 }
312 else
313 {
314 v10 = 0.0;
315 }
316 }
317 result = (bool)a5;
318 a5->vWorldPosition.x = (a2->vWorldPosition.x - v6->vWorldPosition.x) * v10 + v6->vWorldPosition.x;
319 a5->vWorldPosition.y = (a2->vWorldPosition.y - v6->vWorldPosition.y) * v10 + v6->vWorldPosition.y;
320 a5->vWorldPosition.z = (a2->vWorldPosition.z - v6->vWorldPosition.z) * v10 + v6->vWorldPosition.z;
321 a5->u = (a2->u - v6->u) * v10 + v6->u;
322 a5->v = (a2->v - v6->v) * v10 + v6->v;
323 goto LABEL_15;
324 }
325 v13 = v8 < 0.0;
326 v14 = 0;
327 v15 = v8 == 0.0;
328 BYTE1(result) = HIBYTE(v9);
329 if ( v8 < 0.0 )
330 {
331 LABEL_15:
332 LOBYTE(result) = 1;
333 return result;
334 }
335 LOBYTE(result) = 0;
336 return result;
337 }
338 // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2;
339
340 //----- (0049895A) --------------------------------------------------------
341 bool stru9::_49895A(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3)
342 {
343 double v4; // st7@3
344 double v5; // st7@3
345 __int16 v6; // fps@3
346 char v7; // c0@3
347 char v8; // c2@3
348 char v9; // c3@3
349 bool result; // eax@3
350
351 static stru312 static_F942A0;
352 /*static bool __init_flag1 = false;
353 if (!__init_flag1)
354 {
355 __init_flag1 = true;
356
357 stru312::stru312(&static_F942A0);
358 }*/
359
360 static_F942A0.flt_0 = a1->vWorldPosition.x - a2->vWorldPosition.x;
361 static_F942A0.flt_4 = a1->vWorldPosition.y - a2->vWorldPosition.y;
362 v4 = a1->vWorldPosition.z - a2->vWorldPosition.z;
363 HIWORD(result) = HIWORD(a3);
364 static_F942A0.flt_8 = v4;
365 v5 = v4 * a3->flt_8 + static_F942A0.flt_4 * a3->flt_4 + static_F942A0.flt_0 * a3->flt_0;
366 //UNDEF(v6);
367 flt_F942B0 = v5;
368 v7 = v5 < 0.0;
369 v8 = 0;
370 v9 = v5 == 0.0;
371 BYTE1(result) = HIBYTE(v6);
372 LOBYTE(result) = v5 >= 0.0;
373 return result;
374 }
375
376
377 //----- (004989E1) --------------------------------------------------------
378 bool stru9::_4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4)
379 {
380 bool r1;
381 bool r2;
382
383 r1 = _49895A(a1, a3, a4);
384 r2 = _49895A(a2, a3, a4);
385 return !r1 && r2 == 1 ||
386 r1 == 1 && !r2;
387 }
388
389 //----- (004980B9) --------------------------------------------------------
390 bool stru9::_4980B9(RenderVertexSoft *a1, signed int a2, float a3, float a4, float a5, RenderVertexSoft *a6, unsigned int *pOutNumVertices)
391 {
392 bool result; // eax@7
393 unsigned int *v9; // ebx@7
394 char *v10; // edi@8
395 RenderVertexSoft *v11; // esi@9
396 RenderVertexSoft *v12; // ecx@9
397 double v13; // st7@12
398 double v14; // st6@12
399 double v15; // st5@12
400 RenderVertexSoft *v16; // edi@13
401 int v17; // ecx@25
402 VertexBuffer *v18; // edx@26
403 char *v19; // eax@26
404 unsigned int i; // ecx@26
405 bool v21; // [sp+0h] [bp-24h]@9
406 char *v22; // [sp+Ch] [bp-18h]@8
407 RenderVertexSoft *a2a; // [sp+10h] [bp-14h]@0
408 RenderVertexSoft *a1a; // [sp+14h] [bp-10h]@0
409 signed int v25; // [sp+18h] [bp-Ch]@7
410 signed int v26; // [sp+1Ch] [bp-8h]@12
411 int v27; // [sp+1Ch] [bp-8h]@25
412 stru9 *thisa; // [sp+20h] [bp-4h]@1
413
414 thisa = this;
415
416 static RenderVertexSoft stru_AE4BFC;
417 static bool __init_flag1 = false;
418 if (!__init_flag1)
419 {
420 __init_flag1 = true;
421
422 stru_AE4BFC.flt_2C = 0.0;
423 }
424
425 static stru312 static_sub_4980B9_stru_AE4BEC; // idb
426 static bool __init_flag2 = false;
427 if (!__init_flag2)
428 {
429 __init_flag2 = true;
430
431 //stru312::stru312(&static_sub_4980B9_stru_AE4BEC);
432 }
433
434 static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb
435 static bool __init_flag3 = false;
436 if (!__init_flag3)
437 {
438 __init_flag3 = true;
439
440 //VertexBuffer::VertexBuffer(&static_sub_4980B9_stru_AE3FE8);
441 }
442
443 result = 0;
444 v9 = pOutNumVertices;
445 v25 = 0;
446 if ( a2 <= 0 )
447 goto LABEL_32;
448 v10 = (char *)&a1->vWorldPosition.z;
449 v22 = (char *)&a1->vWorldPosition.z;
450 do
451 {
452 v11 = (RenderVertexSoft *)(v10 - 8);
453 v21 = result + 1;
454 v12 = &a1[(result + 1) % a2];
455 if ( *((float *)v10 - 2) != v12->vWorldPosition.x
456 || *((float *)v10 - 1) != v12->vWorldPosition.y
457 || *(float *)v10 != v12->vWorldPosition.z )
458 {
459 v13 = v12->vWorldPosition.x - v11->vWorldPosition.x;
460 v14 = v12->vWorldPosition.y - *((float *)v10 - 1);
461 v15 = v12->vWorldPosition.z - *(float *)v10;
462 ++v25;
463 result = 0;
464 static_sub_4980B9_stru_AE3FE8.uNumVertices = 0;
465 v26 = 0;
466 static_sub_4980B9_stru_AE4BEC.flt_0 = a4 * v15 - v14 * a5;
467 static_sub_4980B9_stru_AE4BEC.flt_4 = v13 * a5 - v15 * a3;
468 static_sub_4980B9_stru_AE4BEC.flt_8 = v14 * a3 - v13 * a4;
469 if ( (signed int)*v9 <= 0 )
470 goto LABEL_32;
471 do
472 {
473 v16 = &a6[result];
474 if ( result )
475 {
476 if ( _4989E1(a1a, &a6[result], v11, &static_sub_4980B9_stru_AE4BEC)
477 && _498774(a1a, v16, v11, &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) )
478 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
479 }
480 else
481 {
482 a2a = &a6[result];
483 }
484 a1a = v16;
485 if ( _49895A(v16, v11, &static_sub_4980B9_stru_AE4BEC) )
486 AddVertex(&static_sub_4980B9_stru_AE3FE8, v16);
487 v9 = pOutNumVertices;
488 result = v26++ + 1;
489 }
490 while ( v26 < (signed int)*pOutNumVertices );
491 if ( !static_sub_4980B9_stru_AE3FE8.uNumVertices )
492 goto LABEL_32;
493 if ( _4989E1(v16, a2a, v11, &static_sub_4980B9_stru_AE4BEC)
494 && _498774(v16, a2a, v11, &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) )
495 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
496 v17 = static_sub_4980B9_stru_AE3FE8.uNumVertices;
497 v27 = 0;
498 if ( static_sub_4980B9_stru_AE3FE8.uNumVertices > 0 )
499 {
500 v18 = &static_sub_4980B9_stru_AE3FE8;
501 v19 = (char *)&a6->vWorldPosition.y;
502 for ( i = (char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].flt_20 - (char *)a6;
503 ;
504 i = (char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].flt_20 - (char *)a6 )
505 {
506 ++v27;
507 *((int *)v19 - 1) = LODWORD(v18->pVertices[0].vWorldPosition.x);
508 v18 = (VertexBuffer *)((char *)v18 + 48);
509 *(float *)v19 = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8 - (char *)a6];
510 *((float *)v19 + 1) = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].vWorldPosition.y
511 - (char *)a6];
512 *((float *)v19 + 8) = *(float *)&v19[i];
513 *((float *)v19 + 9) = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].u - (char *)a6];
514 v17 = static_sub_4980B9_stru_AE3FE8.uNumVertices;
515 v19 += 48;
516 if ( v27 >= static_sub_4980B9_stru_AE3FE8.uNumVertices )
517 break;
518 }
519 }
520 v9 = pOutNumVertices;
521 v10 = v22;
522 *pOutNumVertices = v17;
523 }
524 result = v21;
525 v10 += 48;
526 v22 = v10;
527 }
528 while ( v21 < a2 );
529 if ( v25 < 3 )
530 LABEL_32:
531 *v9 = 0;
532 return 1;
533 }
534 // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag;