0
|
1 #include "LightmapBuilder.h"
|
|
2 #include "Game.h"
|
|
3 #include "stru314.h"
|
|
4 #include "Outdoor.h"
|
|
5
|
|
6 #include "mm7_data.h"
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14 LightsStack_StationaryLight_ *pStationaryLightsStack;
|
|
15 StationaryLight pStationaryLights[400];
|
|
16 int uNumStationaryLightsApplied; // weak
|
|
17 LightsStack_MobileLight_ *pMobileLightsStack;
|
|
18 MobileLight pMobileLights[400];
|
|
19 int uNumMobileLightsApplied;
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25 //----- (0045DF13) --------------------------------------------------------
|
|
26 Lightmap::Lightmap()
|
|
27 {
|
|
28 field_C18 = 0;
|
|
29 }
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35 //----- (0045BB06) --------------------------------------------------------
|
|
36 LightmapBuilder::LightmapBuilder()
|
|
37 {
|
|
38 //std__vector_000004.reserve(512);
|
|
39 //std__vector_183808.reserve(768);
|
|
40
|
|
41 for (uint i = 0; i < 256; ++i)
|
|
42 field_3C8C34[i].flt_2C = 0.0f;
|
|
43 }
|
|
44
|
|
45
|
|
46
|
|
47
|
|
48
|
|
49 //----- (0045BC07) --------------------------------------------------------
|
|
50 char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char a7)
|
|
51 {
|
|
52 char *v7; // eax@3
|
|
53 signed int v8; // ecx@3
|
|
54 RenderVertexSoft *v9; // eax@10
|
|
55 unsigned int v10; // edx@10
|
|
56 const void *v11; // esi@11
|
|
57 void *v12; // edi@11
|
|
58 char v13; // zf@11
|
|
59 stru154 *v14; // esi@12
|
|
60 double v16; // st7@17
|
|
61 double v17; // st6@17
|
|
62 float v18; // eax@17
|
|
63 int *v19; // esi@20
|
|
64 double v20; // st7@21
|
|
65 int v21; // eax@21
|
|
66 unsigned int v22; // eax@21
|
|
67 int v23; // ecx@23
|
|
68 float v24; // ST04_4@23
|
|
69 float v25; // [sp+8h] [bp-64h]@18
|
|
70 Vec3_float_ *v26; // [sp+18h] [bp-54h]@17
|
|
71 int v27; // [sp+1Ch] [bp-50h]@17
|
|
72 int arg0; // [sp+2Ch] [bp-40h]@21
|
|
73 int v29; // [sp+30h] [bp-3Ch]@21
|
|
74 int v30; // [sp+34h] [bp-38h]@21
|
2
|
75 //double v31; // [sp+38h] [bp-34h]@21
|
|
76 //double v32; // [sp+40h] [bp-2Ch]@21
|
|
77 //double v33; // [sp+48h] [bp-24h]@21
|
0
|
78 int v34; // [sp+50h] [bp-1Ch]@24
|
|
79 LightmapBuilder *thisa; // [sp+54h] [bp-18h]@1
|
|
80 int v36; // [sp+58h] [bp-14h]@21
|
|
81 int v37; // [sp+5Ch] [bp-10h]@21
|
|
82 unsigned __int64 v38; // [sp+60h] [bp-Ch]@21
|
|
83 int a9; // [sp+68h] [bp-4h]@8
|
|
84
|
|
85 thisa = this;
|
|
86 if ( !uNumVertices )
|
|
87 return 0;
|
|
88
|
|
89 static bool _static_initialized = false;
|
|
90 static RenderVertexSoft LightmapBuilder_static_sub_45BC07_stru_69B140[64];
|
|
91 if (!_static_initialized)
|
|
92 {
|
|
93 for (uint i = 0; i < 64; ++i)
|
|
94 LightmapBuilder_static_sub_45BC07_stru_69B140[i].flt_2C = 0.0f;
|
|
95 _static_initialized = true;
|
|
96 }
|
|
97
|
|
98 a9 = (int)a5;
|
|
99 if ( a6 == 0.0 )
|
|
100 {
|
|
101 v14 = a3;
|
|
102 }
|
|
103 else
|
|
104 {
|
|
105 if ( (signed int)uNumVertices > 0 )
|
|
106 {
|
|
107 v9 = LightmapBuilder_static_sub_45BC07_stru_69B140;
|
|
108 v10 = (char *)a5 - (char *)LightmapBuilder_static_sub_45BC07_stru_69B140;
|
|
109 a5 = (RenderVertexSoft *)uNumVertices;
|
|
110 do
|
|
111 {
|
|
112 v11 = (char *)v9 + v10;
|
|
113 v12 = v9;
|
|
114 ++v9;
|
|
115 v13 = a5 == (RenderVertexSoft *)1;
|
|
116 a5 = (RenderVertexSoft *)((char *)a5 - 1);
|
|
117 memcpy(v12, v11, 0x30u);
|
|
118 }
|
|
119 while ( !v13 );
|
|
120 }
|
|
121 v14 = a3;
|
|
122 if ( pGame->pIndoorCameraD3D->_437376(
|
|
123 a3,
|
|
124 LightmapBuilder_static_sub_45BC07_stru_69B140,
|
|
125 &uNumVertices) == 1 )
|
|
126 {
|
|
127 if ( !uNumVertices )
|
|
128 return 0;
|
|
129 a9 = (int)LightmapBuilder_static_sub_45BC07_stru_69B140;
|
|
130 }
|
|
131 }
|
|
132 v16 = v14->vNormal.z;
|
|
133 v17 = v14->vNormal.y;
|
|
134 v18 = v14->vNormal.x;
|
|
135
|
|
136 static stru314 LightmapBuilder_static_sub_45BC07_stru_69B110;
|
|
137 v27 = (int)&LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C;
|
|
138 LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.y = v17;
|
|
139 LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.x = v18;
|
|
140 v26 = &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10;
|
|
141 LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.z = v16;
|
|
142 dword_69B138 = LODWORD(v14->field_10);
|
|
143 if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
|
|
144 v14->field_14,
|
|
145 &LightmapBuilder_static_sub_45BC07_stru_69B110.field_4,
|
|
146 &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10,
|
|
147 &LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C) )
|
|
148 {
|
|
149 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0);
|
|
150 ExitProcess(0);
|
|
151 }
|
|
152 a5 = 0;
|
|
153 if ( a2->field_AC > 0 )
|
|
154 {
|
|
155 v19 = a2->_blv_lights_ys;
|
|
156 do
|
|
157 {
|
|
158 v20 = *((float *)v19 + 80) * 255.0;
|
|
159 arg0 = *(v19 - 20);
|
|
160 v29 = *v19;
|
|
161 v30 = v19[60];
|
|
162 v21 = *(v19 - 60);
|
|
163 a6 = v20;
|
|
164 v36 = v21;
|
|
165 v37 = v19[20];
|
2
|
166 //v33 = a6 + 6.7553994e15;
|
0
|
167 a6 = *((float *)v19 + 100) * 255.0;
|
2
|
168 //v32 = a6 + 6.7553994e15;
|
0
|
169 a6 = *((float *)v19 + 120) * 255.0;
|
2
|
170 //v31 = a6 + 6.7553994e15;
|
|
171 //v38 = __PAIR__(LODWORD(v32), LODWORD(v31));
|
3
|
172 v38 = __PAIR__((int)floorf(a6 + 0.5f), (int)floorf(a6 + 0.5f));
|
2
|
173 //v22 = LODWORD(v31) | ((LODWORD(v32) | (LODWORD(v33) << 8)) << 8);
|
3
|
174 v22 = (int)floorf(a6 + 0.5f) | (((int)floorf(a6 + 0.5f) | ((int)floorf(a6 + 0.5f) << 8)) << 8);
|
2
|
175 if (!v22)
|
|
176 v22 = 0x00FFFFFF;
|
0
|
177 v27 = a7;
|
|
178 v23 = (int)a5;
|
|
179 v26 = (Vec3_float_ *)a9;
|
|
180 LOBYTE(v23) = *((unsigned char *)&a5[20].vWorldViewPosition.y + (unsigned int)a2);
|
|
181 v25 = (double)v37;
|
|
182 v24 = (double)v36;
|
|
183 if ( !_45BE86_build_light_polygon(
|
|
184 (int)&arg0,
|
|
185 v24,
|
|
186 v22,
|
|
187 v25,
|
|
188 v23,
|
|
189 &LightmapBuilder_static_sub_45BC07_stru_69B110,
|
|
190 uNumVertices,
|
|
191 (RenderVertexSoft *)a9,
|
|
192 a7) )
|
|
193 {
|
|
194 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
|
|
195 v34 = 5080748;
|
|
196 }
|
|
197 a5 = (RenderVertexSoft *)((char *)a5 + 1);
|
|
198 ++v19;
|
|
199 }
|
|
200 while ( (signed int)a5 < a2->field_AC );
|
|
201 }
|
|
202 return 1;
|
|
203 }
|
|
204
|
|
205 //----- (0045BE86) --------------------------------------------------------
|
|
206 char LightmapBuilder::_45BE86_build_light_polygon(int arg0, float a4, int arg8, float a5, int uLightType, stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag)
|
|
207 {
|
|
208 LightmapBuilder *v10; // esi@1
|
|
209 Lightmap *v11; // edi@3
|
|
210 double v12; // st7@5
|
|
211 double v13; // st7@5
|
|
212 stru314 *v14; // ebx@5
|
|
213 double v15; // st7@5
|
|
214 RenderVertexSoft *pLightmapVertices; // edx@5
|
|
215 double v17; // st7@5
|
|
216 double v18; // st7@5
|
|
217 char *v19; // eax@5
|
|
218 double v20; // st6@5
|
|
219 double v21; // st5@5
|
|
220 signed int v22; // ecx@5
|
|
221 double v23; // st5@5
|
|
222 double v24; // st7@6
|
|
223 int v25; // ebx@8
|
|
224 double v26; // st7@8
|
|
225 int v27; // eax@8
|
|
226 double v28; // st6@8
|
|
227 double v29; // st6@8
|
|
228 double v30; // st5@8
|
|
229 int v31; // eax@8
|
|
230 int v32; // ebx@8
|
|
231 unsigned int v33; // ecx@8
|
|
232 int v34; // edx@9
|
|
233 int v35; // edx@11
|
|
234 unsigned int v36; // edx@13
|
|
235 int v37; // ecx@14
|
|
236 double v38; // st7@14
|
|
237 double v39; // st7@16
|
|
238 double v40; // st7@16
|
|
239 double v41; // st7@22
|
|
240 stru9 *v42; // ecx@22
|
|
241 char result; // al@22
|
|
242 unsigned int *v44; // ebx@23
|
|
243 int v45; // eax@24
|
|
244 RenderVertexSoft *v46; // edi@27
|
|
245 std::string *v47; // ecx@34
|
|
246 char *v48; // esi@39
|
|
247 int v49; // eax@39
|
|
248 unsigned __int8 v50; // sf@39
|
|
249 unsigned __int8 v51; // of@39
|
|
250 const char *v52; // [sp-Ch] [bp-58h]@34
|
|
251 int v53; // [sp-8h] [bp-54h]@34
|
|
252 std::string v54; // [sp-4h] [bp-50h]@19
|
|
253 float v55; // [sp+0h] [bp-4Ch]@22
|
|
254 float v56; // [sp+4h] [bp-48h]@22
|
|
255 int v57; // [sp+8h] [bp-44h]@22
|
|
256 unsigned int v58; // [sp+Ch] [bp-40h]@16
|
|
257 void *v59; // [sp+10h] [bp-3Ch]@16
|
|
258 float v60; // [sp+20h] [bp-2Ch]@8
|
|
259 float v61; // [sp+24h] [bp-28h]@8
|
|
260 float v62; // [sp+28h] [bp-24h]@8
|
|
261 Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
|
2
|
262 //double v64; // [sp+38h] [bp-14h]@8
|
0
|
263 int pLightmapVertices_; // [sp+40h] [bp-Ch]@5
|
|
264 float v66; // [sp+44h] [bp-8h]@5
|
|
265 char v67; // [sp+4Bh] [bp-1h]@2
|
|
266 float arg0b; // [sp+54h] [bp+8h]@8
|
|
267 int arg0c; // [sp+54h] [bp+8h]@8
|
|
268 int arg0a; // [sp+54h] [bp+8h]@8
|
|
269
|
|
270 v10 = this;
|
|
271 if ( a4 == 0.0 )
|
|
272 return 1;
|
|
273 v67 = uLightType & 1;
|
|
274 v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] :
|
|
275 &std__vector_183808[std__vector_183808_size];
|
|
276 v12 = a4 - a5;
|
|
277 this->flt_3C8C24 = v12;
|
|
278 v13 = sqrt((a4 + a4 - v12) * v12);
|
|
279 v10->flt_3C8C28 = v13;
|
|
280 v14 = a7;
|
|
281 v66 = 1.0 / a4;
|
|
282 v10->flt_3C8C2C = 1.0 - (a4 - v13) * v66;
|
|
283 v11->field_C08 = (signed __int64)((double)*(signed int *)arg0 - a5 * v14->field_4.x);
|
|
284 v11->field_C0A = (signed __int64)((double)*(signed int *)(arg0 + 4) - a5 * v14->field_4.y);
|
|
285 v15 = a4;
|
|
286 v11->field_C0C = (signed __int64)((double)*(signed int *)(arg0 + 8) - a5 * v14->field_4.z);
|
|
287 pLightmapVertices = v11->pVertices;
|
|
288 v17 = v15 * v10->flt_3C8C2C;
|
|
289 pLightmapVertices_ = (int)v11->pVertices;
|
|
290 v10->flt_3C8C30 = v17;
|
|
291 v10->flt_3C8C0C = v17 * v14->field_10.x;
|
|
292 v10->flt_3C8C10 = v17 * v14->field_10.y;
|
|
293 v10->flt_3C8C14 = v17 * v14->field_10.z;
|
|
294 v10->flt_3C8C18 = v17 * v14->field_1C.x;
|
|
295 v10->flt_3C8C1C = v17 * v14->field_1C.y;
|
|
296 v10->flt_3C8C20 = v17 * v14->field_1C.z;
|
|
297 LODWORD(a5) = v11->field_C08;
|
|
298 v18 = (double)SLODWORD(a5);
|
|
299 v11->pVertices[0].vWorldPosition.x = v18 - v10->flt_3C8C18 + v10->flt_3C8C0C;
|
|
300 LODWORD(a5) = v11->field_C0A;
|
|
301 v19 = (char *)&v11->pVertices[0].vWorldPosition.y;
|
|
302 v20 = (double)SLODWORD(a5);
|
|
303 v21 = v20 - v10->flt_3C8C1C;
|
|
304 LODWORD(a5) = v11->field_C0C;
|
|
305 v22 = 4;
|
|
306 v11->pVertices[0].vWorldPosition.y = v21 + v10->flt_3C8C10;
|
|
307 v23 = (double)SLODWORD(a5);
|
|
308 a5 = v23;
|
|
309 v11->pVertices[0].vWorldPosition.z = v23 - v10->flt_3C8C20 + v10->flt_3C8C14;
|
|
310 v11->pVertices[0].u = 0.0;
|
|
311 v11->pVertices[0].v = 0.0;
|
|
312 v11->pVertices[1].vWorldPosition.x = v18 - v10->flt_3C8C18 - v10->flt_3C8C0C;
|
|
313 v11->pVertices[1].vWorldPosition.y = v20 - v10->flt_3C8C1C - v10->flt_3C8C10;
|
|
314 v11->pVertices[1].vWorldPosition.z = v23 - v10->flt_3C8C20 - v10->flt_3C8C14;
|
|
315 v11->pVertices[1].u = 0.0;
|
|
316 v11->pVertices[1].v = 1.0;
|
|
317 v11->pVertices[2].vWorldPosition.x = v18 + v10->flt_3C8C18 - v10->flt_3C8C0C;
|
|
318 v11->pVertices[2].vWorldPosition.y = v20 + v10->flt_3C8C1C - v10->flt_3C8C10;
|
|
319 v11->pVertices[2].vWorldPosition.z = v23 + v10->flt_3C8C20 - v10->flt_3C8C14;
|
|
320 v11->pVertices[2].u = 1.0;
|
|
321 v11->pVertices[2].v = 1.0;
|
|
322 v11->pVertices[3].vWorldPosition.x = v18 + v10->flt_3C8C18 + v10->flt_3C8C0C;
|
|
323 v11->pVertices[3].vWorldPosition.y = v20 + v10->flt_3C8C1C + v10->flt_3C8C10;
|
|
324 v11->pVertices[3].vWorldPosition.z = a5 + v10->flt_3C8C20 + v10->flt_3C8C14;
|
|
325 v11->pVertices[3].u = 1.0;
|
|
326 v11->pVertices[3].v = 0.0;
|
|
327 do
|
|
328 {
|
|
329 v24 = v14->field_4.y * *(float *)v19
|
|
330 + *((float *)v19 + 1) * v14->field_4.z
|
|
331 + v14->field_4.x * *((float *)v19 - 1)
|
|
332 + *(float *)&v14->field_28;
|
|
333 *((float *)v19 - 1) = *((float *)v19 - 1) - v24 * v14->field_4.x;
|
|
334 *(float *)v19 = *(float *)v19 - v24 * v14->field_4.y;
|
|
335 v19 += 48;
|
|
336 --v22;
|
|
337 *((float *)v19 - 11) = *((float *)v19 - 11) - v24 * v14->field_4.z;
|
|
338 }
|
|
339 while ( v22 );
|
|
340 v11->field_C10 = arg8;
|
|
341 v11->uNumVertices = 4;
|
|
342 if ( pGame->uFlags2 & 4 )
|
|
343 {
|
|
344 LODWORD(a5) = v11->field_C0C;
|
|
345 v25 = arg0;
|
|
346 v26 = (double)SLODWORD(a5);
|
|
347 LODWORD(a5) = v11->field_C0A;
|
|
348 v27 = v11->field_C08;
|
|
349 a5 = (double)SLODWORD(a5);
|
|
350 arg8 = v27;
|
|
351 v28 = (double)v27;
|
|
352 v61 = a5;
|
|
353 v60 = v28;
|
|
354 v62 = v26;
|
|
355 *(float *)&arg8 = (double)*(signed int *)(arg0 + 8);
|
|
356 arg0b = (double)*(signed int *)(arg0 + 4);
|
|
357 v29 = (double)*(signed int *)v25 - v28;
|
|
358 v30 = arg0b - a5;
|
|
359 a5 = *(float *)&arg8 - v26;
|
|
360 a1.x = v29;
|
|
361 a1.z = a5;
|
|
362 a1.y = v30;
|
|
363 a1.Normalize();
|
2
|
364 //v64 = v62 + 6.7553994e15;
|
|
365 //LODWORD(a5) = LODWORD(v64);
|
3
|
366 LODWORD(a5) = floorf(v62 + 0.5f);
|
2
|
367 //v64 = v61 + 6.7553994e15;
|
|
368 //arg0c = LODWORD(v64);
|
3
|
369 arg0c = floorf(v61 + 0.5f);
|
2
|
370 //v64 = v60 + 6.7553994e15;
|
|
371 //arg8 = LODWORD(v64);
|
3
|
372 arg8 = floorf(v60 + 0.5f);
|
2
|
373 auto v64 /*HIDWORD(v64)*/ = abs(*(int *)(v25 + 8) - (signed)LODWORD(a5));
|
0
|
374 arg0a = abs(*(int *)(v25 + 4) - arg0c);
|
|
375 v31 = abs(*(int *)v25 - arg8);
|
|
376 LODWORD(a5) = v31;
|
|
377 v32 = arg0a;
|
2
|
378 v33 = v64;//HIDWORD(v64);
|
0
|
379 if ( v31 < arg0a )
|
|
380 {
|
|
381 v34 = v31;
|
|
382 v31 = arg0a;
|
|
383 v32 = v34;
|
|
384 }
|
2
|
385 if ( v31 < v64)//SHIDWORD(v64) )
|
0
|
386 {
|
|
387 v35 = v31;
|
2
|
388 v31 = v64;//HIDWORD(v64);
|
0
|
389 v33 = v35;
|
|
390 }
|
|
391 if ( v32 < (signed int)v33 )
|
|
392 {
|
|
393 v36 = v33;
|
|
394 v33 = v32;
|
|
395 v32 = v36;
|
|
396 }
|
|
397 v37 = v33 >> 2;
|
|
398 LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31;
|
|
399 v38 = (double)SLODWORD(a5);
|
|
400 if ( v38 > a4 )
|
|
401 return 1;
|
|
402 a4 = v66 * v38;
|
|
403 if ( uLightType & 4 )
|
|
404 {
|
|
405 v59 = (void *)v37;
|
|
406 uLightType = dword_4D86CC;
|
|
407 v58 = v37;
|
|
408 v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y);
|
|
409 v40 = v39 * 1.0 * *(float *)&uLightType;
|
|
410 }
|
|
411 else
|
|
412 {
|
|
413 if ( uLightType & 8 )
|
|
414 {
|
|
415 v40 = 1.0 * 1.0;
|
|
416 }
|
|
417 else
|
|
418 {
|
|
419 MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0);
|
|
420 v40 = *(float *)&uLightType;
|
|
421 }
|
|
422 }
|
|
423 v14 = a7;
|
|
424 pLightmapVertices = (RenderVertexSoft *)pLightmapVertices_;
|
|
425 v11->flt_C14 = v40 - a4 * v40;
|
|
426 }
|
|
427 else
|
|
428 {
|
|
429 v11->flt_C14 = v10->flt_3C8C2C;
|
|
430 }
|
|
431 v41 = v14->field_4.z;
|
|
432 v42 = pGame->pStru9Instance;
|
|
433 v59 = &v11->uNumVertices;
|
|
434 v58 = (unsigned int)pLightmapVertices;
|
|
435 *(float *)&v57 = v41;
|
|
436 v56 = v14->field_4.y;
|
|
437 v55 = v14->field_4.x;
|
|
438 result = v42->_4980B9(a9, a2, v55, v56, *(float *)&v57, pLightmapVertices, &v11->uNumVertices);
|
|
439 if ( !result )
|
|
440 return result;
|
|
441 v44 = &v11->uNumVertices;
|
|
442 if ( !v11->uNumVertices )
|
|
443 return 1;
|
|
444 v45 = v10->_45C6D6(a2, a9, v11);
|
|
445 if ( v45 != a2 && v45 > 0 )
|
|
446 v10->_45C4B9(a2, a9, v11);
|
|
447 v59 = (void *)*v44;
|
|
448 v46 = (RenderVertexSoft *)pLightmapVertices_;
|
|
449 pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)pLightmapVertices_, (unsigned int)v59);
|
|
450 v59 = 0;
|
|
451 v58 = *v44;
|
|
452 pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v46, v58, 0);
|
|
453 if ( !(uClipFlag & 1) )
|
|
454 goto LABEL_38;
|
|
455 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
456 {
|
|
457 if ( uClipFlag & 2 )
|
|
458 {
|
|
459 v59 = &a4;
|
|
460 v58 = (unsigned int)v10->field_3C8C34;
|
|
461 v57 = *v44;
|
|
462 pGame->pIndoorCameraD3D->_436CDC(v46, v57, v10->field_3C8C34, (unsigned int *)&a4);
|
|
463 LABEL_33:
|
|
464 v59 = v44;
|
|
465 v58 = (unsigned int)v10->field_3C8C34;
|
|
466 v57 = (int)v46;
|
|
467 v56 = a4;
|
|
468 pGame->pIndoorCameraD3D->_437143(LODWORD(a4), v46, v10->field_3C8C34, v44);
|
|
469 goto LABEL_37;
|
|
470 }
|
|
471 if ( uClipFlag & 4 )
|
|
472 {
|
|
473 v59 = &a4;
|
|
474 v58 = (unsigned int)v10->field_3C8C34;
|
|
475 v57 = *v44;
|
|
476 pGame->pIndoorCameraD3D->_436F09(v46, v57, v10->field_3C8C34, (unsigned int *)&a4);
|
|
477 goto LABEL_33;
|
|
478 }
|
|
479 v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330";
|
|
480 v52 = "Undefined clip flag specified";
|
|
481 }
|
|
482 else
|
|
483 {
|
|
484 v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335";
|
|
485 v52 = "Lightpoly builder native indoor clipping not implemented";
|
|
486 }
|
|
487 MessageBoxA(nullptr, v52, (const char *)v58, 0);
|
|
488 LABEL_37:
|
|
489 if ( a4 != 0.0 )
|
|
490 {
|
|
491 LABEL_38:
|
|
492 if ( v67 )
|
|
493 {
|
|
494 v48 = (char *)&v10->std__vector_000004_size;
|
|
495 v49 = *(unsigned int *)v48;
|
|
496 v51 = __OFSUB__(*(unsigned int *)v48, 511);
|
|
497 v50 = *(unsigned int *)v48 - 511 < 0;
|
|
498 }
|
|
499 else
|
|
500 {
|
|
501 v48 = (char *)&v10->std__vector_183808_size;
|
|
502 v49 = *(unsigned int *)v48;
|
|
503 v51 = __OFSUB__(*(unsigned int *)v48, 767);
|
|
504 v50 = *(unsigned int *)v48 - 767 < 0;
|
|
505 }
|
|
506 if ( v50 ^ v51 )
|
|
507 *(unsigned int *)v48 = v49 + 1;
|
|
508 }
|
|
509 return 1;
|
|
510 }
|
|
511
|
|
512 //----- (0045C4B9) --------------------------------------------------------
|
|
513 int LightmapBuilder::_45C4B9(int a2, RenderVertexSoft *a3, Lightmap *pLightmap)
|
|
514 {
|
|
515 Lightmap *v4; // edi@1
|
|
516 int v5; // eax@1
|
|
517 signed int v6; // ecx@1
|
|
518 RenderVertexSoft *v7; // ebx@2
|
|
519 int v8; // edx@3
|
|
520 RenderVertexSoft *v9; // esi@3
|
|
521 int v10; // eax@6
|
|
522 char *v11; // edi@7
|
|
523 RenderVertexSoft *v12; // ecx@8
|
|
524 char v13; // bl@17
|
|
525 signed int v14; // edx@17
|
|
526 double v15; // st6@18
|
|
527 double v16; // st6@21
|
|
528 double v17; // st6@24
|
|
529 signed int v18; // edx@33
|
|
530 int v20; // [sp+4h] [bp-1Ch]@3
|
|
531 int v21; // [sp+8h] [bp-18h]@8
|
|
532 float v22; // [sp+Ch] [bp-14h]@23
|
|
533 float v23; // [sp+10h] [bp-10h]@20
|
|
534 int v24; // [sp+14h] [bp-Ch]@1
|
|
535 RenderVertexSoft *v25; // [sp+18h] [bp-8h]@2
|
|
536 char v26; // [sp+1Eh] [bp-2h]@17
|
|
537 char v27; // [sp+1Fh] [bp-1h]@17
|
|
538
|
|
539 v4 = pLightmap;
|
|
540 v5 = 0;
|
|
541 v6 = pLightmap->uNumVertices;
|
|
542 v24 = 0;
|
|
543 if ( v6 > 0 )
|
|
544 {
|
|
545 v7 = pLightmap->pVertices;
|
|
546 v25 = pLightmap->pVertices;
|
|
547 do
|
|
548 {
|
|
549 v20 = v5 + 1;
|
|
550 v8 = (v5 + 1) % v6;
|
|
551 v9 = &v4->pVertices[v8];
|
|
552 if ( v7->vWorldPosition.x != v9->vWorldPosition.x
|
|
553 || v7->vWorldPosition.y != v4->pVertices[v8].vWorldPosition.y
|
|
554 || v7->vWorldPosition.z != v4->pVertices[v8].vWorldPosition.z )
|
|
555 {
|
|
556 v10 = 0;
|
|
557 if ( a2 > 0 )
|
|
558 {
|
|
559 v11 = (char *)&a3->vWorldPosition.z;
|
|
560 do
|
|
561 {
|
|
562 v21 = v10 + 1;
|
|
563 v12 = &a3[(v10 + 1) % a2];
|
|
564 if ( (*((float *)v11 - 2) != v12->vWorldPosition.x
|
|
565 || *((float *)v11 - 1) != v12->vWorldPosition.y
|
|
566 || *(float *)v11 != v12->vWorldPosition.z)
|
|
567 && v7->vWorldPosition.x == *((float *)v11 - 2)
|
|
568 && v7->vWorldPosition.y == *((float *)v11 - 1)
|
|
569 && v7->vWorldPosition.z == *(float *)v11
|
|
570 && (v9->vWorldPosition.x != v12->vWorldPosition.x
|
|
571 || v9->vWorldPosition.y != v12->vWorldPosition.y
|
|
572 || v9->vWorldPosition.z != v12->vWorldPosition.z) )
|
|
573 {
|
|
574 v13 = 0;
|
|
575 v14 = 0;
|
|
576 v27 = 0;
|
|
577 v26 = 0;
|
|
578 if ( v9->vWorldPosition.x <= (double)v12->vWorldPosition.x )
|
|
579 v15 = v12->vWorldPosition.x - v9->vWorldPosition.x;
|
|
580 else
|
|
581 v15 = v9->vWorldPosition.x - v12->vWorldPosition.x;
|
|
582 v23 = v15;
|
|
583 if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y )
|
|
584 v16 = v12->vWorldPosition.y - v9->vWorldPosition.y;
|
|
585 else
|
|
586 v16 = v9->vWorldPosition.y - v12->vWorldPosition.y;
|
|
587 v22 = v16;
|
|
588 if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z )
|
|
589 v17 = v12->vWorldPosition.z - v9->vWorldPosition.z;
|
|
590 else
|
|
591 v17 = v9->vWorldPosition.z - v12->vWorldPosition.z;
|
|
592 if ( v23 < 1.0 )
|
|
593 {
|
|
594 v13 = 1;
|
|
595 v14 = 1;
|
|
596 }
|
|
597 if ( v22 < 1.0 )
|
|
598 {
|
|
599 v27 = 1;
|
|
600 ++v14;
|
|
601 }
|
|
602 if ( v17 < 1.0 )
|
|
603 {
|
|
604 v26 = 1;
|
|
605 ++v14;
|
|
606 }
|
|
607 if ( v14 > 1 )
|
|
608 {
|
|
609 v18 = 0;
|
|
610 if ( v13 && v9->vWorldPosition.x != v12->vWorldPosition.x )
|
|
611 {
|
|
612 v18 = 1;
|
|
613 v9->vWorldPosition.x = v12->vWorldPosition.x;
|
|
614 }
|
|
615 if ( v27 && v9->vWorldPosition.y != v12->vWorldPosition.y )
|
|
616 {
|
|
617 ++v18;
|
|
618 v9->vWorldPosition.y = v12->vWorldPosition.y;
|
|
619 }
|
|
620 if ( v26 && v9->vWorldPosition.z != v12->vWorldPosition.z )
|
|
621 {
|
|
622 ++v18;
|
|
623 v9->vWorldPosition.z = v12->vWorldPosition.z;
|
|
624 }
|
|
625 if ( v18 > 0 )
|
|
626 ++v24;
|
|
627 }
|
|
628 v7 = v25;
|
|
629 }
|
|
630 ++v10;
|
|
631 v11 += 48;
|
|
632 }
|
|
633 while ( v21 < a2 );
|
|
634 v4 = pLightmap;
|
|
635 }
|
|
636 }
|
|
637 v5 = v20;
|
|
638 v6 = v4->uNumVertices;
|
|
639 ++v7;
|
|
640 v25 = v7;
|
|
641 }
|
|
642 while ( v20 < v6 );
|
|
643 }
|
|
644 return v24;
|
|
645 }
|
|
646
|
|
647 //----- (0045C6D6) --------------------------------------------------------
|
|
648 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap)
|
|
649 {
|
|
650 Lightmap *v4; // edi@1
|
|
651 signed int v5; // ebx@1
|
|
652 signed int v6; // esi@1
|
|
653 RenderVertexSoft *v7; // ecx@2
|
|
654 char *v8; // edx@4
|
|
655 double v9; // st7@6
|
|
656 double v10; // st6@10
|
|
657 double v11; // st5@14
|
|
658 double v12; // st7@17
|
|
659 RenderVertexSoft *v13; // eax@21
|
|
660 int v15; // [sp+Ch] [bp-8h]@1
|
|
661 float v16; // [sp+10h] [bp-4h]@1
|
|
662 int pLightmapa; // [sp+24h] [bp+10h]@3
|
|
663
|
|
664 v4 = pLightmap;
|
|
665 v5 = 0;
|
|
666 v6 = -1;
|
|
667 v16 = 3.4028235e38;
|
|
668 v15 = 0;
|
|
669 if ( (signed int)pLightmap->uNumVertices > 0 )
|
|
670 {
|
|
671 v7 = pLightmap->pVertices;
|
|
672 do
|
|
673 {
|
|
674 pLightmapa = 0;
|
|
675 if ( a2 > 0 )
|
|
676 {
|
|
677 v8 = (char *)&a3->vWorldPosition.z;
|
|
678 do
|
|
679 {
|
|
680 if ( v7->vWorldPosition.x <= (double)*((float *)v8 - 2) )
|
|
681 v9 = *((float *)v8 - 2) - v7->vWorldPosition.x;
|
|
682 else
|
|
683 v9 = v7->vWorldPosition.x - *((float *)v8 - 2);
|
|
684 if ( v9 < 2.0 )
|
|
685 {
|
|
686 v10 = v7->vWorldPosition.y <= (double)*((float *)v8 - 1) ? *((float *)v8 - 1) - v7->vWorldPosition.y : v7->vWorldPosition.y - *((float *)v8 - 1);
|
|
687 if ( v10 < 2.0 )
|
|
688 {
|
|
689 v11 = v7->vWorldPosition.z <= (double)*(float *)v8 ? *(float *)v8 - v7->vWorldPosition.z : v7->vWorldPosition.z - *(float *)v8;
|
|
690 if ( v11 < 2.0 )
|
|
691 {
|
|
692 v12 = v9 + v11 + v10;
|
|
693 if ( v12 < v16 )
|
|
694 {
|
|
695 v16 = v12;
|
|
696 v6 = pLightmapa;
|
|
697 }
|
|
698 }
|
|
699 }
|
|
700 }
|
|
701 ++pLightmapa;
|
|
702 v8 += 48;
|
|
703 }
|
|
704 while ( pLightmapa < a2 );
|
|
705 if ( v6 != -1 )
|
|
706 {
|
|
707 v13 = &a3[v6];
|
|
708 ++v15;
|
|
709 v7->vWorldPosition.x = v13->vWorldPosition.x;
|
|
710 v7->vWorldPosition.y = v13->vWorldPosition.y;
|
|
711 v7->vWorldPosition.z = v13->vWorldPosition.z;
|
|
712 }
|
|
713 }
|
|
714 v6 = -1;
|
|
715 ++v5;
|
|
716 ++v7;
|
|
717 v16 = 3.4028235e38;
|
|
718 }
|
|
719 while ( v5 < (signed int)v4->uNumVertices );
|
|
720 }
|
|
721 return v15;
|
|
722 }
|
|
723
|
|
724 //----- (0045C7F6) --------------------------------------------------------
|
|
725 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID)
|
|
726 {
|
|
727 BLVFace *pFace; // esi@1
|
|
728 int v3; // ebx@1
|
|
729 int uSectorID; // edi@1
|
|
730 int v5; // ecx@5
|
|
731 BLVLightMM7 *v6; // eax@7
|
|
732 int v7; // edi@10
|
|
733 bool result; // eax@14
|
|
734 LightmapBuilder *thisa; // [sp+Ch] [bp-Ch]@1
|
|
735 MobileLight *pMobileLight; // [sp+10h] [bp-8h]@2
|
|
736 int uSectLights; // [sp+10h] [bp-8h]@5
|
|
737 StationaryLight *pStationaryLight; // [sp+10h] [bp-8h]@11
|
|
738 int v13; // [sp+14h] [bp-4h]@1
|
|
739 int i; // [sp+14h] [bp-4h]@5
|
|
740
|
|
741 pFace = &pIndoor->pFaces[uFaceID];
|
|
742 v3 = uNumMobileLightsApplied;
|
|
743 v13 = 0;
|
|
744 thisa = this;
|
|
745 uSectorID = pFace->uSectorID;
|
|
746 uFaceID = 0;
|
|
747 stru_F8AD28.field_2C = (stru_F8AD28.field_3F8 + pIndoor->pSectors[uSectorID].uMinAmbientLightLevel) << 16;
|
|
748 if ( uNumMobileLightsApplied > 0 )
|
|
749 {
|
|
750 pMobileLight = pMobileLights;
|
|
751 do
|
|
752 {
|
|
753 if ( (signed int)uFaceID >= 20 )
|
|
754 break;
|
|
755 ApplyLight_BLV((StationaryLight *)pMobileLight, pFace, &uFaceID, 1, 0);
|
|
756 ++v13;
|
|
757 ++pMobileLight;
|
|
758 }
|
|
759 while ( v13 < v3 );
|
|
760 }
|
|
761 v5 = 0;
|
|
762 i = 0;
|
|
763 for ( uSectLights = pIndoor->pSectors[uSectorID].uNumLights; i < uSectLights; v5 = i++ + 1 )
|
|
764 {
|
|
765 if ( (signed int)uFaceID >= 20 )
|
|
766 break;
|
|
767 v6 = &pIndoor->pLights[*(&pIndoor->pSectors[uSectorID].pLights->vPosition.x + v5)];
|
|
768 if ( !(v6->uAtributes & 8) )
|
|
769 ApplyLight_BLV((StationaryLight *)v6, pFace, &uFaceID, 0, (int)&byte_4E94D0);
|
|
770 }
|
|
771 v7 = 0;
|
|
772 if ( uNumStationaryLightsApplied > 0 )
|
|
773 {
|
|
774 pStationaryLight = pStationaryLights;
|
|
775 do
|
|
776 {
|
|
777 if ( (signed int)uFaceID >= 20 )
|
|
778 break;
|
|
779 ApplyLight_BLV(pStationaryLight, pFace, &uFaceID, 0, (int)&byte_4E94D0);
|
|
780 ++pStationaryLight;
|
|
781 ++v7;
|
|
782 }
|
|
783 while ( v7 < uNumStationaryLightsApplied );
|
|
784 }
|
|
785 result = uFaceID;
|
|
786 stru_F8AD28.field_AC = uFaceID;
|
|
787 LOBYTE(result) = 1;
|
|
788 return result;
|
|
789 }
|
|
790 // 4E94D0: using guessed type char byte_4E94D0;
|
|
791 // 519AB4: using guessed type int uNumStationaryLightsApplied;
|
|
792
|
|
793 //----- (0045C911) --------------------------------------------------------
|
|
794 bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, char X, int a5)
|
|
795 {
|
|
796 BLVFace *result; // eax@0
|
|
797 StationaryLight *v7; // edi@1
|
|
798 signed int v8; // ecx@1
|
|
799 int v9; // edx@2
|
|
800 int v10; // edx@4
|
|
801 int v11; // esi@4
|
|
802 int v12; // edx@6
|
|
803 double v13; // st7@8
|
|
804 __int16 v14; // fps@8
|
|
805 char v15; // c0@9
|
|
806 char v16; // c2@9
|
|
807 char v17; // c3@9
|
|
808 double v18; // st6@12
|
|
809 __int16 v19; // fps@12
|
|
810 char v20; // c0@12
|
|
811 char v21; // c2@12
|
|
812 char v22; // c3@12
|
|
813 signed int v23; // [sp+10h] [bp-4h]@2
|
2
|
814 //float pLighta; // [sp+1Ch] [bp+8h]@13
|
0
|
815 signed int a2a; // [sp+20h] [bp+Ch]@4
|
|
816
|
|
817 v7 = pLight;
|
|
818 v8 = pLight->uRadius;
|
|
819 if ( v8 > 0
|
|
820 && (result = a2, v9 = pLight->vPosition.x, v23 = v9, v9 > a2->pBounding.x1 - v8)
|
|
821 && v9 < v8 + a2->pBounding.x2
|
|
822 && (v10 = pLight->vPosition.y, v11 = a2->pBounding.y1 - v8, a2a = v10, v10 > v11)
|
|
823 && v10 < v8 + result->pBounding.y2
|
|
824 && (v12 = pLight->vPosition.z, v12 > result->pBounding.z1 - v8)
|
|
825 && v12 < v8 + result->pBounding.z2
|
|
826 && ((v13 = (double)v12 * result->pFacePlane.vNormal.z
|
|
827 + (double)a2a * result->pFacePlane.vNormal.y
|
|
828 + (double)v23 * result->pFacePlane.vNormal.x
|
|
829 + result->pFacePlane.dist,
|
|
830 //UNDEF(v14),
|
|
831 X)
|
|
832 || (v15 = v13 < 0.0, v16 = 0, v17 = v13 == 0.0, BYTE1(result) = HIBYTE(v14), v13 >= 0.0))
|
|
833 && (v18 = (double)pLight->uRadius,
|
|
834 //UNDEF(v19),
|
|
835 v20 = v13 < v18,
|
|
836 v21 = 0,
|
|
837 v22 = v13 == v18,
|
|
838 BYTE1(result) = HIBYTE(v19),
|
|
839 v13 <= v18) )
|
|
840 {
|
|
841 stru_F8AD28._blv_lights_radii[*pSlot] = v8;
|
|
842 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v8;
|
|
843 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x;
|
|
844 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y;
|
|
845 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z;
|
|
846 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689;
|
|
847 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
|
|
848 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
|
2
|
849 //pLighta = v13;
|
3
|
850 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v13 + 0.5f));//COERCE_UNSIGNED_INT64(pLighta + 6.7553994e15));
|
0
|
851 result = (BLVFace *)*pSlot;
|
|
852 stru_F8AD28._blv_lights_smthngs[(*pSlot)++] = v7->field_B;
|
|
853 LOBYTE(result) = 1;
|
|
854 }
|
|
855 else
|
|
856 {
|
|
857 LOBYTE(result) = 0;
|
|
858 }
|
|
859 return (bool)result;
|
|
860 }
|
|
861
|
|
862 //----- (0045CA88) --------------------------------------------------------
|
|
863 int LightmapBuilder::_45CA88(stru320 *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal)
|
|
864 {
|
|
865 int result; // eax@1
|
|
866 stru320 *v6; // ecx@2
|
|
867 RenderVertexSoft *v7; // ebx@2
|
|
868 double v8; // st7@2
|
|
869 double v9; // st6@2
|
|
870 char *v10; // eax@3
|
|
871 double v11; // st7@5
|
|
872 __int64 v12; // ST2C_8@5
|
|
873 float v13; // edx@5
|
|
874 int v14; // eax@5
|
|
875 float v15; // ST10_4@5
|
|
876 Vec3_float_ v16; // ST00_12@5
|
|
877 double v17; // st7@5
|
|
878 int a5; // [sp+2Ch] [bp-1Ch]@1
|
|
879 float v19; // [sp+30h] [bp-18h]@1
|
|
880 float v20; // [sp+34h] [bp-14h]@1
|
|
881 LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1
|
|
882 int v22; // [sp+3Ch] [bp-Ch]@1
|
|
883 int *j; // [sp+40h] [bp-8h]@3
|
|
884 int i; // [sp+44h] [bp-4h]@1
|
|
885 int a3a; // [sp+58h] [bp+10h]@2
|
|
886
|
|
887 *(float *)&a5 = 0.0;
|
|
888 v19 = 0.0;
|
|
889 thisa = this;
|
|
890 v20 = 0.0;
|
|
891 result = _45CBD4(a3, a4, dword_69B010, &v22);
|
|
892 for ( i = 0; i < v22; result = i )
|
|
893 {
|
|
894 v6 = a2;
|
|
895 a3a = 0;
|
|
896 v7 = &a3[dword_69B010[i]];
|
|
897 v8 = v7->vWorldPosition.z;
|
|
898 v9 = v7->vWorldPosition.y;
|
|
899 *(float *)&a5 = v7->vWorldPosition.x;
|
|
900 v19 = v9;
|
|
901 v20 = v8;
|
|
902 v7->flt_2C = 0.0;
|
|
903 if ( a2->field_AC > 0 )
|
|
904 {
|
|
905 v10 = (char *)a2->_blv_lights_ys;
|
|
906 for ( j = a2->_blv_lights_ys; ; v10 = (char *)j )
|
|
907 {
|
|
908 v11 = (double)*((signed int *)v10 - 60);
|
|
909 LODWORD(v12) = *((unsigned int *)v10 - 20);
|
|
910 HIDWORD(v12) = *(unsigned int *)v10;
|
|
911 LODWORD(v13) = *((unsigned int *)v10 + 60);
|
|
912 v14 = a3a;
|
|
913 LOBYTE(v14) = v6->_blv_lights_smthngs[a3a];
|
|
914 v15 = v11;
|
|
915 *(_QWORD *)&v16.x = v12;
|
|
916 v16.z = v13;
|
|
917 v17 = _45CC0C_light(v16/*COERCE_VEC3_FLOAT_(v16.x)*/, 1.0, v15, pNormal, *(float *)&a5/*COERCE_FLOAT(&a5)*/, v14)
|
|
918 + v7->flt_2C;
|
|
919 ++a3a;
|
|
920 ++j;
|
|
921 v7->flt_2C = v17;
|
|
922 if ( a3a >= a2->field_AC )
|
|
923 break;
|
|
924 v6 = a2;
|
|
925 }
|
|
926 }
|
|
927 ++i;
|
|
928 }
|
|
929 return result;
|
|
930 }
|
|
931
|
|
932 //----- (0045CB89) --------------------------------------------------------
|
|
933 int LightmapBuilder::_45CB89(RenderVertexSoft *a1, int a2)
|
|
934 {
|
|
935 int v3; // edx@1
|
|
936 int result; // eax@2
|
|
937 char *v5; // ecx@2
|
|
938 double v6; // st7@4
|
|
939 __int16 v7; // fps@4
|
|
940 char v8; // c0@4
|
|
941 char v9; // c2@4
|
|
942 char v10; // c3@4
|
|
943 double v11; // st7@5
|
|
944 double v12; // st7@6
|
|
945 __int16 v13; // fps@6
|
|
946 char v14; // c0@6
|
|
947 char v15; // c2@6
|
|
948 char v16; // c3@6
|
|
949
|
|
950 v3 = a2;
|
|
951 if ( a2 > 0 )
|
|
952 {
|
|
953 HIWORD(result) = HIWORD(a1);
|
|
954 v5 = (char *)&a1->flt_2C;
|
|
955 do
|
|
956 {
|
|
957 if ( *(float *)v5 < 0.0
|
|
958 || (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0, v10 = 1.0 == v6, LOWORD(result) = v7, v6 <= 1.0) )
|
|
959 {
|
|
960 v12 = *(float *)v5;
|
|
961 //UNDEF(v13);
|
|
962 v14 = 0.0 < v12;
|
|
963 v15 = 0;
|
|
964 v16 = 0.0 == v12;
|
|
965 LOWORD(result) = v13;
|
|
966 if ( v12 >= 0.0 )
|
|
967 v11 = *(float *)v5;
|
|
968 else
|
|
969 v11 = 0.0;
|
|
970 }
|
|
971 else
|
|
972 {
|
|
973 v11 = 1.0;
|
|
974 }
|
|
975 *(float *)v5 = v11;
|
|
976 v5 += 48;
|
|
977 --v3;
|
|
978 }
|
|
979 while ( v3 );
|
|
980 }
|
|
981 return result;
|
|
982 }
|
|
983
|
|
984 //----- (0045CBD4) --------------------------------------------------------
|
|
985 int LightmapBuilder::_45CBD4(RenderVertexSoft *a2, int a3, int *a4, int *a5)
|
|
986 {
|
|
987 int result; // eax@1
|
|
988 int v6; // edx@1
|
|
989 int v7; // ecx@2
|
|
990 int v8; // esi@2
|
|
991
|
|
992 result = (int)a5;
|
|
993 v6 = 0;
|
|
994 for ( *a5 = 0; v6 < a3; ++v6 )
|
|
995 {
|
|
996 v7 = *a5;
|
|
997 v8 = 0;
|
|
998 if ( *a5 <= 0 )
|
|
999 {
|
|
1000 LABEL_5:
|
|
1001 a4[v7] = v6;
|
|
1002 ++*a5;
|
|
1003 }
|
|
1004 else
|
|
1005 {
|
|
1006 while ( a4[v8] != v6 )
|
|
1007 {
|
|
1008 ++v8;
|
|
1009 if ( v8 >= v7 )
|
|
1010 goto LABEL_5;
|
|
1011 }
|
|
1012 }
|
|
1013 }
|
|
1014 return result;
|
|
1015 }
|
|
1016
|
|
1017 //----- (0045CC0C) --------------------------------------------------------
|
|
1018 double LightmapBuilder::_45CC0C_light(Vec3_float_ a1, float a2, float a3, Vec3_float_ *pNormal, float a5, int uLightType)
|
|
1019 {
|
|
1020 float v7; // esi@1
|
|
1021 int v8; // eax@1
|
|
1022 int v9; // ebx@1
|
|
1023 unsigned int v10; // ecx@1
|
|
1024 int v11; // edx@2
|
|
1025 int v12; // edx@4
|
|
1026 unsigned int v13; // edx@6
|
|
1027 double v14; // st7@7
|
|
1028 double result; // st7@8
|
|
1029 double v16; // st7@9
|
|
1030 int v17; // esi@9
|
|
1031 const char *v18; // ecx@9
|
|
1032 double v19; // st7@10
|
|
1033 double v20; // st7@10
|
|
1034 std::string v21; // [sp-10h] [bp-40h]@13
|
|
1035 const char *v22[6]; // [sp+0h] [bp-30h]@10
|
|
1036 double v23; // [sp+18h] [bp-18h]@1
|
|
1037 double v24; // [sp+20h] [bp-10h]@1
|
|
1038 int v25; // [sp+28h] [bp-8h]@1
|
|
1039 int v26; // [sp+2Ch] [bp-4h]@1
|
|
1040
|
|
1041 v7 = a5;
|
|
1042 LODWORD(a5) = *(unsigned int *)(LODWORD(a5) + 8);
|
2
|
1043 //v24 = a5 + 6.7553994e15;
|
3
|
1044 v26 = floorf(a5 + 0.5f);//LODWORD(v24);
|
0
|
1045 LODWORD(a5) = *(unsigned int *)(LODWORD(v7) + 4);
|
2
|
1046 //v24 = a5 + 6.7553994e15;
|
3
|
1047 auto _v24 = floorf(a5 + 0.5f);
|
0
|
1048 LODWORD(a5) = *(unsigned int *)LODWORD(v7);
|
2
|
1049 //v23 = a5 + 6.7553994e15;
|
3
|
1050 auto _v23 = floorf(a5 + 0.5f);
|
2
|
1051 //*(_QWORD *)((char *)&v24 + 4) = __PAIR__(LODWORD(v24), LODWORD(v23));
|
0
|
1052 v26 = abs((signed)LODWORD(a1.z) - v26);
|
2
|
1053 //v25 = abs((signed)LODWORD(a1.y) - (signed)LODWORD(v24));
|
|
1054 //v8 = abs((int)a1.x - (signed)LODWORD(v23));
|
|
1055 v25 = abs((signed)LODWORD(a1.y) - (signed)_v24);
|
|
1056 v8 = abs((int)a1.x - (signed)_v23);
|
0
|
1057 LODWORD(a5) = v8;
|
|
1058 v9 = v25;
|
|
1059 v10 = v26;
|
|
1060 if ( v8 < v25 )
|
|
1061 {
|
|
1062 v11 = v8;
|
|
1063 v8 = v25;
|
|
1064 v9 = v11;
|
|
1065 }
|
|
1066 if ( v8 < v26 )
|
|
1067 {
|
|
1068 v12 = v8;
|
|
1069 v8 = v26;
|
|
1070 v10 = v12;
|
|
1071 }
|
|
1072 if ( v9 < (signed int)v10 )
|
|
1073 {
|
|
1074 v13 = v10;
|
|
1075 v10 = v9;
|
|
1076 v9 = v13;
|
|
1077 }
|
|
1078 v14 = (double)(signed int)(((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8);
|
|
1079 if ( v14 <= a3 )
|
|
1080 {
|
|
1081 a5 = v14 / a3;
|
|
1082 v16 = (double)(signed int)a1.x;
|
|
1083 *(float *)&v23 = (double)SLODWORD(a1.y);
|
|
1084 LODWORD(a1.x) = *(unsigned int *)LODWORD(v7);
|
|
1085 v17 = LODWORD(v7) + 4;
|
|
1086 *((float *)&v23 + 1) = (double)SLODWORD(a1.z);
|
|
1087 LODWORD(a1.y) = *(unsigned int *)v17;
|
|
1088 LODWORD(a1.z) = *(unsigned int *)(v17 + 4);
|
|
1089 a3 = *((float *)&v23 + 1) - a1.z;
|
|
1090 a1.z = a3;
|
|
1091 a1.x = v16 - a1.x;
|
|
1092 a1.y = (float)v23 - a1.y;
|
|
1093 a1.Normalize();
|
|
1094 if ( uLightType & 4 )
|
|
1095 {
|
|
1096 v22[1] = v18;
|
|
1097 uLightType = dword_4D86D8;
|
|
1098 v22[0] = v18;
|
|
1099 v19 = fabs(a1.z * pNormal->z + a1.y * pNormal->y + a1.x * pNormal->x);
|
|
1100 v20 = v19 * *(float *)&uLightType * a2;
|
|
1101 }
|
|
1102 else
|
|
1103 {
|
|
1104 if ( uLightType & 8 )
|
|
1105 {
|
|
1106 v20 = 1.3 * a2;
|
|
1107 }
|
|
1108 else
|
|
1109 {
|
|
1110 MessageBoxW(nullptr, L"Invalid light type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:783", 0);
|
|
1111 v20 = *(float *)&uLightType;
|
|
1112 }
|
|
1113 }
|
|
1114 result = v20 - a5 * v20;
|
|
1115 }
|
|
1116 else
|
|
1117 {
|
|
1118 result = 0.0;
|
|
1119 }
|
|
1120 return result;
|
|
1121 }
|
|
1122 // 4D86D8: using guessed type int dword_4D86D8;
|
|
1123
|
|
1124 //----- (0045CDB7) --------------------------------------------------------
|
|
1125 bool LightmapBuilder::ApplyLights_OutdoorFace(ODMFace *pFace)
|
|
1126 {
|
|
1127 int v2; // esi@1
|
|
1128 int v3; // eax@1
|
|
1129 MobileLight *pMobileLight; // ebx@2
|
|
1130 int v5; // esi@5
|
|
1131 StationaryLight *pStationaryLight; // ebx@6
|
|
1132 bool result; // eax@9
|
|
1133 LightmapBuilder *thisa; // [sp+Ch] [bp-8h]@1
|
|
1134 int pSlot; // [sp+10h] [bp-4h]@1
|
|
1135
|
|
1136 v2 = 0;
|
|
1137 thisa = this;
|
|
1138 v3 = stru_F8AD28.field_3F8 + pFace->uShadeType;
|
|
1139 pSlot = 0;
|
|
1140 stru_F8AD28.field_2C = v3 << 16;
|
|
1141 if ( uNumMobileLightsApplied > 0 )
|
|
1142 {
|
|
1143 pMobileLight = pMobileLights;
|
|
1144 do
|
|
1145 {
|
|
1146 if ( pSlot >= 20 )
|
|
1147 break;
|
|
1148 ApplyLight_ODM((StationaryLight *)pMobileLight, pFace, (unsigned int *)&pSlot, 1);
|
|
1149 ++v2;
|
|
1150 ++pMobileLight;
|
|
1151 }
|
|
1152 while ( v2 < uNumMobileLightsApplied );
|
|
1153 }
|
|
1154 v5 = 0;
|
|
1155 if ( uNumStationaryLightsApplied > 0 )
|
|
1156 {
|
|
1157 pStationaryLight = pStationaryLights;
|
|
1158 do
|
|
1159 {
|
|
1160 if ( pSlot >= 20 )
|
|
1161 break;
|
|
1162 ApplyLight_ODM(pStationaryLight, pFace, (unsigned int *)&pSlot, 0);
|
|
1163 ++v5;
|
|
1164 ++pStationaryLight;
|
|
1165 }
|
|
1166 while ( v5 < uNumStationaryLightsApplied );
|
|
1167 }
|
|
1168 result = pSlot;
|
|
1169 stru_F8AD28.field_AC = pSlot;
|
|
1170 LOBYTE(result) = 1;
|
|
1171 return result;
|
|
1172 }
|
|
1173 // 519AB4: using guessed type int uNumStationaryLightsApplied;
|
|
1174
|
|
1175 //----- (0045CE50) --------------------------------------------------------
|
|
1176 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4)
|
|
1177 {
|
|
1178 int result; // eax@0
|
|
1179 signed int v6; // ebx@1
|
|
1180 int v7; // ecx@2
|
|
1181 int v8; // esi@4
|
|
1182 int v9; // edx@6
|
|
1183 int v10; // ecx@8
|
|
1184 int v11; // eax@11
|
|
1185 unsigned int v12; // ebx@11
|
|
1186 RenderD3D *v13; // ecx@11
|
|
1187 char v14; // dl@11
|
|
1188
|
|
1189 v6 = pLight->uRadius;
|
|
1190 if ( v6 > 0
|
|
1191 && (result = (int)pFace, v7 = pLight->vPosition.x, v7 > pFace->pBoundingBox.x1 - v6)
|
|
1192 && v7 < v6 + pFace->pBoundingBox.x2
|
|
1193 && (v8 = pLight->vPosition.y, v8 > pFace->pBoundingBox.y1 - v6)
|
|
1194 && v8 < v6 + pFace->pBoundingBox.y2
|
|
1195 && (v9 = pLight->vPosition.z, v9 > pFace->pBoundingBox.z1 - v6)
|
|
1196 && v9 < v6 + pFace->pBoundingBox.z2
|
|
1197 && ((v10 = (pFace->pFacePlane.dist
|
|
1198 + pLight->vPosition.x * pFace->pFacePlane.vNormal.x
|
|
1199 + v8 * pFace->pFacePlane.vNormal.y
|
|
1200 + v9 * pFace->pFacePlane.vNormal.z) >> 16,
|
|
1201 a4)
|
|
1202 || v10 >= 0)
|
|
1203 && v10 <= v6 )
|
|
1204 {
|
|
1205 stru_F8AD28._blv_lights_radii[*pSlot] = v6;
|
|
1206 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v6;
|
|
1207 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x;
|
|
1208 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y;
|
|
1209 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z;
|
|
1210 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689;
|
|
1211 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
|
|
1212 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
|
|
1213 v11 = abs(v10);
|
|
1214 v12 = pRenderer->bUsingSpecular;
|
|
1215 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11;
|
|
1216 stru_F8AD28._blv_lights_smthngs[*pSlot] = pLight->field_B;
|
|
1217 v13 = pRenderer->pRenderD3D;
|
|
1218 v14 = stru_F8AD28._blv_lights_smthngs[*pSlot];
|
|
1219 if ( pRenderer->pRenderD3D && v12 && v14 & 4 )
|
|
1220 v14 = byte_4E94D2;
|
|
1221 stru_F8AD28._blv_lights_smthngs[*pSlot] = v14;
|
|
1222 result = 4 * *pSlot;
|
|
1223 if ( v13 && v12 )
|
|
1224 {
|
|
1225 if ( stru_F8AD28._blv_lights_smthngs[*pSlot] & 4 )
|
|
1226 {
|
|
1227 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
|
|
1228 * 0.33000001;
|
|
1229 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result)
|
|
1230 * 0.33000001;
|
|
1231 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result)
|
|
1232 * 0.33000001;
|
|
1233 }
|
|
1234 }
|
|
1235 ++*pSlot;
|
|
1236 LOBYTE(result) = 1;
|
|
1237 }
|
|
1238 else
|
|
1239 {
|
|
1240 LOBYTE(result) = 0;
|
|
1241 }
|
|
1242 return result;
|
|
1243 }
|
|
1244 // 4E94D2: using guessed type char byte_4E94D2;
|
|
1245
|
|
1246 //----- (0045D036) --------------------------------------------------------
|
|
1247 bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X)
|
|
1248 {
|
|
1249 int v6; // esi@1
|
|
1250 LightmapBuilder *v7; // edi@1
|
|
1251 MobileLight *v8; // ebx@2
|
|
1252 int v9; // esi@5
|
|
1253 StationaryLight *v10; // ebx@6
|
|
1254 bool result; // eax@9
|
|
1255 unsigned int a7; // [sp+Ch] [bp-4h]@1
|
|
1256
|
|
1257 v6 = 0;
|
|
1258 v7 = this;
|
|
1259 a7 = 0;
|
|
1260 stru_F8AD28.field_2C = pOutdoor->field_CBC_terrain_triangles_shade_type;
|
|
1261 if ( uNumMobileLightsApplied > 0 )
|
|
1262 {
|
|
1263 v8 = pMobileLights;
|
|
1264 do
|
|
1265 {
|
|
1266 if ( (signed int)a7 >= 20 )
|
|
1267 break;
|
|
1268 StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, X, &a7);
|
|
1269 ++v6;
|
|
1270 ++v8;
|
|
1271 }
|
|
1272 while ( v6 < uNumMobileLightsApplied );
|
|
1273 }
|
|
1274 v9 = 0;
|
|
1275 if ( uNumStationaryLightsApplied > 0 )
|
|
1276 {
|
|
1277 v10 = pStationaryLights;
|
|
1278 do
|
|
1279 {
|
|
1280 if ( (signed int)a7 >= 20 )
|
|
1281 break;
|
|
1282 StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, X, &a7);
|
|
1283 ++v9;
|
|
1284 ++v10;
|
|
1285 }
|
|
1286 while ( v9 < uNumStationaryLightsApplied );
|
|
1287 }
|
|
1288 result = a7;
|
|
1289 stru_F8AD28.field_AC = a7;
|
|
1290 LOBYTE(result) = 1;
|
|
1291 return result;
|
|
1292 }
|
|
1293 // 519AB4: using guessed type int uNumStationaryLightsApplied;
|
|
1294
|
|
1295 //----- (0045D0D5) --------------------------------------------------------
|
|
1296 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot)
|
|
1297 {
|
|
1298 StationaryLight *v8; // edi@1
|
|
1299 bool result; // eax@1
|
|
1300 unsigned int v10; // esi@2
|
|
1301 RenderVertexSoft *v11; // ebx@2
|
|
1302 float v12; // eax@3
|
|
1303 float v13; // eax@4
|
|
1304 double v14; // st7@11
|
|
1305 double maxz; // st7@11
|
|
1306 double v16; // st7@11
|
|
1307 double v17; // st6@11
|
|
1308 __int16 v18; // fps@11
|
|
1309 char v19; // c0@11
|
|
1310 char v20; // c2@11
|
|
1311 char v21; // c3@11
|
|
1312 double v22; // st6@12
|
|
1313 __int16 v23; // fps@12
|
|
1314 char v24; // c0@12
|
|
1315 char v25; // c2@12
|
|
1316 char v26; // c3@12
|
|
1317 double v27; // st7@13
|
|
1318 double v28; // st6@13
|
|
1319 __int16 v29; // fps@13
|
|
1320 char v30; // c0@13
|
|
1321 char v31; // c2@13
|
|
1322 char v32; // c3@13
|
|
1323 double v33; // st6@14
|
|
1324 __int16 v34; // fps@14
|
|
1325 char v35; // c0@14
|
|
1326 char v36; // c2@14
|
|
1327 char v37; // c3@14
|
|
1328 double v38; // st7@15
|
|
1329 double v39; // st6@15
|
|
1330 __int16 v40; // fps@15
|
|
1331 char v41; // c0@15
|
|
1332 char v42; // c2@15
|
|
1333 char v43; // c3@15
|
|
1334 double v44; // st6@16
|
|
1335 __int16 v45; // fps@16
|
|
1336 char v46; // c0@16
|
|
1337 char v47; // c2@16
|
|
1338 char v48; // c3@16
|
|
1339 Vec3_float_ *v49; // esi@17
|
|
1340 double v50; // st7@17
|
|
1341 double v51; // st6@17
|
|
1342 signed int v52; // ecx@17
|
|
1343 unsigned int *v53; // esi@18
|
|
1344 int v54; // eax@18
|
|
1345 unsigned int v55; // ebx@18
|
|
1346 RenderD3D *v56; // ecx@18
|
|
1347 char v57; // dl@18
|
|
1348 std::string v58; // [sp-18h] [bp-38h]@10
|
|
1349 const char *v59; // [sp-8h] [bp-28h]@10
|
|
1350 signed int v60; // [sp-4h] [bp-24h]@10
|
|
1351 double v61; // [sp+Ch] [bp-14h]@11
|
|
1352 float minz; // [sp+14h] [bp-Ch]@11
|
|
1353 int v63; // [sp+18h] [bp-8h]@1
|
|
1354 float v64; // [sp+1Ch] [bp-4h]@5
|
|
1355
|
|
1356 v8 = pLight;
|
|
1357 result = pLight->uRadius;
|
|
1358 v63 = pLight->uRadius;
|
|
1359 if ( result <= 0 )
|
|
1360 goto LABEL_27;
|
|
1361 v10 = uStripType;
|
|
1362 v11 = a1;
|
|
1363 if ( uStripType == 4 )
|
|
1364 {
|
|
1365 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x);
|
|
1366 v12 = a1[3].vWorldPosition.x;
|
|
1367 }
|
|
1368 else
|
|
1369 {
|
|
1370 if ( uStripType != 3 )
|
|
1371 {
|
|
1372 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0);
|
|
1373 goto LABEL_11;
|
|
1374 }
|
|
1375 if ( (unsigned char)X )
|
|
1376 {
|
|
1377 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x);
|
|
1378 uStripType = LODWORD(a1[2].vWorldPosition.x);
|
|
1379 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y);
|
|
1380 v13 = v11[2].vWorldPosition.y;
|
|
1381 goto LABEL_5;
|
|
1382 }
|
|
1383 pLight = (StationaryLight *)LODWORD(a1[1].vWorldPosition.x);
|
|
1384 v12 = a1[2].vWorldPosition.x;
|
|
1385 }
|
|
1386 uStripType = LODWORD(v12);
|
|
1387 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y);
|
|
1388 v13 = v11->vWorldPosition.y;
|
|
1389 LABEL_5:
|
|
1390 v64 = v13;
|
|
1391 LABEL_11:
|
|
1392 v60 = v10;
|
|
1393 v59 = (const char *)v11;
|
|
1394 v14 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, v10);
|
|
1395 v60 = v10;
|
|
1396 minz = v14;
|
|
1397 maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, v10);
|
|
1398 result = v8->vPosition.x;
|
|
1399 *((float *)&v61 + 1) = maxz;
|
|
1400 v16 = (double)result;
|
|
1401 *(float *)&X = (double)v63;
|
|
1402 v17 = *(float *)&pLight - *(float *)&X;
|
|
1403 //UNDEF(v18);
|
|
1404 v19 = v16 < v17;
|
|
1405 v20 = 0;
|
|
1406 v21 = v16 == v17;
|
|
1407 BYTE1(result) = HIBYTE(v18);
|
|
1408 if ( v16 <= v17
|
|
1409 || (v22 = *(float *)&X + *(float *)&uStripType,
|
|
1410 //UNDEF(v23),
|
|
1411 v24 = v16 < v22,
|
|
1412 v25 = 0,
|
|
1413 v26 = v16 == v22,
|
|
1414 BYTE1(result) = HIBYTE(v23),
|
|
1415 v16 >= v22)
|
|
1416 || (result = v8->vPosition.y,
|
|
1417 pLight = (StationaryLight *)v8->vPosition.y,
|
|
1418 v27 = (double)(signed int)pLight,
|
|
1419 v28 = *(float *)&a1 - *(float *)&X,
|
|
1420 //UNDEF(v29),
|
|
1421 v30 = v27 < v28,
|
|
1422 v31 = 0,
|
|
1423 v32 = v27 == v28,
|
|
1424 BYTE1(result) = HIBYTE(v29),
|
|
1425 v27 <= v28)
|
|
1426 || (v33 = *(float *)&X + v64,
|
|
1427 //UNDEF(v34),
|
|
1428 v35 = v27 < v33,
|
|
1429 v36 = 0,
|
|
1430 v37 = v27 == v33,
|
|
1431 BYTE1(result) = HIBYTE(v34),
|
|
1432 v27 >= v33)
|
|
1433 || (result = v8->vPosition.z,
|
|
1434 pLight = (StationaryLight *)v8->vPosition.z,
|
|
1435 v38 = (double)(signed int)pLight,
|
|
1436 v39 = minz - *(float *)&X,
|
|
1437 //UNDEF(v40),
|
|
1438 v41 = v38 < v39,
|
|
1439 v42 = 0,
|
|
1440 v43 = v38 == v39,
|
|
1441 BYTE1(result) = HIBYTE(v40),
|
|
1442 v38 <= v39)
|
|
1443 || (v44 = *(float *)&X + *((float *)&v61 + 1),
|
|
1444 //UNDEF(v45),
|
|
1445 v46 = v38 < v44,
|
|
1446 v47 = 0,
|
|
1447 v48 = v38 == v44,
|
|
1448 BYTE1(result) = HIBYTE(v45),
|
|
1449 v38 >= v44)
|
|
1450 || (v49 = pNormal,
|
|
1451 Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3),
|
|
1452 X = v8->vPosition.y,
|
|
1453 v50 = (double)X * v49->y,
|
|
1454 X = v8->vPosition.z,
|
|
1455 v51 = (double)X * v49->z,
|
|
1456 X = v8->vPosition.x,
|
|
1457 *(float *)&a3 = v50 + v51 + (double)X * v49->x + *a3,
|
|
1458 v61 = *(float *)&a3 + 6.7553994e15,
|
|
1459 result = LODWORD(v61),
|
|
1460 X = LODWORD(v61),
|
|
1461 v52 = v63,
|
|
1462 SLODWORD(v61) > v63) )
|
|
1463 {
|
|
1464 LABEL_27:
|
|
1465 LOBYTE(result) = 0;
|
|
1466 return result;
|
|
1467 }
|
|
1468 v53 = pSlot;
|
|
1469 v60 = X;
|
|
1470 stru_F8AD28._blv_lights_radii[*pSlot] = v63;
|
|
1471 stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v52;
|
|
1472 stru_F8AD28._blv_lights_xs[*v53] = v8->vPosition.x;
|
|
1473 stru_F8AD28._blv_lights_ys[*v53] = v8->vPosition.y;
|
|
1474 stru_F8AD28._blv_lights_zs[*v53] = v8->vPosition.z;
|
|
1475 a3 = (float *)v8->uLightColorR;
|
|
1476 stru_F8AD28._blv_lights_rs[*v53] = (double)(signed int)a3 * 0.0039215689;
|
|
1477 a3 = (float *)v8->uLightColorG;
|
|
1478 stru_F8AD28._blv_lights_gs[*v53] = (double)(signed int)a3 * 0.0039215689;
|
|
1479 a3 = (float *)v8->uLightColorB;
|
|
1480 stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.0039215689;
|
|
1481 v54 = abs(v60);
|
|
1482 v55 = pRenderer->bUsingSpecular;
|
|
1483 stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54;
|
|
1484 stru_F8AD28._blv_lights_smthngs[*v53] = v8->field_B;
|
|
1485 v56 = pRenderer->pRenderD3D;
|
|
1486 v57 = stru_F8AD28._blv_lights_smthngs[*v53];
|
|
1487 if ( pRenderer->pRenderD3D && v55 && v57 & 4 )
|
|
1488 v57 = byte_4E94D2;
|
|
1489 stru_F8AD28._blv_lights_smthngs[*v53] = v57;
|
|
1490 result = 4 * *v53;
|
|
1491 if ( v56 && v55 )
|
|
1492 {
|
|
1493 if ( stru_F8AD28._blv_lights_smthngs[*v53] & 4 )
|
|
1494 {
|
|
1495 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
|
|
1496 * 0.33000001;
|
|
1497 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result)
|
|
1498 * 0.33000001;
|
|
1499 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result)
|
|
1500 * 0.33000001;
|
|
1501 }
|
|
1502 }
|
|
1503 ++*v53;
|
|
1504 LOBYTE(result) = 1;
|
|
1505 return result;
|
|
1506 }
|
|
1507 // 4E94D2: using guessed type char byte_4E94D2;
|
|
1508
|
|
1509 //----- (0045D3C7) --------------------------------------------------------
|
|
1510 bool LightmapBuilder::_45D3C7(stru148 *a1)
|
|
1511 {
|
|
1512 LightmapBuilder *v2; // ebx@1
|
|
1513 stru148 *result; // eax@1
|
|
1514 float v4; // ecx@2
|
|
1515 Span *i; // edi@5
|
|
1516
|
|
1517 v2 = this;
|
|
1518 result = (stru148 *)a1->prolly_head;
|
|
1519 if ( result && (v4 = result->field_4, *(int *)&v4) != 0 && *(unsigned int *)(LODWORD(v4) + 60) )
|
|
1520 {
|
|
1521 for ( i = a1->prolly_head; ; i = i->pNext )
|
|
1522 {
|
|
1523 result = i->pParent;
|
|
1524 if ( result->field_108 )
|
|
1525 result = (stru148 *)_45D426(
|
|
1526 i,
|
|
1527 a1->pEdgeList1,
|
|
1528 a1->uEdgeList1Size,
|
|
1529 (Edge *)a1->pEdgeList2,
|
|
1530 a1->uEdgeList2Size);
|
|
1531 if ( a1->prolly_tail == i )
|
|
1532 break;
|
|
1533 }
|
|
1534 LOBYTE(result) = 1;
|
|
1535 }
|
|
1536 else
|
|
1537 {
|
|
1538 LOBYTE(result) = 0;
|
|
1539 }
|
|
1540 return (bool)result;
|
|
1541 }
|
|
1542
|
|
1543 //----- (0045D426) --------------------------------------------------------
|
|
1544 int LightmapBuilder::_45D426(Span *a1, Edge **a2, unsigned int a3, Edge *a4, int a5)
|
|
1545 {
|
|
1546 int v6; // edi@1
|
|
1547 signed int v7; // ebx@3
|
|
1548 signed int v8; // ecx@3
|
|
1549 Span *v9; // esi@3
|
|
1550 double v10; // st7@4
|
|
1551 Edge *v11; // edx@5
|
|
1552 double v12; // st7@11
|
|
1553 int v13; // edx@12
|
|
1554 int v14; // ebx@17
|
|
1555 Edge *v15; // edi@17
|
|
1556 float v16; // ST04_4@17
|
|
1557 float v17; // ST04_4@17
|
|
1558 double v18; // st7@17
|
|
1559 int result; // eax@19
|
2
|
1560 //double v20; // ST14_8@20
|
|
1561 //double v21; // ST14_8@20
|
0
|
1562 double v22; // st7@20
|
|
1563 int v23; // ecx@20
|
|
1564 double v24; // st6@20
|
|
1565 double v25; // st7@23
|
|
1566 double v26; // st7@28
|
|
1567 __int16 v27; // fps@28
|
|
1568 char v28; // c0@28
|
|
1569 char v29; // c2@28
|
|
1570 char v30; // c3@28
|
|
1571 double v31; // st7@29
|
|
1572 double v32; // st7@30
|
|
1573 __int16 v33; // fps@30
|
|
1574 char v34; // c0@30
|
|
1575 char v35; // c2@30
|
|
1576 char v36; // c3@30
|
|
1577 LightmapBuilder *this_4; // [sp+14h] [bp-8h]@1
|
|
1578 signed int v38; // [sp+18h] [bp-4h]@3
|
|
1579 float a1a; // [sp+24h] [bp+8h]@20
|
|
1580 float a2a; // [sp+28h] [bp+Ch]@17
|
|
1581 float a3a; // [sp+2Ch] [bp+10h]@17
|
|
1582 float a5a; // [sp+34h] [bp+18h]@20
|
|
1583 float a5b; // [sp+34h] [bp+18h]@20
|
|
1584
|
|
1585 v6 = 0;
|
|
1586 this_4 = this;
|
|
1587 if ( a5 && a3 )
|
|
1588 {
|
|
1589 v7 = -1;
|
|
1590 v8 = 0;
|
|
1591 v9 = a1;
|
|
1592 v38 = -1;
|
|
1593 if ( (signed int)a3 > 0 )
|
|
1594 {
|
|
1595 v10 = (double)a1->field_A;
|
|
1596 while ( 1 )
|
|
1597 {
|
|
1598 v11 = a2[v8];
|
|
1599 if ( v10 >= v11->field_2C )
|
|
1600 {
|
|
1601 if ( v10 <= v11->field_30 )
|
|
1602 break;
|
|
1603 }
|
|
1604 ++v8;
|
|
1605 if ( v8 >= (signed int)a3 )
|
|
1606 goto LABEL_10;
|
|
1607 }
|
|
1608 v38 = v8;
|
|
1609 }
|
|
1610 LABEL_10:
|
|
1611 if ( a5 > 0 )
|
|
1612 {
|
|
1613 v12 = (double)a1->field_A;
|
|
1614 while ( 1 )
|
|
1615 {
|
|
1616 v13 = *((unsigned int *)&a4->field_0 + v6);
|
|
1617 if ( v12 >= *(float *)(v13 + 44) )
|
|
1618 {
|
|
1619 if ( v12 <= *(float *)(v13 + 48) )
|
|
1620 break;
|
|
1621 }
|
|
1622 ++v6;
|
|
1623 if ( v6 >= a5 )
|
|
1624 goto LABEL_17;
|
|
1625 }
|
|
1626 v7 = v6;
|
|
1627 }
|
|
1628 LABEL_17:
|
|
1629 v14 = *((unsigned int *)&a4->field_0 + v7);
|
|
1630 v15 = a2[v38];
|
|
1631 v16 = (double)a1->field_A;
|
|
1632 a3a = _45D643(a2[v38], v16);
|
|
1633 v17 = (double)a1->field_A;
|
|
1634 v18 = _45D643((Edge *)v14, v17);
|
|
1635 a2a = v18;
|
|
1636 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x80 )
|
|
1637 {
|
|
1638 HIWORD(result) = HIWORD(a3a);
|
|
1639 a1->field_14 = v18;
|
|
1640 a1->field_10 = a3a;
|
|
1641 }
|
|
1642 else
|
|
1643 {
|
|
1644 a5a = ((double)a1->field_A - v15->field_2C) * v15->field_4 + v15->field_24 - 0.5;
|
2
|
1645 //v20 = a5a + 6.7553994e15;
|
|
1646 //a5b = (double)SLODWORD(v20);
|
3
|
1647 a5b = (double)floorf(a5a + 0.5f);
|
0
|
1648 a1a = ((double)a1->field_A - *(float *)(v14 + 44)) * *(float *)(v14 + 4) + *(float *)(v14 + 36) + 0.5;
|
2
|
1649 //v21 = a1a + 6.7553994e15;
|
|
1650 //v22 = (double)SLODWORD(v21);
|
3
|
1651 v22 = (double)floorf(a1a + 0.5f);
|
0
|
1652 result = v9->field_8;
|
|
1653 v23 = v9->field_C;
|
|
1654 v24 = -((a3a - a2a) / (v22 - a5b));
|
|
1655 v9->field_10 = ((double)result - a5b) * v24 + a3a;
|
|
1656 v9->field_14 = a2a - (v22 - (double)(result + v23)) * v24;
|
|
1657 }
|
|
1658 if ( v9->field_10 < 0.0 || v9->field_10 <= 1.0 )
|
|
1659 {
|
|
1660 if ( v9->field_10 >= 0.0 )
|
|
1661 v25 = v9->field_10;
|
|
1662 else
|
|
1663 v25 = 0.0;
|
|
1664 }
|
|
1665 else
|
|
1666 {
|
|
1667 v25 = 1.0;
|
|
1668 }
|
|
1669 v9->field_10 = v25;
|
|
1670 if ( v9->field_14 < 0.0
|
|
1671 || (v26 = v9->field_14,
|
|
1672 //UNDEF(v27),
|
|
1673 v28 = 1.0 < v26,
|
|
1674 v29 = 0,
|
|
1675 v30 = 1.0 == v26,
|
|
1676 BYTE1(result) = HIBYTE(v27),
|
|
1677 v26 <= 1.0) )
|
|
1678 {
|
|
1679 v32 = v9->field_14;
|
|
1680 //UNDEF(v33);
|
|
1681 v34 = 0.0 < v32;
|
|
1682 v35 = 0;
|
|
1683 v36 = 0.0 == v32;
|
|
1684 BYTE1(result) = HIBYTE(v33);
|
|
1685 if ( v32 >= 0.0 )
|
|
1686 v31 = v9->field_14;
|
|
1687 else
|
|
1688 v31 = 0.0;
|
|
1689 }
|
|
1690 else
|
|
1691 {
|
|
1692 v31 = 1.0;
|
|
1693 }
|
|
1694 v9->field_14 = v31;
|
|
1695 LOBYTE(result) = 1;
|
|
1696 }
|
|
1697 else
|
|
1698 {
|
|
1699 LOBYTE(result) = 0;
|
|
1700 }
|
|
1701 return result;
|
|
1702 }
|
|
1703 // 4D864C: using guessed type char byte_4D864C;
|
|
1704
|
|
1705 //----- (0045D643) --------------------------------------------------------
|
|
1706 double LightmapBuilder::_45D643(Edge *a1, float a2)
|
|
1707 {
|
|
1708 double result; // st7@1
|
|
1709
|
|
1710 result = (a1->field_1C - a1->field_20) * -1.0 / (a1->field_30 - a1->field_2C) * (a2 - a1->field_2C) + a1->field_1C;
|
|
1711 if ( result < 0.0 || result <= 1.0 )
|
|
1712 {
|
|
1713 if ( result < 0.0 )
|
|
1714 result = 0.0;
|
|
1715 }
|
|
1716 else
|
|
1717 {
|
|
1718 result = 1.0;
|
|
1719 }
|
|
1720 return result;
|
|
1721 }
|
|
1722
|
|
1723 //----- (0045D698) --------------------------------------------------------
|
|
1724 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2)
|
|
1725 {
|
|
1726 bool result; // eax@1
|
|
1727 LightmapBuilder *v3; // esi@1
|
|
1728 RenderVertexSoft *v4; // edi@3
|
|
1729 RenderVertexSoft *v5; // edi@7
|
|
1730 IndoorCameraD3D *thisa; // [sp+10h] [bp-8h]@1
|
|
1731 bool v7; // [sp+14h] [bp-4h]@2
|
|
1732 bool a2a; // [sp+20h] [bp+8h]@6
|
|
1733
|
|
1734 result = (bool)pGame->pIndoorCameraD3D;
|
|
1735 v3 = this;
|
|
1736 thisa = pGame->pIndoorCameraD3D;
|
|
1737 if ( bit_one_for_list1__bit_two_for_list2 & 1 )
|
|
1738 {
|
|
1739 v7 = 0;
|
|
1740 if ( (signed int)this->std__vector_000004_size > 0 )
|
|
1741 {
|
|
1742 v4 = this->std__vector_000004[0].pVertices;
|
|
1743 do
|
|
1744 {
|
|
1745 pGame->pIndoorCameraD3D->debug_outline_sw(v4, *((unsigned int *)v4 - 1), 0xFF00u, 0.0);
|
|
1746 ++v7;
|
|
1747 v4 = (RenderVertexSoft *)((char *)v4 + 3100);
|
|
1748 result = v7;
|
|
1749 }
|
|
1750 while ( v7 < (signed int)v3->std__vector_000004_size );
|
|
1751 }
|
|
1752 }
|
|
1753 if ( bit_one_for_list1__bit_two_for_list2 & 2 )
|
|
1754 {
|
|
1755 a2a = 0;
|
|
1756 if ( (signed int)v3->std__vector_183808_size > 0 )
|
|
1757 {
|
|
1758 v5 = v3->std__vector_183808[0].pVertices;
|
|
1759 do
|
|
1760 {
|
|
1761 pGame->pIndoorCameraD3D->debug_outline_sw(v5, *((unsigned int *)v5 - 1), 0xC04000u, 0.00019999999);
|
|
1762 ++a2a;
|
|
1763 v5 = (RenderVertexSoft *)((char *)v5 + 3100);
|
|
1764 result = a2a;
|
|
1765 }
|
|
1766 while ( a2a < (signed int)v3->std__vector_183808_size );
|
|
1767 }
|
|
1768 }
|
|
1769 LOBYTE(result) = 1;
|
|
1770 return result;
|
|
1771 }
|
|
1772
|
|
1773 //----- (0045D73F) --------------------------------------------------------
|
|
1774 void LightmapBuilder::DrawLightmaps(int a2)
|
|
1775 {
|
|
1776 if ( a2 == 2 )
|
|
1777 DoDrawLightmaps();
|
|
1778 }
|
|
1779
|
|
1780 //----- (0045D74F) --------------------------------------------------------
|
|
1781 char LightmapBuilder::_45D74F_MessWithLight(int a2, int *a3)
|
|
1782 {
|
|
1783 char v3; // zf@1
|
|
1784 IDirect3DDevice3 *v4; // eax@2
|
|
1785 HRESULT v5; // eax@2
|
|
1786 char *v6; // eax@2
|
|
1787 struct IDirect3DTexture2 *v7; // edi@4
|
|
1788 HRESULT v8; // eax@8
|
|
1789 HRESULT v9; // eax@8
|
|
1790 HRESULT v10; // eax@8
|
|
1791 HRESULT v11; // eax@8
|
|
1792 HRESULT v12; // eax@8
|
|
1793 int *v13; // eax@8
|
|
1794 float v14; // ecx@15
|
|
1795 IDirect3DDevice3 *v15; // eax@21
|
|
1796 HRESULT v16; // eax@21
|
|
1797 IDirect3DDevice3 *v17; // eax@21
|
|
1798 HRESULT v18; // eax@21
|
|
1799 IDirect3DDevice3 *v19; // eax@21
|
|
1800 HRESULT v20; // eax@21
|
|
1801 IDirect3DDevice3 *v21; // eax@21
|
|
1802 HRESULT v22; // eax@21
|
|
1803 IDirect3DDevice3 *v23; // eax@23
|
|
1804 std::string v25; // [sp+44h] [bp-44h]@12
|
|
1805 signed int v26; // [sp+48h] [bp-40h]@21
|
|
1806 signed int v27; // [sp+4Ch] [bp-3Ch]@21
|
|
1807 Lightmap *v28; // [sp+50h] [bp-38h]@2
|
|
1808 int v29; // [sp+54h] [bp-34h]@2
|
|
1809 float v30; // [sp+58h] [bp-30h]@2
|
|
1810 int arg4; // [sp+68h] [bp-20h]@8
|
|
1811 float v32; // [sp+6Ch] [bp-1Ch]@8
|
|
1812 float v33; // [sp+70h] [bp-18h]@8
|
|
1813 int v34; // [sp+74h] [bp-14h]@19
|
|
1814 int v35; // [sp+78h] [bp-10h]@2
|
|
1815 int *v36; // [sp+7Ch] [bp-Ch]@10
|
|
1816 int a1; // [sp+80h] [bp-8h]@12
|
|
1817 float v38; // [sp+84h] [bp-4h]@1
|
|
1818
|
|
1819 v3 = this->std__vector_000004_size == 0;
|
|
1820 LODWORD(v38) = (int)this;
|
|
1821 if ( !v3 )
|
|
1822 {
|
|
1823 v30 = 0.0;
|
|
1824 //v4 = pRenderer->pRenderD3D->pDevice;
|
|
1825 ErrD3D(v4->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
|
|
1826 v6 = (char *)stru_69BD44.c_str();
|
|
1827 if ( !stru_69BD44.c_str() )
|
|
1828 v6 = (char *)&dword_4D86F0;
|
|
1829 v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v6);
|
|
1830 if ( pRenderer->bUsingSpecular )
|
|
1831 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
|
|
1832 if ( !byte_4D864C || !(pGame->uFlags & 1) )
|
|
1833 {
|
|
1834 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
|
|
1835 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
|
|
1836 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7));
|
|
1837 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
|
|
1838 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
|
|
1839 v13 = a3;
|
|
1840 v33 = 1.0;
|
|
1841 v32 = 1.0;
|
|
1842 *(float *)&arg4 = 1.0;
|
|
1843 if ( a3 )
|
|
1844 {
|
|
1845 if ( *a3 != -1 )
|
|
1846 {
|
|
1847 v36 = a3;
|
|
1848 do
|
|
1849 {
|
|
1850 v28 = (Lightmap *)(3100 * *v13 + LODWORD(v38) + 4);
|
|
1851 if ( !DrawLightmap(v28, (Vec3_float_ *)&arg4, 0.0) )
|
|
1852 {
|
|
1853 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1230", 0);
|
|
1854 a1 = 5080812;
|
|
1855 }
|
|
1856 v13 = v36 + 1;
|
|
1857 v36 = v13;
|
|
1858 }
|
|
1859 while ( *v13 != -1 );
|
|
1860 }
|
|
1861 }
|
|
1862 else
|
|
1863 {
|
|
1864 v14 = v38;
|
|
1865 v36 = 0;
|
|
1866 if ( *(unsigned int *)(LODWORD(v38) + 1587204) > 0 )
|
|
1867 {
|
|
1868 a1 = LODWORD(v38) + 4;
|
|
1869 while ( 1 )
|
|
1870 {
|
|
1871 if ( !DrawLightmap((Lightmap *)a1, (Vec3_float_ *)&arg4, 0.0) )
|
|
1872 {
|
|
1873 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0);
|
|
1874 v35 = 5080812;
|
|
1875 }
|
|
1876 v36 = (int *)((char *)v36 + 1);
|
|
1877 a1 += 3100;
|
|
1878 if ( (signed int)v36 >= *(unsigned int *)(LODWORD(v38) + 1587204) )
|
|
1879 break;
|
|
1880 v14 = v38;
|
|
1881 }
|
|
1882 }
|
|
1883 }
|
|
1884 v15 = pRenderer->pRenderD3D->pDevice;
|
|
1885 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
|
|
1886 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
|
|
1887 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
|
|
1888 ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
|
|
1889 }
|
|
1890 if ( pRenderer->bUsingSpecular )
|
|
1891 {
|
|
1892 //LODWORD(v30) = 1;
|
|
1893 //v29 = 28;
|
|
1894 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
|
|
1895 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1);
|
|
1896 v30 = pRenderer->uFogColor;
|
|
1897 v23 = pRenderer->pRenderD3D->pDevice;
|
|
1898 //v29 = 34;
|
|
1899 //v28 = (Lightmap *)v23;
|
|
1900 v23->SetRenderState(D3DRENDERSTATE_FOGCOLOR, LODWORD(pRenderer->uFogColor));
|
|
1901 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
|
|
1902 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, false);
|
|
1903 }
|
|
1904 }
|
|
1905 return 1;
|
|
1906 }
|
|
1907 // 4D864C: using guessed type char byte_4D864C;
|
|
1908 // 4D86F0: using guessed type int dword_4D86F0;
|
|
1909
|
|
1910 //----- (0045DA56) --------------------------------------------------------
|
|
1911 bool LightmapBuilder::DrawLightmaps2(float a2)
|
|
1912 {
|
|
1913 LightmapBuilder *v2; // esi@1
|
|
1914 bool result; // eax@1
|
|
1915 signed int v4; // edi@2
|
|
1916 std::string v5; // [sp-14h] [bp-3Ch]@5
|
|
1917 const char *v6; // [sp-4h] [bp-2Ch]@5
|
|
1918 int v7; // [sp+0h] [bp-28h]@5
|
|
1919 Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2
|
|
1920 std::string *v9; // [sp+18h] [bp-10h]@5
|
|
1921 unsigned int v10; // [sp+1Ch] [bp-Ch]@5
|
|
1922 Lightmap *a1; // [sp+20h] [bp-8h]@3
|
|
1923 int a3; // [sp+27h] [bp-1h]@5
|
|
1924
|
|
1925 v2 = this;
|
|
1926 result = this->std__vector_183808_size;
|
|
1927 if ( result )
|
|
1928 {
|
|
1929 v4 = 0;
|
|
1930 v.z = 1.0;
|
|
1931 v.y = 1.0;
|
|
1932 v.x = 1.0;
|
|
1933 if ( result > 0 )
|
|
1934 {
|
|
1935 a1 = this->std__vector_183808;
|
|
1936 do
|
|
1937 {
|
|
1938 result = DrawLightmap(a1, &v, a2);
|
|
1939 if ( !result )
|
|
1940 {
|
|
1941 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0);
|
|
1942 v10 = 0x4D86ECu;
|
|
1943 }
|
|
1944 ++a1;
|
|
1945 ++v4;
|
|
1946 }
|
|
1947 while ( v4 < (signed int)v2->std__vector_183808_size);
|
|
1948 }
|
|
1949 }
|
|
1950 LOBYTE(result) = 1;
|
|
1951 return result;
|
|
1952 }
|
|
1953
|
|
1954 //----- (0045DAE8) --------------------------------------------------------
|
|
1955 bool LightmapBuilder::DrawLightmap(Lightmap *a1, Vec3_float_ *arg4, float thisa)
|
|
1956 {
|
|
1957 Lightmap *v4; // edx@1
|
|
1958 bool result; // eax@2
|
|
1959 double v6; // st7@3
|
|
1960 Vec3_float_ *v7; // ecx@3
|
|
1961 LEVEL_TYPE v8; // edi@3
|
|
1962 int v9; // esi@3
|
|
1963 double v10; // st7@4
|
|
1964 unsigned int v11; // ebx@6
|
|
1965 char *v12; // ecx@7
|
|
1966 int v13; // edx@7
|
|
1967 double v14; // st7@7
|
|
1968 __int16 v15; // fps@8
|
|
1969 unsigned __int8 v16; // c2@8
|
|
1970 unsigned __int8 v17; // c3@8
|
|
1971 double v18; // st3@8
|
|
1972 int v19; // eax@11
|
|
1973 double v20; // st3@11
|
|
1974 int v21; // eax@11
|
|
1975 char v22; // zf@11
|
|
1976 HRESULT v23; // eax@15
|
|
1977 signed int v24; // [sp-1Ch] [bp-670h]@13
|
|
1978 const char *v25; // [sp-18h] [bp-66Ch]@13
|
|
1979 int v26; // [sp-14h] [bp-668h]@13
|
|
1980 HRESULT a2; // [sp+0h] [bp-654h]@15
|
|
1981 char v28; // [sp+4h] [bp-650h]@7
|
|
1982 double v29; // [sp+640h] [bp-14h]@3
|
|
1983 __int64 v30; // [sp+648h] [bp-Ch]@3
|
|
1984 float v31; // [sp+650h] [bp-4h]@3
|
|
1985 signed int a1b; // [sp+65Ch] [bp+8h]@3
|
|
1986 float a1c; // [sp+65Ch] [bp+8h]@3
|
|
1987 float a1d; // [sp+65Ch] [bp+8h]@3
|
|
1988 float a1e; // [sp+65Ch] [bp+8h]@3
|
|
1989 unsigned int a1a; // [sp+65Ch] [bp+8h]@7
|
|
1990 int arg4a; // [sp+660h] [bp+Ch]@3
|
|
1991
|
|
1992 v4 = a1;
|
|
1993 if ( (signed int)a1->uNumVertices >= 3 )
|
|
1994 {
|
|
1995 v6 = (double)BYTE1(a1->field_C10) * a1->flt_C14;
|
|
1996 v30 = a1->field_C10 & 0xFFi64;
|
|
1997 a1b = BYTE2(a1->field_C10);
|
|
1998 v7 = arg4;
|
2
|
1999 //v31 = v6;
|
0
|
2000 *((float *)&v30 + 1) = (double)v30 * v4->flt_C14;
|
|
2001 a1c = (double)a1b * v4->flt_C14 * arg4->x;
|
2
|
2002 //v29 = a1c + 6.7553994e15;
|
|
2003 //arg4a = LODWORD(v29);
|
3
|
2004 arg4a = floorf(a1c + 0.5f);
|
2
|
2005
|
|
2006 a1d = v6 * v7->y;
|
0
|
2007 v29 = a1d + 6.7553994e15;
|
|
2008 LODWORD(v31) = LODWORD(v29);
|
2
|
2009
|
0
|
2010 a1e = *((float *)&v30 + 1) * v7->z;
|
2
|
2011
|
0
|
2012 v29 = a1e + 6.7553994e15;
|
|
2013 HIDWORD(v30) = LODWORD(v29);
|
2
|
2014
|
0
|
2015 v8 = uCurrentlyLoadedLevelType;
|
|
2016 v9 = LODWORD(v29) | ((LODWORD(v31) | (arg4a << 8)) << 8);
|
|
2017 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
2018 v10 = (double)pOutdoorCamera->shading_dist_mist;
|
|
2019 else
|
|
2020 v10 = 16192.0;
|
|
2021 v11 = v4->uNumVertices;
|
|
2022 if ( (signed int)v11 > 0 )
|
|
2023 {
|
|
2024 v12 = &v28;
|
|
2025 v13 = (int)&v4->pVertices[0].vWorldViewPosition;
|
|
2026 v14 = 1.0 / v10;
|
|
2027 a1a = v11;
|
|
2028 do
|
|
2029 {
|
|
2030 //UNDEF(v15);
|
|
2031 v18 = 1.0 - 1.0 / (v14 * *(float *)v13 * 1000.0);
|
|
2032 if ( !(v17 | v16) )
|
|
2033 {
|
|
2034 v18 = v18 - thisa;
|
|
2035 if ( v18 < 0.000099999997 )
|
|
2036 v18 = 0.000099999997;
|
|
2037 }
|
|
2038 *((float *)v12 + 1) = v18;
|
|
2039 v19 = *(unsigned int *)(v13 + 12);
|
|
2040 *((unsigned int *)v12 + 4) = 0;
|
|
2041 v20 = 1.0 / *(float *)v13;
|
|
2042 *((unsigned int *)v12 - 1) = v19;
|
|
2043 *(unsigned int *)v12 = *(unsigned int *)(v13 + 16);
|
|
2044 *((unsigned int *)v12 + 5) = *(unsigned int *)(v13 + 24);
|
|
2045 v21 = *(unsigned int *)(v13 + 28);
|
|
2046 *((unsigned int *)v12 + 3) = v9;
|
|
2047 *((unsigned int *)v12 + 6) = v21;
|
|
2048 v13 += 48;
|
|
2049 v12 += 32;
|
|
2050 v22 = a1a-- == 1;
|
|
2051 *((float *)v12 - 6) = v20;
|
|
2052 }
|
|
2053 while ( !v22 );
|
|
2054 }
|
|
2055 if ( v8 == 1 )
|
|
2056 {
|
|
2057 v26 = 1346;
|
|
2058 v25 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp";
|
|
2059 v24 = 28;
|
|
2060 }
|
|
2061 else
|
|
2062 {
|
|
2063 v26 = 1354;
|
|
2064 v25 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp";
|
|
2065 v24 = 16;
|
|
2066 }
|
|
2067 v23 = pRenderer->pRenderD3D->pDevice->DrawPrimitive(
|
|
2068 D3DPT_TRIANGLEFAN,
|
|
2069 452,
|
|
2070 &a2,
|
|
2071 v11,
|
|
2072 v24);
|
|
2073 //CheckHRESULT((CheckHRESULT_stru0 *)&thisa, v23, v25, v26, 0);
|
|
2074 LOBYTE(result) = 1;
|
|
2075 }
|
|
2076 else
|
|
2077 {
|
|
2078 LOBYTE(result) = 0;
|
|
2079 }
|
|
2080 return result;
|
|
2081 }
|
|
2082
|
|
2083 //----- (0045DCA9) --------------------------------------------------------
|
|
2084 void LightmapBuilder::DoDrawLightmaps()
|
|
2085 {
|
|
2086 const char *v1; // ebx@0
|
|
2087 int v2; // ebp@0
|
|
2088 int v3; // edi@0
|
|
2089 int v4; // esi@0
|
|
2090 HRESULT v5; // eax@4
|
|
2091 HRESULT v6; // eax@4
|
|
2092 HRESULT v7; // eax@4
|
|
2093 char *v8; // eax@4
|
|
2094 //IDirect3DDevice3Vtbl *v9; // ebp@6
|
|
2095 struct IDirect3DTexture2 *v10; // ST90_4@6
|
|
2096 //IDirect3DDevice3 *v11; // ST88_4@6
|
|
2097 HRESULT v12; // eax@6
|
|
2098 HRESULT v13; // eax@6
|
|
2099 HRESULT v14; // eax@6
|
|
2100 HRESULT v15; // eax@6
|
|
2101 HRESULT v16; // eax@6
|
|
2102 HRESULT v17; // eax@6
|
|
2103 HRESULT v18; // eax@6
|
|
2104 HRESULT v19; // eax@6
|
|
2105 LightmapBuilder *v20; // [sp+98h] [bp-8h]@1
|
|
2106 LightmapBuilder *v21; // [sp+9Ch] [bp-4h]@1
|
|
2107 LightmapBuilder *thisa; // [sp+A4h] [bp+4h]@0
|
|
2108 //CheckHRESULT_stru0 a8; // [sp+A8h] [bp+8h]@0
|
|
2109 //CheckHRESULT_stru0 thisaa; // [sp+B4h] [bp+14h]@0
|
|
2110
|
|
2111 v21 = this;
|
|
2112 v20 = this;
|
|
2113 if ( this->std__vector_183808_size )
|
|
2114 {
|
|
2115 if ( pRenderer->bUsingSpecular )
|
|
2116 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
|
|
2117
|
|
2118 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
|
|
2119 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
|
|
2120 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
|
|
2121 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
|
|
2122
|
|
2123 v8 = (char *)stru_69BD44.c_str();
|
|
2124 if ( !stru_69BD44.size() )
|
|
2125 v8 = (char *)&dword_4D86F0;
|
|
2126 //v9 = pRenderer->pRenderD3D->pDevice->lpVtbl;
|
|
2127 v10 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v8);
|
|
2128 //v11 = pRenderer->pRenderD3D->pDevice;
|
|
2129 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v10));
|
|
2130 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
|
|
2131 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
|
|
2132
|
|
2133 DrawLightmaps2(0.00050000002);
|
|
2134
|
|
2135 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
|
|
2136 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
|
|
2137 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
|
|
2138 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
|
|
2139 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
|
|
2140 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
|
|
2141 if ( pRenderer->bUsingSpecular )
|
|
2142 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
|
|
2143 }
|
|
2144 } |