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