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