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