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