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