annotate Vis.cpp @ 1029:c94d6a37d298

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