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