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