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