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