Mercurial > mm7
annotate Engine/Graphics/stru9.cpp @ 2570:4d199006c716
debug_terrain_polygin
author | Ritor1 |
---|---|
date | Sun, 24 May 2015 20:49:22 +0600 |
parents | b8a56afc6ba1 |
children |
rev | line source |
---|---|
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 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
244 pVertexBuffer->pVertices[pVertexBuffer->uNumVertices].vWorldPosition.x = pVertex->vWorldPosition.x; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
245 pVertexBuffer->pVertices[pVertexBuffer->uNumVertices].vWorldPosition.y = pVertex->vWorldPosition.y; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
246 pVertexBuffer->pVertices[pVertexBuffer->uNumVertices].vWorldPosition.z = pVertex->vWorldPosition.z; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
247 pVertexBuffer->pVertices[pVertexBuffer->uNumVertices].u = pVertex->u; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
248 pVertexBuffer->pVertices[pVertexBuffer->uNumVertices].v = pVertex->v; |
2496 | 249 ++pVertexBuffer->uNumVertices; |
250 } | |
251 | |
252 //----- (00498774) -------------------------------------------------------- | |
253 bool stru9::_498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5) | |
254 { | |
255 RenderVertexSoft *v6; // ecx@5 | |
256 int result; // eax@5 | |
257 double v8; // st7@5 | |
258 __int16 v9; // fps@5 | |
259 double v10; // st7@6 | |
260 double v11; // st6@8 | |
261 double v12; // st6@18 | |
262 char v13; // c0@24 | |
263 char v14; // c2@24 | |
264 char v15; // c3@24 | |
265 float a1a; // [sp+10h] [bp+8h]@5 | |
266 | |
267 __debugbreak(); | |
268 | |
269 static stru312 static_AE3388; | |
270 static stru312 static_AE3378; | |
271 | |
272 v6 = a1; | |
273 static_AE3378.x = a1->vWorldPosition.x - a3->vWorldPosition.x; | |
274 static_AE3378.y = a1->vWorldPosition.y - a3->vWorldPosition.y; | |
275 HIWORD(result) = HIWORD(a4); | |
276 static_AE3378.z = a1->vWorldPosition.z - a3->vWorldPosition.z; | |
277 static_AE3388.x = a2->vWorldPosition.x - a1->vWorldPosition.x; | |
278 static_AE3388.y = a2->vWorldPosition.y - a1->vWorldPosition.y; | |
279 static_AE3388.z = a2->vWorldPosition.z - a1->vWorldPosition.z; | |
280 a1a = static_AE3388.x * a4->x + static_AE3388.z * a4->z + static_AE3388.y * a4->y; | |
281 v8 = static_AE3378.x * a4->x + static_AE3378.z * a4->z + static_AE3378.y * a4->y; | |
282 //UNDEF(v9); | |
283 if ( a1a != 0.0 ) | |
284 { | |
285 v10 = -(v8 / a1a); | |
286 if ( a1a <= 0.0 ) | |
287 { | |
288 if ( v10 <= 0.0 ) | |
289 v12 = 0.0; | |
290 else | |
291 v12 = v10; | |
292 if ( v12 <= 1.0 ) | |
293 { | |
294 if ( v10 <= 0.0 ) | |
295 v10 = (float)0.0; | |
296 } | |
297 else | |
298 v10 = 1.0; | |
299 } | |
300 else | |
301 { | |
302 if ( v10 >= 1.0 ) | |
303 v11 = 1.0; | |
304 else | |
305 v11 = v10; | |
306 if ( v11 >= 0.0 ) | |
307 { | |
308 if ( v10 >= 1.0 ) | |
309 v10 = (float)1.0; | |
310 } | |
311 else | |
312 v10 = 0.0; | |
313 } | |
314 result = (bool)a5; | |
315 a5->vWorldPosition.x = (a2->vWorldPosition.x - v6->vWorldPosition.x) * v10 + v6->vWorldPosition.x; | |
316 a5->vWorldPosition.y = (a2->vWorldPosition.y - v6->vWorldPosition.y) * v10 + v6->vWorldPosition.y; | |
317 a5->vWorldPosition.z = (a2->vWorldPosition.z - v6->vWorldPosition.z) * v10 + v6->vWorldPosition.z; | |
318 a5->u = (a2->u - v6->u) * v10 + v6->u; | |
319 a5->v = (a2->v - v6->v) * v10 + v6->v; | |
320 return 1; | |
321 } | |
322 v13 = v8 < 0.0; | |
323 v14 = 0; | |
324 v15 = v8 == 0.0; | |
325 // BYTE1(result) = HIBYTE(v9); | |
326 if ( v8 < 0.0 ) | |
327 return 1; | |
328 return 0; | |
329 } | |
330 // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2; | |
331 | |
332 //----- (0049895A) -------------------------------------------------------- | |
333 bool stru9::AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3) | |
334 { | |
335 static stru312 static_F942A0; | |
336 | |
337 static_F942A0.x = a1->vWorldPosition.x - a2->vWorldPosition.x; | |
338 static_F942A0.y = a1->vWorldPosition.y - a2->vWorldPosition.y; | |
339 static_F942A0.z = a1->vWorldPosition.z - a2->vWorldPosition.z; | |
340 | |
341 static float flt_F942B4 = static_F942A0.z * a3->z + static_F942A0.y * a3->y + static_F942A0.x * a3->x; | |
342 if (flt_F942B4 >= 0) | |
343 return true; | |
344 return false; | |
345 } | |
346 | |
347 | |
348 //----- (004989E1) -------------------------------------------------------- | |
349 bool stru9::_4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4) | |
350 { | |
351 bool r1; | |
352 bool r2; | |
353 | |
354 r1 = AreVectorsCollinear(a1, a3, a4); | |
355 r2 = AreVectorsCollinear(a2, a3, a4); | |
356 return !r1 && r2 == 1 || | |
357 r1 == 1 && !r2; | |
358 } | |
359 | |
360 //----- (004980B9) -------------------------------------------------------- | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
361 bool stru9::_4980B9(RenderVertexSoft *a1, unsigned int uNumVertices, float pNormalX, float pNormalY, float pNormalZ, RenderVertexSoft *pOutVertices, signed int *pOutNumVertices) |
2496 | 362 { |
363 RenderVertexSoft *v12; // ecx@9 | |
364 double v13; // st7@12 | |
365 double v14; // st6@12 | |
366 double v15; // st5@12 | |
367 signed int v25; // [sp+18h] [bp-Ch]@7 | |
368 | |
369 static RenderVertexSoft stru_AE4BFC; | |
370 static stru312 static_sub_4980B9_stru_AE4BEC; // idb | |
371 static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb | |
372 | |
373 v25 = 0; | |
374 if (uNumVertices <= 0) | |
375 { | |
376 *pOutNumVertices = 0; | |
377 return true; | |
378 } | |
379 | |
380 for (uint i = 0; i < uNumVertices; ++i) | |
381 { | |
382 v12 = &a1[(i + 1) % uNumVertices]; | |
383 if (a1[i].vWorldPosition.x != v12->vWorldPosition.x || | |
384 a1[i].vWorldPosition.y != v12->vWorldPosition.y || | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
385 a1[i].vWorldPosition.z != v12->vWorldPosition.z) |
2496 | 386 { |
387 v13 = v12->vWorldPosition.x - a1[i].vWorldPosition.x; | |
388 v14 = v12->vWorldPosition.y - a1[i].vWorldPosition.y; | |
389 v15 = v12->vWorldPosition.z - a1[i].vWorldPosition.z; | |
390 ++v25; | |
391 | |
392 static_sub_4980B9_stru_AE3FE8.uNumVertices = 0; | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
393 static_sub_4980B9_stru_AE4BEC.x = pNormalY * v15 - v14 * pNormalZ; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
394 static_sub_4980B9_stru_AE4BEC.y = v13 * pNormalZ - v15 * pNormalX; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
395 static_sub_4980B9_stru_AE4BEC.z = v14 * pNormalX - v13 * pNormalY; |
2496 | 396 if (*pOutNumVertices == 0) |
397 return true; | |
398 | |
399 for (uint j = 0; j < *pOutNumVertices; ++j) | |
400 { | |
401 if (j) | |
402 { | |
403 if (_4989E1(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC) && | |
404 _498774(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC)) | |
405 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); | |
406 } | |
407 | |
408 if (AreVectorsCollinear(&pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC)) | |
409 AddVertex(&static_sub_4980B9_stru_AE3FE8, &pOutVertices[j]); | |
410 } | |
411 | |
412 if (!static_sub_4980B9_stru_AE3FE8.uNumVertices) | |
413 { | |
414 *pOutNumVertices = 0; | |
415 return true; | |
416 } | |
417 if (_4989E1(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC) && | |
418 _498774(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) ) | |
419 AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC); | |
420 | |
421 for (uint j = 0; j < static_sub_4980B9_stru_AE3FE8.uNumVertices; ++j) | |
422 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2541
diff
changeset
|
423 pOutVertices[j].vWorldPosition.x = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.x; |
2496 | 424 pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.y; |
425 pOutVertices[j].vWorldPosition.z = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.z; | |
426 pOutVertices[j].u = static_sub_4980B9_stru_AE3FE8.pVertices[j].u; | |
427 pOutVertices[j].v = static_sub_4980B9_stru_AE3FE8.pVertices[j].v; | |
428 } | |
429 *pOutNumVertices = static_sub_4980B9_stru_AE3FE8.uNumVertices; | |
430 } | |
431 } | |
432 | |
433 if (v25 < 3) | |
434 *pOutNumVertices = 0; | |
435 | |
436 return true; | |
437 } | |
438 // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag; |