Mercurial > mm7
annotate stru9.cpp @ 2064:74f06d8a8017
Merge
author | Ritor1 |
---|---|
date | Mon, 02 Dec 2013 20:43:28 +0600 |
parents | c1c74df0a33e |
children | aff7a7b072b7 |
rev | line source |
---|---|
0 | 1 #include "stru9.h" |
2 #include "IndoorCameraD3D.h" | |
3 | |
4 #include "mm7_data.h" | |
5 | |
6 | |
7 | |
8 //----- (00498377) -------------------------------------------------------- | |
1188 | 9 bool stru9::_498377(struct RenderVertexSoft *pPortalBounding, unsigned int uNumVertices, struct IndoorCameraD3D_Vec4 *pVertices, struct RenderVertexSoft *pVertices2, unsigned int *pOutNumVertices) |
0 | 10 { |
687 | 11 int result; // eax@7 |
12 //unsigned int *v7; // ebx@7 | |
13 //char *v8; // esi@8 | |
0 | 14 RenderVertexSoft *v9; // ecx@9 |
687 | 15 //double v10; // st7@12 |
16 //double v11; // st6@12 | |
17 //RenderVertexSoft *v12; // esi@13 | |
18 //int v13; // ecx@25 | |
691 | 19 //VertexBuffer *v14; // edx@26 |
20 //char *v15; // eax@26 | |
21 //unsigned int i; // ecx@26 | |
1188 | 22 //int v17; // [sp+0h] [bp-28h]@9 |
687 | 23 //char *v18; // [sp+10h] [bp-18h]@8 |
0 | 24 RenderVertexSoft *v19; // [sp+14h] [bp-14h]@0 |
687 | 25 //RenderVertexSoft *v20; // [sp+18h] [bp-10h]@0 |
0 | 26 signed int v21; // [sp+1Ch] [bp-Ch]@7 |
687 | 27 //RenderVertexSoft *a2; // [sp+20h] [bp-8h]@8 |
28 //stru9 *thisa; // [sp+24h] [bp-4h]@1 | |
0 | 29 signed int a3a; // [sp+38h] [bp+10h]@12 |
691 | 30 //int a3b; // [sp+38h] [bp+10h]@25 |
0 | 31 |
687 | 32 //__debugbreak(); |
33 //thisa = this; | |
1195 | 34 return true; |
0 | 35 |
36 static RenderVertexSoft static_AE3FB4; | |
691 | 37 /*static bool __init_flag1 = false; |
0 | 38 if (!__init_flag1) |
39 { | |
40 __init_flag1 = true; | |
41 | |
42 static_AE3FB4.flt_2C = 0.0; | |
691 | 43 }*/ |
0 | 44 |
45 static stru312 static_AE3FA4; // idb | |
691 | 46 /*static bool __init_flag2 = false; |
0 | 47 if (!__init_flag2) |
48 { | |
49 __init_flag2 = true; | |
50 | |
51 //stru312::stru312(&static_AE3FA4); | |
691 | 52 }*/ |
0 | 53 |
54 static VertexBuffer static_AE33A0; // idb | |
691 | 55 /*static bool __init_flag3 = false; |
0 | 56 if (!__init_flag3) |
57 { | |
58 __init_flag3 = true; | |
59 | |
60 //VertexBuffer::VertexBuffer(&static_AE33A0); | |
691 | 61 }*/ |
0 | 62 |
1188 | 63 result = false; |
687 | 64 //v7 = pOutNumVertices; |
0 | 65 v21 = 0; |
66 if ( (signed int)uNumVertices <= 0 ) | |
67 { | |
687 | 68 *pOutNumVertices = 0; |
69 return true; | |
70 } | |
71 //a2 = a1; | |
72 //v8 = (char *)&a3->y; | |
73 //v18 = (char *)&a3->y; | |
74 //do | |
1188 | 75 for (uint j = 0; j < uNumVertices; j++ ) |
687 | 76 { |
77 //v17 = result + 1; | |
1188 | 78 result = j; |
79 v9 = &pPortalBounding[(j + 1) % (signed int)uNumVertices]; | |
794 | 80 if ( pPortalBounding->vWorldPosition.x != v9->vWorldPosition.x |
81 || pPortalBounding->vWorldPosition.y != v9->vWorldPosition.y | |
82 || pPortalBounding->vWorldPosition.z != v9->vWorldPosition.z ) | |
0 | 83 { |
687 | 84 //v10 = a3->z; |
85 //v11 = a3->y; | |
0 | 86 ++v21; |
687 | 87 //result = 0; |
0 | 88 static_AE33A0.uNumVertices = 0; |
687 | 89 //a3a = 0; |
1188 | 90 static_AE3FA4.x = pVertices->x; |
91 static_AE3FA4.y = pVertices->y; | |
92 static_AE3FA4.z = pVertices->z; | |
687 | 93 if ( (signed int)*pOutNumVertices <= 0 ) |
0 | 94 { |
687 | 95 *pOutNumVertices = 0; |
96 return true; | |
97 } | |
98 //do | |
99 for ( int i = 0; i < (signed int)*pOutNumVertices; i++ ) | |
100 { | |
101 //v12 = &pVertices[result]; | |
0 | 102 if ( result ) |
103 { | |
1188 | 104 if ( _4989E1(&pVertices2[i], &pVertices2[i], pPortalBounding, &static_AE3FA4) |
105 && _498774(&pVertices2[i], &pVertices2[i], pPortalBounding, &static_AE3FA4, &static_AE3FB4) ) | |
0 | 106 AddVertex(&static_AE33A0, &static_AE3FB4); |
107 } | |
108 else | |
109 { | |
1188 | 110 v19 = &pVertices2[i]; |
0 | 111 } |
687 | 112 //v20 = v12; |
1287 | 113 if ( AreVectorsCollinear(&pVertices2[i], pPortalBounding, &static_AE3FA4) ) |
1188 | 114 AddVertex(&static_AE33A0, &pVertices2[i]); |
687 | 115 //pOutNumVertices = pOutNumVertices; |
116 //a3a++; | |
0 | 117 } |
687 | 118 //while ( a3a < (signed int)*pOutNumVertices ); |
0 | 119 if ( !static_AE33A0.uNumVertices ) |
687 | 120 { |
121 *pOutNumVertices = 0; | |
122 return true; | |
123 } | |
1188 | 124 if ( _4989E1(&pVertices2[result], v19, pPortalBounding, &static_AE3FA4) |
125 && _498774(&pVertices2[result], v19, pPortalBounding, &static_AE3FA4, &static_AE3FB4) ) | |
0 | 126 AddVertex(&static_AE33A0, &static_AE3FB4); |
691 | 127 |
128 for (uint i = 0; i < static_AE33A0.uNumVertices; ++i) | |
129 { | |
1188 | 130 pVertices2[i].vWorldPosition.x = static_AE33A0.pVertices[i].vWorldPosition.x; |
131 pVertices2[i].vWorldPosition.y = static_AE33A0.pVertices[i].vWorldPosition.y; | |
132 pVertices2[i].vWorldPosition.z = static_AE33A0.pVertices[i].vWorldPosition.z; | |
133 pVertices2[i].u = static_AE33A0.pVertices[i].u; | |
134 pVertices2[i].v = static_AE33A0.pVertices[i].v; | |
691 | 135 } |
136 | |
687 | 137 //v13 = static_AE33A0.uNumVertices; |
691 | 138 /*a3b = 0; |
0 | 139 if ( static_AE33A0.uNumVertices > 0 ) |
140 { | |
141 v14 = &static_AE33A0; | |
142 v15 = (char *)&pVertices->vWorldPosition.y; | |
143 for ( i = (char *)&static_AE33A0.pVertices[0].vWorldPosition.y - (char *)pVertices; | |
144 ; | |
145 i = (char *)&static_AE33A0.pVertices[0].vWorldPosition.y - (char *)pVertices ) | |
146 { | |
147 ++a3b; | |
687 | 148 pVertices->vWorldPosition.x = v14->pVertices[0].vWorldPosition.x; |
0 | 149 v14 = (VertexBuffer *)((char *)v14 + 48); |
687 | 150 pVertices->vWorldPosition.y = *(float *)&v15[(char *)&static_AE33A0 - (char *)pVertices]; |
151 pVertices->vWorldPosition.z = *(float *)&v15[i]; | |
152 pVertices->u = *(float *)&v15[(char *)&static_AE33A0.pVertices[0]._rhw - (char *)pVertices]; | |
153 pVertices->v = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].u - (char *)pVertices]; | |
154 //static_AE33A0.uNumVertices = static_AE33A0.uNumVertices; | |
0 | 155 v15 += 48; |
156 if ( a3b >= static_AE33A0.uNumVertices ) | |
157 break; | |
158 } | |
691 | 159 }*/ |
160 | |
687 | 161 //v7 = pOutNumVertices; |
162 //a3->y = a3->y; | |
163 *pOutNumVertices = static_AE33A0.uNumVertices; | |
0 | 164 } |
687 | 165 //result = v17; |
794 | 166 ++pPortalBounding; |
1188 | 167 pVertices++; |
687 | 168 //v18 = (char *)&a3->y; |
0 | 169 } |
687 | 170 //while ( v17 < (signed int)uNumVertices ); |
0 | 171 if ( v21 < 3 ) |
687 | 172 *pOutNumVertices = 0; |
173 return true; | |
0 | 174 } |
687 | 175 |
0 | 176 |
177 //----- (004985FB) -------------------------------------------------------- | |
1301 | 178 bool stru9::CalcPortalShape(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused) |
0 | 179 { |
1301 | 180 //RenderVertexSoft *v9; // ecx@1 |
181 //Vec3_float_ *v10; // esi@1 | |
0 | 182 //char *v11; // ebx@1 |
1301 | 183 //RenderVertexSoft *pVertices; // edi@1 |
184 double pLinelength1; // st7@1 | |
0 | 185 //bool result; // eax@4 |
186 signed int v15; // edx@9 | |
1301 | 187 RenderVertexSoft *pLineEnd; // ecx@9 |
188 double pLinelength2; // st7@9 | |
189 double t; // st6@12 | |
0 | 190 signed int v19; // [sp+Ch] [bp-Ch]@7 |
1301 | 191 //float v20; // [sp+10h] [bp-8h]@1 |
0 | 192 bool v21; // [sp+14h] [bp-4h]@2 |
193 | |
1301 | 194 //v9 = a1; |
195 //v10 = a5; | |
0 | 196 //v11 = (char *)&a1->vWorldPosition.z; |
1980 | 197 RenderVertexSoft* pLineStart = &a1[0]; |
1301 | 198 //pVertices = a3; |
199 pLinelength1 = a5->x * a1[0].vWorldPosition.x + a1[0].vWorldPosition.y * a5->y + a1[0].vWorldPosition.z * a5->z; | |
200 //v20 = v13; | |
201 v21 = pLinelength1 >= a6; | |
0 | 202 |
203 *pOutNumVertices = 0; | |
204 if ( a2 <= 0 ) | |
205 return false; | |
206 v19 = 1; | |
1301 | 207 |
0 | 208 while ( 1 ) |
209 { | |
210 if ( v21 ) | |
211 { | |
1301 | 212 //++pVertices; |
213 memcpy(pVertices, pLineStart, sizeof(RenderVertexSoft)); | |
0 | 214 ++*pOutNumVertices; |
1301 | 215 //v10 = a5; |
216 pVertices++; | |
217 //v9 = a1; | |
0 | 218 } |
219 v15 = 0; | |
1301 | 220 pLineEnd = &a1[v19 % a2]; |
221 pLinelength2 = a5->x * pLineEnd->vWorldPosition.x + pLineEnd->vWorldPosition.y * a5->y + pLineEnd->vWorldPosition.z * a5->z; | |
222 if ( pLinelength2 >= a6 ) | |
0 | 223 v15 = 1; |
1301 | 224 |
0 | 225 if ( v21 != v15 ) |
226 { | |
1301 | 227 t = (a6 - pLinelength1) / (pLinelength2 - pLinelength1); |
228 pVertices->vWorldPosition.x = pLineStart->vWorldPosition.x + (pLineEnd->vWorldPosition.x - pLineStart->vWorldPosition.x) * t; | |
229 pVertices->vWorldPosition.y = pLineStart->vWorldPosition.y + (pLineEnd->vWorldPosition.y - pLineStart->vWorldPosition.y) * t; | |
230 pVertices->vWorldPosition.z = pLineStart->vWorldPosition.z + (pLineEnd->vWorldPosition.z - pLineStart->vWorldPosition.z) * t; | |
231 pVertices->u = pLineStart->u + (pLineEnd->u - pLineStart->u) * t; | |
232 pVertices->v = pLineStart->v + (pLineEnd->v - pLineStart->v) * t; | |
233 ++pVertices; | |
234 //a3 = pVertices; | |
0 | 235 ++*pOutNumVertices; |
236 *a7 = 1; | |
237 } | |
238 | |
1301 | 239 pLineStart++; |
0 | 240 v21 = v15; |
1301 | 241 pLinelength1 = pLinelength2; |
0 | 242 if ( v19 >= a2 ) |
243 break; | |
1301 | 244 //v9 = a1; |
0 | 245 v19++; |
246 } | |
247 | |
248 return *pOutNumVertices >= 3; | |
249 } | |
250 | |
251 //----- (00498737) -------------------------------------------------------- | |
252 void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex) | |
253 { | |
436 | 254 // __debugbreak(); |
0 | 255 RenderVertexSoft *v3; // eax@1 |
256 | |
257 v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices]; | |
258 v3->vWorldPosition.x = pVertex->vWorldPosition.x; | |
259 v3->vWorldPosition.y = pVertex->vWorldPosition.y; | |
260 v3->vWorldPosition.z = pVertex->vWorldPosition.z; | |
261 v3->u = pVertex->u; | |
262 v3->v = pVertex->v; | |
263 ++pVertexBuffer->uNumVertices; | |
264 } | |
265 | |
266 //----- (00498774) -------------------------------------------------------- | |
267 bool stru9::_498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5) | |
268 { | |
269 RenderVertexSoft *v6; // ecx@5 | |
1924
8cd321994943
MSVS 2012 project file & some compilation warning fixes
Nomad
parents:
1301
diff
changeset
|
270 int result; // eax@5 |
0 | 271 double v8; // st7@5 |
272 __int16 v9; // fps@5 | |
273 double v10; // st7@6 | |
274 double v11; // st6@8 | |
275 double v12; // st6@18 | |
276 char v13; // c0@24 | |
277 char v14; // c2@24 | |
278 char v15; // c3@24 | |
279 float a1a; // [sp+10h] [bp+8h]@5 | |
280 | |
281 __debugbreak(); | |
282 | |
283 static stru312 static_AE3388; | |
284 static stru312 static_AE3378; | |
285 | |
286 v6 = a1; | |
287 static_AE3378.x = a1->vWorldPosition.x - a3->vWorldPosition.x; | |
288 static_AE3378.y = a1->vWorldPosition.y - a3->vWorldPosition.y; | |
289 HIWORD(result) = HIWORD(a4); | |
290 static_AE3378.z = a1->vWorldPosition.z - a3->vWorldPosition.z; | |
291 static_AE3388.x = a2->vWorldPosition.x - a1->vWorldPosition.x; | |
292 static_AE3388.y = a2->vWorldPosition.y - a1->vWorldPosition.y; | |
293 static_AE3388.z = a2->vWorldPosition.z - a1->vWorldPosition.z; | |
294 a1a = static_AE3388.x * a4->x + static_AE3388.z * a4->z + static_AE3388.y * a4->y; | |
295 v8 = static_AE3378.x * a4->x + static_AE3378.z * a4->z + static_AE3378.y * a4->y; | |
296 //UNDEF(v9); | |
297 if ( a1a != 0.0 ) | |
298 { | |
299 v10 = -(v8 / a1a); | |
300 if ( a1a <= 0.0 ) | |
301 { | |
302 if ( v10 <= 0.0 ) | |
303 v12 = 0.0; | |
304 else | |
305 v12 = v10; | |
306 if ( v12 <= 1.0 ) | |
307 { | |
308 if ( v10 <= 0.0 ) | |
309 v10 = (float)0.0; | |
310 } | |
311 else | |
312 { | |
313 v10 = 1.0; | |
314 } | |
315 } | |
316 else | |
317 { | |
318 if ( v10 >= 1.0 ) | |
319 v11 = 1.0; | |
320 else | |
321 v11 = v10; | |
322 if ( v11 >= 0.0 ) | |
323 { | |
324 if ( v10 >= 1.0 ) | |
325 v10 = (float)1.0; | |
326 } | |
327 else | |
328 { | |
329 v10 = 0.0; | |
330 } | |
331 } | |
332 result = (bool)a5; | |
333 a5->vWorldPosition.x = (a2->vWorldPosition.x - v6->vWorldPosition.x) * v10 + v6->vWorldPosition.x; | |
334 a5->vWorldPosition.y = (a2->vWorldPosition.y - v6->vWorldPosition.y) * v10 + v6->vWorldPosition.y; | |
335 a5->vWorldPosition.z = (a2->vWorldPosition.z - v6->vWorldPosition.z) * v10 + v6->vWorldPosition.z; | |
336 a5->u = (a2->u - v6->u) * v10 + v6->u; | |
337 a5->v = (a2->v - v6->v) * v10 + v6->v; | |
338 goto LABEL_15; | |
339 } | |
340 v13 = v8 < 0.0; | |
341 v14 = 0; | |
342 v15 = v8 == 0.0; | |
343 BYTE1(result) = HIBYTE(v9); | |
344 if ( v8 < 0.0 ) | |
345 { | |
346 LABEL_15: | |
347 LOBYTE(result) = 1; | |
348 return result; | |
349 } | |
350 LOBYTE(result) = 0; | |
351 return result; | |
352 } | |
353 // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2; | |
354 | |
355 //----- (0049895A) -------------------------------------------------------- | |
356 bool stru9::AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3) | |
357 { | |
358 static stru312 static_F942A0; | |
359 | |
360 static_F942A0.x = a1->vWorldPosition.x - a2->vWorldPosition.x; | |
361 static_F942A0.y = a1->vWorldPosition.y - a2->vWorldPosition.y; | |
362 static_F942A0.z = a1->vWorldPosition.z - a2->vWorldPosition.z; | |
363 | |
364 static float flt_F942B4 = static_F942A0.z * a3->z + static_F942A0.y * a3->y + static_F942A0.x * a3->x; | |
365 if (flt_F942B4 >= 0) | |
366 return true; | |
367 return false; | |
368 } | |
369 | |
370 | |
371 //----- (004989E1) -------------------------------------------------------- | |
372 bool stru9::_4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4) | |
373 { | |
374 bool r1; | |
375 bool r2; | |
376 | |
377 r1 = AreVectorsCollinear(a1, a3, a4); | |
378 r2 = AreVectorsCollinear(a2, a3, a4); | |
379 return !r1 && r2 == 1 || | |
380 r1 == 1 && !r2; | |
381 } | |
382 | |
383 //----- (004980B9) -------------------------------------------------------- | |
384 bool stru9::_4980B9(RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) | |
385 { | |
386 RenderVertexSoft *v12; // ecx@9 | |
387 double v13; // st7@12 | |
388 double v14; // st6@12 | |
389 double v15; // st5@12 | |
390 signed int v25; // [sp+18h] [bp-Ch]@7 | |
391 | |
392 static RenderVertexSoft stru_AE4BFC; | |
393 static stru312 static_sub_4980B9_stru_AE4BEC; // idb | |
394 static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb | |
395 | |
396 v25 = 0; | |
397 if (uNumVertices <= 0) | |
398 { | |
399 *pOutNumVertices = 0; | |
400 return true; | |
401 } | |
402 | |
403 for (uint i = 0; i < uNumVertices; ++i) | |
404 { | |
405 v12 = &a1[(i + 1) % uNumVertices]; | |
406 if (a1[i].vWorldPosition.x != v12->vWorldPosition.x || | |
407 a1[i].vWorldPosition.y != v12->vWorldPosition.y || | |
408 a1[i].vWorldPosition.z!= v12->vWorldPosition.z) | |
409 { | |
410 v13 = v12->vWorldPosition.x - a1[i].vWorldPosition.x; | |
411 v14 = v12->vWorldPosition.y - a1[i].vWorldPosition.y; | |
412 v15 = v12->vWorldPosition.z - a1[i].vWorldPosition.z; | |
413 ++v25; | |
414 | |
415 static_sub_4980B9_stru_AE3FE8.uNumVertices = 0; | |
416 static_sub_4980B9_stru_AE4BEC.x = a4 * v15 - v14 * a5; | |
417 static_sub_4980B9_stru_AE4BEC.y = v13 * a5 - v15 * a3; | |
418 static_sub_4980B9_stru_AE4BEC.z = v14 * a3 - v13 * a4; | |
419 if (*pOutNumVertices == 0) | |
420 return true; | |
421 | |
422 for (uint j = 0; j < *pOutNumVertices; ++j) | |
423 { | |
424 if (j) | |
425 { | |
426 if (_4989E1(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC) && | |
427 _498774(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC)) | |
428 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); | |
429 } | |
430 | |
431 if (AreVectorsCollinear(&pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC)) | |
432 AddVertex(&static_sub_4980B9_stru_AE3FE8, &pOutVertices[j]); | |
433 } | |
434 | |
435 if (!static_sub_4980B9_stru_AE3FE8.uNumVertices) | |
436 { | |
437 *pOutNumVertices = 0; | |
438 return true; | |
439 } | |
440 if (_4989E1(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC) && | |
441 _498774(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) ) | |
442 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); | |
443 | |
444 for (uint j = 0; j < static_sub_4980B9_stru_AE3FE8.uNumVertices; ++j) | |
445 { | |
446 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.x; | |
447 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.y; | |
448 pOutVertices[j].vWorldPosition.z = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.z; | |
449 pOutVertices[j].u = static_sub_4980B9_stru_AE3FE8.pVertices[j].u; | |
450 pOutVertices[j].v = static_sub_4980B9_stru_AE3FE8.pVertices[j].v; | |
451 } | |
452 *pOutNumVertices = static_sub_4980B9_stru_AE3FE8.uNumVertices; | |
453 } | |
454 } | |
455 | |
456 if (v25 < 3) | |
457 *pOutNumVertices = 0; | |
458 | |
459 return true; | |
460 } | |
461 // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag; |