annotate Vis.cpp @ 2488:e8130e8c116f

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