Mercurial > mm7
comparison stru9.cpp @ 0:9c0607679772
init
author | Ritor1 |
---|---|
date | Sat, 12 Jan 2013 09:45:18 +0600 |
parents | |
children | ee11772d0ad2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9c0607679772 |
---|---|
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 __debugbreak(); | |
33 | |
34 thisa = this; | |
35 | |
36 static RenderVertexSoft static_AE3FB4; | |
37 static bool __init_flag1 = false; | |
38 if (!__init_flag1) | |
39 { | |
40 __init_flag1 = true; | |
41 | |
42 static_AE3FB4.flt_2C = 0.0; | |
43 } | |
44 | |
45 static stru312 static_AE3FA4; // idb | |
46 static bool __init_flag2 = false; | |
47 if (!__init_flag2) | |
48 { | |
49 __init_flag2 = true; | |
50 | |
51 //stru312::stru312(&static_AE3FA4); | |
52 } | |
53 | |
54 static VertexBuffer static_AE33A0; // idb | |
55 static bool __init_flag3 = false; | |
56 if (!__init_flag3) | |
57 { | |
58 __init_flag3 = true; | |
59 | |
60 //VertexBuffer::VertexBuffer(&static_AE33A0); | |
61 } | |
62 | |
63 result = 0; | |
64 v7 = pOutNumVertices; | |
65 v21 = 0; | |
66 if ( (signed int)uNumVertices <= 0 ) | |
67 goto LABEL_32; | |
68 a2 = a1; | |
69 v8 = (char *)&a3->y; | |
70 v18 = (char *)&a3->y; | |
71 do | |
72 { | |
73 v17 = result + 1; | |
74 v9 = &a1[(result + 1) % (signed int)uNumVertices]; | |
75 if ( a2->vWorldPosition.x != v9->vWorldPosition.x | |
76 || a2->vWorldPosition.y != v9->vWorldPosition.y | |
77 || a2->vWorldPosition.z != v9->vWorldPosition.z ) | |
78 { | |
79 v10 = *((float *)v8 + 1); | |
80 v11 = *(float *)v8; | |
81 ++v21; | |
82 result = 0; | |
83 static_AE3FA4.x = *((float *)v8 - 1); | |
84 static_AE33A0.uNumVertices = 0; | |
85 a3a = 0; | |
86 static_AE3FA4.y = v11; | |
87 static_AE3FA4.z = v10; | |
88 if ( (signed int)*v7 <= 0 ) | |
89 goto LABEL_32; | |
90 do | |
91 { | |
92 v12 = &pVertices[result]; | |
93 if ( result ) | |
94 { | |
95 if ( _4989E1(v20, &pVertices[result], a2, &static_AE3FA4) | |
96 && _498774(v20, v12, a2, &static_AE3FA4, &static_AE3FB4) ) | |
97 AddVertex(&static_AE33A0, &static_AE3FB4); | |
98 } | |
99 else | |
100 { | |
101 v19 = &pVertices[result]; | |
102 } | |
103 v20 = v12; | |
104 if ( AreVectorsCollinear(v12, a2, &static_AE3FA4) ) | |
105 AddVertex(&static_AE33A0, v12); | |
106 v7 = pOutNumVertices; | |
107 result = a3a++ + 1; | |
108 } | |
109 while ( a3a < (signed int)*pOutNumVertices ); | |
110 if ( !static_AE33A0.uNumVertices ) | |
111 goto LABEL_32; | |
112 if ( _4989E1(v12, v19, a2, &static_AE3FA4) | |
113 && _498774(v12, v19, a2, &static_AE3FA4, &static_AE3FB4) ) | |
114 AddVertex(&static_AE33A0, &static_AE3FB4); | |
115 v13 = static_AE33A0.uNumVertices; | |
116 a3b = 0; | |
117 if ( static_AE33A0.uNumVertices > 0 ) | |
118 { | |
119 v14 = &static_AE33A0; | |
120 v15 = (char *)&pVertices->vWorldPosition.y; | |
121 for ( i = (char *)&static_AE33A0.pVertices[0].vWorldPosition.y - (char *)pVertices; | |
122 ; | |
123 i = (char *)&static_AE33A0.pVertices[0].vWorldPosition.y - (char *)pVertices ) | |
124 { | |
125 ++a3b; | |
126 *((int *)v15 - 1) = *(unsigned int *)(&v14->pVertices[0].vWorldPosition.x); | |
127 v14 = (VertexBuffer *)((char *)v14 + 48); | |
128 *(float *)v15 = *(float *)&v15[(char *)&static_AE33A0 - (char *)pVertices]; | |
129 *((float *)v15 + 1) = *(float *)&v15[i]; | |
130 *((float *)v15 + 8) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].flt_20 - (char *)pVertices]; | |
131 *((float *)v15 + 9) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].u - (char *)pVertices]; | |
132 v13 = static_AE33A0.uNumVertices; | |
133 v15 += 48; | |
134 if ( a3b >= static_AE33A0.uNumVertices ) | |
135 break; | |
136 } | |
137 } | |
138 v7 = pOutNumVertices; | |
139 v8 = v18; | |
140 *pOutNumVertices = v13; | |
141 } | |
142 result = v17; | |
143 ++a2; | |
144 v8 += 24; | |
145 v18 = v8; | |
146 } | |
147 while ( v17 < (signed int)uNumVertices ); | |
148 if ( v21 < 3 ) | |
149 LABEL_32: | |
150 *v7 = 0; | |
151 return 1; | |
152 } | |
153 // AE3FE4: using guessed type char static_init_flag__AE3FB4_bit1__AE3FA4_bit2__AE33A0_bit3; | |
154 | |
155 //----- (004985FB) -------------------------------------------------------- | |
156 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) | |
157 { | |
158 RenderVertexSoft *v9; // ecx@1 | |
159 Vec3_float_ *v10; // esi@1 | |
160 //char *v11; // ebx@1 | |
161 RenderVertexSoft *v12; // edi@1 | |
162 double v13; // st7@1 | |
163 //bool result; // eax@4 | |
164 signed int v15; // edx@9 | |
165 RenderVertexSoft *v16; // ecx@9 | |
166 double v17; // st7@9 | |
167 double v18; // st6@12 | |
168 signed int v19; // [sp+Ch] [bp-Ch]@7 | |
169 float v20; // [sp+10h] [bp-8h]@1 | |
170 bool v21; // [sp+14h] [bp-4h]@2 | |
171 | |
172 v9 = a1; | |
173 v10 = a5; | |
174 //v11 = (char *)&a1->vWorldPosition.z; | |
175 auto v11 = a1; | |
176 v12 = a3; | |
177 v13 = a1->vWorldPosition.y * a5->y + a5->x * a1->vWorldPosition.x + a1->vWorldPosition.z * a5->z; | |
178 v20 = v13; | |
179 v21 = v13 >= a6; | |
180 | |
181 *pOutNumVertices = 0; | |
182 if ( a2 <= 0 ) | |
183 return false; | |
184 v19 = 1; | |
185 while ( 1 ) | |
186 { | |
187 if ( v21 ) | |
188 { | |
189 ++a3; | |
190 memcpy(v12, v11, sizeof(RenderVertexSoft)); | |
191 ++*pOutNumVertices; | |
192 v10 = a5; | |
193 v12 = a3; | |
194 v9 = a1; | |
195 } | |
196 v15 = 0; | |
197 v16 = &v9[v19 % a2]; | |
198 v17 = v16->vWorldPosition.z * v10->z + v16->vWorldPosition.y * v10->y + v10->x * v16->vWorldPosition.x; | |
199 if ( v17 >= a6 ) | |
200 v15 = 1; | |
201 if ( v21 != v15 ) | |
202 { | |
203 v18 = (a6 - v20) / (v17 - v20); | |
204 v12->vWorldPosition.x = (v16->vWorldPosition.x - v11->vWorldPosition.x) * v18 + v11->vWorldPosition.x; | |
205 v12->vWorldPosition.y = (v16->vWorldPosition.y - v11->vWorldPosition.y) * v18 + v11->vWorldPosition.y; | |
206 v12->vWorldPosition.z = (v16->vWorldPosition.z - v11->vWorldPosition.z) * v18 + v11->vWorldPosition.z; | |
207 v12->u = (v16->u - v11->u) * v18 + v11->u; | |
208 v12->v = (v16->v - v11->v) * v18 + v11->v; | |
209 ++v12; | |
210 a3 = v12; | |
211 ++*pOutNumVertices; | |
212 *a7 = 1; | |
213 } | |
214 | |
215 v11++; | |
216 v21 = v15; | |
217 v20 = v17; | |
218 if ( v19 >= a2 ) | |
219 break; | |
220 v9 = a1; | |
221 v19++; | |
222 } | |
223 | |
224 return *pOutNumVertices >= 3; | |
225 } | |
226 | |
227 //----- (00498737) -------------------------------------------------------- | |
228 void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex) | |
229 { | |
230 __debugbreak(); | |
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 __debugbreak(); | |
258 | |
259 static stru312 static_AE3388; | |
260 static stru312 static_AE3378; | |
261 | |
262 v6 = a1; | |
263 static_AE3378.x = a1->vWorldPosition.x - a3->vWorldPosition.x; | |
264 static_AE3378.y = a1->vWorldPosition.y - a3->vWorldPosition.y; | |
265 HIWORD(result) = HIWORD(a4); | |
266 static_AE3378.z = a1->vWorldPosition.z - a3->vWorldPosition.z; | |
267 static_AE3388.x = a2->vWorldPosition.x - a1->vWorldPosition.x; | |
268 static_AE3388.y = a2->vWorldPosition.y - a1->vWorldPosition.y; | |
269 static_AE3388.z = a2->vWorldPosition.z - a1->vWorldPosition.z; | |
270 a1a = static_AE3388.x * a4->x + static_AE3388.z * a4->z + static_AE3388.y * a4->y; | |
271 v8 = static_AE3378.x * a4->x + static_AE3378.z * a4->z + static_AE3378.y * a4->y; | |
272 //UNDEF(v9); | |
273 if ( a1a != 0.0 ) | |
274 { | |
275 v10 = -(v8 / a1a); | |
276 if ( a1a <= 0.0 ) | |
277 { | |
278 if ( v10 <= 0.0 ) | |
279 v12 = 0.0; | |
280 else | |
281 v12 = v10; | |
282 if ( v12 <= 1.0 ) | |
283 { | |
284 if ( v10 <= 0.0 ) | |
285 v10 = (float)0.0; | |
286 } | |
287 else | |
288 { | |
289 v10 = 1.0; | |
290 } | |
291 } | |
292 else | |
293 { | |
294 if ( v10 >= 1.0 ) | |
295 v11 = 1.0; | |
296 else | |
297 v11 = v10; | |
298 if ( v11 >= 0.0 ) | |
299 { | |
300 if ( v10 >= 1.0 ) | |
301 v10 = (float)1.0; | |
302 } | |
303 else | |
304 { | |
305 v10 = 0.0; | |
306 } | |
307 } | |
308 result = (bool)a5; | |
309 a5->vWorldPosition.x = (a2->vWorldPosition.x - v6->vWorldPosition.x) * v10 + v6->vWorldPosition.x; | |
310 a5->vWorldPosition.y = (a2->vWorldPosition.y - v6->vWorldPosition.y) * v10 + v6->vWorldPosition.y; | |
311 a5->vWorldPosition.z = (a2->vWorldPosition.z - v6->vWorldPosition.z) * v10 + v6->vWorldPosition.z; | |
312 a5->u = (a2->u - v6->u) * v10 + v6->u; | |
313 a5->v = (a2->v - v6->v) * v10 + v6->v; | |
314 goto LABEL_15; | |
315 } | |
316 v13 = v8 < 0.0; | |
317 v14 = 0; | |
318 v15 = v8 == 0.0; | |
319 BYTE1(result) = HIBYTE(v9); | |
320 if ( v8 < 0.0 ) | |
321 { | |
322 LABEL_15: | |
323 LOBYTE(result) = 1; | |
324 return result; | |
325 } | |
326 LOBYTE(result) = 0; | |
327 return result; | |
328 } | |
329 // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2; | |
330 | |
331 //----- (0049895A) -------------------------------------------------------- | |
332 bool stru9::AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3) | |
333 { | |
334 static stru312 static_F942A0; | |
335 | |
336 static_F942A0.x = a1->vWorldPosition.x - a2->vWorldPosition.x; | |
337 static_F942A0.y = a1->vWorldPosition.y - a2->vWorldPosition.y; | |
338 static_F942A0.z = a1->vWorldPosition.z - a2->vWorldPosition.z; | |
339 | |
340 static float flt_F942B4 = static_F942A0.z * a3->z + static_F942A0.y * a3->y + static_F942A0.x * a3->x; | |
341 if (flt_F942B4 >= 0) | |
342 return true; | |
343 return false; | |
344 } | |
345 | |
346 | |
347 //----- (004989E1) -------------------------------------------------------- | |
348 bool stru9::_4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4) | |
349 { | |
350 bool r1; | |
351 bool r2; | |
352 | |
353 r1 = AreVectorsCollinear(a1, a3, a4); | |
354 r2 = AreVectorsCollinear(a2, a3, a4); | |
355 return !r1 && r2 == 1 || | |
356 r1 == 1 && !r2; | |
357 } | |
358 | |
359 //----- (004980B9) -------------------------------------------------------- | |
360 bool stru9::_4980B9(RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) | |
361 { | |
362 RenderVertexSoft *v12; // ecx@9 | |
363 double v13; // st7@12 | |
364 double v14; // st6@12 | |
365 double v15; // st5@12 | |
366 signed int v25; // [sp+18h] [bp-Ch]@7 | |
367 | |
368 static RenderVertexSoft stru_AE4BFC; | |
369 static stru312 static_sub_4980B9_stru_AE4BEC; // idb | |
370 static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb | |
371 | |
372 v25 = 0; | |
373 if (uNumVertices <= 0) | |
374 { | |
375 *pOutNumVertices = 0; | |
376 return true; | |
377 } | |
378 | |
379 for (uint i = 0; i < uNumVertices; ++i) | |
380 { | |
381 v12 = &a1[(i + 1) % uNumVertices]; | |
382 if (a1[i].vWorldPosition.x != v12->vWorldPosition.x || | |
383 a1[i].vWorldPosition.y != v12->vWorldPosition.y || | |
384 a1[i].vWorldPosition.z!= v12->vWorldPosition.z) | |
385 { | |
386 v13 = v12->vWorldPosition.x - a1[i].vWorldPosition.x; | |
387 v14 = v12->vWorldPosition.y - a1[i].vWorldPosition.y; | |
388 v15 = v12->vWorldPosition.z - a1[i].vWorldPosition.z; | |
389 ++v25; | |
390 | |
391 static_sub_4980B9_stru_AE3FE8.uNumVertices = 0; | |
392 static_sub_4980B9_stru_AE4BEC.x = a4 * v15 - v14 * a5; | |
393 static_sub_4980B9_stru_AE4BEC.y = v13 * a5 - v15 * a3; | |
394 static_sub_4980B9_stru_AE4BEC.z = v14 * a3 - v13 * a4; | |
395 if (*pOutNumVertices == 0) | |
396 return true; | |
397 | |
398 for (uint j = 0; j < *pOutNumVertices; ++j) | |
399 { | |
400 if (j) | |
401 { | |
402 if (_4989E1(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC) && | |
403 _498774(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC)) | |
404 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); | |
405 } | |
406 | |
407 if (AreVectorsCollinear(&pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC)) | |
408 AddVertex(&static_sub_4980B9_stru_AE3FE8, &pOutVertices[j]); | |
409 } | |
410 | |
411 if (!static_sub_4980B9_stru_AE3FE8.uNumVertices) | |
412 { | |
413 *pOutNumVertices = 0; | |
414 return true; | |
415 } | |
416 if (_4989E1(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC) && | |
417 _498774(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) ) | |
418 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); | |
419 | |
420 for (uint j = 0; j < static_sub_4980B9_stru_AE3FE8.uNumVertices; ++j) | |
421 { | |
422 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.x; | |
423 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.y; | |
424 pOutVertices[j].vWorldPosition.z = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.z; | |
425 pOutVertices[j].u = static_sub_4980B9_stru_AE3FE8.pVertices[j].u; | |
426 pOutVertices[j].v = static_sub_4980B9_stru_AE3FE8.pVertices[j].v; | |
427 } | |
428 *pOutNumVertices = static_sub_4980B9_stru_AE3FE8.uNumVertices; | |
429 } | |
430 } | |
431 | |
432 if (v25 < 3) | |
433 *pOutNumVertices = 0; | |
434 | |
435 return true; | |
436 } | |
437 // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag; |