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