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