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
|
691
|
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
|
691
|
30 //int a3b; // [sp+38h] [bp+10h]@25
|
0
|
31
|
687
|
32 //__debugbreak();
|
0
|
33
|
687
|
34 //thisa = this;
|
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
|
|
63 result = 0;
|
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
|
|
75 for (v17 = 0; v17 < uNumVertices; v17++ )
|
|
76 {
|
|
77 //v17 = result + 1;
|
|
78 result = v17;
|
0
|
79 v9 = &a1[(result + 1) % (signed int)uNumVertices];
|
687
|
80 if ( a1->vWorldPosition.x != v9->vWorldPosition.x
|
|
81 || a1->vWorldPosition.y != v9->vWorldPosition.y
|
|
82 || a1->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;
|
|
90 static_AE3FA4.x = a3->x;
|
|
91 static_AE3FA4.y = a3->y;
|
|
92 static_AE3FA4.z = a3->z;
|
|
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 {
|
687
|
104 if ( _4989E1(&pVertices[i], &pVertices[i], a1, &static_AE3FA4)
|
|
105 && _498774(&pVertices[i], &pVertices[i], a1, &static_AE3FA4, &static_AE3FB4) )
|
0
|
106 AddVertex(&static_AE33A0, &static_AE3FB4);
|
|
107 }
|
|
108 else
|
|
109 {
|
687
|
110 v19 = &pVertices[i];
|
0
|
111 }
|
687
|
112 //v20 = v12;
|
|
113 if ( AreVectorsCollinear(&pVertices[i], a1, &static_AE3FA4) )//
|
|
114 AddVertex(&static_AE33A0, &pVertices[i]);
|
|
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 }
|
|
124 if ( _4989E1(&pVertices[result], v19, a1, &static_AE3FA4)
|
|
125 && _498774(&pVertices[result], v19, a1, &static_AE3FA4, &static_AE3FB4) )
|
0
|
126 AddVertex(&static_AE33A0, &static_AE3FB4);
|
691
|
127
|
|
128 for (uint i = 0; i < static_AE33A0.uNumVertices; ++i)
|
|
129 {
|
|
130 pVertices[i].vWorldPosition.x = static_AE33A0.pVertices[i].vWorldPosition.x;
|
|
131 pVertices[i].vWorldPosition.y = static_AE33A0.pVertices[i].vWorldPosition.y;
|
|
132 pVertices[i].vWorldPosition.z = static_AE33A0.pVertices[i].vWorldPosition.z;
|
|
133 pVertices[i].u = static_AE33A0.pVertices[i].u;
|
|
134 pVertices[i].v = static_AE33A0.pVertices[i].v;
|
|
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;
|
|
166 ++a1;
|
|
167 a3++;
|
|
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) --------------------------------------------------------
|
|
178 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)
|
|
179 {
|
|
180 RenderVertexSoft *v9; // ecx@1
|
|
181 Vec3_float_ *v10; // esi@1
|
|
182 //char *v11; // ebx@1
|
|
183 RenderVertexSoft *v12; // edi@1
|
|
184 double v13; // st7@1
|
|
185 //bool result; // eax@4
|
|
186 signed int v15; // edx@9
|
|
187 RenderVertexSoft *v16; // ecx@9
|
|
188 double v17; // st7@9
|
|
189 double v18; // st6@12
|
|
190 signed int v19; // [sp+Ch] [bp-Ch]@7
|
|
191 float v20; // [sp+10h] [bp-8h]@1
|
|
192 bool v21; // [sp+14h] [bp-4h]@2
|
|
193
|
|
194 v9 = a1;
|
|
195 v10 = a5;
|
|
196 //v11 = (char *)&a1->vWorldPosition.z;
|
|
197 auto v11 = a1;
|
|
198 v12 = a3;
|
|
199 v13 = a1->vWorldPosition.y * a5->y + a5->x * a1->vWorldPosition.x + a1->vWorldPosition.z * a5->z;
|
|
200 v20 = v13;
|
|
201 v21 = v13 >= a6;
|
|
202
|
|
203 *pOutNumVertices = 0;
|
|
204 if ( a2 <= 0 )
|
|
205 return false;
|
|
206 v19 = 1;
|
|
207 while ( 1 )
|
|
208 {
|
|
209 if ( v21 )
|
|
210 {
|
|
211 ++a3;
|
|
212 memcpy(v12, v11, sizeof(RenderVertexSoft));
|
|
213 ++*pOutNumVertices;
|
|
214 v10 = a5;
|
|
215 v12 = a3;
|
|
216 v9 = a1;
|
|
217 }
|
|
218 v15 = 0;
|
|
219 v16 = &v9[v19 % a2];
|
|
220 v17 = v16->vWorldPosition.z * v10->z + v16->vWorldPosition.y * v10->y + v10->x * v16->vWorldPosition.x;
|
|
221 if ( v17 >= a6 )
|
|
222 v15 = 1;
|
|
223 if ( v21 != v15 )
|
|
224 {
|
|
225 v18 = (a6 - v20) / (v17 - v20);
|
|
226 v12->vWorldPosition.x = (v16->vWorldPosition.x - v11->vWorldPosition.x) * v18 + v11->vWorldPosition.x;
|
|
227 v12->vWorldPosition.y = (v16->vWorldPosition.y - v11->vWorldPosition.y) * v18 + v11->vWorldPosition.y;
|
|
228 v12->vWorldPosition.z = (v16->vWorldPosition.z - v11->vWorldPosition.z) * v18 + v11->vWorldPosition.z;
|
|
229 v12->u = (v16->u - v11->u) * v18 + v11->u;
|
|
230 v12->v = (v16->v - v11->v) * v18 + v11->v;
|
|
231 ++v12;
|
|
232 a3 = v12;
|
|
233 ++*pOutNumVertices;
|
|
234 *a7 = 1;
|
|
235 }
|
|
236
|
|
237 v11++;
|
|
238 v21 = v15;
|
|
239 v20 = v17;
|
|
240 if ( v19 >= a2 )
|
|
241 break;
|
|
242 v9 = a1;
|
|
243 v19++;
|
|
244 }
|
|
245
|
|
246 return *pOutNumVertices >= 3;
|
|
247 }
|
|
248
|
|
249 //----- (00498737) --------------------------------------------------------
|
|
250 void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex)
|
|
251 {
|
436
|
252 // __debugbreak();
|
0
|
253 RenderVertexSoft *v3; // eax@1
|
|
254
|
|
255 v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices];
|
|
256 v3->vWorldPosition.x = pVertex->vWorldPosition.x;
|
|
257 v3->vWorldPosition.y = pVertex->vWorldPosition.y;
|
|
258 v3->vWorldPosition.z = pVertex->vWorldPosition.z;
|
|
259 v3->u = pVertex->u;
|
|
260 v3->v = pVertex->v;
|
|
261 ++pVertexBuffer->uNumVertices;
|
|
262 }
|
|
263
|
|
264 //----- (00498774) --------------------------------------------------------
|
|
265 bool stru9::_498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5)
|
|
266 {
|
|
267 RenderVertexSoft *v6; // ecx@5
|
|
268 bool result; // eax@5
|
|
269 double v8; // st7@5
|
|
270 __int16 v9; // fps@5
|
|
271 double v10; // st7@6
|
|
272 double v11; // st6@8
|
|
273 double v12; // st6@18
|
|
274 char v13; // c0@24
|
|
275 char v14; // c2@24
|
|
276 char v15; // c3@24
|
|
277 float a1a; // [sp+10h] [bp+8h]@5
|
|
278
|
|
279 __debugbreak();
|
|
280
|
|
281 static stru312 static_AE3388;
|
|
282 static stru312 static_AE3378;
|
|
283
|
|
284 v6 = a1;
|
|
285 static_AE3378.x = a1->vWorldPosition.x - a3->vWorldPosition.x;
|
|
286 static_AE3378.y = a1->vWorldPosition.y - a3->vWorldPosition.y;
|
|
287 HIWORD(result) = HIWORD(a4);
|
|
288 static_AE3378.z = a1->vWorldPosition.z - a3->vWorldPosition.z;
|
|
289 static_AE3388.x = a2->vWorldPosition.x - a1->vWorldPosition.x;
|
|
290 static_AE3388.y = a2->vWorldPosition.y - a1->vWorldPosition.y;
|
|
291 static_AE3388.z = a2->vWorldPosition.z - a1->vWorldPosition.z;
|
|
292 a1a = static_AE3388.x * a4->x + static_AE3388.z * a4->z + static_AE3388.y * a4->y;
|
|
293 v8 = static_AE3378.x * a4->x + static_AE3378.z * a4->z + static_AE3378.y * a4->y;
|
|
294 //UNDEF(v9);
|
|
295 if ( a1a != 0.0 )
|
|
296 {
|
|
297 v10 = -(v8 / a1a);
|
|
298 if ( a1a <= 0.0 )
|
|
299 {
|
|
300 if ( v10 <= 0.0 )
|
|
301 v12 = 0.0;
|
|
302 else
|
|
303 v12 = v10;
|
|
304 if ( v12 <= 1.0 )
|
|
305 {
|
|
306 if ( v10 <= 0.0 )
|
|
307 v10 = (float)0.0;
|
|
308 }
|
|
309 else
|
|
310 {
|
|
311 v10 = 1.0;
|
|
312 }
|
|
313 }
|
|
314 else
|
|
315 {
|
|
316 if ( v10 >= 1.0 )
|
|
317 v11 = 1.0;
|
|
318 else
|
|
319 v11 = v10;
|
|
320 if ( v11 >= 0.0 )
|
|
321 {
|
|
322 if ( v10 >= 1.0 )
|
|
323 v10 = (float)1.0;
|
|
324 }
|
|
325 else
|
|
326 {
|
|
327 v10 = 0.0;
|
|
328 }
|
|
329 }
|
|
330 result = (bool)a5;
|
|
331 a5->vWorldPosition.x = (a2->vWorldPosition.x - v6->vWorldPosition.x) * v10 + v6->vWorldPosition.x;
|
|
332 a5->vWorldPosition.y = (a2->vWorldPosition.y - v6->vWorldPosition.y) * v10 + v6->vWorldPosition.y;
|
|
333 a5->vWorldPosition.z = (a2->vWorldPosition.z - v6->vWorldPosition.z) * v10 + v6->vWorldPosition.z;
|
|
334 a5->u = (a2->u - v6->u) * v10 + v6->u;
|
|
335 a5->v = (a2->v - v6->v) * v10 + v6->v;
|
|
336 goto LABEL_15;
|
|
337 }
|
|
338 v13 = v8 < 0.0;
|
|
339 v14 = 0;
|
|
340 v15 = v8 == 0.0;
|
|
341 BYTE1(result) = HIBYTE(v9);
|
|
342 if ( v8 < 0.0 )
|
|
343 {
|
|
344 LABEL_15:
|
|
345 LOBYTE(result) = 1;
|
|
346 return result;
|
|
347 }
|
|
348 LOBYTE(result) = 0;
|
|
349 return result;
|
|
350 }
|
|
351 // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2;
|
|
352
|
|
353 //----- (0049895A) --------------------------------------------------------
|
|
354 bool stru9::AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3)
|
|
355 {
|
|
356 static stru312 static_F942A0;
|
|
357
|
|
358 static_F942A0.x = a1->vWorldPosition.x - a2->vWorldPosition.x;
|
|
359 static_F942A0.y = a1->vWorldPosition.y - a2->vWorldPosition.y;
|
|
360 static_F942A0.z = a1->vWorldPosition.z - a2->vWorldPosition.z;
|
|
361
|
|
362 static float flt_F942B4 = static_F942A0.z * a3->z + static_F942A0.y * a3->y + static_F942A0.x * a3->x;
|
|
363 if (flt_F942B4 >= 0)
|
|
364 return true;
|
|
365 return false;
|
|
366 }
|
|
367
|
|
368
|
|
369 //----- (004989E1) --------------------------------------------------------
|
|
370 bool stru9::_4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4)
|
|
371 {
|
|
372 bool r1;
|
|
373 bool r2;
|
|
374
|
|
375 r1 = AreVectorsCollinear(a1, a3, a4);
|
|
376 r2 = AreVectorsCollinear(a2, a3, a4);
|
|
377 return !r1 && r2 == 1 ||
|
|
378 r1 == 1 && !r2;
|
|
379 }
|
|
380
|
|
381 //----- (004980B9) --------------------------------------------------------
|
|
382 bool stru9::_4980B9(RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
|
|
383 {
|
|
384 RenderVertexSoft *v12; // ecx@9
|
|
385 double v13; // st7@12
|
|
386 double v14; // st6@12
|
|
387 double v15; // st5@12
|
|
388 signed int v25; // [sp+18h] [bp-Ch]@7
|
|
389
|
|
390 static RenderVertexSoft stru_AE4BFC;
|
|
391 static stru312 static_sub_4980B9_stru_AE4BEC; // idb
|
|
392 static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb
|
|
393
|
|
394 v25 = 0;
|
|
395 if (uNumVertices <= 0)
|
|
396 {
|
|
397 *pOutNumVertices = 0;
|
|
398 return true;
|
|
399 }
|
|
400
|
|
401 for (uint i = 0; i < uNumVertices; ++i)
|
|
402 {
|
|
403 v12 = &a1[(i + 1) % uNumVertices];
|
|
404 if (a1[i].vWorldPosition.x != v12->vWorldPosition.x ||
|
|
405 a1[i].vWorldPosition.y != v12->vWorldPosition.y ||
|
|
406 a1[i].vWorldPosition.z!= v12->vWorldPosition.z)
|
|
407 {
|
|
408 v13 = v12->vWorldPosition.x - a1[i].vWorldPosition.x;
|
|
409 v14 = v12->vWorldPosition.y - a1[i].vWorldPosition.y;
|
|
410 v15 = v12->vWorldPosition.z - a1[i].vWorldPosition.z;
|
|
411 ++v25;
|
|
412
|
|
413 static_sub_4980B9_stru_AE3FE8.uNumVertices = 0;
|
|
414 static_sub_4980B9_stru_AE4BEC.x = a4 * v15 - v14 * a5;
|
|
415 static_sub_4980B9_stru_AE4BEC.y = v13 * a5 - v15 * a3;
|
|
416 static_sub_4980B9_stru_AE4BEC.z = v14 * a3 - v13 * a4;
|
|
417 if (*pOutNumVertices == 0)
|
|
418 return true;
|
|
419
|
|
420 for (uint j = 0; j < *pOutNumVertices; ++j)
|
|
421 {
|
|
422 if (j)
|
|
423 {
|
|
424 if (_4989E1(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC) &&
|
|
425 _498774(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC))
|
|
426 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
|
|
427 }
|
|
428
|
|
429 if (AreVectorsCollinear(&pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC))
|
|
430 AddVertex(&static_sub_4980B9_stru_AE3FE8, &pOutVertices[j]);
|
|
431 }
|
|
432
|
|
433 if (!static_sub_4980B9_stru_AE3FE8.uNumVertices)
|
|
434 {
|
|
435 *pOutNumVertices = 0;
|
|
436 return true;
|
|
437 }
|
|
438 if (_4989E1(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC) &&
|
|
439 _498774(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) )
|
|
440 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
|
|
441
|
|
442 for (uint j = 0; j < static_sub_4980B9_stru_AE3FE8.uNumVertices; ++j)
|
|
443 {
|
|
444 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.x;
|
|
445 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.y;
|
|
446 pOutVertices[j].vWorldPosition.z = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.z;
|
|
447 pOutVertices[j].u = static_sub_4980B9_stru_AE3FE8.pVertices[j].u;
|
|
448 pOutVertices[j].v = static_sub_4980B9_stru_AE3FE8.pVertices[j].v;
|
|
449 }
|
|
450 *pOutNumVertices = static_sub_4980B9_stru_AE3FE8.uNumVertices;
|
|
451 }
|
|
452 }
|
|
453
|
|
454 if (v25 < 3)
|
|
455 *pOutNumVertices = 0;
|
|
456
|
|
457 return true;
|
|
458 }
|
|
459 // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag; |