194
|
1 #include <assert.h>
|
|
2
|
0
|
3 #include "Vis.h"
|
|
4 #include "Outdoor.h"
|
|
5 #include "Game.h"
|
|
6 #include "Actor.h"
|
|
7 #include "IndoorCamera.h"
|
|
8 #include "Viewport.h"
|
227
|
9 #include "Log.h"
|
0
|
10
|
|
11 #include "mm7_data.h"
|
|
12 //#include "MM7.h"
|
|
13
|
|
14
|
194
|
15 static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8;
|
|
16
|
|
17 Vis_SelectionFilter vis_sprite_filter_1 = {VisObjectType_Sprite, OBJECT_Decoration, 0, 0, 2}; // 00F93E1C
|
|
18 Vis_SelectionFilter vis_sprite_filter_2 = {VisObjectType_Sprite, OBJECT_Decoration, 0, 0, 2}; // 00F93E30
|
|
19 Vis_SelectionFilter vis_face_filter = {VisObjectType_Face, OBJECT_Any, -1, 0, 0}; // 00F93E44
|
|
20 Vis_SelectionFilter vis_door_filter = {VisObjectType_Face, OBJECT_BLVDoor, -1, 0x100000, 0}; // 00F93E58
|
|
21 Vis_SelectionFilter vis_sprite_filter_3 = {VisObjectType_Sprite, OBJECT_Decoration, -1, 0, 4}; // 00F93E6C
|
|
22 Vis_SelectionFilter vis_sprite_filter_4 = {VisObjectType_Any, OBJECT_Item, -1, 0, 0}; // static to sub_44EEA7
|
0
|
23
|
|
24
|
|
25
|
|
26 //----- (004C1026) --------------------------------------------------------
|
196
|
27 Vis_ObjectInfo *Vis::_4C1026(BLVFace *face, unsigned int a3, float pick_depth)
|
0
|
28 {
|
|
29 char *v4; // eax@4
|
|
30 signed int v5; // ecx@4
|
196
|
31 //BLVFace *v6; // ecx@7
|
|
32 //unsigned int v7; // edi@7
|
0
|
33 Vec3_short_ *v8; // eax@9
|
|
34 char *v9; // edx@9
|
|
35 signed int v10; // esi@10
|
196
|
36 //Vec3_int_ **v11; // edx@13
|
|
37 //char *v12; // eax@13
|
|
38 //double v13; // st7@14
|
|
39 //signed int v14; // ebx@14
|
|
40 //Vis *v15; // ebx@15
|
|
41 //Vis_ObjectInfo *result; // eax@21
|
|
42 //Vis_ObjectInfo *v17; // ecx@24
|
0
|
43 RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17
|
|
44 int v20; // [sp+84h] [bp-Ch]@10
|
196
|
45 //int v21; // [sp+88h] [bp-8h]@16
|
|
46 //int v22; // [sp+8Ch] [bp-4h]@16
|
0
|
47 signed int v23; // [sp+98h] [bp+8h]@7
|
|
48
|
196
|
49 //auto ecx0 = this;
|
0
|
50
|
194
|
51 static Vis_SelectionList static_sub_4C1026_stru_F8FE00;
|
0
|
52 static_sub_4C1026_stru_F8FE00.uNumPointers = 0;
|
|
53
|
|
54 static bool _init_flag = false;
|
|
55 static RenderVertexSoft static_sub_4C1026_array_F8F200[64];
|
|
56 if (!_init_flag)
|
|
57 {
|
|
58 _init_flag = true;
|
|
59 for (uint i = 0; i < 64; ++i)
|
|
60 static_sub_4C1026_array_F8F200[i].flt_2C = 0.0f;
|
|
61 }
|
|
62
|
196
|
63 //v6 = a2;
|
0
|
64 v23 = 0;
|
196
|
65 //v7 = face->uNumVertices;
|
|
66 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
0
|
67 {
|
196
|
68 __debugbreak(); // refactor for BLV picking
|
|
69 if ( (signed int)face->uNumVertices > 0 )
|
0
|
70 {
|
|
71 v8 = pIndoor->pVertices;
|
|
72 v9 = (char *)&static_sub_4C1026_array_F8F200[0].vWorldPosition.y;
|
|
73 do
|
|
74 {
|
|
75 v10 = v23++;
|
196
|
76 v20 = v8[face->pVertexIDs[v10]].x;
|
0
|
77 *((float *)v9 - 1) = (double)v20;
|
196
|
78 v20 = v8[face->pVertexIDs[v10]].y;
|
0
|
79 *(float *)v9 = (double)v20;
|
|
80 v9 += 48;
|
196
|
81 v20 = v8[face->pVertexIDs[v10]].z;
|
0
|
82 *((float *)v9 - 11) = (double)v20;
|
|
83 }
|
196
|
84 while ( v23 < (signed int)face->uNumVertices );
|
|
85 }
|
|
86 }
|
|
87 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
88 {
|
|
89 uint bmodel_id = a3 >> 9;
|
|
90 auto v = (Vec3_int_ *)pOutdoor->pBModels[bmodel_id].pVertices.pVertices;
|
|
91 for (uint i = 0; i < face->uNumVertices; ++i)
|
|
92 {
|
|
93 static_sub_4C1026_array_F8F200[i].vWorldPosition.x = v[face->pVertexIDs[i]].x;
|
|
94 static_sub_4C1026_array_F8F200[i].vWorldPosition.y = v[face->pVertexIDs[i]].y;
|
|
95 static_sub_4C1026_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z;
|
0
|
96 }
|
|
97 }
|
196
|
98 else assert(false);
|
|
99
|
|
100 pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, face->uNumVertices);
|
|
101 pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, face->uNumVertices, 1);
|
|
102
|
|
103 //v15 = this;
|
|
104 SortVectors_x(static_sub_4C1026_array_F8F200, 0, face->uNumVertices - 1);
|
|
105 if (static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > pick_depth)
|
|
106 return nullptr;
|
|
107
|
|
108 float screenspace_center_x,
|
|
109 screenspace_center_y;
|
|
110 GetPolygonScreenSpaceCenter(static_sub_4C1026_array_F8F200, face->uNumVertices, &screenspace_center_x, &screenspace_center_y);
|
|
111 if (IsPolygonOccludedByBillboard(static_sub_4C1026_array_F8F200, face->uNumVertices, screenspace_center_x, screenspace_center_y))
|
|
112 return nullptr;
|
|
113
|
|
114 CastPickRay(pRay, screenspace_center_x, screenspace_center_y, pick_depth);
|
|
115
|
|
116 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
117 PickOutdoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter, true);
|
|
118 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
119 PickIndoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter);
|
|
120 else assert(false);
|
|
121
|
|
122 static_sub_4C1026_stru_F8FE00.create_object_pointers();
|
|
123 sort_object_pointers(static_sub_4C1026_stru_F8FE00.object_pointers, 0, static_sub_4C1026_stru_F8FE00.uNumPointers - 1);
|
|
124 if (!static_sub_4C1026_stru_F8FE00.uNumPointers)
|
|
125 return nullptr;
|
|
126
|
|
127 if (!static_sub_4C1026_stru_F8FE00.sub_4C2551(2, a3))
|
|
128 return nullptr;
|
|
129
|
|
130 if (static_sub_4C1026_stru_F8FE00.uNumPointers)
|
|
131 return static_sub_4C1026_stru_F8FE00.object_pointers[0];
|
|
132 else return nullptr;
|
0
|
133 }
|
|
134 // F91E08: using guessed type char static_sub_4C1026_byte_F91E08__init_flags;
|
|
135
|
|
136 //----- (004C12C3) --------------------------------------------------------
|
196
|
137 bool Vis::IsPolygonOccludedByBillboard(RenderVertexSoft *vertices, int num_vertices, float x, float y)
|
0
|
138 {
|
196
|
139 //signed int v5; // esi@1
|
|
140 //RenderBillboardD3D *v6; // edi@2
|
|
141 //double v7; // st7@9
|
|
142 //int v8; // edx@9
|
|
143 //RenderVertexSoft *v9; // ecx@10
|
|
144 //char result; // al@24
|
|
145 //Vis *thisa; // [sp+10h] [bp-8h]@1
|
|
146 //float thisb; // [sp+10h] [bp-8h]@9
|
|
147 //signed int v13; // [sp+14h] [bp-4h]@1
|
|
148 //float a3a; // [sp+28h] [bp+10h]@9
|
|
149 //float a4a; // [sp+2Ch] [bp+14h]@9
|
0
|
150
|
196
|
151 int v13 = -1;
|
|
152 //v5 = 0;
|
|
153 //thisa = this;
|
|
154
|
|
155 //v6 = pRenderer->pBillboardRenderListD3D;
|
|
156 for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
|
82
|
157 {
|
196
|
158 auto billboard = pRenderer->pBillboardRenderListD3D + i;
|
|
159 if (IsPointInsideD3DBillboard(billboard, x, y))
|
0
|
160 {
|
196
|
161 if (v13 == -1)
|
|
162 v13 = i;
|
|
163 else if ((unsigned int)pBillboardRenderList[billboard->uParentBillboardID].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue)
|
|
164 v13 = i;
|
0
|
165 }
|
|
166 }
|
196
|
167
|
|
168 if ( v13 == -1 )
|
|
169 return false;
|
|
170
|
|
171 //v8 = num_vertices;
|
|
172 //v7 = 3.4028235e38;
|
|
173 float min_x = FLT_MAX;
|
|
174 //a4a = 3.4028235e38;
|
|
175 float min_y = FLT_MAX;
|
|
176 //a3a = -3.4028235e38;
|
|
177 float max_x = -FLT_MAX;
|
|
178 //thisb = -3.4028235e38;
|
|
179 float max_y = -FLT_MAX;
|
|
180 for (uint i = 0; i < num_vertices; ++i)
|
|
181 {
|
|
182 //v9 = a1;
|
|
183 //do
|
|
184 //{
|
|
185 auto v = vertices + i;
|
|
186
|
|
187 if (v->vWorldViewProjX < min_x)
|
|
188 min_x = v->vWorldViewProjX;
|
|
189 if (v->vWorldViewProjX > max_x)
|
|
190 max_x = v->vWorldViewProjX;
|
|
191
|
|
192 if (v->vWorldViewProjY < min_y)
|
|
193 min_y = v->vWorldViewProjY;
|
|
194 if (v->vWorldViewProjY > max_y)
|
|
195 max_y = v->vWorldViewProjY;
|
|
196 //++v9;
|
|
197 //--v8;
|
|
198 //}
|
|
199 //while ( v8 );
|
|
200 }
|
|
201
|
|
202 if (min_x < pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.x || pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.y > min_y ||
|
|
203 pRenderer->pBillboardRenderListD3D[v13].pQuards[3].pos.x < max_x || pRenderer->pBillboardRenderListD3D[v13].pQuards[1].pos.y < max_y)
|
|
204 return false;
|
|
205
|
|
206 return true;
|
0
|
207 }
|
|
208
|
|
209 //----- (004C1417) --------------------------------------------------------
|
|
210 void Vis::GetPolygonCenter(RenderVertexD3D3 *pVertices, unsigned int uNumVertices, float *pCenterX, float *pCenterY)
|
|
211 {
|
|
212 static RenderVertexD3D3 unk_F8EA00[64];
|
|
213
|
|
214 memcpy(unk_F8EA00, pVertices, 32 * uNumVertices);
|
|
215
|
|
216 SortVerticesByX(unk_F8EA00, 0, uNumVertices - 1);
|
|
217 *pCenterX = (unk_F8EA00[uNumVertices - 1].pos.x - unk_F8EA00[0].pos.x) * 0.5 + unk_F8EA00[0].pos.x;
|
|
218
|
|
219 SortVerticesByY(unk_F8EA00, 0, uNumVertices - 1);
|
|
220 *pCenterY = (unk_F8EA00[uNumVertices - 1].pos.y - unk_F8EA00[0].pos.y) * 0.5 + unk_F8EA00[0].pos.y;
|
|
221 }
|
|
222
|
|
223 //----- (004C1495) --------------------------------------------------------
|
196
|
224 void Vis::GetPolygonScreenSpaceCenter(RenderVertexSoft *vertices, int num_vertices, float *out_center_x, float *out_center_y)
|
0
|
225 {
|
|
226 char *v5; // eax@2
|
|
227 signed int v6; // ecx@2
|
|
228 float *result; // eax@5
|
|
229
|
|
230 static RenderVertexSoft static_sub_4C1495_array_F8DDF8[64];
|
|
231
|
196
|
232 memcpy(static_sub_4C1495_array_F8DDF8, vertices, 48 * num_vertices);
|
0
|
233
|
196
|
234 SortByScreenSpaceX(static_sub_4C1495_array_F8DDF8, 0, num_vertices - 1);
|
|
235 *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;
|
|
236
|
|
237 SortByScreenSpaceY(static_sub_4C1495_array_F8DDF8, 0, num_vertices - 1);
|
|
238 *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
|
239 }
|
|
240
|
|
241 //----- (004C1542) --------------------------------------------------------
|
194
|
242 void Vis::PickBillboards_Mouse(float fPickDepth, float fX, float fY, Vis_SelectionList *list, Vis_SelectionFilter *filter)
|
0
|
243 {
|
194
|
244 for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
|
0
|
245 {
|
194
|
246 auto d3d_billboard = pRenderer->pBillboardRenderListD3D + i;
|
|
247 if (is_part_of_selection((void *)i, filter) && IsPointInsideD3DBillboard(d3d_billboard, fX, fY))
|
0
|
248 {
|
194
|
249 if (DoesRayIntersectBillboard(fPickDepth, i))
|
0
|
250 {
|
194
|
251 auto billboard = &pBillboardRenderList[d3d_billboard->uParentBillboardID];
|
|
252
|
|
253 list->AddObject((void *)d3d_billboard->uParentBillboardID, VisObjectType_Sprite, billboard->sZValue);
|
0
|
254 }
|
|
255 }
|
|
256 }
|
|
257 }
|
|
258
|
|
259 //----- (004C1607) --------------------------------------------------------
|
|
260 bool Vis::IsPointInsideD3DBillboard(RenderBillboardD3D *a1, float x, float y)
|
|
261 {
|
194
|
262 //RenderBillboardD3D *result; // eax@1
|
0
|
263 double v5; // st7@2
|
|
264 float v6; // ecx@2
|
|
265 float v7; // ST00_4@3
|
|
266 __int16 v8; // fps@6
|
|
267 double v9; // st6@6
|
|
268 char v10; // c0@6
|
|
269 char v11; // c2@6
|
|
270 char v12; // c3@6
|
|
271 __int16 v13; // fps@7
|
|
272 double v14; // st6@7
|
|
273 unsigned __int8 v15; // c0@7
|
|
274 char v16; // c2@7
|
|
275 unsigned __int8 v17; // c3@7
|
|
276 __int16 v18; // fps@8
|
|
277 double v19; // st6@8
|
|
278 char v20; // c0@8
|
|
279 char v21; // c2@8
|
|
280 char v22; // c3@8
|
|
281 __int16 v23; // fps@9
|
|
282 double v24; // st6@9
|
|
283 unsigned __int8 v25; // c0@9
|
|
284 char v26; // c2@9
|
|
285 unsigned __int8 v27; // c3@9
|
|
286 float v28; // [sp+4h] [bp-8h]@2
|
|
287 float v29; // [sp+8h] [bp-4h]@2
|
|
288 float a1a; // [sp+14h] [bp+8h]@2
|
|
289
|
|
290 if ( a1->uParentBillboardID == -1 )
|
194
|
291 return false;
|
|
292
|
|
293 //result = a1;
|
0
|
294 v5 = a1->pQuards[0].pos.x;
|
|
295 a1a = a1->pQuards[3].pos.x;
|
194
|
296 v6 = a1->pQuards[0].pos.y;
|
|
297 //result = (RenderBillboardD3D *)LODWORD(result->pQuards[1].pos.y);
|
0
|
298 v29 = v6;
|
194
|
299 v28 = a1->pQuards[1].pos.y;
|
0
|
300 if ( v5 > a1a )
|
|
301 {
|
|
302 v7 = v5;
|
194
|
303 //HIWORD(result) = HIWORD(v7);
|
0
|
304 v5 = a1a;
|
|
305 a1a = v7;
|
|
306 }
|
|
307 if ( v6 > (double)v28 )
|
|
308 {
|
194
|
309 //result = (RenderBillboardD3D *)LODWORD(v28);
|
0
|
310 v28 = v6;
|
194
|
311 v29 = v28;
|
0
|
312 }
|
|
313 v9 = x + 1.0;
|
|
314 //UNDEF(v8);
|
29
|
315 //v10 = v9 < v5;
|
|
316 //v11 = 0;
|
|
317 //v12 = v9 == v5;
|
|
318 //BYTE1(result) = HIBYTE(v8);//crash
|
194
|
319 if (v9 >= v5 &&
|
|
320 (v14 = x - 1.0, v14<=a1a) &&///*UNDEF(v13),*/ v15 = v14 < a1a, v16 = 0, v17 = v14 == a1a, BYTE1(result) = HIBYTE(v13), v15 | v17)
|
|
321 (v19 = y + 1.0, v19>=v29) &&///*UNDEF(v18),*/ v20 = v19 < v29, v21 = 0, v22 = v19 == v29, BYTE1(result) = HIBYTE(v18), v19 >= v29)
|
|
322 (v24 = y - 1.0, v24<=v28))///*UNDEF(v23),*/ v25 = v24 < v28, v26 = 0, v27 = v24 == v28, BYTE1(result) = HIBYTE(v23), v25 | v27) )
|
|
323 return true;
|
0
|
324 else
|
194
|
325 return false;
|
0
|
326 }
|
|
327
|
|
328 //----- (004C16B4) --------------------------------------------------------
|
196
|
329 void Vis::PickIndoorFaces_Mouse(float fDepth, RenderVertexSoft *pRay, Vis_SelectionList *list, Vis_SelectionFilter *filter)
|
0
|
330 {
|
|
331 int v5; // eax@1
|
|
332 signed int v6; // edi@2
|
|
333 signed int v7; // esi@4
|
|
334 int v8; // ecx@7
|
|
335 int v9; // eax@7
|
|
336 unsigned int *pNumPointers; // eax@7
|
|
337 unsigned int v11; // ecx@7
|
194
|
338 Vis_ObjectInfo *v12; // edi@7
|
0
|
339 RenderVertexSoft a1; // [sp+Ch] [bp-44h]@1
|
|
340 BLVFace *v14; // [sp+3Ch] [bp-14h]@7
|
|
341 void *v15; // [sp+40h] [bp-10h]@7
|
|
342 int v16; // [sp+44h] [bp-Ch]@7
|
|
343 int v17; // [sp+48h] [bp-8h]@1
|
|
344 Vis *thisa; // [sp+4Ch] [bp-4h]@1
|
|
345
|
196
|
346 __debugbreak(); // refactor for BLV picking
|
|
347
|
0
|
348 v5 = 0;
|
|
349 thisa = this;
|
|
350 v17 = 0;
|
|
351 for ( a1.flt_2C = 0.0; v17 < (signed int)pBspRenderer->uNumFaceIDs; ++v17 )
|
|
352 {
|
|
353 v6 = pBspRenderer->pFaceIDs[2 * v5];
|
|
354 if ( v6 >= 0 )
|
|
355 {
|
|
356 if ( v6 < (signed int)pIndoor->uNumFaces )
|
|
357 {
|
|
358 v7 = v6;
|
194
|
359 if ( is_part_of_selection(&pIndoor->pFaces[v6], filter) )
|
0
|
360 {
|
|
361 if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v7]) )
|
|
362 {
|
|
363 if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, &pIndoor->pFaces[v7], 0xFFFFFFFFu) )
|
|
364 {
|
|
365 pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u);
|
|
366 v9 = _48B561_mess_with_scaling_along_z(/*v8, */a1.vWorldViewPosition.x);
|
|
367 LOWORD(v9) = 0;
|
|
368 v15 = (void *)((8 * v6 | 6) + v9);
|
194
|
369 pNumPointers = &list->uNumPointers;
|
0
|
370 v16 = 2;
|
194
|
371 v11 = list->uNumPointers;
|
0
|
372 v14 = &pIndoor->pFaces[v7];
|
194
|
373 v12 = &list->object_pool[v11];
|
|
374 v12->object = &pIndoor->pFaces[v7];
|
|
375 v12 = (Vis_ObjectInfo *)((char *)v12 + 4);
|
|
376 v12->object = v15;
|
0
|
377 v12->sZValue = v16;
|
|
378 ++*pNumPointers;
|
|
379 }
|
|
380 }
|
|
381 }
|
|
382 }
|
|
383 }
|
|
384 v5 = v17 + 1;
|
|
385 }
|
|
386 }
|
|
387
|
|
388 //----- (004C17CF) --------------------------------------------------------
|
196
|
389 void Vis::PickOutdoorFaces_Mouse(float fDepth, RenderVertexSoft *pRay, Vis_SelectionList *list, Vis_SelectionFilter *filter, bool one_sided)
|
|
390 {
|
0
|
391 if (!pOutdoor)
|
|
392 return;
|
196
|
393
|
|
394 for (uint i = 0; i < pOutdoor->uNumBModels; ++i)
|
0
|
395 {
|
196
|
396 int v24;
|
|
397 if (!IsBModelVisible(i, &v24))
|
|
398 continue;
|
|
399 if (one_sided && !v24)
|
|
400 continue;
|
|
401
|
|
402 auto bmodel = &pOutdoor->pBModels[i];
|
|
403
|
|
404 for (uint j = 0; j < bmodel->uNumFaces; ++j)
|
0
|
405 {
|
196
|
406 auto face = bmodel->pFaces + j;
|
|
407 if (is_part_of_selection(face, filter))
|
0
|
408 {
|
196
|
409 BLVFace blv_face;
|
|
410 blv_face.FromODM(face);
|
|
411
|
|
412 RenderVertexSoft intersection;
|
|
413 if (Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &intersection, &blv_face, i))
|
0
|
414 {
|
196
|
415 pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1u);
|
|
416 int v13 = _48B561_mess_with_scaling_along_z(/*v12, */intersection.vWorldViewPosition.x);
|
|
417 LOWORD(v13) = (8 * (j | (i << 6)) | OBJECT_BModel) + v13;
|
|
418
|
|
419 list->AddObject(face, VisObjectType_Face, v13);
|
0
|
420 }
|
|
421 }
|
|
422 }
|
|
423 }
|
|
424 }
|
|
425
|
|
426 //----- (004C1930) --------------------------------------------------------
|
|
427 //bool Vis::j_DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx)
|
|
428 //{return DoesRayIntersectBillboard(fDepth, uD3DBillboardIdx);}
|
|
429
|
|
430 //----- (004C1944) --------------------------------------------------------
|
295
|
431 int Vis::PickClosestActor(int object_id, unsigned int pick_depth, int a4, int a5, int a6)
|
0
|
432 {
|
295
|
433 //float v6; // ST00_4@3
|
|
434 //int result; // eax@4
|
194
|
435 Vis_SelectionFilter v8; // [sp+18h] [bp-20h]@3
|
295
|
436 //__int64 v9; // [sp+2Ch] [bp-Ch]@3
|
|
437 //Vis *v14; // [sp+34h] [bp-4h]@1
|
0
|
438
|
295
|
439 //v14 = this;
|
0
|
440
|
194
|
441 static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8;
|
295
|
442
|
|
443 v8.object_type = VisObjectType_Sprite;
|
194
|
444 v8.object_id = object_id;
|
0
|
445 v8.field_8 = a6;
|
|
446 v8.field_C = a5;
|
|
447 v8.field_10 = a4;
|
|
448 Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers = 0;
|
295
|
449 PickBillboards_Keyboard(pick_depth, &Vis_static_sub_4C1944_stru_F8BDE8, &v8);
|
194
|
450 Vis_static_sub_4C1944_stru_F8BDE8.create_object_pointers(Vis_SelectionList::Unique);
|
0
|
451 sort_object_pointers(
|
194
|
452 Vis_static_sub_4C1944_stru_F8BDE8.object_pointers,
|
0
|
453 0,
|
|
454 Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers - 1);
|
295
|
455
|
|
456 if (!Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers)
|
|
457 return -1;
|
|
458 return Vis_static_sub_4C1944_stru_F8BDE8.object_pointers[0]->sZValue;
|
0
|
459 }
|
|
460
|
|
461 //----- (004C1A02) --------------------------------------------------------
|
|
462 void Vis::_4C1A02()
|
|
463 {
|
|
464 RenderVertexSoft v1; // [sp+8h] [bp-C0h]@1
|
|
465 RenderVertexSoft v2; // [sp+38h] [bp-90h]@1
|
|
466 RenderVertexSoft v3; // [sp+68h] [bp-60h]@1
|
|
467 RenderVertexSoft v4; // [sp+98h] [bp-30h]@1
|
|
468
|
|
469 v4.flt_2C = 0.0;
|
|
470 v4.vWorldPosition.x = 0.0;
|
|
471 v4.vWorldPosition.y = 65536.0;
|
|
472 v4.vWorldPosition.z = 0.0;
|
|
473 v3.flt_2C = 0.0;
|
|
474 v3.vWorldPosition.x = 65536.0;
|
|
475 v3.vWorldPosition.y = 0.0;
|
|
476 v3.vWorldPosition.z = 0.0;
|
|
477 memcpy(&v1, &v3, sizeof(v1));
|
|
478 v3.flt_2C = 0.0;
|
|
479 v3.vWorldPosition.x = 0.0;
|
|
480 v3.vWorldPosition.y = 65536.0;
|
|
481 v3.vWorldPosition.z = 0.0;
|
|
482 memcpy(&v2, &v4, sizeof(v2));
|
|
483 v4.flt_2C = 0.0;
|
|
484 v4.vWorldPosition.x = 65536.0;
|
|
485 v4.vWorldPosition.y = 0.0;
|
|
486 v4.vWorldPosition.z = 0.0;
|
|
487 memcpy(&this->stru_200C, &v1, 0x60u);
|
|
488 memcpy(&v1, &v4, sizeof(v1));
|
|
489 memcpy(&v2, &v3, sizeof(v2));
|
|
490 memcpy(&this->stru_206C, &v1, 0x60u);
|
|
491 }
|
|
492
|
|
493 //----- (004C1ABA) --------------------------------------------------------
|
|
494 bool Vis::SortVectors_x(RenderVertexSoft *a2, int a3, int a4)
|
|
495 {
|
|
496 bool result; // eax@1
|
|
497 RenderVertexSoft *v5; // edx@2
|
|
498 int v6; // ebx@2
|
|
499 int i; // ecx@2
|
|
500 int v8; // esi@3
|
|
501 int v9; // esi@5
|
|
502 RenderVertexSoft *v10; // eax@8
|
|
503 RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8
|
|
504 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
|
|
505 int v13; // [sp+64h] [bp-Ch]@7
|
|
506 Vis *thisa; // [sp+68h] [bp-8h]@1
|
|
507 RenderVertexSoft *v15; // [sp+6Ch] [bp-4h]@2
|
|
508
|
|
509 result = a4;
|
|
510 thisa = this;
|
|
511 if ( a4 > a3 )
|
|
512 {
|
|
513 v5 = a2;
|
|
514 v15 = &a2[a4];
|
|
515 v6 = a3 - 1;
|
|
516 memcpy(&v12, &a2[a4], sizeof(v12));
|
|
517 for ( i = a4; ; i = v13 )
|
|
518 {
|
|
519 v8 = (int)&v5[v6].vWorldViewPosition;
|
|
520 do
|
|
521 {
|
|
522 v8 += 48;
|
|
523 ++v6;
|
|
524 }
|
|
525 while ( *(float *)v8 < (double)v12.vWorldViewPosition.x );
|
|
526 v9 = (int)&v5[i].vWorldViewPosition;
|
|
527 do
|
|
528 {
|
|
529 v9 -= 48;
|
|
530 --i;
|
|
531 }
|
|
532 while ( *(float *)v9 > (double)v12.vWorldViewPosition.x );
|
|
533 v13 = i;
|
|
534 if ( v6 >= i )
|
|
535 break;
|
|
536 v10 = &v5[i];
|
|
537 memcpy(&v11, &a2[v6], sizeof(v11));
|
|
538 v5 = a2;
|
|
539 memcpy(&a2[v6], v10, sizeof(a2[v6]));
|
|
540 memcpy(v10, &v11, 0x30u);
|
|
541 }
|
|
542 memcpy(&v11, &v5[v6], sizeof(v11));
|
|
543 memcpy(&v5[v6], v15, sizeof(v5[v6]));
|
|
544 memcpy(v15, &v11, 0x30u);
|
|
545 SortVectors_x(v5, a3, v6 - 1);
|
|
546 SortVectors_x(a2, v6 + 1, a4);
|
|
547 }
|
|
548 return true;
|
|
549 }
|
|
550
|
|
551 //----- (004C1BAA) --------------------------------------------------------
|
194
|
552 int Vis::get_object_zbuf_val(Vis_ObjectInfo *info)
|
0
|
553 {
|
194
|
554 switch (info->object_type)
|
|
555 {
|
|
556 case VisObjectType_Sprite:
|
|
557 case VisObjectType_Face:
|
|
558 return info->sZValue;
|
0
|
559
|
194
|
560 default:
|
|
561 MessageBoxW(nullptr, L"Undefined type requested for: CVis::get_object_zbuf_val()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1037", 0);
|
|
562 return -1;
|
0
|
563 }
|
|
564 }
|
|
565
|
|
566 //----- (004C1BF1) --------------------------------------------------------
|
|
567 int Vis::get_picked_object_zbuf_val()
|
|
568 {
|
194
|
569 if (!default_list.uNumPointers)
|
|
570 return -1;
|
0
|
571
|
194
|
572 return get_object_zbuf_val(default_list.object_pointers[0]);
|
0
|
573 }
|
|
574
|
|
575 //----- (004C1C0C) --------------------------------------------------------
|
|
576 bool Vis::Intersect_Ray_Face(RenderVertexSoft *pRayStart, RenderVertexSoft *pRayEnd, float *pDepth, RenderVertexSoft *a4, BLVFace *a5, unsigned int a6)
|
|
577 {
|
|
578 BLVFace *v7; // ebx@1
|
|
579 bool result; // eax@1
|
|
580 double v9; // st7@3
|
|
581 __int16 v10; // fps@3
|
|
582 char v11; // c0@3
|
|
583 char v12; // c2@3
|
|
584 char v13; // c3@3
|
|
585 __int16 v14; // fps@5
|
|
586 char v15; // c0@5
|
|
587 char v16; // c2@5
|
|
588 char v17; // c3@5
|
|
589 double v18; // st5@6
|
|
590 __int16 v19; // fps@6
|
|
591 char v20; // c0@6
|
|
592 char v21; // c2@6
|
|
593 char v22; // c3@6
|
|
594 unsigned __int8 v23; // c0@6
|
|
595 char v24; // c2@6
|
|
596 unsigned __int8 v25; // c3@6
|
|
597 char v26; // zf@6
|
|
598 double v27; // st6@10
|
|
599 __int16 v28; // fps@10
|
|
600 unsigned __int8 v29; // c0@10
|
|
601 char v30; // c2@10
|
|
602 unsigned __int8 v31; // c3@10
|
|
603 double v32; // st7@11
|
|
604 Vec2_short_ v33; // ST1E_4@11
|
|
605 Vec3_short_ v34; // ST04_6@11
|
|
606 float a5a; // [sp+30h] [bp+18h]@10
|
|
607 float a5b; // [sp+30h] [bp+18h]@13
|
|
608
|
|
609 v7 = a5;
|
|
610 result = a5->uAttributes;
|
|
611 if ( result & 1
|
|
612 || BYTE1(result) & 0x20
|
|
613 || (v9 = pRayEnd->vWorldPosition.z * a5->pFacePlane.vNormal.z
|
|
614 + a5->pFacePlane.vNormal.y * pRayEnd->vWorldPosition.y
|
|
615 + pRayEnd->vWorldPosition.x * a5->pFacePlane.vNormal.x,
|
|
616 //UNDEF(v10),
|
|
617 v11 = v9 < 0.0,
|
|
618 v12 = 0,
|
|
619 v13 = v9 == 0.0,
|
|
620 BYTE1(result) = HIBYTE(v10),
|
|
621 v9 == 0.0)
|
|
622 || (/*UNDEF(v14),*/ v15 = v9 < 0.0, v16 = 0, v17 = v9 == 0.0, BYTE1(result) = HIBYTE(v14), v9 > 0.0) )// ray's away (>) from face surface or parallel (==)
|
|
623 goto LABEL_12;
|
|
624 v18 = -(a5->pFacePlane.vNormal.y * pRayStart->vWorldPosition.y// ray-plane intersection
|
|
625 + pRayStart->vWorldPosition.x * a5->pFacePlane.vNormal.x
|
|
626 + pRayStart->vWorldPosition.z * a5->pFacePlane.vNormal.z
|
|
627 + a5->pFacePlane.dist);
|
|
628 //UNDEF(v19);
|
|
629 v20 = v9 < 0.0;
|
|
630 v21 = 0;
|
|
631 v22 = v9 == 0.0;
|
|
632 BYTE1(result) = HIBYTE(v19);
|
|
633 v23 = v18 < 0.0;
|
|
634 v24 = 0;
|
|
635 v25 = v18 == 0.0;
|
|
636 v26 = (BYTE1(result) & 0x41) == 0;
|
|
637 BYTE1(result) = HIBYTE(v19);
|
|
638 if ( v26 )
|
|
639 {
|
|
640 if ( v18 < 0.0 )
|
|
641 goto LABEL_12;
|
|
642 }
|
|
643 else
|
|
644 {
|
|
645 if ( !(v23 | v25) )
|
|
646 {
|
|
647 LABEL_12:
|
|
648 LOBYTE(result) = 0;
|
|
649 return result;
|
|
650 }
|
|
651 }
|
|
652 a5a = v18;
|
|
653 v27 = a5a / v9;
|
|
654 HIWORD(result) = HIWORD(pDepth);
|
|
655 //UNDEF(v28);
|
|
656 v29 = v27 < *pDepth;
|
|
657 v30 = 0;
|
|
658 v31 = v27 == *pDepth;
|
|
659 BYTE1(result) = HIBYTE(v28);
|
|
660 if ( !(v29 | v31)
|
|
661 || (a4->vWorldPosition.x = v27 * pRayEnd->vWorldPosition.x + pRayStart->vWorldPosition.x,
|
|
662 a4->vWorldPosition.y = v27 * pRayEnd->vWorldPosition.y + pRayStart->vWorldPosition.y,
|
|
663 v32 = v27 * pRayEnd->vWorldPosition.z + pRayStart->vWorldPosition.z,
|
|
664 a4->vWorldPosition.z = v32,
|
|
665 v33.x = (signed __int64)a4->vWorldPosition.x,
|
|
666 v33.y = (signed __int64)a4->vWorldPosition.y,
|
|
667 *(int *)&v34.x = v33.x,
|
|
668 v34.z = (signed __int64)v32,
|
|
669 result = _4C1D2B(v7, v34, a6),
|
|
670 *(float *)&result == 0.0) )
|
|
671 goto LABEL_12;
|
|
672 *(float *)&result = v27;
|
|
673 a5b = v27;
|
|
674 *(int *)pDepth = LODWORD(a5b);
|
|
675 LOBYTE(result) = 1;
|
|
676 return result;
|
|
677 }
|
|
678
|
|
679 //----- (004C1D2B) --------------------------------------------------------
|
|
680 int Vis::_4C1D2B(BLVFace *pFace, Vec3_short_ a2, unsigned int uModelID)
|
|
681 {
|
|
682 BLVFace *v4; // esi@1
|
|
683 int v5; // esi@10
|
|
684 bool v6; // edi@10
|
|
685 int v7; // ecx@12
|
|
686 signed int v8; // edx@12
|
|
687 signed int v9; // eax@13
|
|
688 signed int v10; // ebx@14
|
|
689 int v11; // edi@16
|
|
690 signed int v12; // ST28_4@18
|
|
691 signed __int64 v13; // qtt@18
|
|
692 signed int result; // eax@21
|
|
693 int v15; // [sp+10h] [bp-Ch]@10
|
|
694 signed int v16; // [sp+18h] [bp-4h]@10
|
|
695
|
|
696 v4 = pFace;
|
|
697 if ( a2.z < pFace->pBounding.z1
|
|
698 || a2.z > pFace->pBounding.z2
|
|
699 || a2.x < pFace->pBounding.x1
|
|
700 || a2.x > pFace->pBounding.x2
|
|
701 || a2.y < pFace->pBounding.y1
|
|
702 || a2.y > pFace->pBounding.y2
|
|
703 || (uModelID != -1 ? _4C2186_BLV_IntersectBModel(
|
|
704 (int *)&pFace,
|
|
705 (int *)&uModelID,
|
|
706 &word_F8BC48_displaced_face_intersect_plane_coords_a,
|
|
707 &word_F8BD18_displaced_face_intersect_plane_coords_b,
|
|
708 &a2,
|
|
709 pFace,
|
|
710 uModelID) : _4C1EE5_BLV_IntersectBModel_2(
|
|
711 (int *)&pFace,
|
|
712 (int *)&uModelID,
|
|
713 &word_F8BC48_displaced_face_intersect_plane_coords_a,
|
|
714 &word_F8BD18_displaced_face_intersect_plane_coords_b,
|
|
715 &a2,
|
|
716 pFace),
|
|
717 v5 = 2 * v4->uNumVertices,
|
|
718 v16 = 0,
|
|
719 *(&word_F8BC48_displaced_face_intersect_plane_coords_a + v5) = word_F8BC48_displaced_face_intersect_plane_coords_a,
|
|
720 *(&word_F8BD18_displaced_face_intersect_plane_coords_b + v5) = word_F8BD18_displaced_face_intersect_plane_coords_b,
|
|
721 v15 = 0,
|
|
722 v6 = word_F8BD18_displaced_face_intersect_plane_coords_b >= (signed int)uModelID,
|
|
723 v5 <= 0) )
|
|
724 goto LABEL_25;
|
|
725 do
|
|
726 {
|
|
727 if ( v16 >= 2 )
|
|
728 break;
|
|
729 v7 = 2 * v15;
|
|
730 v8 = *(&word_F8BD18_displaced_face_intersect_plane_coords_b + v15 + 1);
|
|
731 if ( v6 ^ v8 >= (signed int)uModelID )
|
|
732 {
|
|
733 v9 = *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7 + 2);
|
|
734 if ( v9 >= (signed int)pFace )
|
|
735 v10 = 0;
|
|
736 else
|
|
737 v10 = 2;
|
|
738 v11 = v10 | *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7) < (signed int)pFace;
|
|
739 if ( v11 != 3 )
|
|
740 {
|
|
741 if ( !v11
|
|
742 || (v12 = v9 - *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7),
|
|
743 LODWORD(v13) = v12 << 16,
|
|
744 HIDWORD(v13) = v12 >> 16,
|
|
745 *(__int16 *)((char *)&word_F8BC48_displaced_face_intersect_plane_coords_a + v7)
|
|
746 + ((signed int)(((unsigned __int64)(v13
|
|
747 / (v8
|
|
748 - *(__int16 *)((char *)&word_F8BD18_displaced_face_intersect_plane_coords_b
|
|
749 + v7))
|
|
750 * (signed int)((uModelID
|
|
751 - *(__int16 *)((char *)&word_F8BD18_displaced_face_intersect_plane_coords_b
|
|
752 + v7)) << 16)) >> 16)
|
|
753 + 32768) >> 16) >= (signed int)pFace) )
|
|
754 ++v16;
|
|
755 }
|
|
756 }
|
|
757 ++v15;
|
|
758 v6 = v8 >= (signed int)uModelID;
|
|
759 }
|
|
760 while ( v15 < v5 );
|
|
761 result = 1;
|
|
762 if ( v16 != 1 )
|
|
763 LABEL_25:
|
|
764 result = 0;
|
|
765 return result;
|
|
766 }
|
|
767
|
|
768 //----- (004C1EE5) --------------------------------------------------------
|
|
769 bool Vis::_4C1EE5_BLV_IntersectBModel_2(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *pFace)
|
|
770 {
|
|
771 bool result; // eax@1
|
|
772 unsigned int v8; // ecx@1
|
|
773 Vec3_short_ *v9; // ecx@2
|
|
774 __int16 *v10; // edx@3
|
|
775 signed int v11; // ecx@4
|
|
776 char v12; // zf@6
|
|
777 Vec3_short_ *v13; // ecx@6
|
|
778 int v14; // edx@7
|
|
779 __int16 *v15; // edx@8
|
|
780 signed int v16; // ecx@9
|
|
781 int v17; // edx@11
|
|
782 __int16 *v18; // edx@12
|
|
783 signed int v19; // ecx@13
|
|
784 signed int a5a; // [sp+24h] [bp+18h]@2
|
|
785 signed int a5b; // [sp+24h] [bp+18h]@7
|
|
786 signed int a5c; // [sp+24h] [bp+18h]@11
|
|
787
|
|
788 result = (bool)pFace;
|
|
789 v8 = pFace->uAttributes;
|
|
790 if ( BYTE1(v8) & 1 )
|
|
791 {
|
|
792 v9 = a5;
|
|
793 a5a = 0;
|
|
794 *a1 = v9->x;
|
|
795 *a2 = v9->y;
|
|
796 if ( pFace->uNumVertices )
|
|
797 {
|
|
798 v10 = a4 + 1;
|
|
799 do
|
|
800 {
|
|
801 v11 = a5a;
|
|
802 a3[2 * a5a] = pFace->pXInterceptDisplacements[a5a] + pIndoor->pVertices[pFace->pVertexIDs[a5a]].x;
|
|
803 *(v10 - 1) = pFace->pYInterceptDisplacements[v11] + pIndoor->pVertices[pFace->pVertexIDs[v11]].y;
|
|
804 *(__int16 *)((char *)v10 + (int)a3 - (int)a4) = pFace->pXInterceptDisplacements[v11 + 1]
|
|
805 + pIndoor->pVertices[pFace->pVertexIDs[v11 + 1]].x;
|
|
806 ++a5a;
|
|
807 *v10 = pFace->pYInterceptDisplacements[v11 + 1] + pIndoor->pVertices[pFace->pVertexIDs[v11 + 1]].y;
|
|
808 v10 += 2;
|
|
809 }
|
|
810 while ( a5a < pFace->uNumVertices );
|
|
811 }
|
|
812 }
|
|
813 else
|
|
814 {
|
|
815 v12 = (BYTE1(v8) & 2) == 0;
|
|
816 v13 = a5;
|
|
817 if ( v12 )
|
|
818 {
|
|
819 v17 = a5->y;
|
|
820 a5c = 0;
|
|
821 *a1 = v17;
|
|
822 *a2 = v13->z;
|
|
823 if ( pFace->uNumVertices )
|
|
824 {
|
|
825 v18 = a4 + 1;
|
|
826 do
|
|
827 {
|
|
828 v19 = a5c;
|
|
829 a3[2 * a5c] = pFace->pYInterceptDisplacements[a5c] + pIndoor->pVertices[pFace->pVertexIDs[a5c]].y;
|
|
830 *(v18 - 1) = pFace->pZInterceptDisplacements[v19] + pIndoor->pVertices[pFace->pVertexIDs[v19]].z;
|
|
831 *(__int16 *)((char *)v18 + (int)(char *)a3 - (char *)a4) = pFace->pYInterceptDisplacements[v19 + 1]
|
|
832 + pIndoor->pVertices[pFace->pVertexIDs[v19 + 1]].y;
|
|
833 ++a5c;
|
|
834 *v18 = pFace->pZInterceptDisplacements[v19 + 1] + pIndoor->pVertices[pFace->pVertexIDs[v19 + 1]].z;
|
|
835 v18 += 2;
|
|
836 }
|
|
837 while ( a5c < pFace->uNumVertices );
|
|
838 }
|
|
839 }
|
|
840 else
|
|
841 {
|
|
842 v14 = a5->x;
|
|
843 a5b = 0;
|
|
844 *a1 = v14;
|
|
845 *a2 = v13->z;
|
|
846 if ( pFace->uNumVertices )
|
|
847 {
|
|
848 v15 = a4 + 1;
|
|
849 do
|
|
850 {
|
|
851 v16 = a5b;
|
|
852 a3[2 * a5b] = pFace->pXInterceptDisplacements[a5b] + pIndoor->pVertices[pFace->pVertexIDs[a5b]].x;
|
|
853 *(v15 - 1) = pFace->pZInterceptDisplacements[v16] + pIndoor->pVertices[pFace->pVertexIDs[v16]].z;
|
|
854 *(__int16 *)((char *)v15 + (int)a3 - (int)a4) = pFace->pXInterceptDisplacements[v16 + 1]
|
|
855 + pIndoor->pVertices[pFace->pVertexIDs[v16 + 1]].x;
|
|
856 ++a5b;
|
|
857 *v15 = pFace->pZInterceptDisplacements[v16 + 1] + pIndoor->pVertices[pFace->pVertexIDs[v16 + 1]].z;
|
|
858 v15 += 2;
|
|
859 }
|
|
860 while ( a5b < pFace->uNumVertices );
|
|
861 }
|
|
862 }
|
|
863 }
|
|
864 LOBYTE(result) = 1;
|
|
865 return result;
|
|
866 }
|
|
867
|
|
868 //----- (004C2186) --------------------------------------------------------
|
|
869 bool Vis::_4C2186_BLV_IntersectBModel(int *a1, int *a2, __int16 *a3, __int16 *a4, Vec3_short_ *a5, BLVFace *a6, unsigned int uModelID)
|
|
870 {
|
|
871 bool result; // eax@1
|
|
872 int *v9; // esi@1
|
|
873 unsigned int v10; // ecx@1
|
|
874 unsigned int v11; // edx@3
|
|
875 signed int v12; // ecx@4
|
|
876 __int16 v13; // si@4
|
|
877 __int16 *v14; // ecx@4
|
|
878 unsigned int v15; // edx@8
|
|
879 signed int v16; // ecx@9
|
|
880 __int16 v17; // si@9
|
|
881 __int16 *v18; // ecx@9
|
|
882 unsigned int v19; // edx@12
|
|
883 signed int v20; // ecx@13
|
|
884 __int16 v21; // si@13
|
|
885 __int16 *v22; // ecx@13
|
|
886 signed int a1a; // [sp+14h] [bp+8h]@1
|
|
887 __int16 *a5a; // [sp+24h] [bp+18h]@3
|
|
888 __int16 *a5b; // [sp+24h] [bp+18h]@8
|
|
889 __int16 *a5c; // [sp+24h] [bp+18h]@12
|
|
890
|
|
891 result = (bool)a6;
|
|
892 v9 = a1;
|
|
893 v10 = a6->uAttributes;
|
|
894 a1a = 0;
|
|
895 if ( BYTE1(v10) & 1 )
|
|
896 {
|
|
897 *v9 = a5->x;
|
|
898 *a2 = a5->y;
|
|
899 if ( a6->uNumVertices )
|
|
900 {
|
|
901 v11 = 188 * uModelID + 72;
|
|
902 a5a = a4 + 1;
|
|
903 do
|
|
904 {
|
|
905 v12 = a1a;
|
|
906 a3[2 * a1a] = a6->pXInterceptDisplacements[a1a]
|
79
|
907 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[a1a]);
|
|
908 + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[a1a]].x;
|
0
|
909 *(a5a - 1) = a6->pYInterceptDisplacements[v12]
|
79
|
910 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12] + 4);
|
|
911 + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[v12]].y;
|
0
|
912 *(__int16 *)((char *)a5a + (int)(char *)a3 - (char *)a4) = a6->pXInterceptDisplacements[v12 + 1]
|
79
|
913 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11]
|
|
914 // + 12 * a6->pVertexIDs[v12 + 1]);
|
|
915 + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[v12+1]].x;
|
0
|
916 v13 = a6->pYInterceptDisplacements[v12 + 1]
|
79
|
917 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12 + 1] + 4);
|
|
918 + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[v12 + 1]].y;
|
0
|
919 v14 = a5a;
|
|
920 ++a1a;
|
|
921 a5a += 2;
|
|
922 *v14 = v13;
|
|
923 }
|
|
924 while ( a1a < a6->uNumVertices );
|
|
925 }
|
|
926 }
|
|
927 else
|
|
928 {
|
|
929 if ( BYTE1(v10) & 2 )
|
|
930 {
|
|
931 *v9 = a5->x;
|
|
932 *a2 = a5->z;
|
|
933 if ( a6->uNumVertices )
|
|
934 {
|
|
935 v15 = 188 * uModelID + 72;
|
|
936 a5b = a4 + 1;
|
|
937 do
|
|
938 {
|
|
939 v16 = a1a;
|
|
940 a3[2 * a1a] = a6->pXInterceptDisplacements[a1a]
|
79
|
941 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[a1a]);
|
|
942 + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[a1a]].x;
|
0
|
943 *(a5b - 1) = a6->pZInterceptDisplacements[v16]
|
79
|
944 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16] + 8);
|
|
945 + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[v16]].y;
|
|
946 *(__int16 *)((char *)a5b + (int)a3 - (int)a4) = a6->pXInterceptDisplacements[v16 + 1]
|
|
947 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15]
|
|
948 // + 12 * a6->pVertexIDs[v16 + 1]);
|
|
949 + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[v16+1]].x;
|
0
|
950 v17 = a6->pZInterceptDisplacements[v16 + 1]
|
79
|
951 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16 + 1] + 8);
|
|
952 + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[v16+1]].z;
|
0
|
953 v18 = a5b;
|
|
954 ++a1a;
|
|
955 a5b += 2;
|
|
956 *v18 = v17;
|
|
957 }
|
|
958 while ( a1a < a6->uNumVertices );
|
|
959 }
|
|
960 }
|
|
961 else
|
|
962 {
|
|
963 *v9 = a5->y;
|
|
964 *a2 = a5->z;
|
|
965 if ( a6->uNumVertices )
|
|
966 {
|
|
967 v19 = 188 * uModelID + 72;
|
|
968 a5c = a4 + 1;
|
|
969 do
|
|
970 {
|
|
971 v20 = a1a;
|
|
972 a3[2 * a1a] = a6->pYInterceptDisplacements[a1a]
|
79
|
973 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[a1a] + 4);
|
|
974 + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[a1a]].y;
|
0
|
975 *(a5c - 1) = a6->pZInterceptDisplacements[v20]
|
79
|
976 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20] + 8);
|
|
977 + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[a1a]].z;
|
0
|
978 *(__int16 *)((char *)a5c + (int)(char *)a3 - (char *)a4) = a6->pYInterceptDisplacements[v20 + 1]
|
79
|
979 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19]
|
|
980 // + 12 * a6->pVertexIDs[v20 + 1]
|
|
981 // + 4);
|
|
982 + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[v20+1]].y;
|
|
983 v21 = a6->pZInterceptDisplacements[v20 + 1]
|
|
984 // + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20 + 1] + 8);
|
|
985 + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[v20+1]].z;
|
0
|
986 v22 = a5c;
|
|
987 ++a1a;
|
|
988 a5c += 2;
|
|
989 *v22 = v21;
|
|
990 }
|
|
991 while ( a1a < a6->uNumVertices );
|
|
992 }
|
|
993 }
|
|
994 }
|
|
995 LOBYTE(result) = 1;
|
|
996 return result;
|
|
997 }
|
|
998
|
|
999 //----- (004C248E) --------------------------------------------------------
|
|
1000 void Vis::CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth)
|
|
1001 {
|
|
1002 int v5; // ebx@1
|
|
1003 int v6; // edi@1
|
|
1004 int v7; // esi@1
|
|
1005 Vec3_int_ v8; // ST08_12@1
|
|
1006 int v9; // ST04_4@1
|
|
1007 int v10; // eax@1
|
|
1008 RenderVertexSoft v11[2]; // [sp+2Ch] [bp-74h]@1
|
|
1009 int v12; // [sp+8Ch] [bp-14h]@1
|
|
1010 int v13; // [sp+90h] [bp-10h]@1
|
|
1011 int outz; // [sp+94h] [bp-Ch]@1
|
|
1012 int outy; // [sp+98h] [bp-8h]@1
|
|
1013 int v16; // [sp+9Ch] [bp-4h]@1
|
|
1014
|
|
1015 v5 = pIndoorCamera->pos.y;
|
|
1016 v6 = pIndoorCamera->pos.x;
|
|
1017 v13 = pIndoorCamera->pos.x;
|
|
1018 v12 = pIndoorCamera->pos.y;
|
|
1019 v16 = pIndoorCamera->pos.z;
|
|
1020 v7 = pIndoorCamera->sRotationY + UnprojectX((signed __int64)fMouseX);
|
|
1021 v8.z = v16;
|
|
1022 v8.x = v6;
|
|
1023 v8.y = v5;
|
|
1024 v9 = pIndoorCamera->sRotationX + UnprojectY((signed __int64)fMouseY);
|
|
1025 v10 = _48B561_mess_with_scaling_along_z(/*(int)&fMouseX, */fPickDepth);
|
|
1026 Vec3_int_::Rotate(v10, v7, v9, v8, (int *)&fMouseX, &outy, &outz);
|
|
1027 v11[0].flt_2C = 0.0;
|
|
1028 v11[0].vWorldPosition.x = (double)SLODWORD(fMouseX);
|
|
1029 v11[0].vWorldPosition.y = (double)outy;
|
|
1030 v11[0].vWorldPosition.z = (double)outz;
|
|
1031 v11[1].flt_2C = 0.0;
|
|
1032 v11[1].vWorldPosition.x = (double)v13;
|
|
1033 v11[1].vWorldPosition.y = (double)v12;
|
|
1034 v11[1].vWorldPosition.z = (double)v16;
|
|
1035 memcpy(pRay, &v11[1], 0x30u);
|
|
1036 memcpy(&pRay[1], v11, sizeof(pRay[1]));
|
|
1037 }
|
|
1038
|
|
1039 //----- (004C2551) --------------------------------------------------------
|
194
|
1040 Vis_ObjectInfo *Vis_SelectionList::sub_4C2551(int a2, int a3)
|
0
|
1041 {
|
|
1042 unsigned int v3; // esi@1
|
|
1043 signed int v4; // edx@1
|
|
1044 char *v5; // eax@2
|
194
|
1045 Vis_ObjectInfo *result; // eax@6
|
0
|
1046
|
|
1047 v3 = this->uNumPointers;
|
|
1048 v4 = 0;
|
|
1049 if ( (signed int)v3 <= 0 )
|
|
1050 {
|
|
1051 LABEL_6:
|
|
1052 result = 0;
|
|
1053 }
|
|
1054 else
|
|
1055 {
|
194
|
1056 v5 = (char *)&this->object_pool[0].sZValue;
|
0
|
1057 while ( *((int *)v5 + 1) != a2 || (*(int *)v5 & 0xFFFF) != a3 )
|
|
1058 {
|
|
1059 ++v4;
|
|
1060 v5 += 12;
|
|
1061 if ( v4 >= (signed int)v3 )
|
|
1062 goto LABEL_6;
|
|
1063 }
|
194
|
1064 result = &this->object_pool[v4];
|
0
|
1065 }
|
|
1066 return result;
|
|
1067 }
|
|
1068
|
|
1069 //----- (004C2591) --------------------------------------------------------
|
194
|
1070 void Vis_SelectionList::create_object_pointers(PointerCreationType type)
|
0
|
1071 {
|
194
|
1072 switch (type)
|
|
1073 {
|
|
1074 case All:
|
|
1075 {
|
|
1076 for (uint i = 0; i < uNumPointers; ++i)
|
|
1077 object_pointers[i] = &object_pool[i];
|
|
1078 }
|
|
1079 break;
|
0
|
1080
|
194
|
1081 case Unique: // seems quite retarted; the inner if condition will never trigger, since we compare pointers, not values. pointers will always be unique
|
|
1082 { // but it may be decompilation error thou
|
|
1083 bool create = true;
|
|
1084
|
|
1085 for (uint i = 0; i < uNumPointers; ++i)
|
0
|
1086 {
|
194
|
1087 for (uint j = 0; j < i; ++j)
|
0
|
1088 {
|
194
|
1089 if (object_pointers[j] == &object_pool[i])
|
0
|
1090 {
|
194
|
1091 create = false;
|
|
1092 break;
|
0
|
1093 }
|
|
1094 }
|
194
|
1095
|
|
1096 if (create)
|
|
1097 object_pointers[i] = &object_pool[i];
|
0
|
1098 }
|
|
1099 }
|
196
|
1100 break;
|
194
|
1101
|
|
1102 default:
|
0
|
1103 MessageBoxW(nullptr, L"Unknown pointer creation flag passed to ::create_object_pointers()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:1358", 0);
|
|
1104 }
|
|
1105 }
|
|
1106
|
|
1107 //----- (004C264A) --------------------------------------------------------
|
194
|
1108 void Vis::sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right)
|
0
|
1109 {
|
|
1110 int v4; // edx@1
|
|
1111 int v5; // ebx@1
|
|
1112 int v6; // esi@2
|
|
1113 signed int i; // ecx@2
|
|
1114 int v8; // eax@3
|
|
1115 int v9; // ebx@4
|
|
1116 int v10; // ebx@6
|
194
|
1117 Vis_ObjectInfo *v11; // eax@7
|
0
|
1118 Vis *thisa; // [sp+4h] [bp-4h]@1
|
194
|
1119 Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2
|
0
|
1120
|
|
1121 v4 = left;
|
|
1122 v5 = right;
|
|
1123 thisa = this;
|
|
1124 if ( right > left )
|
|
1125 {
|
|
1126 do
|
|
1127 {
|
|
1128 v6 = v4 - 1;
|
|
1129 a3a = pPointers[v5];
|
|
1130 for ( i = v5; ; pPointers[i] = v11 )
|
|
1131 {
|
|
1132 v8 = a3a->sZValue;
|
|
1133 LOWORD(v8) = 0;
|
|
1134 do
|
|
1135 {
|
|
1136 ++v6;
|
|
1137 v9 = pPointers[v6]->sZValue;
|
|
1138 LOWORD(v9) = 0;
|
|
1139 }
|
|
1140 while ( v9 < (unsigned int)v8 );
|
|
1141 do
|
|
1142 {
|
|
1143 if ( i < 1 )
|
|
1144 break;
|
|
1145 --i;
|
|
1146 v10 = pPointers[i]->sZValue;
|
|
1147 LOWORD(v10) = 0;
|
|
1148 }
|
|
1149 while ( v10 > (unsigned int)v8 );
|
|
1150 v11 = pPointers[v6];
|
|
1151 if ( v6 >= i )
|
|
1152 break;
|
|
1153 pPointers[v6] = pPointers[i];
|
|
1154 }
|
|
1155 v5 = right;
|
|
1156 pPointers[v6] = pPointers[right];
|
|
1157 pPointers[right] = v11;
|
|
1158 sort_object_pointers(pPointers, v4, v6 - 1);
|
|
1159 v4 = v6 + 1;
|
|
1160 }
|
|
1161 while ( right > v6 + 1 );
|
|
1162 }
|
|
1163 }
|
|
1164
|
|
1165 //----- (004C26D0) --------------------------------------------------------
|
|
1166 bool Vis::SortVerticesByX(RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd)
|
|
1167 {
|
|
1168 bool result; // eax@1
|
|
1169 RenderVertexD3D3 *v5; // edx@2
|
|
1170 RenderVertexD3D3 *v6; // esi@2
|
|
1171 void *v7; // edi@2
|
|
1172 unsigned int v8; // ebx@2
|
|
1173 RenderVertexD3D3 *v9; // ecx@3
|
|
1174 RenderVertexD3D3 *v10; // ecx@5
|
|
1175 RenderVertexD3D3 *v11; // eax@8
|
|
1176 RenderVertexD3D3 v12; // [sp+4h] [bp-4Ch]@8
|
|
1177 RenderVertexD3D3 v13; // [sp+24h] [bp-2Ch]@2
|
|
1178 Vis *thisa; // [sp+44h] [bp-Ch]@1
|
|
1179 RenderVertexD3D3 *v15; // [sp+48h] [bp-8h]@2
|
|
1180 unsigned int v16; // [sp+4Ch] [bp-4h]@2
|
|
1181
|
|
1182 result = uEnd;
|
|
1183 thisa = this;
|
|
1184 if ( (signed int)uEnd > (signed int)uStart )
|
|
1185 {
|
|
1186 v5 = a2;
|
|
1187 v6 = &a2[uEnd];
|
|
1188 v7 = &v13;
|
|
1189 v15 = &a2[uEnd];
|
|
1190 v8 = uStart - 1;
|
|
1191 v16 = uEnd;
|
|
1192 while ( 1 )
|
|
1193 {
|
|
1194 memcpy(v7, v6, 0x20u);
|
|
1195 v9 = &v5[v8];
|
|
1196 do
|
|
1197 {
|
|
1198 ++v9;
|
|
1199 ++v8;
|
|
1200 }
|
|
1201 while ( v9->pos.x < (double)v13.pos.x );
|
|
1202 v10 = &v5[v16];
|
|
1203 do
|
|
1204 {
|
|
1205 --v10;
|
|
1206 --v16;
|
|
1207 }
|
|
1208 while ( v10->pos.x > (double)v13.pos.x );
|
|
1209 if ( (signed int)v8 >= (signed int)v16 )
|
|
1210 break;
|
|
1211 v11 = &v5[v16];
|
|
1212 memcpy(&v12, &a2[v8], sizeof(v12));
|
|
1213 v5 = a2;
|
|
1214 memcpy(&a2[v8], v11, sizeof(a2[v8]));
|
|
1215 v6 = &v12;
|
|
1216 v7 = v11;
|
|
1217 }
|
|
1218 memcpy(&v12, &v5[v8], sizeof(v12));
|
|
1219 memcpy(&v5[v8], v15, sizeof(v5[v8]));
|
|
1220 memcpy(v15, &v12, 0x20u);
|
|
1221 SortVerticesByX(v5, uStart, v8 - 1);
|
|
1222 SortVerticesByX(a2, v8 + 1, uEnd);
|
|
1223 }
|
|
1224 return true;
|
|
1225 }
|
|
1226
|
|
1227 //----- (004C27AD) --------------------------------------------------------
|
|
1228 bool Vis::SortVerticesByY(RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd)
|
|
1229 {
|
|
1230 bool result; // eax@1
|
|
1231 RenderVertexD3D3 *v5; // edx@2
|
|
1232 RenderVertexD3D3 *v6; // esi@2
|
30
|
1233 void *v7; // edi@2
|
0
|
1234 unsigned int v8; // ebx@2
|
30
|
1235 float *v9; // ecx@3
|
|
1236 float *v10; // ecx@5
|
|
1237 RenderVertexD3D3 *v11; // eax@8
|
0
|
1238 RenderVertexD3D3 v12; // [sp+4h] [bp-4Ch]@8
|
30
|
1239 RenderVertexD3D3 v13; // [sp+24h] [bp-2Ch]@2
|
0
|
1240 Vis *thisa; // [sp+44h] [bp-Ch]@1
|
30
|
1241 RenderVertexD3D3 *v15; // [sp+48h] [bp-8h]@2
|
|
1242 unsigned int v16; // [sp+4Ch] [bp-4h]@2
|
0
|
1243
|
|
1244 result = uEnd;
|
|
1245 thisa = this;
|
|
1246 if ( (signed int)uEnd > (signed int)uStart )
|
|
1247 {
|
|
1248 v5 = a2;
|
|
1249 v6 = &a2[uEnd];
|
30
|
1250 v7 = &v13;
|
|
1251 v15 = &a2[uEnd];
|
0
|
1252 v8 = uStart - 1;
|
30
|
1253 v16 = uEnd;
|
0
|
1254 while ( 1 )
|
|
1255 {
|
30
|
1256 memcpy(v7, v6, 0x20u);
|
|
1257 v9 = &v5[v8].pos.y;
|
0
|
1258 do
|
|
1259 {
|
30
|
1260 v9+=8;
|
0
|
1261 ++v8;
|
|
1262 }
|
30
|
1263 while ( *v9 < (double)v13.pos.y );
|
|
1264 v10 = &v5[v16].pos.y;
|
0
|
1265 do
|
|
1266 {
|
30
|
1267 v10-=8;
|
|
1268 --v16;
|
0
|
1269 }
|
30
|
1270 while ( *v10 > (double)v13.pos.y );
|
|
1271 if ( (signed int)v8 >= (signed int)v16 )
|
0
|
1272 break;
|
30
|
1273 v11 = &v5[v16];
|
0
|
1274 memcpy(&v12, &a2[v8], sizeof(v12));
|
|
1275 v5 = a2;
|
30
|
1276 memcpy(&a2[v8], v11, sizeof(a2[v8]));
|
0
|
1277 v6 = &v12;
|
30
|
1278 v7 = v11;
|
0
|
1279 }
|
|
1280 memcpy(&v12, &v5[v8], sizeof(v12));
|
30
|
1281 memcpy(&v5[v8], v15, sizeof(v5[v8]));
|
|
1282 memcpy(v15, &v12, 0x20u);
|
194
|
1283 SortVerticesByY(v5, uStart, v8 - 1);
|
|
1284 SortVerticesByY(a2, v8 + 1, uEnd);
|
0
|
1285 }
|
|
1286 return true;
|
|
1287 }
|
|
1288
|
|
1289 //----- (004C288E) --------------------------------------------------------
|
196
|
1290 bool Vis::SortByScreenSpaceX(RenderVertexSoft *pArray, int sLeft, int sRight)
|
0
|
1291 {
|
|
1292 bool result; // eax@1
|
|
1293 RenderVertexSoft *v5; // edx@2
|
|
1294 int v6; // ebx@2
|
|
1295 int i; // ecx@2
|
|
1296 int v8; // esi@3
|
|
1297 int v9; // esi@5
|
159
|
1298 //RenderVertexSoft *v10; // eax@8
|
|
1299 const void *v10;
|
0
|
1300 RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8
|
|
1301 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
|
159
|
1302 //float v13; // [sp+4Ch] [bp-24h]@4
|
0
|
1303 int v14; // [sp+64h] [bp-Ch]@7
|
159
|
1304 //Vis *thisa; // [sp+68h] [bp-8h]@1
|
196
|
1305 //void *thisa;
|
159
|
1306 //RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
|
|
1307 const void *v16;
|
0
|
1308
|
196
|
1309 //thisa = this;
|
159
|
1310 if (sRight <= sLeft)
|
|
1311 return true;
|
|
1312 v5 = pArray;
|
|
1313 v16 = &pArray[sRight];
|
|
1314 v6 = sLeft - 1;
|
|
1315 memcpy(&v12, &pArray[sRight], sizeof(v12));
|
|
1316 for ( i = sRight; ; i = v14 )
|
0
|
1317 {
|
159
|
1318 v8 = (int)&v5[v6].vWorldViewProjX;
|
|
1319 do
|
0
|
1320 {
|
159
|
1321 v8 += 48;
|
|
1322 ++v6;
|
|
1323 }
|
|
1324 while ( *(float *)v8 < v12.vWorldViewProjX);
|
|
1325 v9 = (int)&v5[i].vWorldViewProjX;
|
|
1326 do
|
|
1327 {
|
|
1328 v9 -= 48;
|
|
1329 --i;
|
0
|
1330 }
|
159
|
1331 while ( *(float *)v9 > v12.vWorldViewProjX);
|
|
1332 v14 = i;
|
|
1333 if ( v6 >= i )
|
|
1334 break;
|
|
1335 v10 = &v5[i];
|
|
1336 memcpy(&v11, &pArray[v6], sizeof(v11));
|
|
1337 v5 = pArray;
|
|
1338 memcpy(&pArray[v6], v10, sizeof(pArray[v6]));
|
|
1339 memcpy((void *)v10, &v11, sizeof(0x30u));
|
0
|
1340 }
|
159
|
1341 memcpy(&v11, &v5[v6], sizeof(v11));
|
|
1342 memcpy(&v5[v6], v16, sizeof(v5[v6]));
|
|
1343 memcpy((void *)v16, &v11, sizeof(0x30u));
|
196
|
1344 SortByScreenSpaceX(v5, sLeft, v6 - 1);
|
|
1345 SortByScreenSpaceX(pArray, v6 + 1, sRight);
|
0
|
1346 return true;
|
|
1347 }
|
|
1348
|
|
1349 //----- (004C297E) --------------------------------------------------------
|
196
|
1350 bool Vis::SortByScreenSpaceY(RenderVertexSoft *pArray, int sLeft, int sRight)
|
0
|
1351 {
|
159
|
1352 //bool result; // eax@1
|
0
|
1353 RenderVertexSoft *v5; // edx@2
|
|
1354 int v6; // ebx@2
|
|
1355 int i; // ecx@2
|
|
1356 int v8; // esi@3
|
|
1357 int v9; // esi@5
|
159
|
1358 //RenderVertexSoft *v10; // eax@8
|
|
1359 const void *v10;
|
|
1360 //char v11; // [sp+4h] [bp-6Ch]@8
|
|
1361 RenderVertexSoft v11;
|
0
|
1362 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2
|
159
|
1363 //float v13; // [sp+50h] [bp-20h]@4
|
0
|
1364 int v14; // [sp+64h] [bp-Ch]@7
|
159
|
1365 //Vis *thisa; // [sp+68h] [bp-8h]@1
|
0
|
1366 RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
|
|
1367
|
159
|
1368 if (sRight <= sLeft)
|
|
1369 return true;
|
|
1370 v5 = pArray;
|
|
1371 v16 = &pArray[sRight];
|
|
1372 v6 = sLeft - 1;
|
|
1373 memcpy(&v12, &pArray[sRight], sizeof(v12));
|
|
1374 for ( i = sRight; ; i = v14 )
|
0
|
1375 {
|
159
|
1376 v8 = (int)&v5[v6].vWorldViewProjY;
|
|
1377 do
|
|
1378 {
|
|
1379 v8 += 48;
|
|
1380 ++v6;
|
|
1381 }
|
|
1382 while ( *(float *)v8 < v12.vWorldViewProjY);
|
|
1383 v9 = (int)&v5[v6].vWorldViewProjY;
|
|
1384 do
|
0
|
1385 {
|
159
|
1386 v9 -= 48;
|
|
1387 --i;
|
0
|
1388 }
|
159
|
1389 while ( *(float *)v9 > v12.vWorldViewProjY);
|
|
1390 v14 = i;
|
|
1391 if ( v6 >= i )
|
|
1392 break;
|
|
1393 v10 = &v5[i];
|
|
1394 memcpy(&v11, &pArray[v6], sizeof(0x30));
|
|
1395 v5 = pArray;
|
|
1396 memcpy(&pArray[v6], v10, sizeof(pArray[v6]));
|
|
1397 memcpy((void *)v10, &v11, sizeof(0x30));
|
0
|
1398 }
|
159
|
1399 memcpy(&v11, &v5[v6], sizeof(0x30));
|
|
1400 memcpy(&v5[v6], v16, sizeof(v5[v6]));
|
|
1401 memcpy((void *)v16, &v11, sizeof(0x30));
|
196
|
1402 SortByScreenSpaceY(v5, sLeft, v6 - 1);
|
|
1403 SortByScreenSpaceY(pArray, v6 + 1, sRight);
|
0
|
1404 return true;
|
|
1405 }
|
|
1406
|
|
1407
|
|
1408 //----- (004C04AF) --------------------------------------------------------
|
|
1409 Vis::Vis()
|
|
1410 {
|
|
1411 RenderVertexSoft v3; // [sp+Ch] [bp-60h]@1
|
|
1412 RenderVertexSoft v4; // [sp+3Ch] [bp-30h]@1
|
|
1413
|
|
1414 v3.flt_2C = 0.0;
|
|
1415 v3.vWorldPosition.x = 0.0;
|
|
1416 v3.vWorldPosition.y = 65536.0;
|
|
1417 v3.vWorldPosition.z = 0.0;
|
|
1418 v4.flt_2C = 0.0;
|
|
1419 v4.vWorldPosition.x = 65536.0;
|
|
1420 v4.vWorldPosition.y = 0.0;
|
|
1421 v4.vWorldPosition.z = 0.0;
|
196
|
1422 memcpy(&stru_200C, &v4, sizeof(stru_200C));
|
|
1423
|
0
|
1424 v4.flt_2C = 0.0;
|
|
1425 v4.vWorldPosition.x = 0.0;
|
|
1426 v4.vWorldPosition.y = 65536.0;
|
|
1427 v4.vWorldPosition.z = 0.0;
|
196
|
1428 memcpy(&stru_203C, &v3, sizeof(stru_203C));
|
|
1429
|
0
|
1430 v3.flt_2C = 0.0;
|
|
1431 v3.vWorldPosition.x = 65536.0;
|
|
1432 v3.vWorldPosition.y = 0.0;
|
|
1433 v3.vWorldPosition.z = 0.0;
|
196
|
1434 memcpy(&stru_206C, &v3, sizeof(stru_206C));
|
|
1435 memcpy(&stru_209C, &v4, sizeof(stru_209C));
|
|
1436
|
|
1437 keyboard_pick_depth = 512;
|
0
|
1438 }
|
|
1439
|
|
1440 //----- (004C055C) --------------------------------------------------------
|
194
|
1441 Vis_SelectionList::Vis_SelectionList()
|
0
|
1442 {
|
|
1443 for (uint i = 0; i < 512; ++i)
|
|
1444 {
|
194
|
1445 object_pool[i].object = nullptr;
|
|
1446 object_pool[i].sZValue = -1;
|
|
1447 object_pool[i].object_type = VisObjectType_Any;
|
0
|
1448 }
|
|
1449 uNumPointers = 0;
|
|
1450 }
|
|
1451
|
|
1452 //----- (004C05CC) --------------------------------------------------------
|
194
|
1453 bool Vis::PickKeyboard(Vis_SelectionList *list, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
|
0
|
1454 {
|
194
|
1455 if (!list)
|
|
1456 list = &default_list;
|
|
1457 list->uNumPointers = 0;
|
0
|
1458
|
196
|
1459 PickBillboards_Keyboard(keyboard_pick_depth, list, sprite_filter);
|
194
|
1460 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
196
|
1461 PickIndoorFaces_Keyboard(keyboard_pick_depth, list, face_filter);
|
194
|
1462 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
196
|
1463 PickOutdoorFaces_Keyboard(keyboard_pick_depth, list, face_filter);
|
0
|
1464 else
|
194
|
1465 assert(false);
|
|
1466
|
|
1467 list->create_object_pointers(Vis_SelectionList::Unique);
|
|
1468 sort_object_pointers(list->object_pointers, 0, list->uNumPointers - 1);
|
|
1469
|
0
|
1470 return true;
|
|
1471 }
|
|
1472
|
|
1473 //----- (004C0646) --------------------------------------------------------
|
194
|
1474 bool Vis::PickMouse(float fDepth, float fMouseX, float fMouseY, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
|
0
|
1475 {
|
|
1476 RenderVertexSoft pMouseRay[2]; // [sp+1Ch] [bp-60h]@1
|
|
1477
|
194
|
1478 default_list.uNumPointers = 0;
|
0
|
1479 CastPickRay(pMouseRay, fMouseX, fMouseY, fDepth);
|
194
|
1480 PickBillboards_Mouse(fDepth, fMouseX, fMouseY, &default_list, sprite_filter);
|
0
|
1481 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
196
|
1482 PickIndoorFaces_Mouse(fDepth, pMouseRay, &default_list, face_filter);
|
227
|
1483 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
1484 PickOutdoorFaces_Mouse(fDepth, pMouseRay, &default_list, face_filter, false);
|
0
|
1485 else
|
227
|
1486 {
|
|
1487 Log::Warning(L"Picking mouse in undefined level"); // picking in main menu is default (buggy) game behavious. should've returned false in Game::PickMouse
|
|
1488 return false;
|
|
1489 }
|
194
|
1490 default_list.create_object_pointers(Vis_SelectionList::All);
|
|
1491 sort_object_pointers(default_list.object_pointers, 0, default_list.uNumPointers - 1);
|
|
1492
|
0
|
1493 return true;
|
|
1494 }
|
|
1495
|
|
1496 //----- (004C06F8) --------------------------------------------------------
|
196
|
1497 void Vis::PickBillboards_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter)
|
0
|
1498 {
|
194
|
1499 for (int i = 0; i < pRenderer->uNumBillboardsToDraw; ++i)
|
|
1500 {
|
|
1501 auto d3d_billboard = &pRenderer->pBillboardRenderListD3D[i];
|
0
|
1502
|
194
|
1503 if (is_part_of_selection((void *)i, filter))
|
0
|
1504 {
|
194
|
1505 if (DoesRayIntersectBillboard(pick_depth, i))
|
0
|
1506 {
|
194
|
1507 auto billboard = &pBillboardRenderList[d3d_billboard->uParentBillboardID];
|
|
1508
|
|
1509 list->AddObject((void *)d3d_billboard->uParentBillboardID, VisObjectType_Sprite, billboard->sZValue);
|
0
|
1510 }
|
|
1511 }
|
|
1512 }
|
|
1513 }
|
|
1514
|
194
|
1515
|
|
1516 // tests the object against selection filter to determine whether it can be picked or not
|
0
|
1517 //----- (004C0791) --------------------------------------------------------
|
194
|
1518 bool Vis::is_part_of_selection(void *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, Vis_SelectionFilter *filter)
|
0
|
1519 {
|
194
|
1520 //stru157 *v3; // esi@1
|
|
1521 //int result; // eax@1
|
0
|
1522 int v5; // edx@2
|
194
|
1523 //int v6; // ecx@2
|
|
1524 //char v7; // zf@3
|
0
|
1525 int v8; // esi@5
|
|
1526 std::string *v9; // ecx@7
|
|
1527 Actor *v10; // edi@18
|
194
|
1528 //const char *v12; // [sp-20h] [bp-2Ch]@7
|
0
|
1529 int v13; // [sp-1Ch] [bp-28h]@7
|
194
|
1530 //std::string v14; // [sp-18h] [bp-24h]@7
|
|
1531 //const char *v15; // [sp-8h] [bp-14h]@7
|
0
|
1532 int v16; // [sp-4h] [bp-10h]@7
|
|
1533
|
194
|
1534 switch (filter->object_type)
|
0
|
1535 {
|
194
|
1536 case VisObjectType_Any:
|
|
1537 return true;
|
|
1538
|
|
1539 case VisObjectType_Sprite:
|
0
|
1540 {
|
194
|
1541 v5 = filter->field_10;
|
|
1542 int object_idx = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 0xFFFF) >> 3;
|
|
1543 int object_type = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 7;
|
|
1544 if ( v5 & 2 )
|
|
1545 {
|
|
1546 if (object_type == filter->object_id)
|
|
1547 return false;
|
|
1548 return true;
|
|
1549 }
|
|
1550 if ( v5 & 4 )
|
|
1551 {
|
|
1552 v8 = filter->object_id;
|
|
1553 if ( object_type != filter->object_id)
|
|
1554 return true;
|
|
1555 if (v8 != OBJECT_Decoration)
|
|
1556 {
|
|
1557 MessageBoxA(nullptr, "Unsupported \"exclusion if no event\" type in CVis::is_part_of_selection", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:207", 0);
|
|
1558 return true;
|
|
1559 }
|
|
1560 if (pLevelDecorations[object_idx].uCog || pLevelDecorations[object_idx].field_16_event_id)
|
|
1561 return true;
|
|
1562 return pLevelDecorations[object_idx].IsInteractive();
|
|
1563 }
|
|
1564 if (object_type == filter->object_id)
|
|
1565 {
|
|
1566 if (object_type != OBJECT_Actor)
|
|
1567 {
|
|
1568 MessageBoxA(nullptr, "Default case reached in VIS", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:245", 0);
|
|
1569 return true;
|
|
1570 }
|
|
1571
|
|
1572 v10 = &pActors[object_idx];
|
|
1573 int result = 1 << LOBYTE(v10->uAIState);
|
|
1574 if ( result & filter->field_C
|
|
1575 || !(result & filter->field_8)
|
|
1576 || v5 & 8 && (result = MonsterStats::BelongsToSupertype(v10->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) == 0 )
|
|
1577 return false;
|
|
1578 if ( !(filter->field_10 & 1) )
|
|
1579 return true;
|
|
1580
|
|
1581 result = v10->GetActorsRelation(nullptr);
|
|
1582 if (result == 0)
|
|
1583 return false;
|
|
1584 return true;
|
|
1585 }
|
|
1586 return false;
|
0
|
1587 }
|
194
|
1588
|
|
1589 case VisObjectType_Face:
|
0
|
1590 {
|
194
|
1591 uint face_attrib = 0;
|
|
1592 bool no_event = true;
|
|
1593 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
1594 {
|
|
1595 auto face = (ODMFace *)uD3DBillboardIdx_or_pBLVFace_or_pODMFace;
|
|
1596 no_event = face->sCogTriggeredID == 0;
|
|
1597 face_attrib = face->uAttributes;
|
|
1598 }
|
|
1599 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
1600 {
|
|
1601 auto face = (BLVFace *)uD3DBillboardIdx_or_pBLVFace_or_pODMFace;
|
|
1602 no_event = pIndoor->pFaceExtras[face->uFaceExtraID].uEventID == 0;
|
|
1603 face_attrib = face->uAttributes;
|
|
1604 }
|
|
1605 else
|
|
1606 assert(false);
|
|
1607
|
|
1608 if (filter->object_id != OBJECT_BLVDoor)
|
|
1609 return true;
|
|
1610 if (no_event || face_attrib & filter->field_C)
|
|
1611 return false;
|
|
1612 return (face_attrib & filter->field_8) != 0;
|
0
|
1613 }
|
194
|
1614
|
|
1615 default:
|
|
1616 assert(false);
|
0
|
1617 }
|
|
1618 }
|
|
1619
|
|
1620 //----- (004C091D) --------------------------------------------------------
|
|
1621 bool Vis::DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx)
|
|
1622 {
|
159
|
1623 int v3; // eax@3
|
|
1624 //signed int v5; // ecx@4
|
|
1625 //float v6; // ST04_4@6
|
|
1626 //float v7; // ST00_4@7
|
194
|
1627 //int v8; // eax@10
|
|
1628 //unsigned int v9; // eax@12
|
159
|
1629 int v10; // eax@17
|
|
1630 double v11; // st6@18
|
|
1631 double v12; // st7@18
|
|
1632 double v13; // st4@18
|
|
1633 float v14; // ST0C_4@22
|
|
1634 float v15; // ST08_4@22
|
|
1635 //float v16; // ST04_4@23
|
|
1636 //float v17; // ST00_4@24
|
194
|
1637 //signed int v18; // eax@27
|
|
1638 //unsigned int v19; // eax@29
|
159
|
1639 double v20; // st6@32
|
|
1640 double v21; // st7@32
|
|
1641 int v22; // eax@32
|
|
1642 double v23; // st7@36
|
|
1643 //void *v24; // esi@40
|
|
1644 float v25; // ST08_4@40
|
|
1645 //float v26; // ST04_4@41
|
|
1646 //float v27; // ST00_4@42
|
|
1647 int v28; // eax@45
|
|
1648 unsigned int v29; // eax@47
|
|
1649 char result; // al@48
|
|
1650 struct RenderVertexSoft pPickingRay[2];
|
|
1651 //int v31; // [sp+20h] [bp-DCh]@5
|
|
1652 struct RenderVertexSoft local_80[2];
|
|
1653 //int v32; // [sp+80h] [bp-7Ch]@22
|
|
1654 float v33; // [sp+E0h] [bp-1Ch]@33
|
|
1655 float v34; // [sp+E4h] [bp-18h]@32
|
|
1656 int v35; // [sp+E8h] [bp-14h]@5
|
|
1657 int v36; // [sp+ECh] [bp-10h]@5
|
194
|
1658 int v37; // [sp+F0h] [bp-Ch]@5
|
159
|
1659 float v38; // [sp+F4h] [bp-8h]@17
|
|
1660 //void *v39; // [sp+F8h] [bp-4h]@1
|
|
1661 signed int v40; // [sp+108h] [bp+Ch]@17
|
|
1662 float v41; // [sp+108h] [bp+Ch]@32
|
0
|
1663
|
194
|
1664 static Vis_SelectionList Vis_static_stru_F91E10;
|
0
|
1665 Vis_static_stru_F91E10.uNumPointers = 0;
|
159
|
1666 v3 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].uParentBillboardID;
|
|
1667 if (v3 == -1)
|
|
1668 return false;
|
|
1669 if (pBillboardRenderList[v3].GetFloatZ() > fDepth)
|
0
|
1670 {
|
159
|
1671 LABEL_49:
|
|
1672 return false;
|
|
1673 }
|
194
|
1674
|
159
|
1675 v37 = pBillboardRenderList[v3].sZValue & 0xFFFF0000;
|
|
1676 GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuards, 4, (float *)&v35, (float *)&v36);
|
194
|
1677 CastPickRay(pPickingRay, *(float *)&v35, *(float *)&v36, fDepth);
|
|
1678 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
196
|
1679 PickIndoorFaces_Mouse(fDepth, pPickingRay, &Vis_static_stru_F91E10, &vis_face_filter);
|
0
|
1680 else
|
196
|
1681 PickOutdoorFaces_Mouse(fDepth, pPickingRay, &Vis_static_stru_F91E10, &vis_face_filter, false);
|
194
|
1682 Vis_static_stru_F91E10.create_object_pointers();
|
|
1683 sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1);
|
159
|
1684 if (Vis_static_stru_F91E10.uNumPointers)
|
0
|
1685 {
|
194
|
1686 if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z)
|
|
1687 return 1;
|
159
|
1688 }
|
|
1689 else if ((double)(pViewport->uScreenX) <= *(float *)&v35 &&
|
|
1690 (double)pViewport->uScreenZ >= *(float *)&v35 &&
|
|
1691 (double)pViewport->uScreenY <= *(float *)&v36 &&
|
|
1692 (double)pViewport->uScreenW >= *(float *)&v36)
|
|
1693 return 1;
|
|
1694 v40 = 0;
|
|
1695 v10 = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y;
|
|
1696 LODWORD(v38) = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y;
|
0
|
1697 while ( 1 )
|
|
1698 {
|
159
|
1699 v12 = *(float *)(v10 - 4);
|
|
1700 v11 = *(float *)v10;
|
|
1701 v13 = *(float *)(v10 - 4);
|
0
|
1702 Vis_static_stru_F91E10.uNumPointers = 0;
|
159
|
1703 if ( v13 >= (double)(pViewport->uScreenX))
|
0
|
1704 {
|
159
|
1705 if ( v12 <= (double)pViewport->uScreenZ )
|
0
|
1706 {
|
159
|
1707 if ( v11 >= (double)pViewport->uScreenY )
|
|
1708 {
|
|
1709 if ( v11 <= (double)pViewport->uScreenW )
|
|
1710 {
|
|
1711 v14 = v11;
|
|
1712 v15 = v12;
|
|
1713 CastPickRay(local_80, SLODWORD(v15), v14, fDepth);
|
|
1714 if ( uCurrentlyLoadedLevelType == 1 )
|
196
|
1715 PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter);
|
159
|
1716 else
|
196
|
1717 PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false);
|
194
|
1718 Vis_static_stru_F91E10.create_object_pointers();
|
|
1719 sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1);
|
159
|
1720 if ( !Vis_static_stru_F91E10.uNumPointers )
|
|
1721 break;
|
194
|
1722 else
|
|
1723 {
|
|
1724 //v18 = Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : (int);
|
|
1725 //v19 = *(_DWORD *)(v18 + 4);
|
|
1726 //LOWORD(v19) = 0;
|
|
1727 if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z)
|
159
|
1728 break;
|
194
|
1729 }
|
159
|
1730 }
|
|
1731 }
|
0
|
1732 }
|
|
1733 }
|
159
|
1734 ++v40;
|
|
1735 v10 = LODWORD(v38) + 32;
|
|
1736 LODWORD(v38) += 32;
|
|
1737 if ( v40 >= 4 )
|
0
|
1738 {
|
159
|
1739 if ( uCurrentlyLoadedLevelType != 2 )
|
|
1740 return false;
|
|
1741 v21 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.x;
|
|
1742 v20 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x;
|
|
1743 v22 = *(int *)(&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y);
|
|
1744 v34 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x;
|
|
1745 LODWORD(v38) = v22;
|
|
1746 v41 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[1].pos.y;
|
|
1747 if ( v21 > v20 )
|
0
|
1748 {
|
159
|
1749 v33 = v21;
|
|
1750 v21 = v34;
|
|
1751 v20 = v33;
|
0
|
1752 }
|
159
|
1753 if ( v38 > (double)v41 )
|
|
1754 v41 = v38;
|
|
1755 Vis_static_stru_F91E10.uNumPointers = 0;
|
|
1756 v23 = (v20 - v21) * 0.5;
|
|
1757 if ( v23 < (double)(pViewport->uScreenX)
|
|
1758 || v23 > (double)pViewport->uScreenZ
|
|
1759 || (double)pViewport->uScreenY > v41
|
|
1760 || (double)pViewport->uScreenW < v41
|
|
1761 || ((v25 = v23, CastPickRay(local_80, SLODWORD(v25), v41, fDepth), uCurrentlyLoadedLevelType != 1) ?
|
196
|
1762 (PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false)) :
|
|
1763 (PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter)),
|
194
|
1764 (Vis_static_stru_F91E10.create_object_pointers(),
|
|
1765 sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1),
|
159
|
1766 Vis_static_stru_F91E10.uNumPointers)
|
194
|
1767 && (Vis_static_stru_F91E10.uNumPointers <= 0 ? (v28 = 0) : (v28 = (int)Vis_static_stru_F91E10.object_pointers),
|
159
|
1768 v29 = *(_DWORD *)(v28 + 4),
|
|
1769 LOWORD(v29) = 0,
|
|
1770 v29 <= v37)) )
|
|
1771 return false;
|
0
|
1772 break;
|
|
1773 }
|
|
1774 }
|
194
|
1775 return true;
|
0
|
1776 }
|
|
1777 // F93E18: using guessed type char static_byte_F93E18_init;
|
|
1778
|
|
1779 //----- (004C0D32) --------------------------------------------------------
|
196
|
1780 void Vis::PickIndoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter)
|
0
|
1781 {
|
|
1782 int result; // eax@1
|
|
1783 signed int v5; // esi@2
|
|
1784 BLVFace *v6; // edi@4
|
|
1785 unsigned int v7; // eax@6
|
194
|
1786 Vis_ObjectInfo *v8; // eax@6
|
|
1787 //int v9; // ST18_4@7
|
|
1788 //unsigned int v10; // ST1C_4@7
|
|
1789 //unsigned int v11; // ecx@7
|
0
|
1790 signed int i; // [sp+18h] [bp-8h]@1
|
|
1791 Vis *thisa; // [sp+1Ch] [bp-4h]@1
|
|
1792
|
|
1793 result = 0;
|
|
1794 thisa = this;
|
|
1795 for ( i = 0; i < (signed int)pBspRenderer->uNumFaceIDs; ++i )
|
|
1796 {
|
|
1797 v5 = pBspRenderer->pFaceIDs[2 * result];
|
|
1798 if ( v5 >= 0 )
|
|
1799 {
|
|
1800 if ( v5 < (signed int)pIndoor->uNumFaces )
|
|
1801 {
|
|
1802 v6 = &pIndoor->pFaces[v5];
|
|
1803 if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v5]) )
|
|
1804 {
|
194
|
1805 if ( is_part_of_selection(v6, filter) )
|
0
|
1806 {
|
|
1807 v7 = 8 * v5;
|
194
|
1808 LOBYTE(v7) = 8 * v5 | OBJECT_BModel;
|
|
1809 v8 = _4C1026(v6, v7, pick_depth);
|
0
|
1810 if ( v8 )
|
194
|
1811 list->AddObject(v8->object, v8->object_type, v8->sZValue);
|
0
|
1812 }
|
|
1813 }
|
|
1814 }
|
|
1815 }
|
|
1816 result = i + 1;
|
|
1817 }
|
|
1818 }
|
|
1819
|
|
1820 //----- (004C0DEA) --------------------------------------------------------
|
196
|
1821 void Vis::PickOutdoorFaces_Keyboard(float pick_depth, Vis_SelectionList *list, Vis_SelectionFilter *filter)
|
0
|
1822 {
|
196
|
1823 for (uint i = 0; i < pOutdoor->uNumBModels; ++i)
|
|
1824 {
|
|
1825 int v17;
|
|
1826 if (!IsBModelVisible(i, &v17))
|
|
1827 continue;
|
|
1828 if (!v17)
|
|
1829 continue;
|
0
|
1830
|
196
|
1831 auto bmodel = pOutdoor->pBModels + i;
|
|
1832 for (uint j = 0; j < bmodel->uNumFaces; ++j)
|
0
|
1833 {
|
196
|
1834 auto face = bmodel->pFaces + j;
|
|
1835
|
|
1836 if (is_part_of_selection(face, filter) )
|
0
|
1837 {
|
196
|
1838 BLVFace blv_face;
|
|
1839 blv_face.FromODM(face);
|
|
1840
|
|
1841 int pid = 8 * (j | (i << 6)) | OBJECT_BModel;
|
|
1842 if (auto object_info = _4C1026(&blv_face, pid, pick_depth))
|
|
1843 list->AddObject(object_info->object, object_info->object_type, object_info->sZValue);
|
0
|
1844 }
|
|
1845 }
|
|
1846 }
|
|
1847 } |