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