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