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