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