annotate Vis.cpp @ 1974:0f62a2b8bd0a

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