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