comparison stru10.cpp @ 795:472ca68386d4

more stru10 & stru9
author Nomad
date Mon, 25 Mar 2013 14:23:40 +0200
parents 4a00901e063c
children 39eaa6b00141
comparison
equal deleted inserted replaced
794:4a00901e063c 795:472ca68386d4
8 8
9 #include "mm7_data.h" 9 #include "mm7_data.h"
10 10
11 11
12 12
13 int _49CE9E_sub0_x(RenderVertexSoft *pVertices, unsigned int uNumVertices, float test_val)
14 {
15 float max_val = FLT_MAX;
16 int idx = -1;
17
18 float temp_val;
19 for (uint i = 0; i < uNumVertices; ++i)
20 {
21 if (pVertices[i].vWorldPosition.x <= test_val)
22 temp_val = test_val - pVertices[i].vWorldPosition.x;
23 else
24 temp_val = pVertices[i].vWorldPosition.x - test_val;
25
26 if (temp_val < max_val)
27 {
28 max_val = temp_val;
29 idx = i;
30 }
31 }
32 return idx;
33 }
34
35
36 int _49CE9E_sub0_y(RenderVertexSoft *pVertices, unsigned int uNumVertices, float test_val)
37 {
38 float max_val = FLT_MAX;
39 int idx = -1;
40
41 float temp_val;
42 for (uint i = 0; i < uNumVertices; ++i)
43 {
44 if (pVertices[i].vWorldPosition.y <= test_val)
45 temp_val = test_val - pVertices[i].vWorldPosition.y;
46 else
47 temp_val = pVertices[i].vWorldPosition.y - test_val;
48
49 if (temp_val < max_val)
50 {
51 max_val = temp_val;
52 idx = i;
53 }
54 }
55 return idx;
56 }
57
58
59 int _49CE9E_sub0_z(RenderVertexSoft *pVertices, unsigned int uNumVertices, float test_val)
60 {
61 float max_val = FLT_MAX;
62 int idx = -1;
63
64 float temp_val;
65 for (uint i = 0; i < uNumVertices; ++i)
66 {
67 if (pVertices[i].vWorldPosition.z <= test_val)
68 temp_val = test_val - pVertices[i].vWorldPosition.z;
69 else
70 temp_val = pVertices[i].vWorldPosition.z - test_val;
71
72 if (temp_val < max_val)
73 {
74 max_val = temp_val;
75 idx = i;
76 }
77 }
78 return idx;
79 }
13 80
14 //----- (0049CE9E) -------------------------------------------------------- 81 //----- (0049CE9E) --------------------------------------------------------
15 void stru10::_49CE9E(BLVFace *pFace, RenderVertexSoft *a2, signed int a3, RenderVertexSoft *a4) 82 void stru10::_49CE9E(BLVFace *pFace, RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutLimits)
16 { 83 {
17 char *v5; // eax@1 84 assert(sizeof(RenderVertexSoft) == 0x30);
18 signed int v6; // edx@1 85
19 unsigned int v7; // eax@3 86 RenderVertexSoft pLimits[64];
20 signed int v8; // ecx@11 87 stru10::CalcPolygonLimits(pFace, pLimits);
21 signed int v9; // esi@11 88
22 RenderVertexSoft *v10; // edx@12 89 if (pFace->uAttributes & FACE_XY_PLANE)
23 double v11; // st6@14 90 {
24 RenderVertexSoft *v12; // edx@19 91 memcpy(&pOutLimits[0], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[0].vWorldPosition.x)], 0x30);
25 signed int v13; // ecx@19 92 memcpy(&pOutLimits[2], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[2].vWorldPosition.x)], 0x30);
26 signed int v14; // esi@19 93 memcpy(&pOutLimits[1], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[1].vWorldPosition.y)], 0x30);
27 RenderVertexSoft *v15; // edi@20 94 memcpy(&pOutLimits[3], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[3].vWorldPosition.y)], 0x30);
28 double v16; // st6@22 95 }
29 signed int v17; // ecx@27 96 else if (pFace->uAttributes & FACE_XZ_PLANE)
30 signed int v18; // edi@27 97 {
31 char *v19; // esi@28 98 memcpy(&pOutLimits[0], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[0].vWorldPosition.x)], 0x30);
32 double v20; // st6@30 99 memcpy(&pOutLimits[2], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[2].vWorldPosition.x)], 0x30);
33 signed int v21; // ecx@35 100 memcpy(&pOutLimits[1], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[1].vWorldPosition.z)], 0x30);
34 signed int v22; // edi@35 101 memcpy(&pOutLimits[3], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[3].vWorldPosition.z)], 0x30);
35 char *v23; // esi@36 102 }
36 double v24; // st7@38 103 else if (pFace->uAttributes & FACE_YZ_PLANE)
37 signed int v25; // ecx@45 104 {
38 signed int v26; // esi@45 105 memcpy(&pOutLimits[0], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[0].vWorldPosition.y)], 0x30);
39 RenderVertexSoft *v27; // edx@46 106 memcpy(&pOutLimits[2], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[2].vWorldPosition.y)], 0x30);
40 double v28; // st6@48 107 memcpy(&pOutLimits[1], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[1].vWorldPosition.z)], 0x30);
41 signed int v29; // ecx@53 108 memcpy(&pOutLimits[3], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[3].vWorldPosition.z)], 0x30);
42 signed int v30; // esi@53 109 }
43 RenderVertexSoft *v31; // edi@54
44 double v32; // st6@56
45 signed int v33; // ecx@61
46 signed int v34; // edi@61
47 char *v35; // esi@62
48 double v36; // st6@64
49 signed int v37; // edi@69
50 char *v38; // esi@70
51 double v39; // st7@72
52 RenderVertexSoft *v40; // esi@77
53 signed int v41; // ecx@79
54 signed int v42; // esi@79
55 char *v43; // edx@80
56 double v44; // st6@82
57 RenderVertexSoft *v45; // eax@87
58 signed int v46; // ecx@87
59 signed int v47; // edi@87
60 char *v48; // esi@88
61 double v49; // st6@90
62 signed int v50; // ecx@96
63 signed int v51; // edi@96
64 char *v52; // esi@97
65 double v53; // st6@99
66 signed int v54; // ecx@105
67 signed int v55; // edi@105
68 char *v56; // esi@106
69 double v57; // st7@108
70 RenderVertexSoft a2a[64]; // [sp+0h] [bp-C18h]@1
71 float v59; // [sp+C00h] [bp-18h]@4
72 float v60; // [sp+C04h] [bp-14h]@9
73 float v61; // [sp+C08h] [bp-10h]@4
74 float v62; // [sp+C0Ch] [bp-Ch]@9
75 float v63; // [sp+C10h] [bp-8h]@4
76 float v64; // [sp+C14h] [bp-4h]@4
77 float a1a; // [sp+C20h] [bp+8h]@11
78 float a1b; // [sp+C20h] [bp+8h]@19
79 float a1c; // [sp+C20h] [bp+8h]@27
80 float a1d; // [sp+C20h] [bp+8h]@35
81 float a1e; // [sp+C20h] [bp+8h]@45
82 float a1f; // [sp+C20h] [bp+8h]@53
83 float a1g; // [sp+C20h] [bp+8h]@61
84 float a1h; // [sp+C20h] [bp+8h]@69
85 float a1i; // [sp+C20h] [bp+8h]@79
86 float a1j; // [sp+C20h] [bp+8h]@87
87 float a1k; // [sp+C20h] [bp+8h]@96
88 float a1l; // [sp+C20h] [bp+8h]@105
89
90 v5 = (char *)&a2a[0].flt_2C;
91 v6 = 64;
92 do
93 {
94 *(float *)v5 = 0.0;
95 v5 += 48;
96 --v6;
97 }
98 while ( v6 );
99 stru10::CalcPolygonLimits(pFace, a2a);
100 v7 = pFace->uAttributes;
101 if ( v7 & 0x100 )
102 {
103 v63 = a2a[0].vWorldPosition.x;
104 v59 = a2a[2].vWorldPosition.x;
105 v61 = a2a[1].vWorldPosition.y;
106 v64 = a2a[3].vWorldPosition.y;
107 goto LABEL_10;
108 }
109 if ( v7 & 0x200 )
110 {
111 v63 = a2a[0].vWorldPosition.x;
112 v59 = a2a[2].vWorldPosition.x;
113 }
114 else
115 {
116 if ( !(v7 & 0x400) )
117 goto LABEL_10;
118 v61 = a2a[0].vWorldPosition.y;
119 v64 = a2a[2].vWorldPosition.y;
120 }
121 v62 = a2a[1].vWorldPosition.z;
122 v60 = a2a[3].vWorldPosition.z;
123 LABEL_10:
124 if ( v7 & 0x100 )
125 {
126 v8 = -1;
127 a1a = 3.4028235e38;
128 v9 = 0;
129 if ( a3 > 0 )
130 {
131 v10 = a2;
132 do
133 {
134 if ( v10->vWorldPosition.x <= (double)v63 )
135 v11 = v63 - v10->vWorldPosition.x;
136 else
137 v11 = v10->vWorldPosition.x - v63;
138 if ( v11 < a1a )
139 {
140 a1a = v11;
141 v8 = v9;
142 }
143 ++v9;
144 ++v10;
145 }
146 while ( v9 < a3 );
147 }
148 v12 = a4;
149 a1b = 3.4028235e38;
150 memcpy(a4, &a2[v8], 0x30u);
151 v13 = -1;
152 v14 = 0;
153 if ( a3 > 0 )
154 {
155 v15 = a2;
156 do
157 {
158 if ( v15->vWorldPosition.x <= (double)v59 )
159 v16 = v59 - v15->vWorldPosition.x;
160 else
161 v16 = v15->vWorldPosition.x - v59;
162 if ( v16 < a1b )
163 {
164 a1b = v16;
165 v13 = v14;
166 }
167 ++v14;
168 ++v15;
169 }
170 while ( v14 < a3 );
171 }
172 a1c = 3.4028235e38;
173 memcpy(&a4[2], &a2[v13], sizeof(a4[2]));
174 v17 = -1;
175 v18 = 0;
176 if ( a3 > 0 )
177 {
178 v19 = (char *)&a2->vWorldPosition.y;
179 do
180 {
181 if ( *(float *)v19 <= (double)v61 )
182 v20 = v61 - *(float *)v19;
183 else
184 v20 = *(float *)v19 - v61;
185 if ( v20 < a1c )
186 {
187 a1c = v20;
188 v17 = v18;
189 }
190 ++v18;
191 v19 += 48;
192 }
193 while ( v18 < a3 );
194 }
195 a1d = 3.4028235e38;
196 memcpy(&a4[1], &a2[v17], sizeof(a4[1]));
197 v21 = -1;
198 v22 = 0;
199 if ( a3 > 0 )
200 {
201 v23 = (char *)&a2->vWorldPosition.y;
202 do
203 {
204 if ( *(float *)v23 <= (double)v64 )
205 v24 = v64 - *(float *)v23;
206 else
207 v24 = *(float *)v23 - v64;
208 if ( v24 < a1d )
209 {
210 a1d = v24;
211 v21 = v22;
212 }
213 ++v22;
214 v23 += 48;
215 }
216 while ( v22 < a3 );
217 }
218 LABEL_77:
219 v40 = &a2[v21];
220 goto LABEL_115;
221 }
222 if ( v7 & 0x200 )
223 {
224 v25 = -1;
225 a1e = 3.4028235e38;
226 v26 = 0;
227 if ( a3 > 0 )
228 {
229 v27 = a2;
230 do
231 {
232 if ( v27->vWorldPosition.x <= (double)v63 )
233 v28 = v63 - v27->vWorldPosition.x;
234 else
235 v28 = v27->vWorldPosition.x - v63;
236 if ( v28 < a1e )
237 {
238 a1e = v28;
239 v25 = v26;
240 }
241 ++v26;
242 ++v27;
243 }
244 while ( v26 < a3 );
245 }
246 v12 = a4;
247 a1f = 3.4028235e38;
248 memcpy(a4, &a2[v25], 0x30u);
249 v29 = -1;
250 v30 = 0;
251 if ( a3 > 0 )
252 {
253 v31 = a2;
254 do
255 {
256 if ( v31->vWorldPosition.x <= (double)v59 )
257 v32 = v59 - v31->vWorldPosition.x;
258 else
259 v32 = v31->vWorldPosition.x - v59;
260 if ( v32 < a1f )
261 {
262 a1f = v32;
263 v29 = v30;
264 }
265 ++v30;
266 ++v31;
267 }
268 while ( v30 < a3 );
269 }
270 a1g = 3.4028235e38;
271 memcpy(&a4[2], &a2[v29], sizeof(a4[2]));
272 v33 = -1;
273 v34 = 0;
274 if ( a3 > 0 )
275 {
276 v35 = (char *)&a2->vWorldPosition.z;
277 do
278 {
279 if ( *(float *)v35 <= (double)v62 )
280 v36 = v62 - *(float *)v35;
281 else
282 v36 = *(float *)v35 - v62;
283 if ( v36 < a1g )
284 {
285 a1g = v36;
286 v33 = v34;
287 }
288 ++v34;
289 v35 += 48;
290 }
291 while ( v34 < a3 );
292 }
293 a1h = 3.4028235e38;
294 memcpy(&a4[1], &a2[v33], sizeof(a4[1]));
295 v21 = -1;
296 v37 = 0;
297 if ( a3 > 0 )
298 {
299 v38 = (char *)&a2->vWorldPosition.z;
300 do
301 {
302 if ( *(float *)v38 <= (double)v60 )
303 v39 = v60 - *(float *)v38;
304 else
305 v39 = *(float *)v38 - v60;
306 if ( v39 < a1h )
307 {
308 a1h = v39;
309 v21 = v37;
310 }
311 ++v37;
312 v38 += 48;
313 }
314 while ( v37 < a3 );
315 }
316 goto LABEL_77;
317 }
318 if ( !(v7 & 0x400) )
319 return;
320 v41 = -1;
321 a1i = 3.4028235e38;
322 v42 = 0;
323 if ( a3 > 0 )
324 {
325 v43 = (char *)&a2->vWorldPosition.y;
326 do
327 {
328 if ( *(float *)v43 <= (double)v61 )
329 v44 = v61 - *(float *)v43;
330 else
331 v44 = *(float *)v43 - v61;
332 if ( v44 < a1i )
333 {
334 a1i = v44;
335 v41 = v42;
336 }
337 ++v42;
338 v43 += 48;
339 }
340 while ( v42 < a3 );
341 }
342 v45 = a2;
343 v12 = a4;
344 a1j = 3.4028235e38;
345 memcpy(a4, &a2[v41], 0x30u);
346 v46 = -1;
347 v47 = 0;
348 if ( a3 > 0 )
349 {
350 v48 = (char *)&a2->vWorldPosition.y;
351 do
352 {
353 if ( *(float *)v48 <= (double)v64 )
354 v49 = v64 - *(float *)v48;
355 else
356 v49 = *(float *)v48 - v64;
357 if ( v49 < a1j )
358 {
359 a1j = v49;
360 v46 = v47;
361 }
362 ++v47;
363 v48 += 48;
364 }
365 while ( v47 < a3 );
366 v45 = a2;
367 }
368 a1k = 3.4028235e38;
369 memcpy(&a4[2], &v45[v46], sizeof(a4[2]));
370 v50 = -1;
371 v51 = 0;
372 if ( a3 > 0 )
373 {
374 v52 = (char *)&v45->vWorldPosition.z;
375 do
376 {
377 if ( *(float *)v52 <= (double)v62 )
378 v53 = v62 - *(float *)v52;
379 else
380 v53 = *(float *)v52 - v62;
381 if ( v53 < a1k )
382 {
383 a1k = v53;
384 v50 = v51;
385 }
386 ++v51;
387 v52 += 48;
388 }
389 while ( v51 < a3 );
390 v45 = a2;
391 }
392 a1l = 3.4028235e38;
393 memcpy(&a4[1], &v45[v50], sizeof(a4[1]));
394 v54 = -1;
395 v55 = 0;
396 if ( a3 > 0 )
397 {
398 v56 = (char *)&v45->vWorldPosition.z;
399 do
400 {
401 if ( *(float *)v56 <= (double)v60 )
402 v57 = v60 - *(float *)v56;
403 else
404 v57 = *(float *)v56 - v60;
405 if ( v57 < a1l )
406 {
407 a1l = v57;
408 v54 = v55;
409 }
410 ++v55;
411 v56 += 48;
412 }
413 while ( v55 < a3 );
414 v45 = a2;
415 }
416 v40 = &v45[v54];
417 LABEL_115:
418 memcpy(&v12[3], v40, sizeof(v12[3]));
419 } 110 }
420 111
421 //----- (0049D379) -------------------------------------------------------- 112 //----- (0049D379) --------------------------------------------------------
422 void stru10::CalcPolygonLimits(BLVFace *pFace, RenderVertexSoft *pOutVertices) 113 void stru10::CalcPolygonLimits(BLVFace *pFace, RenderVertexSoft *pOutVertices)
423 { 114 {
1059 stru10::~stru10() 750 stru10::~stru10()
1060 { 751 {
1061 } 752 }
1062 753
1063 //----- (0049C5DA) -------------------------------------------------------- 754 //----- (0049C5DA) --------------------------------------------------------
1064 char stru10::_49C5DA(BLVFace *a2, RenderVertexSoft *a3, int *a4, IndoorCameraD3D_Vec4 *a5, RenderVertexSoft *a6) 755 char stru10::_49C5DA(BLVFace *pFace, RenderVertexSoft *pVertices, unsigned int *pNumVertices, IndoorCameraD3D_Vec4 *a5, RenderVertexSoft *pOutBounding)
1065 { 756 {
1066 //stru10 *v6; // edi@1 757 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1
1067 //char *v7; // eax@1 758
1068 //signed int v8; // ecx@1 759 _49CE9E(pFace, pVertices, *pNumVertices, pLimits);
1069 //IndoorCameraD3D *v9; // esi@3 760
1070 char result; // al@6 761 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
1071 RenderVertexSoft a4a[4]; // [sp+Ch] [bp-C0h]@1 762 // pGame->pIndoorCameraD3D->debug_outline_sw(a4a, 4u, 0xFF1E1Eu, 0.000099999997);
1072 763 if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
1073 /*v6 = this; 764 return _49C720(pOutBounding, a5);
1074 v7 = (char *)&a4a[0].flt_2C; 765 return false;
1075 v8 = 4;
1076 do
1077 {
1078 *(float *)v7 = 0.0;
1079 v7 += 48;
1080 --v8;
1081 }
1082 while ( v8 );
1083 v9 = pGame->pIndoorCameraD3D;*/
1084 _49CE9E(a2, a3, *a4, a4a);
1085 if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
1086 pGame->pIndoorCameraD3D->debug_outline_sw(a4a, 4u, 0xFF1E1Eu, 0.000099999997);
1087 result = CalcFaceBounding(a2, a4a, 4u, a6);
1088 if ( result )
1089 result = _49C720(a6, a5);
1090 return result;
1091 } 766 }
1092 // 4D864C: using guessed type char byte_4D864C; 767 // 4D864C: using guessed type char byte_4D864C;
1093 768
1094 //----- (0049C681) -------------------------------------------------------- 769 //----- (0049C681) --------------------------------------------------------
1095 char stru10::MessWithPortal(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pOutBounding) 770 bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pOutBounding)
1096 { 771 {
1097 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1 772 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1
1098 773
1099 CalcPolygonLimits(pFace, pLimits); 774 CalcPolygonLimits(pFace, pLimits);
1100 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) 775 //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
1104 return false; 779 return false;
1105 } 780 }
1106 // 4D864C: using guessed type char byte_4D864C; 781 // 4D864C: using guessed type char byte_4D864C;
1107 782
1108 //----- (0049C720) -------------------------------------------------------- 783 //----- (0049C720) --------------------------------------------------------
1109 char stru10::_49C720(RenderVertexSoft *a2, IndoorCameraD3D_Vec4 *a4) 784 char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *a4)
1110 { 785 {
1111 char result; // al@2
1112 Vec3_float_ a3; // [sp+4h] [bp-34h]@1 786 Vec3_float_ a3; // [sp+4h] [bp-34h]@1
1113 float v5; // [sp+30h] [bp-8h]@1
1114 stru10 *thisa; // [sp+34h] [bp-4h]@1
1115
1116 v5 = 0.0;
1117 a3.x = (double)pBLVRenderParams->vPartyPos.x; 787 a3.x = (double)pBLVRenderParams->vPartyPos.x;
1118 a3.y = (double)pBLVRenderParams->vPartyPos.y; 788 a3.y = (double)pBLVRenderParams->vPartyPos.y;
1119 thisa = this;
1120 a3.z = (double)pBLVRenderParams->vPartyPos.z; 789 a3.z = (double)pBLVRenderParams->vPartyPos.z;
1121 if ( FindFaceNormal(a2, a2 + 1, &a3, a4) 790
1122 && FindFaceNormal(a2 + 1, a2 + 2, &a3, a4 + 1) 791 if (FindFaceNormal(pFaceBounding, pFaceBounding + 1, &a3, a4) &&
1123 && FindFaceNormal(a2 + 2, a2 + 3, &a3, a4 + 2) ) 792 FindFaceNormal(pFaceBounding + 1, pFaceBounding + 2, &a3, a4 + 1) &&
1124 result = FindFaceNormal(a2 + 3, a2, &a3, a4 + 3) != 0; 793 FindFaceNormal(pFaceBounding + 2, pFaceBounding + 3, &a3, a4 + 2) &&
1125 else 794 FindFaceNormal(pFaceBounding + 3, pFaceBounding, &a3, a4 + 3))
1126 result = 0; 795 return true;
1127 return result; 796 return false;
1128 } 797 }
1129 798
1130 //----- (0049C7C5) -------------------------------------------------------- 799 //----- (0049C7C5) --------------------------------------------------------
1131 bool stru10::FindFaceNormal(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4) 800 bool stru10::FindFaceNormal(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4)
1132 { 801 {