2496
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6 #include "Engine/Engine.h"
|
2496
|
7 #include "stru10.h"
|
|
8 #include "Indoor.h"
|
2541
|
9 #include "Engine/Party.h"
|
2496
|
10
|
|
11
|
|
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 }
|
|
80
|
|
81 //----- (0049CE9E) --------------------------------------------------------
|
|
82 void stru10::_49CE9E(BLVFace *pFace, RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutLimits)
|
|
83 {
|
|
84 Assert(sizeof(RenderVertexSoft) == 0x30);
|
|
85
|
|
86 RenderVertexSoft pLimits[64];
|
|
87 stru10::CalcPolygonLimits(pFace, pLimits);
|
|
88
|
|
89 if (pFace->uAttributes & FACE_XY_PLANE)
|
|
90 {
|
|
91 memcpy(&pOutLimits[0], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[0].vWorldPosition.x)], 0x30);
|
|
92 memcpy(&pOutLimits[2], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[2].vWorldPosition.x)], 0x30);
|
|
93 memcpy(&pOutLimits[1], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[1].vWorldPosition.y)], 0x30);
|
|
94 memcpy(&pOutLimits[3], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[3].vWorldPosition.y)], 0x30);
|
|
95 }
|
|
96 else if (pFace->uAttributes & FACE_XZ_PLANE)
|
|
97 {
|
|
98 memcpy(&pOutLimits[0], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[0].vWorldPosition.x)], 0x30);
|
|
99 memcpy(&pOutLimits[2], &pVertices[_49CE9E_sub0_x(pVertices, uNumVertices, pLimits[2].vWorldPosition.x)], 0x30);
|
|
100 memcpy(&pOutLimits[1], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[1].vWorldPosition.z)], 0x30);
|
|
101 memcpy(&pOutLimits[3], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[3].vWorldPosition.z)], 0x30);
|
|
102 }
|
|
103 else if (pFace->uAttributes & FACE_YZ_PLANE)
|
|
104 {
|
|
105 memcpy(&pOutLimits[0], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[0].vWorldPosition.y)], 0x30);
|
|
106 memcpy(&pOutLimits[2], &pVertices[_49CE9E_sub0_y(pVertices, uNumVertices, pLimits[2].vWorldPosition.y)], 0x30);
|
|
107 memcpy(&pOutLimits[1], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[1].vWorldPosition.z)], 0x30);
|
|
108 memcpy(&pOutLimits[3], &pVertices[_49CE9E_sub0_z(pVertices, uNumVertices, pLimits[3].vWorldPosition.z)], 0x30);
|
|
109 }
|
|
110 }
|
|
111
|
|
112 //----- (0049D379) --------------------------------------------------------
|
|
113 void stru10::CalcPolygonLimits(BLVFace *pFace, RenderVertexSoft *pOutVertices)
|
|
114 {
|
|
115 struct
|
|
116 {
|
|
117 float x;
|
|
118 float y;
|
|
119 int c;
|
|
120 } v46[40]; //[sp+0C];
|
|
121
|
|
122 if (pFace->uAttributes & FACE_XY_PLANE)
|
|
123 {
|
|
124 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
125 {
|
|
126 v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
|
|
127 v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pYInterceptDisplacements[i];
|
|
128 v46[i].c = i;
|
|
129 }
|
|
130 }
|
|
131 if (pFace->uAttributes & FACE_XZ_PLANE)
|
|
132 {
|
|
133 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
134 {
|
|
135 v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
|
|
136 v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].z + pFace->pZInterceptDisplacements[i];
|
|
137 v46[i].c = i;
|
|
138 }
|
|
139 }
|
|
140 if (pFace->uAttributes & FACE_YZ_PLANE)
|
|
141 {
|
|
142 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
143 {
|
|
144 v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pYInterceptDisplacements[i];
|
|
145 v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].z + pFace->pZInterceptDisplacements[i];
|
|
146 v46[i].c = i;
|
|
147 }
|
|
148 }
|
|
149
|
|
150 float x_min = v46[0].x;
|
|
151 uint x_min_idx = 0;
|
|
152
|
|
153 float x_max = v46[0].x;
|
|
154 uint x_max_idx = 0;
|
|
155
|
|
156 float y_min = v46[0].y;
|
|
157 uint y_min_idx = 0;
|
|
158
|
|
159 float y_max = v46[0].y;
|
|
160 uint y_max_idx = 0;
|
|
161
|
|
162 for (uint i = 0; i < pFace->uNumVertices; ++i)
|
|
163 {
|
|
164 if (v46[i].x < x_min)
|
|
165 {
|
|
166 x_min = v46[i].x;
|
|
167 x_min_idx = v46[i].c;
|
|
168 }
|
|
169 if (v46[i].x > x_max)
|
|
170 {
|
|
171 x_max = v46[i].x;
|
|
172 x_max_idx = v46[i].c;
|
|
173 }
|
|
174
|
|
175 if (v46[i].y < y_min)
|
|
176 {
|
|
177 y_min = v46[i].y;
|
|
178 y_min_idx = v46[i].c;
|
|
179 }
|
|
180 if (v46[i].y > y_max)
|
|
181 {
|
|
182 y_max = v46[i].y;
|
|
183 y_max_idx = v46[i].c;
|
|
184 }
|
|
185 }
|
|
186
|
|
187 RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24
|
|
188 v1.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].x;
|
|
189 v1.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].y;
|
|
190 v1.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].z;
|
|
191 memcpy(&pOutVertices[0], &v1, sizeof(RenderVertexSoft));
|
|
192
|
|
193 RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24
|
|
194 v2.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].x;
|
|
195 v2.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].y;
|
|
196 v2.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].z;
|
|
197 memcpy(&pOutVertices[1], &v2, sizeof(RenderVertexSoft));
|
|
198
|
|
199 RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24
|
|
200 v3.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].x;
|
|
201 v3.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].y;
|
|
202 v3.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].z;
|
|
203 memcpy(&pOutVertices[2], &v3, sizeof(RenderVertexSoft));
|
|
204
|
|
205 RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24
|
|
206 v4.vWorldPosition.x = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].x;
|
|
207 v4.vWorldPosition.y = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].y;
|
|
208 v4.vWorldPosition.z = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].z;
|
|
209 memcpy(&pOutVertices[3], &v4, sizeof(RenderVertexSoft));
|
|
210 }
|
|
211
|
|
212
|
|
213 //----- (0049C9E3) --------------------------------------------------------
|
|
214 bool stru10::CalcFaceBounding(BLVFace *pFace, RenderVertexSoft *pFaceLimits, unsigned int uNumVertices, RenderVertexSoft *pOutBounding)
|
|
215 {
|
|
216 //IndoorCameraD3D *v6; // edi@1
|
|
217 //PolygonType v7; // al@1
|
|
218 //unsigned int v8; // edx@7
|
|
219 //char v10; // zf@10
|
|
220 //float v13; // ST14_4@20
|
|
221 //stru10 *v15; // ecx@21
|
|
222 //RenderVertexSoft *v16; // ST0C_4@21
|
|
223 //bool result; // eax@21
|
|
224 //float v18; // ST14_4@24
|
|
225 //stru10 *v19; // edi@29
|
|
226 //float v20; // ST14_4@30
|
|
227 //float v21; // ST14_4@30
|
|
228 //float v22; // ST14_4@30
|
|
229 //float v23; // ST14_4@30
|
|
230 //float v24; // ST14_4@31
|
|
231 //RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
|
|
232 //RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
233 //IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
|
|
234 //stru10 *v31; // [sp+84h] [bp-1Ch]@1
|
|
235 //float v32; // [sp+88h] [bp-18h]@8
|
|
236 Vec3_float_ a1; // [sp+8Ch] [bp-14h]@1
|
|
237 //float v35; // [sp+9Ch] [bp-4h]@8
|
|
238
|
|
239 //auto a3 = pFace;
|
|
240 //auto arg4 = pFaceBounding;
|
|
241
|
|
242 //_ESI = a3;
|
|
243 //v31 = this;
|
2543
|
244 //v6 = pIndoorCameraD3D;
|
2496
|
245 //v7 = a3->uPolygonType;
|
|
246
|
|
247 a1.x = 0.0f;
|
|
248 a1.y = 0.0f;
|
|
249 a1.z = 0.0f;
|
|
250
|
|
251 float var_28;
|
|
252 float var_24;
|
|
253 switch (pFace->uPolygonType)
|
|
254 {
|
|
255 case POLYGON_VerticalWall:
|
|
256 a1.x = -pFace->pFacePlane.vNormal.y;// направление полигона
|
|
257 a1.y = pFace->pFacePlane.vNormal.x;
|
|
258 a1.z = 0.0f;
|
|
259 a1.Normalize();
|
|
260
|
|
261 var_28 = 0;
|
|
262 var_24 = 1;
|
|
263 break;
|
|
264
|
|
265 case POLYGON_Floor:
|
|
266 case POLYGON_Ceiling:
|
|
267 a1.x = 1;
|
|
268 a1.y = 0;
|
|
269 a1.z = 0.0f;
|
|
270
|
|
271 var_28 = 1;
|
|
272 var_24 = 0;
|
|
273 break;
|
|
274
|
|
275 default:
|
|
276 Error("Invalid polygon type (%u)", pFace->uPolygonType);
|
|
277 }
|
|
278
|
|
279
|
|
280 float face_center_x;
|
|
281 float face_center_y;
|
|
282 float face_center_z;
|
|
283 float a3;
|
|
284 float var_8;
|
|
285
|
|
286 if (pFace->uAttributes & FACE_XY_PLANE)
|
|
287 {
|
|
288 face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;
|
|
289 face_center_y = (pFaceLimits[3].vWorldPosition.y + pFaceLimits[1].vWorldPosition.y) / 2;
|
|
290 face_center_z = (pFaceLimits[0].vWorldPosition.z + pFaceLimits[2].vWorldPosition.z) / 2;
|
|
291
|
|
292 a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;
|
|
293 var_8 = face_center_y - pFaceLimits[1].vWorldPosition.y;
|
|
294 }
|
|
295 if (pFace->uAttributes & FACE_XZ_PLANE)
|
|
296 {
|
|
297 face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;// центр полигона
|
|
298 face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2;
|
|
299 face_center_z = (pFaceLimits[1].vWorldPosition.z + pFaceLimits[3].vWorldPosition.z) / 2;
|
|
300
|
|
301 a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;//от центра до верхнего края
|
|
302 var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z;// высота от центра
|
|
303
|
|
304 if (pFace->uPolygonType == POLYGON_VerticalWall)
|
|
305 a3 /= a1.x;
|
|
306 }
|
|
307 if (pFace->uAttributes & FACE_YZ_PLANE)
|
|
308 {
|
|
309 face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;
|
|
310 face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2;
|
|
311 face_center_z = (pFaceLimits[1].vWorldPosition.z + pFaceLimits[3].vWorldPosition.z) / 2;
|
|
312
|
|
313 a3 = face_center_y - pFaceLimits[0].vWorldPosition.y;
|
|
314 var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z;
|
|
315 // [0.5]
|
|
316 if (pFace->uPolygonType == POLYGON_VerticalWall)
|
|
317 {
|
|
318 if (a1.x != 1.0f)
|
|
319 a3 /= a1.y;
|
|
320 }
|
|
321 }
|
|
322
|
|
323
|
|
324
|
|
325
|
|
326 //_EBX = arg0;
|
|
327 //v15 = v31;
|
|
328 //v16 = arg0;
|
|
329 //float var_20 = var_8 * var_24;
|
|
330 //var_8 = a3 * a1.z;
|
|
331 //float arg_0 = var_8 + var_4;
|
|
332
|
|
333 /*
|
|
334
|
|
335
|
|
336
|
|
337 .text:0049CBB3 fld [ebp+var_8] 0 var8
|
|
338 .text:0049CBB6 1 fmul ds:flt_4D84E8 0 var8 * flt_4D84E8
|
|
339
|
|
340 .text:0049CBBC 1 fld [ebp+var_8] 0 var8
|
|
341 1 var8 * flt_4D84E8
|
|
342
|
|
343 .text:0049CBBF 2 fmul [ebp+var_28] 0 var8 * var28
|
|
344 1 var8 * flt_4D84E8
|
|
345
|
|
346 .text:0049CBC2 2 fld [ebp+var_8] 0 var8
|
|
347 1 var8 * var28
|
|
348 2 var8 * flt_4D84E8
|
|
349
|
|
350 .text:0049CBC5 3 fmul [ebp+var_24] 0 var8 * var24 768
|
|
351 1 var8 * var28 0
|
|
352 2 var8 * flt_4D84E8 0
|
|
353
|
|
354 .text:0049CBD5 3 fst [ebp+var_20] 0 var8 * var24 768
|
|
355 1 var8 * var28 0
|
|
356 2 var8 * flt_4D84E8 0
|
|
357 [var20] var8 * var24 768
|
|
358
|
|
359 .text:0049CBD8 3 fld [ebp+a3] 0 a3 -1984
|
|
360 1 var8 * var24 768
|
|
361 2 var8 * var28 0
|
|
362 3 var8 * flt_4D84E8 0
|
|
363
|
|
364 .text:0049CBDB 4 fmul [ebp+a1.x] 0 a3 * a1.x 1984
|
|
365 1 var8 * var24 768
|
|
366 2 var8 * var28 0
|
|
367 3 var8 * flt_4D84E8 0
|
|
368
|
|
369 .text:0049CBDE 4 fld [ebp+a3] 0 a3
|
|
370 1 a3 * a1.x 1984
|
|
371 2 var8 * var24 768
|
|
372 3 var8 * var28 0
|
|
373 4 var8 * flt_4D84E8 0
|
|
374
|
|
375 .text:0049CBE1 5 fmul [ebp+a1.y] 0 a3 * a1.y 0
|
|
376 1 a3 * a1.x 1984
|
|
377 2 var8 * var24 768
|
|
378 3 var8 * var28 0
|
|
379 4 var8 * flt_4D84E8 0
|
|
380 .text:0049CBE4 5 fld [ebp+a3]
|
|
381 .text:0049CBE7 6 fmul [ebp+a1.z] 0 a3 * a1.z 0
|
|
382 1 a3 * a1.y 0
|
|
383 2 a3 * a1.x 1984
|
|
384 3 var8 * var24 768
|
|
385 4 var8 * var28 0
|
|
386 5 var8 * flt_4D84E8 0
|
|
387
|
|
388 .text:0049CBEC 6 fstp [ebp+var_8]
|
|
389 var8 <- a3 * a1.z 0
|
|
390
|
|
391 .text:0049CBEF 5 fld [ebp+arg4] 0 arg4 -1700
|
|
392 1 a3 * a1.y 0
|
|
393 2 a3 * a1.x 1984
|
|
394 3 var8 * var24 768
|
|
395 4 var8 * var28 0
|
|
396 5 var8 * flt_4D84E8 0
|
|
397
|
|
398 .text:0049CBF2 6 fsub st, st(2) 0 arg4 - a3 * a1.x -3684
|
|
399 1 a3 * a1.y 0
|
|
400 2 a3 * a1.x 1984
|
|
401 3 var8 * var24 768
|
|
402 4 var8 * var28 0
|
|
403 5 var8 * flt_4D84E8 0
|
|
404
|
|
405 .text:0049CBF4 6 fld st 0 arg4 - a3 * a1.x -3684
|
|
406 1 arg4 - a3 * a1.x -3684
|
|
407 2 a3 * a1.y 0
|
|
408 3 a3 * a1.x 1984
|
|
409 4 var8 * var24 768
|
|
410 5 var8 * var28 0
|
|
411 6 var8 * flt_4D84E8 0
|
|
412
|
|
413 .text:0049CBF6 7 fadd st, st(6) 0 arg4 - a3 * a1.x + var8 * flt_4D84E8 -3684
|
|
414 1 arg4 - a3 * a1.x -3684
|
|
415 2 a3 * a1.y 0
|
|
416 3 a3 * a1.x 1984
|
|
417 4 var8 * var24 768
|
|
418 5 var8 * var28 0
|
|
419 6 var8 * flt_4D84E8 0
|
|
420 .text:0049CBF8 7 fstp dword ptr [ebx]
|
|
421 [0].x <- arg4 - a3 * a1.x + var8 * flt_4D84E8 -3684
|
|
422
|
|
423 .text:0049CBFA 6 fld [ebp+var_18] 0 var18 1480
|
|
424 1 arg4 - a3 * a1.x -3684
|
|
425 2 a3 * a1.y 0
|
|
426 3 a3 * a1.x 1984
|
|
427 4 var8 * var24 768
|
|
428 5 var8 * var28 0
|
|
429 6 var8 * flt_4D84E8 0
|
|
430
|
|
431 .text:0049CBFD 7 fsub st, st(2) 0 var18 - a3 * a1.y 1480
|
|
432 1 arg4 - a3 * a1.x -3684
|
|
433 2 a3 * a1.y 0
|
|
434 3 a3 * a1.x 1984
|
|
435 4 var8 * var24 768
|
|
436 5 var8 * var28 0
|
|
437 6 var8 * flt_4D84E8 0
|
|
438
|
|
439 .text:0049CBFF 7 fld st 0 var18 - a3 * a1.y 1480
|
|
440 1 var18 - a3 * a1.y 1480
|
|
441 2 arg4 - a3 * a1.x -3684
|
|
442 3 a3 * a1.y 0
|
|
443 4 a3 * a1.x 1984
|
|
444 5 var8 * var24 768
|
|
445 6 var8 * var28 0
|
|
446 7 var8 * flt_4D84E8 0
|
|
447
|
|
448 .text:0049CC01 8 fadd st, st(6) 0 var18 - a3 * a1.y + var8 * var28 1480
|
|
449 1 var18 - a3 * a1.y 1480
|
|
450 2 arg4 - a3 * a1.x -3684
|
|
451 3 a3 * a1.y 0
|
|
452 4 a3 * a1.x 1984
|
|
453 5 var8 * var24 768
|
|
454 6 var8 * var28 0
|
|
455 7 var8 * flt_4D84E8 0
|
|
456
|
|
457 .text:0049CC03 8 fstp dword ptr [ebx+4]
|
|
458 [0].y <- var18 - a3 * a1.y + var8 * var28 1480
|
|
459
|
|
460 .text:0049CC06 7 fld [ebp+var_4]
|
|
461 .text:0049CC09 8 fsub [ebp+var_8] 0 var4 - a3 * a1.z 768
|
|
462 1 var18 - a3 * a1.y 1480
|
|
463 2 arg4 - a3 * a1.x -3684
|
|
464 3 a3 * a1.y 0
|
|
465 4 a3 * a1.x 1984
|
|
466 5 var8 * var24 768
|
|
467 6 var8 * var28 0
|
|
468 7 var8 * flt_4D84E8 0
|
|
469 .text:0049CC0C 8 fst [ebp+a3]
|
|
470 a3 <- var4 - a3 * a1.z 768
|
|
471
|
|
472 .text:0049CC0F 8 fadd st, st(5)
|
|
473 .text:0049CC11 8 fstp dword ptr [ebx+8]
|
|
474 [0].z <- var4 - a3 * a1.z + var8 * var24 1536
|
|
475
|
|
476 0 var18 - a3 * a1.y 1480
|
|
477 1 arg4 - a3 * a1.x -3684
|
|
478 2 a3 * a1.y 0
|
|
479 3 a3 * a1.x 1984
|
|
480 4 var8 * var24 768
|
|
481 5 var8 * var28 0
|
|
482 6 var8 * flt_4D84E8 0
|
|
483
|
|
484
|
|
485
|
|
486
|
|
487 [var20] var8 * var24 768
|
|
488 [var8] a3 * a1.z
|
|
489 [a3] var4 - a3 * a1.z 768
|
|
490
|
|
491
|
|
492 .text:0049CC14 7 fld st(1)
|
|
493 .text:0049CC16 8 fsub st, st(7) 0 arg4 - a3 * a1.x - var8 * flt_4D84E8 -3684
|
|
494 1 var18 - a3 * a1.y 1480
|
|
495 2 arg4 - a3 * a1.x -3684
|
|
496 3 a3 * a1.y 0
|
|
497 4 a3 * a1.x 1984
|
|
498 5 var8 * var24 768
|
|
499 6 var8 * var28 0
|
|
500 7 var8 * flt_4D84E8 0
|
|
501 .text:0049CC18 8 fstp dword ptr [ebx+30h]
|
|
502 [1].x <- arg4 - a3 * a1.x - var8 * flt_4D84E8 -3684
|
|
503
|
|
504 0 var18 - a3 * a1.y 1480
|
|
505 1 arg4 - a3 * a1.x -3684
|
|
506 2 a3 * a1.y 0
|
|
507 3 a3 * a1.x 1984
|
|
508 4 var8 * var24 768
|
|
509 5 var8 * var28 0
|
|
510 6 var8 * flt_4D84E8 0
|
|
511 .text:0049CC1B 7 fsub st, st(5)
|
|
512 .text:0049CC1D 7 fstp dword ptr [ebx+34h]
|
|
513 [1].y <- var18 - a3 * a1.y - var8 * var28 1480
|
|
514 .text:0049CC20 6 fstp st
|
|
515 0 a3 * a1.y 0
|
|
516 1 a3 * a1.x 1984
|
|
517 2 var8 * var24 768
|
|
518 3 var8 * var28 0
|
|
519 4 var8 * flt_4D84E8 0
|
|
520
|
|
521
|
|
522 [var20] var8 * var24 768
|
|
523 [var8] a3 * a1.z
|
|
524 [a3] var4 - a3 * a1.z 768
|
|
525
|
|
526 .text:0049CC22 5 fld [ebp+a3] 0 var4 - a3 * a1.z 768
|
|
527 1 a3 * a1.y 0
|
|
528 2 a3 * a1.x 1984
|
|
529 3 var8 * var24 768
|
|
530 4 var8 * var28 0
|
|
531 5 var8 * flt_4D84E8 0
|
|
532 .text:0049CC25 6 fsub st, st(3)
|
|
533 .text:0049CC27 6 fstp dword ptr [ebx+38h]
|
|
534 [1].z <- var4 - a3 * a1.z - var8 * var24 768 - 768 = 0
|
|
535
|
|
536 0 a3 * a1.y 0
|
|
537 1 a3 * a1.x 1984
|
|
538 2 var8 * var24 768
|
|
539 3 var8 * var28 0
|
|
540 4 var8 * flt_4D84E8 0
|
|
541
|
|
542
|
|
543 .text:0049CC2A fld st(1)
|
|
544 .text:0049CC2C 6 fadd [ebp+arg4] 0 arg4 + a3 * a1.x 284
|
|
545 1 a3 * a1.y 0
|
|
546 2 a3 * a1.x 1984
|
|
547 3 var8 * var24 768
|
|
548 4 var8 * var28 0
|
|
549 5 var8 * flt_4D84E8 0
|
|
550 .text:0049CC2F 6 fst [ebp+a3]
|
|
551
|
|
552 [var20] var8 * var24 768
|
|
553 [var8] a3 * a1.z
|
|
554 [a3] arg4 + a3 * a1.x 284
|
|
555 .text:0049CC32 6 fsub st, st(5)
|
|
556 .text:0049CC34 6 fstp dword ptr [ebx+60h]
|
|
557 [2].x <- arg4 + a3 * a1.x - var8 * flt_4D84E8 284
|
|
558
|
|
559 0 a3 * a1.y 0
|
|
560 1 a3 * a1.x 1984
|
|
561 2 var8 * var24 768
|
|
562 3 var8 * var28 0
|
|
563 4 var8 * flt_4D84E8 0
|
|
564
|
|
565 .text:0049CC37 5 fadd [ebp+var_18] 0 var18 + a3 * a1.y 1480
|
|
566 1 a3 * a1.x 1984
|
|
567 2 var8 * var24 768
|
|
568 3 var8 * var28 0
|
|
569 4 var8 * flt_4D84E8 0
|
|
570
|
|
571 .text:0049CC3A 5 fstp st(2) 0 a3 * a1.x 1984
|
|
572 1 var18 + a3 * a1.y 1480
|
|
573 2 var8 * var28 0
|
|
574 3 var8 * flt_4D84E8 0
|
|
575
|
|
576 .text:0049CC3C 4 fstp st 0 var18 + a3 * a1.y 1480
|
|
577 1 var8 * var28 0
|
|
578 2 var8 * flt_4D84E8 0
|
|
579
|
|
580 .text:0049CC3E 3 fld st 0 var18 + a3 * a1.y 1480
|
|
581 1 var18 + a3 * a1.y 1480
|
|
582 2 var8 * var28 0
|
|
583 3 var8 * flt_4D84E8 0
|
|
584 .text:0049CC40 4 fsub st, st(2)
|
|
585 .text:0049CC42 4 fstp dword ptr [ebx+64h]
|
|
586 [2].y <- var18 + a3 * a1.y - var8 * var28 1480
|
|
587
|
|
588 0 var18 + a3 * a1.y 1480
|
|
589 1 var8 * var28 0
|
|
590 2 var8 * flt_4D84E8 0
|
|
591
|
|
592 [var20] var8 * var24 768
|
|
593 [var8] a3 * a1.z
|
|
594 [a3] arg4 + a3 * a1.x 284
|
|
595 .text:0049CC45 3 fld [ebp+var_8]
|
|
596 .text:0049CC48 4 fadd [ebp+var_4] 0 var4 + a3 * a1.z 768
|
|
597 1 var18 + a3 * a1.y 1480
|
|
598 2 var8 * var28 0
|
|
599 3 var8 * flt_4D84E8 0
|
|
600
|
|
601 .text:0049CC4B 4 fst [ebp+arg0]
|
|
602 [var20] var8 * var24 768
|
|
603 [arg0] var4 + a3 * a1.z 768
|
|
604 [var8] a3 * a1.z 0
|
|
605 [a3] arg4 + a3 * a1.x 284
|
|
606
|
|
607 .text:0049CC4E 4 fsub [ebp+var_20]
|
|
608 .text:0049CC51 4 fstp dword ptr [ebx+68h]
|
|
609 [2].z <- var4 + a3 * a1.z - var8 * var24 0
|
|
610
|
|
611
|
|
612
|
|
613 [var20] var8 * var24 768
|
|
614 [arg0] var4 + a3 * a1.z 768
|
|
615 [var8] a3 * a1.z 0
|
|
616 [a3] arg4 + a3 * a1.x 284
|
|
617
|
|
618
|
|
619 0 var18 + a3 * a1.y 1480
|
|
620 1 var8 * var28 0
|
|
621 2 var8 * flt_4D84E8 0
|
|
622
|
|
623 .text:0049CC54 3 fld [ebp+a3]
|
|
624 .text:0049CC57 4 fadd st, st(3)
|
|
625 .text:0049CC59 4 fstp dword ptr [ebx+90h]
|
|
626 [3].x <- arg4 + a3 * a1.x + var8 * flt_4D84E8 284
|
|
627
|
|
628 .text:0049CC5F 3 fadd st, st(1)
|
|
629 .text:0049CC61 3 fstp dword ptr [ebx+94h]
|
|
630 [3].y <- var18 + a3 * a1.y + var8 * var28 1480
|
|
631
|
|
632 .text:0049CC67 2 fstp st
|
|
633 .text:0049CC69 1 fstp st
|
|
634 0 empty
|
|
635 .text:0049CC6B 0 fld [ebp+arg0]
|
|
636 .text:0049CC6E 1 fadd [ebp+var_20]
|
|
637 .text:0049CC71 1 fstp dword ptr [ebx+98h]
|
|
638 [3].z <- var4 + a3 * a1.z + var8 * var24 1536
|
|
639
|
|
640 0 empty
|
|
641 */
|
|
642
|
|
643 pOutBounding[0].vWorldPosition.x = face_center_x - a3 * a1.x + var_8 * flt_4D84E8;
|
|
644 pOutBounding[0].vWorldPosition.y = face_center_y - a3 * a1.y + var_8 * var_28;
|
|
645 pOutBounding[0].vWorldPosition.z = face_center_z - a3 * a1.z + var_8 * var_24;
|
|
646
|
|
647 pOutBounding[1].vWorldPosition.x = face_center_x - a3 * a1.x - var_8 * flt_4D84E8;
|
|
648 pOutBounding[1].vWorldPosition.y = face_center_y - a3 * a1.y - var_8 * var_28;
|
|
649 pOutBounding[1].vWorldPosition.z = face_center_z - a3 * a1.z - var_8 * var_24;
|
|
650
|
|
651 pOutBounding[2].vWorldPosition.x = face_center_x + a3 * a1.x - var_8 * flt_4D84E8;
|
|
652 pOutBounding[2].vWorldPosition.y = face_center_y + a3 * a1.y - var_8 * var_28;
|
|
653 pOutBounding[2].vWorldPosition.z = face_center_z + a3 * a1.z - var_8 * var_24;
|
|
654
|
|
655 pOutBounding[3].vWorldPosition.x = face_center_x + a3 * a1.x + var_8 * flt_4D84E8;
|
|
656 pOutBounding[3].vWorldPosition.y = face_center_y + a3 * a1.y + var_8 * var_28;
|
|
657 pOutBounding[3].vWorldPosition.z = face_center_z + a3 * a1.z + var_8 * var_24;
|
|
658
|
|
659 a1.x = 0.0f;
|
|
660 a1.y = 0.0f;
|
|
661 a1.z = 0.0f;
|
|
662 a3 = face_center_x + a3 * a1.x;
|
|
663
|
|
664 if (!FindFacePlane(pOutBounding, &a1, &a3))
|
|
665 return false;
|
|
666
|
|
667
|
|
668
|
|
669 RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
|
|
670 memcpy(&v25, pOutBounding, sizeof(RenderVertexSoft));
|
|
671
|
2543
|
672 float _dp = (v25.vWorldPosition.x - pIndoorCameraD3D->vPartyPos.x) * a1.x +
|
|
673 (v25.vWorldPosition.y - pIndoorCameraD3D->vPartyPos.y) * a1.y +
|
|
674 (v25.vWorldPosition.z - pIndoorCameraD3D->vPartyPos.z) * a1.z;
|
2496
|
675 if (fabs(_dp) < 1e-6f)
|
|
676 {
|
|
677 memcpy(&v25, &pOutBounding[1], sizeof(RenderVertexSoft));
|
|
678 memcpy(&pOutBounding[1], &pOutBounding[3], sizeof(RenderVertexSoft));
|
|
679 memcpy(&pOutBounding[3], &v25, sizeof(RenderVertexSoft));
|
|
680 }
|
|
681
|
2541
|
682 //if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
|
2496
|
683 //{
|
|
684 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
685 if ( draw_portals_loops )
|
|
686 {
|
|
687 if (!bDoNotDrawPortalFrustum)
|
|
688 {
|
|
689 v26.vWorldPosition.x = pParty->vPosition.x;
|
|
690 v26.vWorldPosition.y = pParty->vPosition.y;
|
|
691 v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum
|
|
692
|
2543
|
693 pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0);
|
|
694 pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0);
|
|
695 pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0);
|
|
696 pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0);
|
2496
|
697 bDoNotDrawPortalFrustum = true;
|
|
698 }
|
2543
|
699 pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding
|
2496
|
700 }
|
|
701 //}
|
|
702
|
2543
|
703 //pIndoorCameraD3D->debug_outline_sw(pFaceLimits, 4, 0xFFF14040, 0.000099999997); // limits
|
2496
|
704
|
2541
|
705 /*if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
|
2496
|
706 {
|
|
707 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
708 v26.vWorldPosition.x = face_center_x; // corner to center
|
|
709 v26.vWorldPosition.y = face_center_y;
|
|
710 v26.vWorldPosition.z = face_center_z;
|
|
711
|
2543
|
712 pIndoorCameraD3D->do_draw_debug_line_sw(pFaceLimits, 0xFF00u, &v26, 0xFF0000u, 0, 0);
|
2496
|
713 }*/
|
|
714
|
|
715
|
|
716 /*if ( byte_4D864C )
|
|
717 {
|
2541
|
718 if ( pEngine->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)*/
|
2496
|
719 {
|
|
720 RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
|
|
721 RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
|
|
722
|
|
723 v25.vWorldPosition.x = face_center_x; // portal normal
|
|
724 v25.vWorldPosition.y = face_center_y;
|
|
725 v25.vWorldPosition.z = face_center_z;
|
|
726
|
|
727 v26.vWorldPosition.x = face_center_x + a1.x * 400.0f;
|
|
728 v26.vWorldPosition.y = face_center_y + a1.y * 400.0f;
|
|
729 v26.vWorldPosition.z = face_center_z + a1.z * 400.0f;
|
|
730
|
|
731 if ( draw_portals_loops )
|
2543
|
732 pIndoorCameraD3D->do_draw_debug_line_sw(&v25, -1, &v26, 0xFFFF00u, 0, 0);
|
2496
|
733 }
|
|
734 //}
|
|
735
|
|
736 return true;
|
|
737 }
|
|
738
|
|
739
|
|
740
|
|
741 //----- (0049C5B0) --------------------------------------------------------
|
|
742 stru10::stru10()
|
|
743 {
|
|
744 this->bDoNotDrawPortalFrustum = false;
|
|
745 }
|
|
746
|
|
747 //----- (0049C5BD) --------------------------------------------------------
|
|
748 stru10::~stru10()
|
|
749 {
|
|
750 }
|
|
751
|
|
752 //----- (0049C5DA) --------------------------------------------------------
|
|
753 char stru10::_49C5DA(BLVFace *pFace, RenderVertexSoft *pVertices, unsigned int *pNumVertices, IndoorCameraD3D_Vec4 *a5, RenderVertexSoft *pOutBounding)
|
|
754 {
|
|
755 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1
|
|
756
|
|
757 _49CE9E(pFace, pVertices, *pNumVertices, pLimits);
|
|
758
|
2541
|
759 //if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
|
2543
|
760 // pIndoorCameraD3D->debug_outline_sw(a4a, 4u, 0xFF1E1Eu, 0.000099999997);
|
2496
|
761 if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
|
|
762 return _49C720(pOutBounding, a5);
|
|
763 return false;
|
|
764 }
|
|
765 // 4D864C: using guessed type char byte_4D864C;
|
|
766
|
|
767 //----- (0049C681) --------------------------------------------------------
|
|
768 bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *pPortalDataFrustum, RenderVertexSoft *pOutBounding)
|
|
769 {
|
|
770 RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1
|
|
771
|
|
772 CalcPolygonLimits(pFace, pLimits);//определение границ портала
|
2541
|
773 //if ( byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
|
2543
|
774 // pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997);
|
2496
|
775 if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))
|
|
776 return _49C720(pOutBounding, pPortalDataFrustum) != 0;
|
|
777 return false;
|
|
778 }
|
|
779
|
|
780 // 4D864C: using guessed type char byte_4D864C;
|
|
781
|
|
782 //----- (0049C720) --------------------------------------------------------
|
|
783 char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *pPortalDataFrustum)
|
|
784 {
|
|
785 Vec3_float_ pRayStart; // [sp+4h] [bp-34h]@1
|
2543
|
786 pRayStart.x = (double)pIndoorCameraD3D->vPartyPos.x;
|
|
787 pRayStart.y = (double)pIndoorCameraD3D->vPartyPos.y;
|
|
788 pRayStart.z = (double)pIndoorCameraD3D->vPartyPos.z;
|
2496
|
789
|
|
790 if (FindFaceNormal(&pFaceBounding[0], &pFaceBounding[1], &pRayStart, &pPortalDataFrustum[0]) &&
|
|
791 FindFaceNormal(&pFaceBounding[1], &pFaceBounding[2], &pRayStart, &pPortalDataFrustum[1]) &&
|
|
792 FindFaceNormal(&pFaceBounding[2], &pFaceBounding[3], &pRayStart, &pPortalDataFrustum[2]) &&
|
|
793 FindFaceNormal(&pFaceBounding[3], &pFaceBounding[0], &pRayStart, &pPortalDataFrustum[3]))
|
|
794 return true;
|
|
795 return false;
|
|
796 }
|
|
797
|
|
798 //----- (0049C7C5) --------------------------------------------------------
|
|
799 bool stru10::FindFaceNormal(RenderVertexSoft *pFaceBounding1, RenderVertexSoft *pFaceBounding2, Vec3_float_ *pRayStart, IndoorCameraD3D_Vec4 *pPortalDataFrustum)
|
|
800 {
|
|
801 Vec3_float_ ray_dir; // [sp+4h] [bp-48h]@1
|
|
802 Vec3_float_ pRay2; // [sp+10h] [bp-3Ch]@1
|
|
803
|
|
804 ray_dir.x = pFaceBounding1->vWorldPosition.x - pRayStart->x;//get ray for cmera to bounding1
|
|
805 ray_dir.y = pFaceBounding1->vWorldPosition.y - pRayStart->y;
|
|
806 ray_dir.z = pFaceBounding1->vWorldPosition.z - pRayStart->z;
|
|
807 Vec3_float_::Cross(&ray_dir, &pRay2, pFaceBounding2->vWorldPosition.x - pFaceBounding1->vWorldPosition.x,
|
|
808 pFaceBounding2->vWorldPosition.y - pFaceBounding1->vWorldPosition.y,
|
|
809 pFaceBounding2->vWorldPosition.z - pFaceBounding1->vWorldPosition.z);
|
|
810
|
|
811 float sqr_mag = pRay2.x * pRay2.x + pRay2.y * pRay2.y + pRay2.z * pRay2.z;
|
|
812 if (fabsf(sqr_mag) > 1e-6f)
|
|
813 {
|
|
814 float inv_mag = 1.0f / sqrtf(sqr_mag);
|
|
815 pRay2.x *= inv_mag;
|
|
816 pRay2.y *= inv_mag;
|
|
817 pRay2.z *= inv_mag;
|
|
818 pRay2.Normalize();
|
|
819
|
|
820 pPortalDataFrustum->x = pRay2.x;
|
|
821 pPortalDataFrustum->y = pRay2.y;
|
|
822 pPortalDataFrustum->z = pRay2.z;
|
|
823 pPortalDataFrustum->dot = pRayStart->z * pRay2.z + pRayStart->y * pRay2.y + pRayStart->x * pRay2.x;
|
|
824 return true;
|
|
825 }
|
|
826 return false;
|
|
827 }
|
|
828
|
|
829 //----- (0049C8DC) --------------------------------------------------------
|
|
830 bool stru10::FindFacePlane(RenderVertexSoft *arg0, Vec3_float_ *a2, float *a3)
|
|
831 {
|
|
832 Vec3_float_ v1; // [sp+8h] [bp-3Ch]@1
|
|
833 Vec3_float_ v2; // [sp+14h] [bp-30h]@1
|
|
834
|
|
835 v1.x = arg0[1].vWorldPosition.x - arg0[0].vWorldPosition.x;
|
|
836 v1.y = arg0[1].vWorldPosition.y - arg0[0].vWorldPosition.y;
|
|
837 v1.z = arg0[1].vWorldPosition.z - arg0[0].vWorldPosition.z;
|
|
838
|
|
839 Vec3_float_::Cross(&v1, &v2, arg0[2].vWorldPosition.x - arg0[1].vWorldPosition.x,
|
|
840 arg0[2].vWorldPosition.y - arg0[1].vWorldPosition.y,
|
|
841 arg0[2].vWorldPosition.z - arg0[1].vWorldPosition.z);
|
|
842
|
|
843 float sqr_mag = v2.x * v2.x + v2.y * v2.y + v2.z * v2.z;
|
|
844 if (fabsf(sqr_mag) > 1e-6f)
|
|
845 {
|
|
846 //v2.Normalize();
|
|
847 float inv_mag = 1.0f / sqrtf(sqr_mag);
|
|
848 v2.x *= inv_mag;
|
|
849 v2.y *= inv_mag;
|
|
850 v2.z *= inv_mag;
|
|
851
|
|
852 a2->x = v2.x;
|
|
853 a2->y = v2.y;
|
|
854 a2->z = v2.z;
|
|
855 *a3 = -(arg0[0].vWorldPosition.z * v2.z + arg0[0].vWorldPosition.y * v2.y + arg0[0].vWorldPosition.x * v2.x);
|
|
856 return true;
|
|
857 }
|
|
858 return false;
|
|
859 }
|