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