0
|
1 #include "Vis.h"
|
|
2 #include "Outdoor.h"
|
|
3 #include "Game.h"
|
|
4 #include "Actor.h"
|
|
5 #include "IndoorCamera.h"
|
|
6 #include "Viewport.h"
|
|
7 #include "stru157.h"
|
|
8
|
|
9 #include "mm7_data.h"
|
|
10 //#include "MM7.h"
|
|
11
|
|
12
|
|
13 static Vis_stru1 Vis_static_sub_4C1944_stru_F8BDE8;
|
|
14
|
|
15
|
|
16
|
|
17 //----- (004C1026) --------------------------------------------------------
|
|
18 Vis_stru1_stru0 *Vis::_4C1026(BLVFace *a2, unsigned int a3, float a4)
|
|
19 {
|
|
20 char *v4; // eax@4
|
|
21 signed int v5; // ecx@4
|
|
22 BLVFace *v6; // ecx@7
|
|
23 unsigned int v7; // edi@7
|
|
24 Vec3_short_ *v8; // eax@9
|
|
25 char *v9; // edx@9
|
|
26 signed int v10; // esi@10
|
|
27 Vec3_int_ **v11; // edx@13
|
|
28 char *v12; // eax@13
|
|
29 double v13; // st7@14
|
|
30 signed int v14; // ebx@14
|
|
31 Vis *v15; // ebx@15
|
|
32 Vis_stru1_stru0 *result; // eax@21
|
|
33 Vis_stru1_stru0 *v17; // ecx@24
|
|
34 RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17
|
|
35 int v20; // [sp+84h] [bp-Ch]@10
|
|
36 int v21; // [sp+88h] [bp-8h]@16
|
|
37 int v22; // [sp+8Ch] [bp-4h]@16
|
|
38 signed int v23; // [sp+98h] [bp+8h]@7
|
|
39
|
|
40 auto ecx0 = this;
|
|
41
|
|
42 static Vis_stru1 static_sub_4C1026_stru_F8FE00;
|
|
43 static_sub_4C1026_stru_F8FE00.uNumPointers = 0;
|
|
44
|
|
45 static bool _init_flag = false;
|
|
46 static RenderVertexSoft static_sub_4C1026_array_F8F200[64];
|
|
47 if (!_init_flag)
|
|
48 {
|
|
49 _init_flag = true;
|
|
50 for (uint i = 0; i < 64; ++i)
|
|
51 static_sub_4C1026_array_F8F200[i].flt_2C = 0.0f;
|
|
52 }
|
|
53
|
|
54 v6 = a2;
|
|
55 v23 = 0;
|
|
56 v7 = v6->uNumVertices;
|
|
57 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
58 {
|
|
59 if ( (signed int)v7 > 0 )
|
|
60 {
|
|
61 v8 = pIndoor->pVertices;
|
|
62 v9 = (char *)&static_sub_4C1026_array_F8F200[0].vWorldPosition.y;
|
|
63 do
|
|
64 {
|
|
65 v10 = v23++;
|
|
66 v20 = v8[v6->pVertexIDs[v10]].x;
|
|
67 *((float *)v9 - 1) = (double)v20;
|
|
68 v20 = v8[v6->pVertexIDs[v10]].y;
|
|
69 *(float *)v9 = (double)v20;
|
|
70 v9 += 48;
|
|
71 v20 = v8[v6->pVertexIDs[v10]].z;
|
|
72 *((float *)v9 - 11) = (double)v20;
|
|
73 }
|
|
74 while ( v23 < (signed int)v7 );
|
|
75 }
|
|
76 }
|
|
77 else
|
|
78 {
|
|
79 if ( (signed int)v7 > 0 )
|
|
80 {
|
|
81 v11 = &pOutdoor->pBModels[a3 >> 9].pVertices.pVertices;
|
|
82 v12 = (char *)&static_sub_4C1026_array_F8F200[0].vWorldPosition.y;
|
|
83 do
|
|
84 {
|
|
85 *((float *)v12 - 1) = (double)(*v11)[v6->pVertexIDs[v23]].x;
|
|
86 v13 = (double)(*v11)[v6->pVertexIDs[v23]].y;
|
|
87 v14 = v23++;
|
|
88 *(float *)v12 = v13;
|
|
89 v12 += 48;
|
|
90 *((float *)v12 - 11) = (double)(*v11)[v6->pVertexIDs[v14]].z;
|
|
91 }
|
|
92 while ( v23 < (signed int)v7 );
|
|
93 }
|
|
94 }
|
|
95 pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, v7);
|
|
96 pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(static_sub_4C1026_array_F8F200, v7, 1);
|
|
97 v15 = this;
|
|
98 SortVectors_x(static_sub_4C1026_array_F8F200, 0, v7 - 1);
|
|
99 if ( static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > (double)a4
|
|
100 || (_4C1495(static_sub_4C1026_array_F8F200, v7, (float *)&v21, (float *)&v22),
|
|
101 _4C12C3_FindSomeBillboard(static_sub_4C1026_array_F8F200, v7, *(float *)&v21, *(float *)&v22))
|
|
102 || ((CastPickRay(pRay, *(float *)&v21, *(float *)&v22, a4), uCurrentlyLoadedLevelType != LEVEL_Indoor) ? PickOutdoor(a4, pRay, &static_sub_4C1026_stru_F8FE00, &a5, 1) : PickIndoor(a4, pRay, &static_sub_4C1026_stru_F8FE00, &a5),
|
|
103 (static_sub_4C1026_stru_F8FE00.create_object_pointers(0),
|
|
104 sort_object_pointers(
|
|
105 static_sub_4C1026_stru_F8FE00.array_1804,
|
|
106 0,
|
|
107 static_sub_4C1026_stru_F8FE00.uNumPointers - 1),
|
|
108 !static_sub_4C1026_stru_F8FE00.uNumPointers)
|
|
109 || (result = static_sub_4C1026_stru_F8FE00.sub_4C2551(2, a3)) == 0
|
|
110 || (signed int)static_sub_4C1026_stru_F8FE00.uNumPointers > 1
|
|
111 && ((signed int)static_sub_4C1026_stru_F8FE00.uNumPointers <= 0 ? (v17 = 0) : (v17 = static_sub_4C1026_stru_F8FE00.array_1804[0]),
|
|
112 result != v17)) )
|
|
113 result = 0;
|
|
114 return result;
|
|
115 }
|
|
116 // F91E08: using guessed type char static_sub_4C1026_byte_F91E08__init_flags;
|
|
117
|
|
118 //----- (004C12C3) --------------------------------------------------------
|
|
119 char Vis::_4C12C3_FindSomeBillboard(RenderVertexSoft *a1, int a2, float a3, float a4)
|
|
120 {
|
|
121 signed int v5; // esi@1
|
|
122 char *v6; // edi@2
|
|
123 double v7; // st7@9
|
|
124 int v8; // edx@9
|
|
125 char *v9; // ecx@10
|
|
126 char result; // al@24
|
|
127 Vis *thisa; // [sp+10h] [bp-8h]@1
|
|
128 float thisb; // [sp+10h] [bp-8h]@9
|
|
129 signed int v13; // [sp+14h] [bp-4h]@1
|
|
130 float a3a; // [sp+28h] [bp+10h]@9
|
|
131 float a4a; // [sp+2Ch] [bp+14h]@9
|
|
132
|
|
133 v13 = -1;
|
|
134 v5 = 0;
|
|
135 thisa = this;
|
|
136 if ( (signed int)pRenderer->uNumBillboardsToDraw <= 0 )
|
|
137 goto LABEL_28;
|
|
138 v6 = (char *)&pRenderer->pBillboardRenderListD3D[0].uParentBillboardID;
|
|
139 do
|
|
140 {
|
|
141 if ( IsPointInsideD3DBillboard((RenderBillboardD3D *)(v6 - 152), a3, a4)
|
|
142 && (v13 == -1
|
|
143 || (unsigned int)pBillboardRenderList[*(int *)v6].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue) )
|
|
144 v13 = v5;
|
|
145 ++v5;
|
|
146 v6 += 156;
|
|
147 }
|
|
148 while ( v5 < (signed int)pRenderer->uNumBillboardsToDraw );
|
|
149 if ( v13 == -1 )
|
|
150 goto LABEL_28;
|
|
151 v7 = 3.4028235e38;
|
|
152 v8 = a2;
|
|
153 a4a = 3.4028235e38;
|
|
154 a3a = -3.4028235e38;
|
|
155 thisb = -3.4028235e38;
|
|
156 if ( a2 > 0 )
|
|
157 {
|
|
158 v9 = (char *)&a1->vWorldViewProjY;
|
|
159 do
|
|
160 {
|
|
161 if ( *((float *)v9 - 1) < v7 )
|
|
162 v7 = *((float *)v9 - 1);
|
|
163 if ( *((float *)v9 - 1) > (double)a3a )
|
|
164 a3a = *((float *)v9 - 1);
|
|
165 if ( *(float *)v9 < (double)a4a )
|
|
166 a4a = *(float *)v9;
|
|
167 if ( *(float *)v9 > (double)thisb )
|
|
168 thisb = *(float *)v9;
|
|
169 v9 += 48;
|
|
170 --v8;
|
|
171 }
|
|
172 while ( v8 );
|
|
173 }
|
|
174 if ( v7 < pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.x
|
|
175 || pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.y > (double)a4a
|
|
176 || pRenderer->pBillboardRenderListD3D[v13].pQuards[3].pos.x < (double)a3a
|
|
177 || pRenderer->pBillboardRenderListD3D[v13].pQuards[1].pos.y < (double)thisb )
|
|
178 LABEL_28:
|
|
179 result = 0;
|
|
180 else
|
|
181 result = 1;
|
|
182 return result;
|
|
183 }
|
|
184
|
|
185 //----- (004C1417) --------------------------------------------------------
|
|
186 void Vis::GetPolygonCenter(RenderVertexD3D3 *pVertices, unsigned int uNumVertices, float *pCenterX, float *pCenterY)
|
|
187 {
|
|
188 static RenderVertexD3D3 unk_F8EA00[64];
|
|
189
|
|
190 memcpy(unk_F8EA00, pVertices, 32 * uNumVertices);
|
|
191
|
|
192 SortVerticesByX(unk_F8EA00, 0, uNumVertices - 1);
|
|
193 *pCenterX = (unk_F8EA00[uNumVertices - 1].pos.x - unk_F8EA00[0].pos.x) * 0.5 + unk_F8EA00[0].pos.x;
|
|
194
|
|
195 SortVerticesByY(unk_F8EA00, 0, uNumVertices - 1);
|
|
196 *pCenterY = (unk_F8EA00[uNumVertices - 1].pos.y - unk_F8EA00[0].pos.y) * 0.5 + unk_F8EA00[0].pos.y;
|
|
197 }
|
|
198
|
|
199 //----- (004C1495) --------------------------------------------------------
|
|
200 float *Vis::_4C1495(RenderVertexSoft *Src, int a2, float *a3, float *a4)
|
|
201 {
|
|
202 char *v5; // eax@2
|
|
203 signed int v6; // ecx@2
|
|
204 float *result; // eax@5
|
|
205 Vis *thisa; // [sp+0h] [bp-4h]@1
|
|
206
|
|
207 thisa = this;
|
|
208
|
|
209 static bool static_sub_4C1495_byte_F8E9F8__init_flags = false; // weak
|
|
210 static RenderVertexSoft static_sub_4C1495_array_F8DDF8[64];
|
|
211 if ( !static_sub_4C1495_byte_F8E9F8__init_flags )
|
|
212 {
|
|
213 static_sub_4C1495_byte_F8E9F8__init_flags = true;
|
|
214
|
|
215 for (uint i = 0; i < 64; ++i)
|
|
216 static_sub_4C1495_array_F8DDF8[i].flt_2C = 0.0f;
|
|
217 }
|
|
218
|
|
219 memcpy(static_sub_4C1495_array_F8DDF8, Src, 48 * a2);
|
|
220 sort_objects_2(static_sub_4C1495_array_F8DDF8, 0, a2 - 1);
|
|
221 *a3 = (*(float *)&Vis_static_sub_4C1944_stru_F8BDE8.array_1804[12 * a2 + 509]
|
|
222 - static_sub_4C1495_array_F8DDF8[0].vWorldViewProjX)
|
|
223 * 0.5
|
|
224 + static_sub_4C1495_array_F8DDF8[0].vWorldViewProjX;
|
|
225 sort_objects_3(static_sub_4C1495_array_F8DDF8, 0, a2 - 1);
|
|
226 result = a4;
|
|
227 *a4 = (*(float *)&Vis_static_sub_4C1944_stru_F8BDE8.array_1804[12 * a2 + 510]
|
|
228 - static_sub_4C1495_array_F8DDF8[0].vWorldViewProjY)
|
|
229 * 0.5
|
|
230 + static_sub_4C1495_array_F8DDF8[0].vWorldViewProjY;
|
|
231 return result;
|
|
232 }
|
|
233
|
|
234 //----- (004C1542) --------------------------------------------------------
|
|
235 void Vis::PickBillboards(float fPickDepth, float fX, float fY, Vis_stru1 *a4, stru157 *a2)
|
|
236 {
|
|
237 int v6; // ST1C_4@6
|
|
238 Vis_stru1_stru0 *v7; // edi@6
|
|
239 Vis *thisa; // [sp+20h] [bp-Ch]@1
|
|
240 void **v9; // [sp+24h] [bp-8h]@2
|
|
241 unsigned int uD3DBillboardIdx; // [sp+28h] [bp-4h]@1
|
|
242
|
|
243 uD3DBillboardIdx = 0;
|
|
244 thisa = this;
|
|
245 if ( (signed int)pRenderer->uNumBillboardsToDraw > 0 )
|
|
246 {
|
|
247 v9 = (void **)&pRenderer->pBillboardRenderListD3D[0].uParentBillboardID;
|
|
248 do
|
|
249 {
|
|
250 if ( is_part_of_selection((BLVFace *)uD3DBillboardIdx, a2)
|
|
251 && IsPointInsideD3DBillboard((RenderBillboardD3D *)(v9 - 38), fX, fY) )
|
|
252 {
|
|
253 if ( DoesRayIntersectBillboard(fPickDepth, uD3DBillboardIdx) )
|
|
254 {
|
|
255 v6 = pBillboardRenderList[(int)*v9].sZValue;
|
|
256 v7 = &a4->array_0004[a4->uNumPointers];
|
|
257 v7->pObjectInfo = *v9;
|
|
258 v7 = (Vis_stru1_stru0 *)((char *)v7 + 4);
|
|
259 v7->pObjectInfo = (void *)v6;
|
|
260 v7->sZValue = 1;
|
|
261 ++a4->uNumPointers;
|
|
262 }
|
|
263 }
|
|
264 ++uD3DBillboardIdx;
|
|
265 v9 += 39;
|
|
266 }
|
|
267 while ( (signed int)uD3DBillboardIdx < (signed int)pRenderer->uNumBillboardsToDraw );
|
|
268 }
|
|
269 }
|
|
270
|
|
271 //----- (004C1607) --------------------------------------------------------
|
|
272 bool Vis::IsPointInsideD3DBillboard(RenderBillboardD3D *a1, float x, float y)
|
|
273 {
|
|
274 RenderBillboardD3D *result; // eax@1
|
|
275 double v5; // st7@2
|
|
276 float v6; // ecx@2
|
|
277 float v7; // ST00_4@3
|
|
278 __int16 v8; // fps@6
|
|
279 double v9; // st6@6
|
|
280 char v10; // c0@6
|
|
281 char v11; // c2@6
|
|
282 char v12; // c3@6
|
|
283 __int16 v13; // fps@7
|
|
284 double v14; // st6@7
|
|
285 unsigned __int8 v15; // c0@7
|
|
286 char v16; // c2@7
|
|
287 unsigned __int8 v17; // c3@7
|
|
288 __int16 v18; // fps@8
|
|
289 double v19; // st6@8
|
|
290 char v20; // c0@8
|
|
291 char v21; // c2@8
|
|
292 char v22; // c3@8
|
|
293 __int16 v23; // fps@9
|
|
294 double v24; // st6@9
|
|
295 unsigned __int8 v25; // c0@9
|
|
296 char v26; // c2@9
|
|
297 unsigned __int8 v27; // c3@9
|
|
298 float v28; // [sp+4h] [bp-8h]@2
|
|
299 float v29; // [sp+8h] [bp-4h]@2
|
|
300 float a1a; // [sp+14h] [bp+8h]@2
|
|
301
|
|
302 result = a1;
|
|
303 if ( a1->uParentBillboardID == -1 )
|
|
304 goto LABEL_14;
|
|
305 v5 = a1->pQuards[0].pos.x;
|
|
306 a1a = a1->pQuards[3].pos.x;
|
|
307 v6 = result->pQuards[0].pos.y;
|
|
308 result = (RenderBillboardD3D *)LODWORD(result->pQuards[1].pos.y);
|
|
309 v29 = v6;
|
|
310 LODWORD(v28) = (int)result;
|
|
311 if ( v5 > a1a )
|
|
312 {
|
|
313 v7 = v5;
|
|
314 HIWORD(result) = HIWORD(v7);
|
|
315 v5 = a1a;
|
|
316 a1a = v7;
|
|
317 }
|
|
318 if ( v6 > (double)v28 )
|
|
319 {
|
|
320 result = (RenderBillboardD3D *)LODWORD(v28);
|
|
321 v28 = v6;
|
|
322 LODWORD(v29) = (int)result;
|
|
323 }
|
|
324 v9 = x + 1.0;
|
|
325 //UNDEF(v8);
|
|
326 v10 = v9 < v5;
|
|
327 v11 = 0;
|
|
328 v12 = v9 == v5;
|
|
329 BYTE1(result) = HIBYTE(v8);
|
|
330 if ( v9 >= v5
|
|
331 && (v14 = x - 1.0, /*UNDEF(v13),*/ v15 = v14 < a1a, v16 = 0, v17 = v14 == a1a, BYTE1(result) = HIBYTE(v13), v15 | v17)
|
|
332 && (v19 = y + 1.0, /*UNDEF(v18),*/ v20 = v19 < v29, v21 = 0, v22 = v19 == v29, BYTE1(result) = HIBYTE(v18), v19 >= v29)
|
|
333 && (v24 = y - 1.0, /*UNDEF(v23),*/ v25 = v24 < v28, v26 = 0, v27 = v24 == v28, BYTE1(result) = HIBYTE(v23), v25 | v27) )
|
|
334 LOBYTE(result) = 1;
|
|
335 else
|
|
336 LABEL_14:
|
|
337 LOBYTE(result) = 0;
|
|
338 return (bool)result;
|
|
339 }
|
|
340
|
|
341 //----- (004C16B4) --------------------------------------------------------
|
|
342 void Vis::PickIndoor(float fDepth, RenderVertexSoft *pRay, Vis_stru1 *a4, stru157 *a5)
|
|
343 {
|
|
344 int v5; // eax@1
|
|
345 signed int v6; // edi@2
|
|
346 signed int v7; // esi@4
|
|
347 int v8; // ecx@7
|
|
348 int v9; // eax@7
|
|
349 unsigned int *pNumPointers; // eax@7
|
|
350 unsigned int v11; // ecx@7
|
|
351 Vis_stru1_stru0 *v12; // edi@7
|
|
352 RenderVertexSoft a1; // [sp+Ch] [bp-44h]@1
|
|
353 BLVFace *v14; // [sp+3Ch] [bp-14h]@7
|
|
354 void *v15; // [sp+40h] [bp-10h]@7
|
|
355 int v16; // [sp+44h] [bp-Ch]@7
|
|
356 int v17; // [sp+48h] [bp-8h]@1
|
|
357 Vis *thisa; // [sp+4Ch] [bp-4h]@1
|
|
358
|
|
359 v5 = 0;
|
|
360 thisa = this;
|
|
361 v17 = 0;
|
|
362 for ( a1.flt_2C = 0.0; v17 < (signed int)pStru170->uNumFaceIDs; ++v17 )
|
|
363 {
|
|
364 v6 = pStru170->pFaceIDs[2 * v5];
|
|
365 if ( v6 >= 0 )
|
|
366 {
|
|
367 if ( v6 < (signed int)pIndoor->uNumFaces )
|
|
368 {
|
|
369 v7 = v6;
|
|
370 if ( is_part_of_selection(&pIndoor->pFaces[v6], a5) )
|
|
371 {
|
|
372 if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(&pIndoor->pFaces[v7]) )
|
|
373 {
|
|
374 if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, &pIndoor->pFaces[v7], 0xFFFFFFFFu) )
|
|
375 {
|
|
376 pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u);
|
|
377 v9 = _48B561_mess_with_scaling_along_z(/*v8, */a1.vWorldViewPosition.x);
|
|
378 LOWORD(v9) = 0;
|
|
379 v15 = (void *)((8 * v6 | 6) + v9);
|
|
380 pNumPointers = &a4->uNumPointers;
|
|
381 v16 = 2;
|
|
382 v11 = a4->uNumPointers;
|
|
383 v14 = &pIndoor->pFaces[v7];
|
|
384 v12 = &a4->array_0004[v11];
|
|
385 v12->pObjectInfo = &pIndoor->pFaces[v7];
|
|
386 v12 = (Vis_stru1_stru0 *)((char *)v12 + 4);
|
|
387 v12->pObjectInfo = v15;
|
|
388 v12->sZValue = v16;
|
|
389 ++*pNumPointers;
|
|
390 }
|
|
391 }
|
|
392 }
|
|
393 }
|
|
394 }
|
|
395 v5 = v17 + 1;
|
|
396 }
|
|
397 }
|
|
398
|
|
399 //----- (004C17CF) --------------------------------------------------------
|
|
400 void Vis::PickOutdoor(float fDepth, RenderVertexSoft *pRay, Vis_stru1 *a4, stru157 *a5, char a6)
|
|
401 {
|
|
402 int v6; // esi@1
|
|
403 unsigned int v7; // ecx@1
|
|
404 BSPModel *v8; // ebx@3
|
|
405 bool v9; // eax@3
|
|
406 int v10; // eax@8
|
|
407 ODMFace *v11; // esi@10
|
|
408 int v12; // ecx@12
|
|
409 int v13; // eax@12
|
|
410 unsigned int *pNumPointers; // eax@12
|
|
411 Vis_stru1_stru0 *v15; // edi@12
|
|
412 BLVFace thisa; // [sp+10h] [bp-B8h]@1
|
|
413 RenderVertexSoft a1; // [sp+70h] [bp-58h]@1
|
|
414 void *v18; // [sp+A0h] [bp-28h]@12
|
|
415 void *v19; // [sp+A4h] [bp-24h]@12
|
|
416 int v20; // [sp+A8h] [bp-20h]@12
|
|
417 int v21; // [sp+ACh] [bp-1Ch]@8
|
|
418 Vis *v22; // [sp+B0h] [bp-18h]@1
|
|
419 int v23; // [sp+B4h] [bp-14h]@9
|
|
420 int v24; // [sp+B8h] [bp-10h]@1
|
|
421 unsigned int v25; // [sp+BCh] [bp-Ch]@2
|
|
422 unsigned int v26; // [sp+C0h] [bp-8h]@1
|
|
423 int v27; // [sp+C4h] [bp-4h]@8
|
|
424
|
|
425 v22 = this;
|
|
426 v6 = 0;
|
|
427 v7 = 0;
|
|
428 v24 = 0;
|
|
429 v26 = 0;
|
|
430 a1.flt_2C = 0.0;
|
|
431 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
432 {
|
|
433 v25 = 0;
|
|
434 do
|
|
435 {
|
|
436 v8 = &pOutdoor->pBModels[v25 / 0xBC];
|
|
437 v9 = IsBModelVisible(v7, &v24);
|
|
438 if ( a6 )
|
|
439 {
|
|
440 if ( v9 && v24 != v6 )
|
|
441 {
|
|
442 LABEL_8:
|
|
443 v10 = v8->uNumFaces;
|
|
444 v27 = v6;
|
|
445 v21 = v10;
|
|
446 if ( v10 > v6 )
|
|
447 {
|
|
448 v23 = v6;
|
|
449 do
|
|
450 {
|
|
451 v11 = (ODMFace *)((char *)v8->pFaces + v23);
|
|
452 if ( is_part_of_selection((BLVFace *)((char *)v8->pFaces + v23), a5) )
|
|
453 {
|
|
454 thisa.FromODM(v11);
|
|
455 if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, &thisa, v26) )
|
|
456 {
|
|
457 pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u);
|
|
458 v18 = v11;
|
|
459 v13 = _48B561_mess_with_scaling_along_z(/*v12, */a1.vWorldViewPosition.x);
|
|
460 LOWORD(v13) = 0;
|
|
461 v20 = 2;
|
|
462 v19 = (void *)((8 * (v27 | (v26 << 6)) | 6) + v13);
|
|
463 pNumPointers = &a4->uNumPointers;
|
|
464 v15 = &a4->array_0004[a4->uNumPointers];
|
|
465 v15->pObjectInfo = v18;
|
|
466 v15 = (Vis_stru1_stru0 *)((char *)v15 + 4);
|
|
467 v15->pObjectInfo = v19;
|
|
468 v15->sZValue = v20;
|
|
469 ++*pNumPointers;
|
|
470 }
|
|
471 }
|
|
472 ++v27;
|
|
473 v23 += 308;
|
|
474 }
|
|
475 while ( v27 < v21 );
|
|
476 v6 = 0;
|
|
477 }
|
|
478 goto LABEL_15;
|
|
479 }
|
|
480 }
|
|
481 else
|
|
482 {
|
|
483 if ( v9 )
|
|
484 goto LABEL_8;
|
|
485 }
|
|
486 LABEL_15:
|
|
487 v25 += 188;
|
|
488 v7 = v26++ + 1;
|
|
489 }
|
|
490 while ( (signed int)v26 < (signed int)pOutdoor->uNumBModels );
|
|
491 }
|
|
492 }
|
|
493
|
|
494 //----- (004C1930) --------------------------------------------------------
|
|
495 //bool Vis::j_DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx)
|
|
496 //{return DoesRayIntersectBillboard(fDepth, uD3DBillboardIdx);}
|
|
497
|
|
498 //----- (004C1944) --------------------------------------------------------
|
|
499 int Vis::_4C1944(int a2, unsigned int a3, int a4, int a5, int a6)
|
|
500 {
|
|
501 float v6; // ST00_4@3
|
|
502 int result; // eax@4
|
|
503 stru157 v8; // [sp+18h] [bp-20h]@3
|
|
504 __int64 v9; // [sp+2Ch] [bp-Ch]@3
|
|
505 Vis *v14; // [sp+34h] [bp-4h]@1
|
|
506
|
|
507 v14 = this;
|
|
508
|
|
509 static Vis_stru1 Vis_static_sub_4C1944_stru_F8BDE8;
|
|
510
|
|
511 v8.field_4 = a2;
|
|
512 v8.field_8 = a6;
|
|
513 v8.field_C = a5;
|
|
514 v8.field_10 = a4;
|
|
515 v9 = a3;
|
|
516 Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers = 0;
|
|
517 v6 = (double)a3;
|
|
518 v8.field_0 = 1;
|
|
519 _4C06F8(v6, &Vis_static_sub_4C1944_stru_F8BDE8, &v8);
|
|
520 Vis_static_sub_4C1944_stru_F8BDE8.create_object_pointers(1u);
|
|
521 sort_object_pointers(
|
|
522 Vis_static_sub_4C1944_stru_F8BDE8.array_1804,
|
|
523 0,
|
|
524 Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers - 1);
|
|
525 if ( (signed int)Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers <= 0 )
|
|
526 result = -1;
|
|
527 else
|
|
528 result = Vis_static_sub_4C1944_stru_F8BDE8.array_1804[0]->sZValue;
|
|
529 return result;
|
|
530 }
|
|
531 // F8DDF0: using guessed type char Vis_static_sub_4C1944_byte_F8DDF0_init;
|
|
532
|
|
533 //----- (004C1A02) --------------------------------------------------------
|
|
534 void Vis::_4C1A02()
|
|
535 {
|
|
536 RenderVertexSoft v1; // [sp+8h] [bp-C0h]@1
|
|
537 RenderVertexSoft v2; // [sp+38h] [bp-90h]@1
|
|
538 RenderVertexSoft v3; // [sp+68h] [bp-60h]@1
|
|
539 RenderVertexSoft v4; // [sp+98h] [bp-30h]@1
|
|
540
|
|
541 v4.flt_2C = 0.0;
|
|
542 v4.vWorldPosition.x = 0.0;
|
|
543 v4.vWorldPosition.y = 65536.0;
|
|
544 v4.vWorldPosition.z = 0.0;
|
|
545 v3.flt_2C = 0.0;
|
|
546 v3.vWorldPosition.x = 65536.0;
|
|
547 v3.vWorldPosition.y = 0.0;
|
|
548 v3.vWorldPosition.z = 0.0;
|
|
549 memcpy(&v1, &v3, sizeof(v1));
|
|
550 v3.flt_2C = 0.0;
|
|
551 v3.vWorldPosition.x = 0.0;
|
|
552 v3.vWorldPosition.y = 65536.0;
|
|
553 v3.vWorldPosition.z = 0.0;
|
|
554 memcpy(&v2, &v4, sizeof(v2));
|
|
555 v4.flt_2C = 0.0;
|
|
556 v4.vWorldPosition.x = 65536.0;
|
|
557 v4.vWorldPosition.y = 0.0;
|
|
558 v4.vWorldPosition.z = 0.0;
|
|
559 memcpy(&this->stru_200C, &v1, 0x60u);
|
|
560 memcpy(&v1, &v4, sizeof(v1));
|
|
561 memcpy(&v2, &v3, sizeof(v2));
|
|
562 memcpy(&this->stru_206C, &v1, 0x60u);
|
|
563 }
|
|
564
|
|
565 //----- (004C1ABA) --------------------------------------------------------
|
|
566 bool Vis::SortVectors_x(RenderVertexSoft *a2, int a3, int a4)
|
|
567 {
|
|
568 bool result; // eax@1
|
|
569 RenderVertexSoft *v5; // edx@2
|
|
570 int v6; // ebx@2
|
|
571 int i; // ecx@2
|
|
572 int v8; // esi@3
|
|
573 int v9; // esi@5
|
|
574 RenderVertexSoft *v10; // eax@8
|
|
575 RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8
|
|
576 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
|
|
577 int v13; // [sp+64h] [bp-Ch]@7
|
|
578 Vis *thisa; // [sp+68h] [bp-8h]@1
|
|
579 RenderVertexSoft *v15; // [sp+6Ch] [bp-4h]@2
|
|
580
|
|
581 result = a4;
|
|
582 thisa = this;
|
|
583 if ( a4 > a3 )
|
|
584 {
|
|
585 v5 = a2;
|
|
586 v15 = &a2[a4];
|
|
587 v6 = a3 - 1;
|
|
588 memcpy(&v12, &a2[a4], sizeof(v12));
|
|
589 for ( i = a4; ; i = v13 )
|
|
590 {
|
|
591 v8 = (int)&v5[v6].vWorldViewPosition;
|
|
592 do
|
|
593 {
|
|
594 v8 += 48;
|
|
595 ++v6;
|
|
596 }
|
|
597 while ( *(float *)v8 < (double)v12.vWorldViewPosition.x );
|
|
598 v9 = (int)&v5[i].vWorldViewPosition;
|
|
599 do
|
|
600 {
|
|
601 v9 -= 48;
|
|
602 --i;
|
|
603 }
|
|
604 while ( *(float *)v9 > (double)v12.vWorldViewPosition.x );
|
|
605 v13 = i;
|
|
606 if ( v6 >= i )
|
|
607 break;
|
|
608 v10 = &v5[i];
|
|
609 memcpy(&v11, &a2[v6], sizeof(v11));
|
|
610 v5 = a2;
|
|
611 memcpy(&a2[v6], v10, sizeof(a2[v6]));
|
|
612 memcpy(v10, &v11, 0x30u);
|
|
613 }
|
|
614 memcpy(&v11, &v5[v6], sizeof(v11));
|
|
615 memcpy(&v5[v6], v15, sizeof(v5[v6]));
|
|
616 memcpy(v15, &v11, 0x30u);
|
|
617 SortVectors_x(v5, a3, v6 - 1);
|
|
618 SortVectors_x(a2, v6 + 1, a4);
|
|
619 }
|
|
620 return true;
|
|
621 }
|
|
622
|
|
623 //----- (004C1BAA) --------------------------------------------------------
|
|
624 int Vis::get_object_zbuf_val(Vis_stru1_stru0 *a2)
|
|
625 {
|
|
626 unsigned int v2; // eax@1
|
|
627 int result; // eax@3
|
|
628 std::string v4; // [sp-18h] [bp-1Ch]@4
|
|
629 const char *v5; // [sp-8h] [bp-Ch]@4
|
|
630 int v6; // [sp-4h] [bp-8h]@4
|
|
631 Vis *v7; // [sp+0h] [bp-4h]@1
|
|
632
|
|
633 v7 = this;
|
|
634 v2 = a2->uObjectType;
|
|
635 if ( (signed int)v2 <= 0 || (signed int)v2 > 2 )
|
|
636 {
|
|
637 MessageBoxW(nullptr, L"Undefined type requested for: CVis::get_object_zbuf_val()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1037", 0);
|
|
638 result = -1;
|
|
639 }
|
|
640 else
|
|
641 {
|
|
642 result = a2->sZValue;
|
|
643 }
|
|
644 return result;
|
|
645 }
|
|
646
|
|
647 //----- (004C1BF1) --------------------------------------------------------
|
|
648 int Vis::get_picked_object_zbuf_val()
|
|
649 {
|
|
650 int result; // eax@2
|
|
651
|
|
652 if ( (signed int)this->stru1.uNumPointers <= 0 )
|
|
653 result = -1;
|
|
654 else
|
|
655 result = get_object_zbuf_val(this->stru1.array_1804[0]);
|
|
656 return result;
|
|
657 }
|
|
658
|
|
659 //----- (004C1C0C) --------------------------------------------------------
|
|
660 bool Vis::Intersect_Ray_Face(RenderVertexSoft *pRayStart, RenderVertexSoft *pRayEnd, float *pDepth, RenderVertexSoft *a4, BLVFace *a5, unsigned int a6)
|
|
661 {
|
|
662 BLVFace *v7; // ebx@1
|
|
663 bool result; // eax@1
|
|
664 double v9; // st7@3
|
|
665 __int16 v10; // fps@3
|
|
666 char v11; // c0@3
|
|
667 char v12; // c2@3
|
|
668 char v13; // c3@3
|
|
669 __int16 v14; // fps@5
|
|
670 char v15; // c0@5
|
|
671 char v16; // c2@5
|
|
672 char v17; // c3@5
|
|
673 double v18; // st5@6
|
|
674 __int16 v19; // fps@6
|
|
675 char v20; // c0@6
|
|
676 char v21; // c2@6
|
|
677 char v22; // c3@6
|
|
678 unsigned __int8 v23; // c0@6
|
|
679 char v24; // c2@6
|
|
680 unsigned __int8 v25; // c3@6
|
|
681 char v26; // zf@6
|
|
682 double v27; // st6@10
|
|
683 __int16 v28; // fps@10
|
|
684 unsigned __int8 v29; // c0@10
|
|
685 char v30; // c2@10
|
|
686 unsigned __int8 v31; // c3@10
|
|
687 double v32; // st7@11
|
|
688 Vec2_short_ v33; // ST1E_4@11
|
|
689 Vec3_short_ v34; // ST04_6@11
|
|
690 float a5a; // [sp+30h] [bp+18h]@10
|
|
691 float a5b; // [sp+30h] [bp+18h]@13
|
|
692
|
|
693 v7 = a5;
|
|
694 result = a5->uAttributes;
|
|
695 if ( result & 1
|
|
696 || BYTE1(result) & 0x20
|
|
697 || (v9 = pRayEnd->vWorldPosition.z * a5->pFacePlane.vNormal.z
|
|
698 + a5->pFacePlane.vNormal.y * pRayEnd->vWorldPosition.y
|
|
699 + pRayEnd->vWorldPosition.x * a5->pFacePlane.vNormal.x,
|
|
700 //UNDEF(v10),
|
|
701 v11 = v9 < 0.0,
|
|
702 v12 = 0,
|
|
703 v13 = v9 == 0.0,
|
|
704 BYTE1(result) = HIBYTE(v10),
|
|
705 v9 == 0.0)
|
|
706 || (/*UNDEF(v14),*/ v15 = v9 < 0.0, v16 = 0, v17 = v9 == 0.0, BYTE1(result) = HIBYTE(v14), v9 > 0.0) )// ray's away (>) from face surface or parallel (==)
|
|
707 goto LABEL_12;
|
|
708 v18 = -(a5->pFacePlane.vNormal.y * pRayStart->vWorldPosition.y// ray-plane intersection
|
|
709 + pRayStart->vWorldPosition.x * a5->pFacePlane.vNormal.x
|
|
710 + pRayStart->vWorldPosition.z * a5->pFacePlane.vNormal.z
|
|
711 + a5->pFacePlane.dist);
|
|
712 //UNDEF(v19);
|
|
713 v20 = v9 < 0.0;
|
|
714 v21 = 0;
|
|
715 v22 = v9 == 0.0;
|
|
716 BYTE1(result) = HIBYTE(v19);
|
|
717 v23 = v18 < 0.0;
|
|
718 v24 = 0;
|
|
719 v25 = v18 == 0.0;
|
|
720 v26 = (BYTE1(result) & 0x41) == 0;
|
|
721 BYTE1(result) = HIBYTE(v19);
|
|
722 if ( v26 )
|
|
723 {
|
|
724 if ( v18 < 0.0 )
|
|
725 goto LABEL_12;
|
|
726 }
|
|
727 else
|
|
728 {
|
|
729 if ( !(v23 | v25) )
|
|
730 {
|
|
731 LABEL_12:
|
|
732 LOBYTE(result) = 0;
|
|
733 return result;
|
|
734 }
|
|
735 }
|
|
736 a5a = v18;
|
|
737 v27 = a5a / v9;
|
|
738 HIWORD(result) = HIWORD(pDepth);
|
|
739 //UNDEF(v28);
|
|
740 v29 = v27 < *pDepth;
|
|
741 v30 = 0;
|
|
742 v31 = v27 == *pDepth;
|
|
743 BYTE1(result) = HIBYTE(v28);
|
|
744 if ( !(v29 | v31)
|
|
745 || (a4->vWorldPosition.x = v27 * pRayEnd->vWorldPosition.x + pRayStart->vWorldPosition.x,
|
|
746 a4->vWorldPosition.y = v27 * pRayEnd->vWorldPosition.y + pRayStart->vWorldPosition.y,
|
|
747 v32 = v27 * pRayEnd->vWorldPosition.z + pRayStart->vWorldPosition.z,
|
|
748 a4->vWorldPosition.z = v32,
|
|
749 v33.x = (signed __int64)a4->vWorldPosition.x,
|
|
750 v33.y = (signed __int64)a4->vWorldPosition.y,
|
|
751 *(int *)&v34.x = v33.x,
|
|
752 v34.z = (signed __int64)v32,
|
|
753 result = _4C1D2B(v7, v34, a6),
|
|
754 *(float *)&result == 0.0) )
|
|
755 goto LABEL_12;
|
|
756 *(float *)&result = v27;
|
|
757 a5b = v27;
|
|
758 *(int *)pDepth = LODWORD(a5b);
|
|
759 LOBYTE(result) = 1;
|
|
760 return result;
|
|
761 }
|
|
762
|
|
763 //----- (004C1D2B) --------------------------------------------------------
|
|
764 int Vis::_4C1D2B(BLVFace *pFace, Vec3_short_ a2, unsigned int uModelID)
|
|
765 {
|
|
766 BLVFace *v4; // esi@1
|
|
767 int v5; // esi@10
|
|
768 bool v6; // edi@10
|
|
769 int v7; // ecx@12
|
|
770 signed int v8; // edx@12
|
|
771 signed int v9; // eax@13
|
|
772 signed int v10; // ebx@14
|
|
773 int v11; // edi@16
|
|
774 signed int v12; // ST28_4@18
|
|
775 signed __int64 v13; // qtt@18
|
|
776 signed int result; // eax@21
|
|
777 int v15; // [sp+10h] [bp-Ch]@10
|
|
778 signed int v16; // [sp+18h] [bp-4h]@10
|
|
779
|
|
780 v4 = pFace;
|
|
781 if ( a2.z < pFace->pBounding.z1
|
|
782 || a2.z > pFace->pBounding.z2
|
|
783 || a2.x < pFace->pBounding.x1
|
|
784 || a2.x > pFace->pBounding.x2
|
|
785 || a2.y < pFace->pBounding.y1
|
|
786 || a2.y > pFace->pBounding.y2
|
|
787 || (uModelID != -1 ? _4C2186_BLV_IntersectBModel(
|
|
788 (int *)&pFace,
|
|
789 (int *)&uModelID,
|
|
790 &word_F8BC48_displaced_face_intersect_plane_coords_a,
|
|
791 &word_F8BD18_displaced_face_intersect_plane_coords_b,
|
|
792 &a2,
|
|
793 pFace,
|
|
794 uModelID) : _4C1EE5_BLV_IntersectBModel_2(
|
|
795 (int *)&pFace,
|
|
796 (int *)&uModelID,
|
|
797 &word_F8BC48_displaced_face_intersect_plane_coords_a,
|
|
798 &word_F8BD18_displaced_face_intersect_plane_coords_b,
|
|
799 &a2,
|
|
800 pFace),
|
|
801 v5 = 2 * v4->uNumVertices,
|
|
802 v16 = 0,
|
|
803 *(&word_F8BC48_displaced_face_intersect_plane_coords_a + v5) = word_F8BC48_displaced_face_intersect_plane_coords_a,
|
|
804 *(&word_F8BD18_displaced_face_intersect_plane_coords_b + v5) = word_F8BD18_displaced_face_intersect_plane_coords_b,
|
|
805 v15 = 0,
|
|
806 v6 = word_F8BD18_displaced_face_intersect_plane_coords_b >= (signed int)uModelID,
|
|
807 v5 <= 0) )
|
|
808 goto LABEL_25;
|
|
809 do
|
|
810 {
|
|
811 if ( v16 >= 2 )
|
|
812 break;
|
|
813 v7 = 2 * v15;
|
|
814 v8 = *(&word_F8BD18_displaced_face_intersect_plane_coords_b + v15 + 1);
|
|
815 if ( v6 ^ v8 >= (signed int)uModelID )
|
|
816 {
|
|
817 v9 = *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7 + 2);
|
|
818 if ( v9 >= (signed int)pFace )
|
|
819 v10 = 0;
|
|
820 else
|
|
821 v10 = 2;
|
|
822 v11 = v10 | *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7) < (signed int)pFace;
|
|
823 if ( v11 != 3 )
|
|
824 {
|
|
825 if ( !v11
|
|
826 || (v12 = v9 - *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7),
|
|
827 LODWORD(v13) = v12 << 16,
|
|
828 HIDWORD(v13) = v12 >> 16,
|
|
829 *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7)
|
|
830 + ((signed int)(((unsigned __int64)(v13
|
|
831 / (v8
|
|
832 - *(__int16 *)((char *)&word_F8BD18_displaced_face_intersect_plane_coords_b
|
|
833 + v7))
|
|
834 * (signed int)((uModelID
|
|
835 - *(__int16 *)((char *)&word_F8BD18_displaced_face_intersect_plane_coords_b
|
|
836 + v7)) << 16)) >> 16)
|
|
837 + 32768) >> 16) >= (signed int)pFace) )
|
|
838 ++v16;
|
|
839 }
|
|
840 }
|
|
841 ++v15;
|
|
842 v6 = v8 >= (signed int)uModelID;
|
|
843 }
|
|
844 while ( v15 < v5 );
|
|
845 result = 1;
|
|
846 if ( v16 != 1 )
|
|
847 LABEL_25:
|
|
848 result = 0;
|
|
849 return result;
|
|
850 }
|
|
851
|
|
852 //----- (004C1EE5) --------------------------------------------------------
|
|
853 bool Vis::_4C1EE5_BLV_IntersectBModel_2(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *pFace)
|
|
854 {
|
|
855 bool result; // eax@1
|
|
856 unsigned int v8; // ecx@1
|
|
857 Vec3_short_ *v9; // ecx@2
|
|
858 __int16 *v10; // edx@3
|
|
859 signed int v11; // ecx@4
|
|
860 char v12; // zf@6
|
|
861 Vec3_short_ *v13; // ecx@6
|
|
862 int v14; // edx@7
|
|
863 __int16 *v15; // edx@8
|
|
864 signed int v16; // ecx@9
|
|
865 int v17; // edx@11
|
|
866 __int16 *v18; // edx@12
|
|
867 signed int v19; // ecx@13
|
|
868 signed int a5a; // [sp+24h] [bp+18h]@2
|
|
869 signed int a5b; // [sp+24h] [bp+18h]@7
|
|
870 signed int a5c; // [sp+24h] [bp+18h]@11
|
|
871
|
|
872 result = (bool)pFace;
|
|
873 v8 = pFace->uAttributes;
|
|
874 if ( BYTE1(v8) & 1 )
|
|
875 {
|
|
876 v9 = a5;
|
|
877 a5a = 0;
|
|
878 *a1 = v9->x;
|
|
879 *a2 = v9->y;
|
|
880 if ( pFace->uNumVertices )
|
|
881 {
|
|
882 v10 = a4 + 1;
|
|
883 do
|
|
884 {
|
|
885 v11 = a5a;
|
|
886 a3[2 * a5a] = pFace->pXInterceptDisplacements[a5a] + pIndoor->pVertices[pFace->pVertexIDs[a5a]].x;
|
|
887 *(v10 - 1) = pFace->pYInterceptDisplacements[v11] + pIndoor->pVertices[pFace->pVertexIDs[v11]].y;
|
|
888 *(__int16 *)((char *)v10 + (int)a3 - (int)a4) = pFace->pXInterceptDisplacements[v11 + 1]
|
|
889 + pIndoor->pVertices[pFace->pVertexIDs[v11 + 1]].x;
|
|
890 ++a5a;
|
|
891 *v10 = pFace->pYInterceptDisplacements[v11 + 1] + pIndoor->pVertices[pFace->pVertexIDs[v11 + 1]].y;
|
|
892 v10 += 2;
|
|
893 }
|
|
894 while ( a5a < pFace->uNumVertices );
|
|
895 }
|
|
896 }
|
|
897 else
|
|
898 {
|
|
899 v12 = (BYTE1(v8) & 2) == 0;
|
|
900 v13 = a5;
|
|
901 if ( v12 )
|
|
902 {
|
|
903 v17 = a5->y;
|
|
904 a5c = 0;
|
|
905 *a1 = v17;
|
|
906 *a2 = v13->z;
|
|
907 if ( pFace->uNumVertices )
|
|
908 {
|
|
909 v18 = a4 + 1;
|
|
910 do
|
|
911 {
|
|
912 v19 = a5c;
|
|
913 a3[2 * a5c] = pFace->pYInterceptDisplacements[a5c] + pIndoor->pVertices[pFace->pVertexIDs[a5c]].y;
|
|
914 *(v18 - 1) = pFace->pZInterceptDisplacements[v19] + pIndoor->pVertices[pFace->pVertexIDs[v19]].z;
|
|
915 *(__int16 *)((char *)v18 + (int)(char *)a3 - (char *)a4) = pFace->pYInterceptDisplacements[v19 + 1]
|
|
916 + pIndoor->pVertices[pFace->pVertexIDs[v19 + 1]].y;
|
|
917 ++a5c;
|
|
918 *v18 = pFace->pZInterceptDisplacements[v19 + 1] + pIndoor->pVertices[pFace->pVertexIDs[v19 + 1]].z;
|
|
919 v18 += 2;
|
|
920 }
|
|
921 while ( a5c < pFace->uNumVertices );
|
|
922 }
|
|
923 }
|
|
924 else
|
|
925 {
|
|
926 v14 = a5->x;
|
|
927 a5b = 0;
|
|
928 *a1 = v14;
|
|
929 *a2 = v13->z;
|
|
930 if ( pFace->uNumVertices )
|
|
931 {
|
|
932 v15 = a4 + 1;
|
|
933 do
|
|
934 {
|
|
935 v16 = a5b;
|
|
936 a3[2 * a5b] = pFace->pXInterceptDisplacements[a5b] + pIndoor->pVertices[pFace->pVertexIDs[a5b]].x;
|
|
937 *(v15 - 1) = pFace->pZInterceptDisplacements[v16] + pIndoor->pVertices[pFace->pVertexIDs[v16]].z;
|
|
938 *(__int16 *)((char *)v15 + (int)a3 - (int)a4) = pFace->pXInterceptDisplacements[v16 + 1]
|
|
939 + pIndoor->pVertices[pFace->pVertexIDs[v16 + 1]].x;
|
|
940 ++a5b;
|
|
941 *v15 = pFace->pZInterceptDisplacements[v16 + 1] + pIndoor->pVertices[pFace->pVertexIDs[v16 + 1]].z;
|
|
942 v15 += 2;
|
|
943 }
|
|
944 while ( a5b < pFace->uNumVertices );
|
|
945 }
|
|
946 }
|
|
947 }
|
|
948 LOBYTE(result) = 1;
|
|
949 return result;
|
|
950 }
|
|
951
|
|
952 //----- (004C2186) --------------------------------------------------------
|
|
953 bool Vis::_4C2186_BLV_IntersectBModel(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *a6, unsigned int uModelID)
|
|
954 {
|
|
955 bool result; // eax@1
|
|
956 int *v9; // esi@1
|
|
957 unsigned int v10; // ecx@1
|
|
958 unsigned int v11; // edx@3
|
|
959 signed int v12; // ecx@4
|
|
960 __int16 v13; // si@4
|
|
961 __int16 *v14; // ecx@4
|
|
962 unsigned int v15; // edx@8
|
|
963 signed int v16; // ecx@9
|
|
964 __int16 v17; // si@9
|
|
965 __int16 *v18; // ecx@9
|
|
966 unsigned int v19; // edx@12
|
|
967 signed int v20; // ecx@13
|
|
968 __int16 v21; // si@13
|
|
969 __int16 *v22; // ecx@13
|
|
970 signed int a1a; // [sp+14h] [bp+8h]@1
|
|
971 __int16 *a5a; // [sp+24h] [bp+18h]@3
|
|
972 __int16 *a5b; // [sp+24h] [bp+18h]@8
|
|
973 __int16 *a5c; // [sp+24h] [bp+18h]@12
|
|
974
|
|
975 result = (bool)a6;
|
|
976 v9 = a1;
|
|
977 v10 = a6->uAttributes;
|
|
978 a1a = 0;
|
|
979 if ( BYTE1(v10) & 1 )
|
|
980 {
|
|
981 *v9 = a5->x;
|
|
982 *a2 = a5->y;
|
|
983 if ( a6->uNumVertices )
|
|
984 {
|
|
985 v11 = 188 * uModelID + 72;
|
|
986 a5a = a4 + 1;
|
|
987 do
|
|
988 {
|
|
989 v12 = a1a;
|
|
990 a3[2 * a1a] = a6->pXInterceptDisplacements[a1a]
|
|
991 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[a1a]);
|
|
992 *(a5a - 1) = a6->pYInterceptDisplacements[v12]
|
|
993 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12] + 4);
|
|
994 *(__int16 *)((char *)a5a + (int)(char *)a3 - (char *)a4) = a6->pXInterceptDisplacements[v12 + 1]
|
|
995 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11]
|
|
996 + 12 * a6->pVertexIDs[v12 + 1]);
|
|
997 v13 = a6->pYInterceptDisplacements[v12 + 1]
|
|
998 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12 + 1] + 4);
|
|
999 v14 = a5a;
|
|
1000 ++a1a;
|
|
1001 a5a += 2;
|
|
1002 *v14 = v13;
|
|
1003 }
|
|
1004 while ( a1a < a6->uNumVertices );
|
|
1005 }
|
|
1006 }
|
|
1007 else
|
|
1008 {
|
|
1009 if ( BYTE1(v10) & 2 )
|
|
1010 {
|
|
1011 *v9 = a5->x;
|
|
1012 *a2 = a5->z;
|
|
1013 if ( a6->uNumVertices )
|
|
1014 {
|
|
1015 v15 = 188 * uModelID + 72;
|
|
1016 a5b = a4 + 1;
|
|
1017 do
|
|
1018 {
|
|
1019 v16 = a1a;
|
|
1020 a3[2 * a1a] = a6->pXInterceptDisplacements[a1a]
|
|
1021 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[a1a]);
|
|
1022 *(a5b - 1) = a6->pZInterceptDisplacements[v16]
|
|
1023 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16] + 8);
|
|
1024 *(__int16 *)((char *)a5b + (int)a3 - (int)a4) = a6->pXInterceptDisplacements[v16 + 1]
|
|
1025 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15]
|
|
1026 + 12 * a6->pVertexIDs[v16 + 1]);
|
|
1027 v17 = a6->pZInterceptDisplacements[v16 + 1]
|
|
1028 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16 + 1] + 8);
|
|
1029 v18 = a5b;
|
|
1030 ++a1a;
|
|
1031 a5b += 2;
|
|
1032 *v18 = v17;
|
|
1033 }
|
|
1034 while ( a1a < a6->uNumVertices );
|
|
1035 }
|
|
1036 }
|
|
1037 else
|
|
1038 {
|
|
1039 *v9 = a5->y;
|
|
1040 *a2 = a5->z;
|
|
1041 if ( a6->uNumVertices )
|
|
1042 {
|
|
1043 v19 = 188 * uModelID + 72;
|
|
1044 a5c = a4 + 1;
|
|
1045 do
|
|
1046 {
|
|
1047 v20 = a1a;
|
|
1048 a3[2 * a1a] = a6->pYInterceptDisplacements[a1a]
|
|
1049 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[a1a] + 4);
|
|
1050 *(a5c - 1) = a6->pZInterceptDisplacements[v20]
|
|
1051 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20] + 8);
|
|
1052 *(__int16 *)((char *)a5c + (int)(char *)a3 - (char *)a4) = a6->pYInterceptDisplacements[v20 + 1]
|
|
1053 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19]
|
|
1054 + 12 * a6->pVertexIDs[v20 + 1]
|
|
1055 + 4);
|
|
1056 v21 = a6->pZInterceptDisplacements[v20 + 1]
|
|
1057 + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20 + 1] + 8);
|
|
1058 v22 = a5c;
|
|
1059 ++a1a;
|
|
1060 a5c += 2;
|
|
1061 *v22 = v21;
|
|
1062 }
|
|
1063 while ( a1a < a6->uNumVertices );
|
|
1064 }
|
|
1065 }
|
|
1066 }
|
|
1067 LOBYTE(result) = 1;
|
|
1068 return result;
|
|
1069 }
|
|
1070
|
|
1071 //----- (004C248E) --------------------------------------------------------
|
|
1072 void Vis::CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth)
|
|
1073 {
|
|
1074 int v5; // ebx@1
|
|
1075 int v6; // edi@1
|
|
1076 int v7; // esi@1
|
|
1077 Vec3_int_ v8; // ST08_12@1
|
|
1078 int v9; // ST04_4@1
|
|
1079 int v10; // eax@1
|
|
1080 RenderVertexSoft v11[2]; // [sp+2Ch] [bp-74h]@1
|
|
1081 int v12; // [sp+8Ch] [bp-14h]@1
|
|
1082 int v13; // [sp+90h] [bp-10h]@1
|
|
1083 int outz; // [sp+94h] [bp-Ch]@1
|
|
1084 int outy; // [sp+98h] [bp-8h]@1
|
|
1085 int v16; // [sp+9Ch] [bp-4h]@1
|
|
1086
|
|
1087 v5 = pIndoorCamera->pos.y;
|
|
1088 v6 = pIndoorCamera->pos.x;
|
|
1089 v13 = pIndoorCamera->pos.x;
|
|
1090 v12 = pIndoorCamera->pos.y;
|
|
1091 v16 = pIndoorCamera->pos.z;
|
|
1092 v7 = pIndoorCamera->sRotationY + UnprojectX((signed __int64)fMouseX);
|
|
1093 v8.z = v16;
|
|
1094 v8.x = v6;
|
|
1095 v8.y = v5;
|
|
1096 v9 = pIndoorCamera->sRotationX + UnprojectY((signed __int64)fMouseY);
|
|
1097 v10 = _48B561_mess_with_scaling_along_z(/*(int)&fMouseX, */fPickDepth);
|
|
1098 Vec3_int_::Rotate(v10, v7, v9, v8, (int *)&fMouseX, &outy, &outz);
|
|
1099 v11[0].flt_2C = 0.0;
|
|
1100 v11[0].vWorldPosition.x = (double)SLODWORD(fMouseX);
|
|
1101 v11[0].vWorldPosition.y = (double)outy;
|
|
1102 v11[0].vWorldPosition.z = (double)outz;
|
|
1103 v11[1].flt_2C = 0.0;
|
|
1104 v11[1].vWorldPosition.x = (double)v13;
|
|
1105 v11[1].vWorldPosition.y = (double)v12;
|
|
1106 v11[1].vWorldPosition.z = (double)v16;
|
|
1107 memcpy(pRay, &v11[1], 0x30u);
|
|
1108 memcpy(&pRay[1], v11, sizeof(pRay[1]));
|
|
1109 }
|
|
1110
|
|
1111 //----- (004C2551) --------------------------------------------------------
|
|
1112 Vis_stru1_stru0 *Vis_stru1::sub_4C2551(int a2, int a3)
|
|
1113 {
|
|
1114 unsigned int v3; // esi@1
|
|
1115 signed int v4; // edx@1
|
|
1116 char *v5; // eax@2
|
|
1117 Vis_stru1_stru0 *result; // eax@6
|
|
1118
|
|
1119 v3 = this->uNumPointers;
|
|
1120 v4 = 0;
|
|
1121 if ( (signed int)v3 <= 0 )
|
|
1122 {
|
|
1123 LABEL_6:
|
|
1124 result = 0;
|
|
1125 }
|
|
1126 else
|
|
1127 {
|
|
1128 v5 = (char *)&this->array_0004[0].sZValue;
|
|
1129 while ( *((int *)v5 + 1) != a2 || (*(int *)v5 & 0xFFFF) != a3 )
|
|
1130 {
|
|
1131 ++v4;
|
|
1132 v5 += 12;
|
|
1133 if ( v4 >= (signed int)v3 )
|
|
1134 goto LABEL_6;
|
|
1135 }
|
|
1136 result = &this->array_0004[v4];
|
|
1137 }
|
|
1138 return result;
|
|
1139 }
|
|
1140
|
|
1141 //----- (004C2591) --------------------------------------------------------
|
|
1142 Vis_stru1_stru0 **Vis_stru1::create_object_pointers(unsigned int flag)
|
|
1143 {
|
|
1144 Vis_stru1_stru0 **result; // eax@1
|
|
1145 signed int v3; // esi@2
|
|
1146 Vis_stru1_stru0 *v4; // edx@3
|
|
1147 unsigned __int8 v5; // zf@7
|
|
1148 unsigned __int8 v6; // sf@7
|
|
1149 Vis_stru1_stru0 **v7; // ebx@8
|
|
1150 Vis_stru1_stru0 *v8; // esi@8
|
|
1151 signed int v9; // edi@9
|
|
1152 Vis_stru1_stru0 **v10; // edx@10
|
|
1153 std::string v11; // [sp-18h] [bp-28h]@19
|
|
1154 const char *v12; // [sp-8h] [bp-18h]@19
|
|
1155 int v13; // [sp-4h] [bp-14h]@19
|
|
1156 char v14; // [sp+Ch] [bp-4h]@19
|
|
1157
|
|
1158 result = 0;
|
|
1159 if ( flag )
|
|
1160 {
|
|
1161 if ( flag == 1 )
|
|
1162 {
|
|
1163 v5 = this->uNumPointers == 0;
|
|
1164 v6 = (this->uNumPointers & 0x80000000u) != 0;
|
|
1165 BYTE3(flag) = 1;
|
|
1166 if ( !(v6 | v5) )
|
|
1167 {
|
|
1168 v7 = this->array_1804;
|
|
1169 v8 = this->array_0004;
|
|
1170 do
|
|
1171 {
|
|
1172 v9 = 0;
|
|
1173 if ( (signed int)result > 0 )
|
|
1174 {
|
|
1175 v10 = this->array_1804;
|
|
1176 while ( *v10 != v8 )
|
|
1177 {
|
|
1178 ++v9;
|
|
1179 ++v10;
|
|
1180 if ( v9 >= (signed int)result )
|
|
1181 goto LABEL_15;
|
|
1182 }
|
|
1183 BYTE3(flag) = 0;
|
|
1184 }
|
|
1185 LABEL_15:
|
|
1186 if ( BYTE3(flag) )
|
|
1187 *v7 = v8;
|
|
1188 result = (Vis_stru1_stru0 **)((char *)result + 1);
|
|
1189 ++v7;
|
|
1190 ++v8;
|
|
1191 }
|
|
1192 while ( (signed int)result < (signed int)this->uNumPointers );
|
|
1193 }
|
|
1194 }
|
|
1195 else
|
|
1196 {
|
|
1197 MessageBoxW(nullptr, L"Unknown pointer creation flag passed to ::create_object_pointers()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1358", 0);
|
|
1198 }
|
|
1199 }
|
|
1200 else
|
|
1201 {
|
|
1202 v3 = 0;
|
|
1203 if ( (signed int)this->uNumPointers > 0 )
|
|
1204 {
|
|
1205 result = this->array_1804;
|
|
1206 v4 = this->array_0004;
|
|
1207 do
|
|
1208 {
|
|
1209 *result = v4;
|
|
1210 ++v3;
|
|
1211 ++result;
|
|
1212 ++v4;
|
|
1213 }
|
|
1214 while ( v3 < (signed int)this->uNumPointers );
|
|
1215 }
|
|
1216 }
|
|
1217 return result;
|
|
1218 }
|
|
1219
|
|
1220 //----- (004C264A) --------------------------------------------------------
|
|
1221 void Vis::sort_object_pointers(Vis_stru1_stru0 **pPointers, int left, int right)
|
|
1222 {
|
|
1223 int v4; // edx@1
|
|
1224 int v5; // ebx@1
|
|
1225 int v6; // esi@2
|
|
1226 signed int i; // ecx@2
|
|
1227 int v8; // eax@3
|
|
1228 int v9; // ebx@4
|
|
1229 int v10; // ebx@6
|
|
1230 Vis_stru1_stru0 *v11; // eax@7
|
|
1231 Vis *thisa; // [sp+4h] [bp-4h]@1
|
|
1232 Vis_stru1_stru0 *a3a; // [sp+14h] [bp+Ch]@2
|
|
1233
|
|
1234 v4 = left;
|
|
1235 v5 = right;
|
|
1236 thisa = this;
|
|
1237 if ( right > left )
|
|
1238 {
|
|
1239 do
|
|
1240 {
|
|
1241 v6 = v4 - 1;
|
|
1242 a3a = pPointers[v5];
|
|
1243 for ( i = v5; ; pPointers[i] = v11 )
|
|
1244 {
|
|
1245 v8 = a3a->sZValue;
|
|
1246 LOWORD(v8) = 0;
|
|
1247 do
|
|
1248 {
|
|
1249 ++v6;
|
|
1250 v9 = pPointers[v6]->sZValue;
|
|
1251 LOWORD(v9) = 0;
|
|
1252 }
|
|
1253 while ( v9 < (unsigned int)v8 );
|
|
1254 do
|
|
1255 {
|
|
1256 if ( i < 1 )
|
|
1257 break;
|
|
1258 --i;
|
|
1259 v10 = pPointers[i]->sZValue;
|
|
1260 LOWORD(v10) = 0;
|
|
1261 }
|
|
1262 while ( v10 > (unsigned int)v8 );
|
|
1263 v11 = pPointers[v6];
|
|
1264 if ( v6 >= i )
|
|
1265 break;
|
|
1266 pPointers[v6] = pPointers[i];
|
|
1267 }
|
|
1268 v5 = right;
|
|
1269 pPointers[v6] = pPointers[right];
|
|
1270 pPointers[right] = v11;
|
|
1271 sort_object_pointers(pPointers, v4, v6 - 1);
|
|
1272 v4 = v6 + 1;
|
|
1273 }
|
|
1274 while ( right > v6 + 1 );
|
|
1275 }
|
|
1276 }
|
|
1277
|
|
1278 //----- (004C26D0) --------------------------------------------------------
|
|
1279 bool Vis::SortVerticesByX(RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd)
|
|
1280 {
|
|
1281 bool result; // eax@1
|
|
1282 RenderVertexD3D3 *v5; // edx@2
|
|
1283 RenderVertexD3D3 *v6; // esi@2
|
|
1284 void *v7; // edi@2
|
|
1285 unsigned int v8; // ebx@2
|
|
1286 RenderVertexD3D3 *v9; // ecx@3
|
|
1287 RenderVertexD3D3 *v10; // ecx@5
|
|
1288 RenderVertexD3D3 *v11; // eax@8
|
|
1289 RenderVertexD3D3 v12; // [sp+4h] [bp-4Ch]@8
|
|
1290 RenderVertexD3D3 v13; // [sp+24h] [bp-2Ch]@2
|
|
1291 Vis *thisa; // [sp+44h] [bp-Ch]@1
|
|
1292 RenderVertexD3D3 *v15; // [sp+48h] [bp-8h]@2
|
|
1293 unsigned int v16; // [sp+4Ch] [bp-4h]@2
|
|
1294
|
|
1295 result = uEnd;
|
|
1296 thisa = this;
|
|
1297 if ( (signed int)uEnd > (signed int)uStart )
|
|
1298 {
|
|
1299 v5 = a2;
|
|
1300 v6 = &a2[uEnd];
|
|
1301 v7 = &v13;
|
|
1302 v15 = &a2[uEnd];
|
|
1303 v8 = uStart - 1;
|
|
1304 v16 = uEnd;
|
|
1305 while ( 1 )
|
|
1306 {
|
|
1307 memcpy(v7, v6, 0x20u);
|
|
1308 v9 = &v5[v8];
|
|
1309 do
|
|
1310 {
|
|
1311 ++v9;
|
|
1312 ++v8;
|
|
1313 }
|
|
1314 while ( v9->pos.x < (double)v13.pos.x );
|
|
1315 v10 = &v5[v16];
|
|
1316 do
|
|
1317 {
|
|
1318 --v10;
|
|
1319 --v16;
|
|
1320 }
|
|
1321 while ( v10->pos.x > (double)v13.pos.x );
|
|
1322 if ( (signed int)v8 >= (signed int)v16 )
|
|
1323 break;
|
|
1324 v11 = &v5[v16];
|
|
1325 memcpy(&v12, &a2[v8], sizeof(v12));
|
|
1326 v5 = a2;
|
|
1327 memcpy(&a2[v8], v11, sizeof(a2[v8]));
|
|
1328 v6 = &v12;
|
|
1329 v7 = v11;
|
|
1330 }
|
|
1331 memcpy(&v12, &v5[v8], sizeof(v12));
|
|
1332 memcpy(&v5[v8], v15, sizeof(v5[v8]));
|
|
1333 memcpy(v15, &v12, 0x20u);
|
|
1334 SortVerticesByX(v5, uStart, v8 - 1);
|
|
1335 SortVerticesByX(a2, v8 + 1, uEnd);
|
|
1336 }
|
|
1337 return true;
|
|
1338 }
|
|
1339
|
|
1340 //----- (004C27AD) --------------------------------------------------------
|
|
1341 bool Vis::SortVerticesByY(RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd)
|
|
1342 {
|
|
1343 bool result; // eax@1
|
|
1344 RenderVertexD3D3 *v5; // edx@2
|
|
1345 RenderVertexD3D3 *v6; // esi@2
|
|
1346 RenderVertexD3D3 v7; // qdi@2
|
|
1347 unsigned int v8; // ebx@2
|
|
1348 int v9; // ecx@3
|
|
1349 int v10; // ecx@5
|
|
1350 float v11; // eax@8
|
|
1351 RenderVertexD3D3 v12; // [sp+4h] [bp-4Ch]@8
|
|
1352 char v13; // [sp+24h] [bp-2Ch]@2
|
|
1353 float v14; // [sp+28h] [bp-28h]@4
|
|
1354 Vis *thisa; // [sp+44h] [bp-Ch]@1
|
|
1355 RenderVertexD3D3 *v16; // [sp+48h] [bp-8h]@2
|
|
1356 unsigned int v17; // [sp+4Ch] [bp-4h]@2
|
|
1357
|
|
1358 result = uEnd;
|
|
1359 thisa = this;
|
|
1360 if ( (signed int)uEnd > (signed int)uStart )
|
|
1361 {
|
|
1362 v5 = a2;
|
|
1363 v6 = &a2[uEnd];
|
|
1364 LODWORD(v7.pos.x) = (int)&v13;
|
|
1365 v16 = &a2[uEnd];
|
|
1366 v8 = uStart - 1;
|
|
1367 v17 = uEnd;
|
|
1368 while ( 1 )
|
|
1369 {
|
|
1370 memcpy(*(void **)&v7.pos.x, v6, 0x20u);
|
|
1371 v9 = (int)&v5[v8].pos.y;
|
|
1372 do
|
|
1373 {
|
|
1374 v9 += 32;
|
|
1375 ++v8;
|
|
1376 }
|
|
1377 while ( *(float *)v9 < (double)v14 );
|
|
1378 v10 = (int)&v5[v17].pos.y;
|
|
1379 do
|
|
1380 {
|
|
1381 v10 -= 32;
|
|
1382 --v17;
|
|
1383 }
|
|
1384 while ( *(float *)v10 > (double)v14 );
|
|
1385 if ( (signed int)v8 >= (signed int)v17 )
|
|
1386 break;
|
|
1387 LODWORD(v11) = (int)&v5[v17];
|
|
1388 memcpy(&v12, &a2[v8], sizeof(v12));
|
|
1389 v5 = a2;
|
|
1390 memcpy(&a2[v8], *(void **)&v11, sizeof(a2[v8]));
|
|
1391 v6 = &v12;
|
|
1392 v7.pos.x = v11;
|
|
1393 }
|
|
1394 memcpy(&v12, &v5[v8], sizeof(v12));
|
|
1395 memcpy(&v5[v8], v16, sizeof(v5[v8]));
|
|
1396 memcpy(v16, &v12, 0x20u);
|
|
1397 SortVerticesByY(v5, uStart, v8 - 1);
|
|
1398 SortVerticesByY(a2, v8 + 1, uEnd);
|
|
1399 }
|
|
1400 return true;
|
|
1401 }
|
|
1402
|
|
1403 //----- (004C288E) --------------------------------------------------------
|
|
1404 bool Vis::sort_objects_2(RenderVertexSoft *pArray, int sLeft, int sRight)
|
|
1405 {
|
|
1406 bool result; // eax@1
|
|
1407 RenderVertexSoft *v5; // edx@2
|
|
1408 int v6; // ebx@2
|
|
1409 int i; // ecx@2
|
|
1410 int v8; // esi@3
|
|
1411 int v9; // esi@5
|
|
1412 RenderVertexSoft *v10; // eax@8
|
|
1413 RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8
|
|
1414 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
|
|
1415 float v13; // [sp+4Ch] [bp-24h]@4
|
|
1416 int v14; // [sp+64h] [bp-Ch]@7
|
|
1417 Vis *thisa; // [sp+68h] [bp-8h]@1
|
|
1418 RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
|
|
1419
|
|
1420 result = sRight;
|
|
1421 thisa = this;
|
|
1422 if ( sRight > sLeft )
|
|
1423 {
|
|
1424 v5 = pArray;
|
|
1425 v16 = &pArray[sRight];
|
|
1426 v6 = sLeft - 1;
|
|
1427 memcpy(&v12, &pArray[sRight], sizeof(v12));
|
|
1428 for ( i = sRight; ; i = v14 )
|
|
1429 {
|
|
1430 v8 = (int)&v5[v6].vWorldViewProjX;
|
|
1431 do
|
|
1432 {
|
|
1433 v8 += 48;
|
|
1434 ++v6;
|
|
1435 }
|
|
1436 while ( *(float *)v8 < (double)v13 );
|
|
1437 v9 = (int)&v5[i].vWorldViewProjX;
|
|
1438 do
|
|
1439 {
|
|
1440 v9 -= 48;
|
|
1441 --i;
|
|
1442 }
|
|
1443 while ( *(float *)v9 > (double)v13 );
|
|
1444 v14 = i;
|
|
1445 if ( v6 >= i )
|
|
1446 break;
|
|
1447 v10 = &v5[i];
|
|
1448 memcpy(&v11, &pArray[v6], sizeof(v11));
|
|
1449 v5 = pArray;
|
|
1450 memcpy(&pArray[v6], v10, sizeof(pArray[v6]));
|
|
1451 memcpy(v10, &v11, 0x30u);
|
|
1452 }
|
|
1453 memcpy(&v11, &v5[v6], sizeof(v11));
|
|
1454 memcpy(&v5[v6], v16, sizeof(v5[v6]));
|
|
1455 memcpy(v16, &v11, 0x30u);
|
|
1456 sort_objects_2(v5, sLeft, v6 - 1);
|
|
1457 sort_objects_2(pArray, v6 + 1, sRight);
|
|
1458 }
|
|
1459 return true;
|
|
1460 }
|
|
1461
|
|
1462 //----- (004C297E) --------------------------------------------------------
|
|
1463 bool Vis::sort_objects_3(RenderVertexSoft *pArray, int sLeft, int sRight)
|
|
1464 {
|
|
1465 bool result; // eax@1
|
|
1466 RenderVertexSoft *v5; // edx@2
|
|
1467 int v6; // ebx@2
|
|
1468 int i; // ecx@2
|
|
1469 int v8; // esi@3
|
|
1470 int v9; // esi@5
|
|
1471 RenderVertexSoft *v10; // eax@8
|
|
1472 char v11; // [sp+4h] [bp-6Ch]@8
|
|
1473 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
|
|
1474 float v13; // [sp+50h] [bp-20h]@4
|
|
1475 int v14; // [sp+64h] [bp-Ch]@7
|
|
1476 Vis *thisa; // [sp+68h] [bp-8h]@1
|
|
1477 RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
|
|
1478
|
|
1479 result = sRight;
|
|
1480 thisa = this;
|
|
1481 if ( sRight > sLeft )
|
|
1482 {
|
|
1483 v5 = pArray;
|
|
1484 v16 = &pArray[sRight];
|
|
1485 v6 = sLeft - 1;
|
|
1486 memcpy(&v12, &pArray[sRight], sizeof(v12));
|
|
1487 for ( i = sRight; ; i = v14 )
|
|
1488 {
|
|
1489 v8 = (int)&v5[v6].vWorldViewProjY;
|
|
1490 do
|
|
1491 {
|
|
1492 v8 += 48;
|
|
1493 ++v6;
|
|
1494 }
|
|
1495 while ( *(float *)v8 < (double)v13 );
|
|
1496 v9 = (int)&v5[i].vWorldViewProjY;
|
|
1497 do
|
|
1498 {
|
|
1499 v9 -= 48;
|
|
1500 --i;
|
|
1501 }
|
|
1502 while ( *(float *)v9 > (double)v13 );
|
|
1503 v14 = i;
|
|
1504 if ( v6 >= i )
|
|
1505 break;
|
|
1506 v10 = &v5[i];
|
|
1507 memcpy(&v11, &pArray[v6], 0x30u);
|
|
1508 v5 = pArray;
|
|
1509 memcpy(&pArray[v6], v10, sizeof(pArray[v6]));
|
|
1510 memcpy(v10, &v11, 0x30u);
|
|
1511 }
|
|
1512 memcpy(&v11, &v5[v6], 0x30u);
|
|
1513 memcpy(&v5[v6], v16, sizeof(v5[v6]));
|
|
1514 memcpy(v16, &v11, 0x30u);
|
|
1515 sort_objects_3(v5, sLeft, v6 - 1);
|
|
1516 sort_objects_3(pArray, v6 + 1, sRight);
|
|
1517 }
|
|
1518 return true;
|
|
1519 }
|
|
1520
|
|
1521
|
|
1522 //----- (004C04AF) --------------------------------------------------------
|
|
1523 Vis::Vis()
|
|
1524 {
|
|
1525 Vis *v1; // ebx@1
|
|
1526 Vis *result; // eax@1
|
|
1527 RenderVertexSoft v3; // [sp+Ch] [bp-60h]@1
|
|
1528 RenderVertexSoft v4; // [sp+3Ch] [bp-30h]@1
|
|
1529
|
|
1530 v1 = this;
|
|
1531 v3.flt_2C = 0.0;
|
|
1532 v3.vWorldPosition.x = 0.0;
|
|
1533 v3.vWorldPosition.y = 65536.0;
|
|
1534 v3.vWorldPosition.z = 0.0;
|
|
1535 v4.flt_2C = 0.0;
|
|
1536 v4.vWorldPosition.x = 65536.0;
|
|
1537 v4.vWorldPosition.y = 0.0;
|
|
1538 v4.vWorldPosition.z = 0.0;
|
|
1539 memcpy(&v1->stru_200C, &v4, sizeof(v1->stru_200C));
|
|
1540 v4.flt_2C = 0.0;
|
|
1541 v4.vWorldPosition.x = 0.0;
|
|
1542 v4.vWorldPosition.y = 65536.0;
|
|
1543 v4.vWorldPosition.z = 0.0;
|
|
1544 memcpy(&v1->stru_203C, &v3, sizeof(v1->stru_203C));
|
|
1545 v3.flt_2C = 0.0;
|
|
1546 v3.vWorldPosition.x = 65536.0;
|
|
1547 v3.vWorldPosition.y = 0.0;
|
|
1548 v3.vWorldPosition.z = 0.0;
|
|
1549 memcpy(&v1->stru_206C, &v3, sizeof(v1->stru_206C));
|
|
1550 result = v1;
|
|
1551 memcpy(&v1->stru_209C, &v4, sizeof(v1->stru_209C));
|
|
1552 v1->field_20CC = 512;
|
|
1553 }
|
|
1554
|
|
1555 //----- (004C055C) --------------------------------------------------------
|
|
1556 Vis_stru1::Vis_stru1()
|
|
1557 {
|
|
1558 for (uint i = 0; i < 512; ++i)
|
|
1559 {
|
|
1560 array_0004[i].pObjectInfo = 0;
|
|
1561 array_0004[i].sZValue = -1;
|
|
1562 array_0004[i].uObjectType = 0;
|
|
1563 }
|
|
1564 uNumPointers = 0;
|
|
1565 }
|
|
1566
|
|
1567
|
|
1568
|
|
1569
|
|
1570 //----- (004C05CC) --------------------------------------------------------
|
|
1571 bool Vis::_4C05CC(Vis_stru1 *a2, stru157 *a3, stru157 *a4)
|
|
1572 {
|
|
1573 Vis_stru1 *v4; // esi@1
|
|
1574 Vis *v5; // ebx@1
|
|
1575 char *v6; // edi@3
|
|
1576 float v7; // ST00_4@3
|
|
1577 bool result; // eax@6
|
|
1578 float v9; // [sp+4h] [bp-14h]@3
|
|
1579
|
|
1580 v4 = a2;
|
|
1581 v5 = this;
|
|
1582 if ( !a2 )
|
|
1583 v4 = &this->stru1;
|
|
1584 v4->uNumPointers = 0;
|
|
1585 v6 = (char *)&this->field_20CC;
|
|
1586 v7 = (double)this->field_20CC;
|
|
1587 _4C06F8(v7, v4, a3);
|
|
1588 v9 = (double)*(signed int *)v6;
|
|
1589 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1590 _4C0D32_BLV(v9, v4, a4);
|
|
1591 else
|
|
1592 _4C0DEA_ODM(v9, v4, a4);
|
|
1593 v4->create_object_pointers(1u);
|
|
1594 sort_object_pointers(v4->array_1804, 0, v4->uNumPointers - 1);
|
|
1595 return true;
|
|
1596 }
|
|
1597
|
|
1598 //----- (004C0646) --------------------------------------------------------
|
|
1599 bool Vis::PickMouse(float fDepth, float fMouseX, float fMouseY, stru157 *a5, stru157 *a6)
|
|
1600 {
|
|
1601 Vis *v6; // esi@1
|
|
1602 bool result; // eax@4
|
|
1603 RenderVertexSoft pMouseRay[2]; // [sp+1Ch] [bp-60h]@1
|
|
1604
|
|
1605 v6 = this;
|
|
1606 this->stru1.uNumPointers = 0;
|
|
1607 CastPickRay(pMouseRay, fMouseX, fMouseY, fDepth);
|
|
1608 PickBillboards(fDepth, fMouseX, fMouseY, &v6->stru1, a5);
|
|
1609 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1610 PickIndoor(fDepth, pMouseRay, &v6->stru1, a6);
|
|
1611 else
|
|
1612 PickOutdoor(fDepth, pMouseRay, &v6->stru1, a6, 0);
|
|
1613 v6->stru1.create_object_pointers(0);
|
|
1614 sort_object_pointers(v6->stru1.array_1804, 0, v6->stru1.uNumPointers - 1);
|
|
1615 return true;
|
|
1616 }
|
|
1617
|
|
1618 //----- (004C06F8) --------------------------------------------------------
|
|
1619 void Vis::_4C06F8(float arg0, Vis_stru1 *a3, stru157 *a2)
|
|
1620 {
|
|
1621 int v4; // ST18_4@5
|
|
1622 Vis_stru1_stru0 *v5; // edi@5
|
|
1623 void **v7; // [sp+24h] [bp-8h]@2
|
|
1624 unsigned int uD3DBillboardIdx; // [sp+28h] [bp-4h]@1
|
|
1625
|
|
1626 uD3DBillboardIdx = 0;
|
|
1627 auto ecx0 = this;
|
|
1628 if ( (signed int)pRenderer->uNumBillboardsToDraw > 0 )
|
|
1629 {
|
|
1630 v7 = (void **)&pRenderer->pBillboardRenderListD3D[0].uParentBillboardID;
|
|
1631 do
|
|
1632 {
|
|
1633 if ( is_part_of_selection((BLVFace *)uD3DBillboardIdx, a2) )
|
|
1634 {
|
|
1635 if ( DoesRayIntersectBillboard(arg0, uD3DBillboardIdx) )
|
|
1636 {
|
|
1637 v4 = pBillboardRenderList[(int)*v7].sZValue;
|
|
1638 v5 = &a3->array_0004[a3->uNumPointers];
|
|
1639 v5->pObjectInfo = *v7;
|
|
1640 v5 = (Vis_stru1_stru0 *)((char *)v5 + 4);
|
|
1641 v5->pObjectInfo = (void *)v4;
|
|
1642 v5->sZValue = 1;
|
|
1643 ++a3->uNumPointers;
|
|
1644 }
|
|
1645 }
|
|
1646 ++uD3DBillboardIdx;
|
|
1647 v7 += 39;
|
|
1648 }
|
|
1649 while ( (signed int)uD3DBillboardIdx < (signed int)pRenderer->uNumBillboardsToDraw );
|
|
1650 }
|
|
1651 }
|
|
1652
|
|
1653 //----- (004C0791) --------------------------------------------------------
|
|
1654 bool Vis::is_part_of_selection(BLVFace *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, stru157 *a2)
|
|
1655 {
|
|
1656 stru157 *v3; // esi@1
|
|
1657 int result; // eax@1
|
|
1658 int v5; // edx@2
|
|
1659 int v6; // ecx@2
|
|
1660 char v7; // zf@3
|
|
1661 int v8; // esi@5
|
|
1662 std::string *v9; // ecx@7
|
|
1663 Actor *v10; // edi@18
|
|
1664 char v11; // zf@26
|
|
1665 const char *v12; // [sp-20h] [bp-2Ch]@7
|
|
1666 int v13; // [sp-1Ch] [bp-28h]@7
|
|
1667 std::string v14; // [sp-18h] [bp-24h]@7
|
|
1668 const char *v15; // [sp-8h] [bp-14h]@7
|
|
1669 int v16; // [sp-4h] [bp-10h]@7
|
|
1670
|
|
1671 v3 = a2;
|
|
1672 result = a2->field_0;
|
|
1673 if ( a2->field_0 != 1 )
|
|
1674 {
|
|
1675 if ( result != 2
|
|
1676 || (uCurrentlyLoadedLevelType != LEVEL_Indoor ? (v11 = LOWORD(uD3DBillboardIdx_or_pBLVFace_or_pODMFace[3].pFacePlane.vNormal.y) == 0,
|
|
1677 result = uD3DBillboardIdx_or_pBLVFace_or_pODMFace->pFacePlane_old.dist) : (v11 = pIndoor->pFaceExtras[uD3DBillboardIdx_or_pBLVFace_or_pODMFace->uFaceExtraID].uEventID == 0, result = uD3DBillboardIdx_or_pBLVFace_or_pODMFace->uAttributes),
|
|
1678 a2->field_4 != 1) )
|
|
1679 goto LABEL_16;
|
|
1680 if ( v11 || result & a2->field_C )
|
|
1681 goto LABEL_33;
|
|
1682 v7 = (result & a2->field_8) == 0;
|
|
1683 goto LABEL_32;
|
|
1684 }
|
|
1685 v5 = a2->field_10;
|
|
1686 result = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].sZValue & 0xFFFF) >> 3;
|
|
1687 v6 = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].sZValue & 7;
|
|
1688 if ( v5 & 2 )
|
|
1689 {
|
|
1690 v7 = v6 == a2->field_4;
|
|
1691 goto LABEL_32;
|
|
1692 }
|
|
1693 if ( v5 & 4 )
|
|
1694 {
|
|
1695 v8 = a2->field_4;
|
|
1696 if ( v6 != v8 )
|
|
1697 goto LABEL_16;
|
|
1698 if ( v8 != 5 )
|
|
1699 {
|
|
1700 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:207";
|
|
1701 v12 = "Unsupported \"exclusion if no event\" type in CVis::is_part_of_selection";
|
|
1702 LABEL_15:
|
|
1703 MessageBoxA(nullptr, v12, v15, 0);
|
|
1704 return true;
|
|
1705 }
|
|
1706 result *= 32;
|
|
1707 if ( *(__int16 *)((char *)&pLevelDecorations[0].uCog + result)
|
|
1708 || *(__int16 *)((char *)&pLevelDecorations[0].field_16_event_id + result) )
|
|
1709 goto LABEL_16;
|
|
1710 result = pLevelDecorations[result / sizeof(LevelDecoration)].IsInteractive();
|
|
1711 goto LABEL_11;
|
|
1712 }
|
|
1713 if ( v6 == a2->field_4 )
|
|
1714 {
|
|
1715 if ( v6 != 3 )
|
|
1716 {
|
|
1717 v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:245";
|
|
1718 v12 = "Default case reached in VIS";
|
|
1719 goto LABEL_15;
|
|
1720 }
|
|
1721 v10 = &pActors[result];
|
|
1722 result = 1 << LOBYTE(v10->uAIState);
|
|
1723 if ( result & a2->field_C
|
|
1724 || !(result & a2->field_8)
|
|
1725 || v5 & 8 && (result = MonsterStats::BelongsToSupertype(v10->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) == 0 )
|
|
1726 goto LABEL_33;
|
|
1727 if ( !(v3->field_10 & 1) )
|
|
1728 goto LABEL_16;
|
|
1729 result = v10->GetActorsRelation(nullptr);
|
|
1730 LABEL_11:
|
|
1731 v7 = result == 0;
|
|
1732 LABEL_32:
|
|
1733 if ( v7 )
|
|
1734 goto LABEL_33;
|
|
1735 LABEL_16:
|
|
1736 return true;
|
|
1737 }
|
|
1738 LABEL_33:
|
|
1739 LOBYTE(result) = 0;
|
|
1740 return result;
|
|
1741 }
|
|
1742
|
|
1743 //----- (004C091D) --------------------------------------------------------
|
|
1744 bool Vis::DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx)
|
|
1745 {
|
|
1746 unsigned int v3; // esi@3
|
|
1747 bool result; // eax@3
|
|
1748 int v5; // ecx@4
|
|
1749 double v6; // st7@4
|
|
1750 __int16 v7; // fps@4
|
|
1751 double v8; // st7@4
|
|
1752 unsigned __int8 v9; // c0@4
|
|
1753 char v10; // c2@4
|
|
1754 unsigned __int8 v11; // c3@4
|
|
1755 Vis_stru1_stru0 *v12; // eax@10
|
|
1756 __int16 v13; // fps@16
|
|
1757 double v14; // st7@16
|
|
1758 char v15; // c0@16
|
|
1759 char v16; // c2@16
|
|
1760 char v17; // c3@16
|
|
1761 double v18; // st7@18
|
|
1762 double v19; // st6@18
|
|
1763 double v20; // st4@18
|
|
1764 float v21; // ST0C_4@22
|
|
1765 float v22; // ST08_4@22
|
|
1766 signed int v23; // eax@27
|
|
1767 double v24; // st7@32
|
|
1768 double v25; // st6@32
|
|
1769 float v26; // eax@32
|
|
1770 double v27; // st7@36
|
|
1771 double v28; // st6@36
|
|
1772 __int16 v29; // fps@36
|
|
1773 char v30; // c0@36
|
|
1774 char v31; // c2@36
|
|
1775 char v32; // c3@36
|
|
1776 double v33; // st6@37
|
|
1777 __int16 v34; // fps@37
|
|
1778 char v35; // c0@37
|
|
1779 char v36; // c2@37
|
|
1780 char v37; // c3@37
|
|
1781 __int16 v38; // fps@38
|
|
1782 double v39; // st6@38
|
|
1783 unsigned __int8 v40; // c0@38
|
|
1784 char v41; // c2@38
|
|
1785 unsigned __int8 v42; // c3@38
|
|
1786 __int16 v43; // fps@39
|
|
1787 double v44; // st6@39
|
|
1788 char v45; // c0@39
|
|
1789 char v46; // c2@39
|
|
1790 char v47; // c3@39
|
|
1791 Vis *v48; // esi@40
|
|
1792 float v49; // ST08_4@40
|
|
1793 Vis_stru1_stru0 *v50; // eax@45
|
|
1794 RenderVertexSoft pRay[2]; // [sp+20h] [bp-DCh]@5
|
|
1795 RenderVertexSoft a3[2]; // [sp+80h] [bp-7Ch]@22
|
|
1796 float v53; // [sp+E0h] [bp-1Ch]@33
|
|
1797 float v54; // [sp+E4h] [bp-18h]@32
|
|
1798 float fBillboardCenterX; // [sp+E8h] [bp-14h]@5
|
|
1799 float fBillboardCenterY; // [sp+ECh] [bp-10h]@5
|
|
1800 unsigned int v57; // [sp+F0h] [bp-Ch]@5
|
|
1801 float v58; // [sp+F4h] [bp-8h]@17
|
|
1802 Vis *thisa; // [sp+F8h] [bp-4h]@1
|
|
1803 signed int a3a; // [sp+108h] [bp+Ch]@17
|
|
1804 float a3b; // [sp+108h] [bp+Ch]@32
|
|
1805
|
|
1806 thisa = this;
|
|
1807
|
|
1808 static Vis_stru1 Vis_static_stru_F91E10;
|
|
1809
|
|
1810 Vis_static_stru_F91E10.uNumPointers = 0;
|
|
1811 v3 = uD3DBillboardIdx;
|
|
1812 result = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].uParentBillboardID;
|
|
1813 if ( result != -1
|
|
1814 && (v5 = pBillboardRenderList[result].sZValue,
|
|
1815 v6 = (double)(unsigned __int16)pBillboardRenderList[result].sZValue,
|
|
1816 result = v5 >> 16,
|
|
1817 v8 = v6 * 0.000015259022 + (double)(v5 >> 16),
|
|
1818 //UNDEF(v7),
|
|
1819 v9 = v8 < fDepth,
|
|
1820 v10 = 0,
|
|
1821 v11 = v8 == fDepth,
|
|
1822 BYTE1(result) = HIBYTE(v7),
|
|
1823 v9 | v11) )
|
|
1824 {
|
|
1825 LOWORD(v5) = 0;
|
|
1826 v57 = v5;
|
|
1827 GetPolygonCenter(
|
|
1828 pRenderer->pBillboardRenderListD3D[v3].pQuards,
|
|
1829 4u,
|
|
1830 &fBillboardCenterX,
|
|
1831 &fBillboardCenterY);
|
|
1832 CastPickRay(pRay, fBillboardCenterX, fBillboardCenterY, fDepth);
|
|
1833 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1834 PickIndoor(fDepth, pRay, &Vis_static_stru_F91E10, &a5);
|
|
1835 else
|
|
1836 PickOutdoor(fDepth, pRay, &Vis_static_stru_F91E10, &a5, 0);
|
|
1837 Vis_static_stru_F91E10.create_object_pointers(0);
|
|
1838 sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1);
|
|
1839 HIWORD(result) = HIWORD(Vis_static_stru_F91E10.uNumPointers);
|
|
1840 if ( Vis_static_stru_F91E10.uNumPointers
|
|
1841 && ((signed int)Vis_static_stru_F91E10.uNumPointers <= 0 ? (v12 = 0) : (v12 = Vis_static_stru_F91E10.array_1804[0]),
|
|
1842 result = v12->sZValue,
|
|
1843 LOWORD(result) = 0,
|
|
1844 result <= v57)
|
|
1845 || (double)(signed int)pViewport->uScreenX > fBillboardCenterX
|
|
1846 || (double)(signed int)pViewport->uScreenZ < fBillboardCenterX
|
|
1847 || (double)(signed int)pViewport->uScreenY > fBillboardCenterY
|
|
1848 || (v14 = (double)(signed int)pViewport->uScreenW,
|
|
1849 //UNDEF(v13),
|
|
1850 v15 = v14 < fBillboardCenterY,
|
|
1851 v16 = 0,
|
|
1852 v17 = v14 == fBillboardCenterY,
|
|
1853 BYTE1(result) = HIBYTE(v13),
|
|
1854 v14 < fBillboardCenterY) )
|
|
1855 {
|
|
1856 a3a = 0;
|
|
1857 result = (bool)&pRenderer->pBillboardRenderListD3D[v3].pQuards[0].pos.y;
|
|
1858
|
|
1859 __debugbreak();
|
|
1860 {
|
|
1861 LODWORD(v58) = (int)((char *)&pRenderer + v3 * 156 + 1062620);// pBillboardRenderListD3D+0x0C
|
|
1862 }
|
|
1863
|
|
1864 while ( 1 )
|
|
1865 {
|
|
1866 v18 = *(float *)(result - 4);
|
|
1867 v19 = *(float *)result;
|
|
1868 v20 = *(float *)(result - 4);
|
|
1869 Vis_static_stru_F91E10.uNumPointers = 0;
|
|
1870 if ( v20 >= (double)(signed int)pViewport->uScreenX )
|
|
1871 {
|
|
1872 if ( v18 <= (double)(signed int)pViewport->uScreenZ
|
|
1873 && v19 >= (double)(signed int)pViewport->uScreenY
|
|
1874 && v19 <= (double)(signed int)pViewport->uScreenW )
|
|
1875 {
|
|
1876 v21 = v19;
|
|
1877 v22 = v18;
|
|
1878 CastPickRay(a3, v22, v21, fDepth);
|
|
1879 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
1880 PickIndoor(fDepth, a3, &Vis_static_stru_F91E10, &a5);
|
|
1881 else
|
|
1882 PickOutdoor(fDepth, a3, &Vis_static_stru_F91E10, &a5, 0);
|
|
1883 Vis_static_stru_F91E10.create_object_pointers(0);
|
|
1884 sort_object_pointers(
|
|
1885 Vis_static_stru_F91E10.array_1804,
|
|
1886 0,
|
|
1887 Vis_static_stru_F91E10.uNumPointers - 1);
|
|
1888 result = Vis_static_stru_F91E10.uNumPointers;
|
|
1889 if ( !Vis_static_stru_F91E10.uNumPointers )
|
|
1890 break;
|
|
1891 v23 = (signed int)(Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : Vis_static_stru_F91E10.array_1804[0]);
|
|
1892 result = *(int *)(v23 + 4);
|
|
1893 LOWORD(result) = 0;
|
|
1894 if ( result > v57 )
|
|
1895 break;
|
|
1896 }
|
|
1897 }
|
|
1898 ++a3a;
|
|
1899 result = LODWORD(v58) + 32;
|
|
1900 LODWORD(v58) += 32;
|
|
1901 if ( a3a >= 4 )
|
|
1902 {
|
|
1903 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
|
|
1904 goto LABEL_49;
|
|
1905 v24 = pRenderer->pBillboardRenderListD3D[v3].pQuards[0].pos.x;
|
|
1906 v25 = pRenderer->pBillboardRenderListD3D[v3].pQuards[3].pos.x;
|
|
1907 v26 = pRenderer->pBillboardRenderListD3D[v3].pQuards[0].pos.y;
|
|
1908 v54 = pRenderer->pBillboardRenderListD3D[v3].pQuards[3].pos.x;
|
|
1909 v58 = v26;
|
|
1910 result = LODWORD(pRenderer->pBillboardRenderListD3D[v3].pQuards[1].pos.y);
|
|
1911 a3b = pRenderer->pBillboardRenderListD3D[v3].pQuards[1].pos.y;
|
|
1912 if ( v24 > v25 )
|
|
1913 {
|
|
1914 v53 = v24;
|
|
1915 v24 = v54;
|
|
1916 v25 = v53;
|
|
1917 }
|
|
1918 if ( v58 > (double)a3b )
|
|
1919 a3b = v58;
|
|
1920 if ( (Vis_static_stru_F91E10.uNumPointers = 0,
|
|
1921 v27 = (v25 - v24) * 0.5,
|
|
1922 v28 = (double)(signed int)pViewport->uScreenX,
|
|
1923 //UNDEF(v29),
|
|
1924 v30 = v27 < v28,
|
|
1925 v31 = 0,
|
|
1926 v32 = v27 == v28,
|
|
1927 BYTE1(result) = HIBYTE(v29),
|
|
1928 v27 < v28)
|
|
1929 || (v33 = (double)(signed int)pViewport->uScreenZ,
|
|
1930 //UNDEF(v34),
|
|
1931 v35 = v27 < v33,
|
|
1932 v36 = 0,
|
|
1933 v37 = v27 == v33,
|
|
1934 BYTE1(result) = HIBYTE(v34),
|
|
1935 v27 > v33)
|
|
1936 || (v39 = (double)(signed int)pViewport->uScreenY,
|
|
1937 //UNDEF(v38),
|
|
1938 v40 = v39 < a3b,
|
|
1939 v41 = 0,
|
|
1940 v42 = v39 == a3b,
|
|
1941 BYTE1(result) = HIBYTE(v38),
|
|
1942 !(v40 | v42))
|
|
1943 || (v44 = (double)(signed int)pViewport->uScreenW,
|
|
1944 //UNDEF(v43),
|
|
1945 v45 = v44 < a3b,
|
|
1946 v46 = 0,
|
|
1947 v47 = v44 == a3b,
|
|
1948 BYTE1(result) = HIBYTE(v43),
|
|
1949 v44 < a3b)
|
|
1950 || ((v48 = thisa, v49 = v27, CastPickRay(a3, v49, a3b, fDepth), uCurrentlyLoadedLevelType != LEVEL_Indoor) ? PickOutdoor(fDepth, a3, &Vis_static_stru_F91E10, &a5, 0) : PickIndoor(fDepth, a3, &Vis_static_stru_F91E10, &a5),
|
|
1951 (Vis_static_stru_F91E10.create_object_pointers(0),
|
|
1952 sort_object_pointers(
|
|
1953 Vis_static_stru_F91E10.array_1804,
|
|
1954 0,
|
|
1955 Vis_static_stru_F91E10.uNumPointers - 1),
|
|
1956 (result = Vis_static_stru_F91E10.uNumPointers) != 0)
|
|
1957 && ((signed int)Vis_static_stru_F91E10.uNumPointers <= 0 ? (v50 = 0) : (v50 = Vis_static_stru_F91E10.array_1804[0]),
|
|
1958 result = v50->sZValue,
|
|
1959 LOWORD(result) = 0,
|
|
1960 result <= v57)) )
|
|
1961 goto LABEL_49;
|
|
1962 break;
|
|
1963 }
|
|
1964 }
|
|
1965 }
|
|
1966 LOBYTE(result) = 1;
|
|
1967 }
|
|
1968 else
|
|
1969 {
|
|
1970 LABEL_49:
|
|
1971 return false;
|
|
1972 }
|
|
1973 return result;
|
|
1974 }
|
|
1975 // F93E18: using guessed type char static_byte_F93E18_init;
|
|
1976
|
|
1977 //----- (004C0D32) --------------------------------------------------------
|
|
1978 int Vis::_4C0D32_BLV(float a1, Vis_stru1 *arg4, stru157 *a2)
|
|
1979 {
|
|
1980 int result; // eax@1
|
|
1981 signed int v5; // esi@2
|
|
1982 BLVFace *v6; // edi@4
|
|
1983 unsigned int v7; // eax@6
|
|
1984 Vis_stru1_stru0 *v8; // eax@6
|
|
1985 int v9; // ST18_4@7
|
|
1986 unsigned int v10; // ST1C_4@7
|
|
1987 unsigned int v11; // ecx@7
|
|
1988 signed int i; // [sp+18h] [bp-8h]@1
|
|
1989 Vis *thisa; // [sp+1Ch] [bp-4h]@1
|
|
1990
|
|
1991 result = 0;
|
|
1992 thisa = this;
|
|
1993 for ( i = 0; i < (signed int)pStru170->uNumFaceIDs; ++i )
|
|
1994 {
|
|
1995 v5 = pStru170->pFaceIDs[2 * result];
|
|
1996 if ( v5 >= 0 )
|
|
1997 {
|
|
1998 if ( v5 < (signed int)pIndoor->uNumFaces )
|
|
1999 {
|
|
2000 v6 = &pIndoor->pFaces[v5];
|
|
2001 if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(&pIndoor->pFaces[v5]) )
|
|
2002 {
|
|
2003 if ( is_part_of_selection(v6, a2) )
|
|
2004 {
|
|
2005 v7 = 8 * v5;
|
|
2006 LOBYTE(v7) = 8 * v5 | 6;
|
|
2007 v8 = _4C1026(v6, v7, a1);
|
|
2008 if ( v8 )
|
|
2009 {
|
|
2010 v9 = v8->sZValue;
|
|
2011 v10 = v8->uObjectType;
|
|
2012 v11 = 3 * arg4->uNumPointers;
|
|
2013 arg4->array_0004[arg4->uNumPointers].pObjectInfo = v8->pObjectInfo;
|
|
2014 arg4->array_0004[4 * v11 / 0xC].sZValue = v9;
|
|
2015 arg4->array_0004[4 * v11 / 0xC].uObjectType = v10;
|
|
2016 ++arg4->uNumPointers;
|
|
2017 }
|
|
2018 }
|
|
2019 }
|
|
2020 }
|
|
2021 }
|
|
2022 result = i + 1;
|
|
2023 }
|
|
2024 return result;
|
|
2025 }
|
|
2026
|
|
2027 //----- (004C0DEA) --------------------------------------------------------
|
|
2028 void Vis::_4C0DEA_ODM(float arg0, Vis_stru1 *a3, stru157 *a2)
|
|
2029 {
|
|
2030 int v4; // esi@1
|
|
2031 BSPModel *v5; // ebx@3
|
|
2032 unsigned __int8 v6; // zf@5
|
|
2033 char v7; // sf@5
|
|
2034 unsigned __int8 v8; // of@5
|
|
2035 ODMFace *v9; // esi@7
|
|
2036 unsigned int v10; // eax@8
|
|
2037 Vis_stru1_stru0 *v11; // eax@8
|
|
2038 unsigned int v12; // ecx@9
|
|
2039 BLVFace f; // [sp+10h] [bp-84h]@1
|
|
2040 void *v14; // [sp+70h] [bp-24h]@9
|
|
2041 int v15; // [sp+74h] [bp-20h]@9
|
|
2042 unsigned int v16; // [sp+78h] [bp-1Ch]@9
|
|
2043 int v17; // [sp+7Ch] [bp-18h]@1
|
|
2044 Vis *v18; // [sp+80h] [bp-14h]@1
|
|
2045 int v19; // [sp+84h] [bp-10h]@6
|
|
2046 unsigned int v20; // [sp+88h] [bp-Ch]@2
|
|
2047 int v21; // [sp+8Ch] [bp-8h]@5
|
|
2048 int a1; // [sp+90h] [bp-4h]@1
|
|
2049
|
|
2050 auto ecx0 = this;
|
|
2051 v18 = ecx0;
|
|
2052 v4 = 0;
|
|
2053 v17 = 0;
|
|
2054 a1 = 0;
|
|
2055 if ( (signed int)pOutdoor->uNumBModels > 0 )
|
|
2056 {
|
|
2057 v20 = 0;
|
|
2058 do
|
|
2059 {
|
|
2060 v5 = &pOutdoor->pBModels[v20 / 0xBC];
|
|
2061 if ( IsBModelVisible(a1, &v17) )
|
|
2062 {
|
|
2063 if ( v17 != v4 )
|
|
2064 {
|
|
2065 v8 = __OFSUB__(v5->uNumFaces, v4);
|
|
2066 v6 = v5->uNumFaces == v4;
|
|
2067 v7 = ((v5->uNumFaces - v4) & 0x80000000u) != 0;
|
|
2068 v21 = v4;
|
|
2069 if ( !((unsigned __int8)(v7 ^ v8) | v6) )
|
|
2070 {
|
|
2071 v19 = v4;
|
|
2072 do
|
|
2073 {
|
|
2074 v9 = (ODMFace *)((char *)v5->pFaces + v19);
|
|
2075 if ( is_part_of_selection((BLVFace *)((char *)v5->pFaces + v19), a2) )
|
|
2076 {
|
|
2077 f.FromODM(v9);
|
|
2078 v10 = 8 * (v21 | (a1 << 6));
|
|
2079 LOBYTE(v10) = v10 | 6;
|
|
2080 v11 = _4C1026(&f, v10, arg0);
|
|
2081 if ( v11 )
|
|
2082 {
|
|
2083 v14 = v11->pObjectInfo;
|
|
2084 v15 = v11->sZValue;
|
|
2085 v12 = a3->uNumPointers;
|
|
2086 v16 = v11->uObjectType;
|
|
2087 v12 *= 3;
|
|
2088 *((int *)&a3->array_0004[0].pObjectInfo + v12) = (int)v14;
|
|
2089 *(&a3->array_0004[0].sZValue + v12) = v15;
|
|
2090 *(&a3->array_0004[0].uObjectType + v12) = v16;
|
|
2091 ++a3->uNumPointers;
|
|
2092 }
|
|
2093 }
|
|
2094 ++v21;
|
|
2095 v19 += 308;
|
|
2096 }
|
|
2097 while ( v21 < (signed int)v5->uNumFaces );
|
|
2098 v4 = 0;
|
|
2099 }
|
|
2100 }
|
|
2101 }
|
|
2102 ++a1;
|
|
2103 v20 += 188;
|
|
2104 }
|
|
2105 while ( a1 < (signed int)pOutdoor->uNumBModels );
|
|
2106 }
|
|
2107 } |