annotate Vis.cpp @ 709:af08fc9e29c8

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