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