Mercurial > mm7
annotate LightmapBuilder.cpp @ 2461:ff7f4995aa25
function MakeScreenshot()
author | Ritor1 |
---|---|
date | Tue, 05 Aug 2014 17:00:35 +0600 |
parents | 8b04ba723324 |
children | 1d04e48651d4 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2245
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 #include "LightmapBuilder.h" |
7 #include "Game.h" | |
8 #include "stru314.h" | |
9 #include "Outdoor.h" | |
1277 | 10 #include "Outdoor_stuff.h" |
0 | 11 #include "Log.h" |
1545 | 12 #include "ErrorHandling.h" |
0 | 13 |
1262 | 14 #include "Lights.h" |
1016 | 15 |
0 | 16 #include "mm7_data.h" |
17 | |
18 | |
19 | |
1016 | 20 #include "stru9.h" |
0 | 21 |
22 | |
23 | |
24 | |
25 LightsStack_StationaryLight_ *pStationaryLightsStack = new LightsStack_StationaryLight_; | |
26 //StationaryLight pStationaryLights[400]; | |
27 //int uNumStationaryLightsApplied; // weak | |
28 LightsStack_MobileLight_ *pMobileLightsStack = new LightsStack_MobileLight_; | |
29 //MobileLight pMobileLights[400]; | |
30 //int uNumMobileLightsApplied; | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 //----- (0045DF13) -------------------------------------------------------- | |
37 Lightmap::Lightmap() | |
38 { | |
39 field_C18 = 0; | |
40 } | |
41 | |
42 //----- (0045BB06) -------------------------------------------------------- | |
43 LightmapBuilder::LightmapBuilder() | |
44 { | |
45 } | |
46 | |
47 //----- (0045BC07) -------------------------------------------------------- | |
48 bool LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char uClipFlag) | |
49 { | |
50 Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21 | |
51 RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8 | |
52 | |
53 if (!uNumVertices) | |
54 return false; | |
55 | |
56 static RenderVertexSoft static_69B140[64]; | |
57 | |
58 a9 = a5; | |
59 if (a6) | |
60 { | |
61 for (uint i = 0; i < uNumVertices; ++i) | |
62 memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft)); | |
63 | |
687 | 64 //__debugbreak(); |
2245 | 65 if (pGame->pIndoorCameraD3D->_437376(a3, static_69B140, &uNumVertices) == 1) |
0 | 66 { |
67 if ( !uNumVertices ) | |
68 return false; | |
69 a9 = static_69B140; | |
70 } | |
71 } | |
72 | |
73 static stru314 static_69B110; | |
74 static_69B110.field_4.x = a3->face_plane.vNormal.x; | |
75 static_69B110.field_4.y = a3->face_plane.vNormal.y; | |
76 static_69B110.field_4.z = a3->face_plane.vNormal.z; | |
77 static_69B110.dist = a3->face_plane.dist; | |
2245 | 78 if (!pGame->pIndoorCameraD3D->GetFacetOrientation(a3->polygonType, &static_69B110.field_4, |
79 &static_69B110.field_10, &static_69B110.field_1C)) | |
0 | 80 { |
81 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0); | |
82 ExitProcess(0); | |
83 } | |
84 | |
85 for (uint i = 0; i < a2->uNumLightsApplied; ++i) | |
86 { | |
87 pos.x = a2->_blv_lights_xs[i]; | |
88 pos.y = a2->_blv_lights_ys[i]; | |
89 pos.z = a2->_blv_lights_zs[i]; | |
90 | |
91 uint uColorR = (uint)floorf(a2->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF, | |
92 uColorG = (uint)floorf(a2->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF, | |
93 uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF; | |
94 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB; | |
95 if (!uColor) | |
96 uColor = 0x00FFFFF; | |
97 | |
2245 | 98 if (!_45BE86_build_light_polygon(&pos, a2->_blv_lights_radii[i], uColor, a2->_blv_lights_light_dot_faces[i], |
99 a2->_blv_lights_types[i], &static_69B110, uNumVertices, a9, uClipFlag) ) | |
0 | 100 { |
101 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0); | |
102 } | |
103 } | |
104 return true; | |
105 } | |
106 | |
107 //----- (0045BE86) -------------------------------------------------------- | |
108 bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag) | |
109 { | |
110 Lightmap *v11; // edi@3 | |
111 double v17; // st7@5 | |
112 double v24; // st7@6 | |
113 double v38; // st7@14 | |
114 double v39; // st7@16 | |
115 double v40; // st7@16 | |
116 int v45; // eax@24 | |
117 | |
118 if (fabsf(radius) < 1e-6f) | |
119 return true; | |
120 | |
121 v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] : | |
122 &std__vector_183808[std__vector_183808_size]; | |
123 flt_3C8C24 = radius - dot_dist; | |
124 flt_3C8C28 = sqrt((radius + dot_dist) * (radius - dot_dist)); | |
125 flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius; | |
126 v11->field_C08 = (double)pos->x - dot_dist * a7->field_4.x; | |
127 v11->field_C0A = (double)pos->y - dot_dist * a7->field_4.y; | |
128 v11->field_C0C = (double)pos->z - dot_dist * a7->field_4.z; | |
129 | |
130 v17 = radius * flt_3C8C2C_lightmaps_brightness; | |
131 flt_3C8C30 = v17; | |
132 flt_3C8C0C = v17 * a7->field_10.x; | |
133 flt_3C8C10 = v17 * a7->field_10.y; | |
134 flt_3C8C14 = v17 * a7->field_10.z; | |
135 flt_3C8C18 = v17 * a7->field_1C.x; | |
136 flt_3C8C1C = v17 * a7->field_1C.y; | |
137 flt_3C8C20 = v17 * a7->field_1C.z; | |
138 | |
139 /* | |
140 v11->pVertices[0].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C; | |
141 v11->pVertices[0].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10; | |
142 v11->pVertices[0].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14; | |
143 v11->pVertices[0].u = 0.0; | |
144 v11->pVertices[0].v = 0.0; | |
145 | |
146 v11->pVertices[1].vWorldPosition.x = v11->field_C08 - flt_3C8C18 - flt_3C8C0C; | |
147 v11->pVertices[1].vWorldPosition.y = v11->field_C0A - flt_3C8C1C - flt_3C8C10; | |
148 v11->pVertices[1].vWorldPosition.z = v11->field_C0C - flt_3C8C20 - flt_3C8C14; | |
149 v11->pVertices[1].u = 0.0; | |
150 v11->pVertices[1].v = 1.0; | |
151 | |
152 v11->pVertices[2].vWorldPosition.x = v11->field_C08 + flt_3C8C18 - flt_3C8C0C; | |
153 v11->pVertices[2].vWorldPosition.y = v11->field_C0A + flt_3C8C1C - flt_3C8C10; | |
154 v11->pVertices[2].vWorldPosition.z = v11->field_C0C + flt_3C8C20 - flt_3C8C14; | |
155 v11->pVertices[2].u = 1.0; | |
156 v11->pVertices[2].v = 1.0; | |
157 | |
158 v11->pVertices[3].vWorldPosition.x = v11->field_C08 + flt_3C8C18 + flt_3C8C0C; | |
159 v11->pVertices[3].vWorldPosition.y = v11->field_C0A + flt_3C8C1C + flt_3C8C10; | |
160 v11->pVertices[3].vWorldPosition.z = v11->field_C0C + flt_3C8C20 + flt_3C8C14; | |
161 v11->pVertices[3].u = 1.0; | |
162 v11->pVertices[3].v = 0.0; | |
163 */ | |
164 | |
165 for (uint i = 0; i < 4; ++i) | |
166 { | |
167 v11->pVertices[i].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C; | |
168 v11->pVertices[i].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10; | |
169 v11->pVertices[i].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14; | |
170 v11->pVertices[i].u = 0.0; | |
171 v11->pVertices[i].v = 0.0; | |
172 | |
173 v24 = a7->field_4.y * v11->pVertices[i].vWorldPosition.y | |
174 + a7->field_4.z * v11->pVertices[i].vWorldPosition.z | |
175 + a7->field_4.x * v11->pVertices[i].vWorldPosition.x | |
176 + a7->dist; | |
177 | |
178 v11->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x; | |
179 v11->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y; | |
180 v11->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z; | |
181 } | |
182 | |
183 v11->uColorMask = uColorMask; | |
184 v11->uNumVertices = 4; | |
185 | |
186 if (~pGame->uFlags2 & 4) | |
187 v11->fBrightness = flt_3C8C2C_lightmaps_brightness; | |
188 else | |
189 { | |
190 Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8 | |
191 a1.x = (double)pos->x - v11->field_C08; | |
192 a1.y = (double)pos->y - v11->field_C0A; | |
193 a1.z = (double)pos->z - v11->field_C0C; | |
194 a1.Normalize(); | |
195 | |
196 auto dist_x = abs(pos->x - v11->field_C08), //v31 | |
197 dist_y = abs(pos->y - v11->field_C0A), //v32 arg0a | |
198 dist_z = abs(pos->z - v11->field_C0C); //v33 _v64 | |
2235
6ab7d7c112bb
adding int_get_vector_length calls where the calls were inlined
Grumpy7
parents:
2155
diff
changeset
|
199 v38 = int_get_vector_length(dist_x, dist_y, dist_z); |
0 | 200 if (v38 > radius) |
201 return true; | |
202 //radius = (1 / radius) * v38; | |
203 if ( uLightType & 4 ) | |
204 { | |
205 //v59 = (void *)v37; | |
206 //uLightType = flt_4D86CC; | |
207 //v58 = v37; | |
208 v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y); | |
209 v40 = v39 * 1.0 * flt_4D86CC; | |
210 | |
211 v11->fBrightness = v40 - (1 / radius) * v38 * v40; | |
212 } | |
213 else if ( uLightType & 8 ) | |
214 { | |
215 v40 = 1.0 * 1.0; | |
216 v11->fBrightness = v40 - (1 / radius) * v38; | |
217 } | |
218 else | |
219 MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0); | |
220 } | |
221 | |
222 if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices, | |
223 a7->field_4.x, a7->field_4.y, a7->field_4.z, | |
224 v11->pVertices, &v11->uNumVertices)) | |
225 return false; | |
226 | |
227 //v44 = &v11->uNumVertices; | |
228 if (!v11->uNumVertices) | |
229 return true; | |
230 | |
2325 | 231 v45 = _45C6D6(uNumVertices, a9, v11); |
0 | 232 if ( v45 != uNumVertices && v45 > 0 ) |
233 _45C4B9(uNumVertices, a9, v11); | |
234 //v59 = v11->uNumVertices; | |
235 //v46 = (RenderVertexSoft *)pLightmapVertices_; | |
236 pGame->pIndoorCameraD3D->ViewTransform(v11->pVertices, v11->uNumVertices); | |
237 //v59 = 0; | |
238 //v58 = v11->uNumVertices; | |
239 pGame->pIndoorCameraD3D->Project(v11->pVertices, v11->uNumVertices, 0); | |
240 | |
241 unsigned int _a4 = 0; | |
242 if ( !(uClipFlag & 1) ) | |
243 _a4 = 1; | |
244 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
245 { | |
246 if ( uClipFlag & 2 ) | |
247 { | |
248 //v59 = &a4; | |
249 //v58 = (unsigned int)field_3C8C34; | |
250 //v57 = *v44; | |
251 pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4); | |
252 | |
253 //v59 = v44; | |
254 //v58 = (unsigned int)field_3C8C34; | |
255 //v57 = (int)v46; | |
256 //v56 = a4; | |
257 pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices); | |
258 } | |
259 else if ( uClipFlag & 4 ) | |
260 { | |
261 //v59 = &a4; | |
262 //v58 = (unsigned int)field_3C8C34; | |
263 //v57 = *v44; | |
264 pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4); | |
265 | |
266 //v59 = v44; | |
267 //v58 = (unsigned int)field_3C8C34; | |
268 //v57 = (int)v46; | |
269 //v56 = a4; | |
270 pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices); | |
271 } | |
272 else | |
273 MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0); | |
274 } | |
275 else | |
276 MessageBoxW(nullptr, L"Lightpoly builder native indoor clipping not implemented", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335", 0); | |
277 | |
278 if (_a4) | |
279 { | |
280 if (uLightType & 1) | |
281 { | |
282 //v48 = (char *)&std__vector_000004_size; | |
283 //v49 = std__vector_000004_size; | |
284 //v51 = __OFSUB__(std__vector_000004_size, 511); | |
285 //v50 = std__vector_000004_size - 511 < 0; | |
286 if (std__vector_000004_size < 512 - 1) | |
287 ++std__vector_000004_size; | |
288 } | |
289 else | |
290 { | |
291 //v48 = (char *)&std__vector_183808_size; | |
292 //v49 = std__vector_183808_size; | |
293 //v51 = __OFSUB__(std__vector_183808_size, 767); | |
294 //v50 = std__vector_183808_size - 767 < 0; | |
295 if (std__vector_183808_size < 768 - 1) | |
296 ++std__vector_183808_size; | |
297 } | |
298 //if ( v50 ^ v51 ) | |
299 // *(unsigned int *)v48 = v49 + 1; | |
300 } | |
301 return true; | |
302 } | |
303 | |
304 //----- (0045C4B9) -------------------------------------------------------- | |
305 int LightmapBuilder::_45C4B9(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) | |
306 { | |
307 Lightmap *v4; // edi@1 | |
308 int v5; // eax@1 | |
309 signed int v6; // ecx@1 | |
310 RenderVertexSoft *v7; // ebx@2 | |
311 int v8; // edx@3 | |
312 RenderVertexSoft *v9; // esi@3 | |
313 int v10; // eax@6 | |
2334 | 314 // char *v11; // edi@7 |
0 | 315 RenderVertexSoft *v12; // ecx@8 |
316 char v13; // bl@17 | |
317 signed int v14; // edx@17 | |
318 double v15; // st6@18 | |
319 double v16; // st6@21 | |
320 double v17; // st6@24 | |
321 signed int v18; // edx@33 | |
322 int v20; // [sp+4h] [bp-1Ch]@3 | |
2316 | 323 //int v21; // [sp+8h] [bp-18h]@8 |
0 | 324 float v22; // [sp+Ch] [bp-14h]@23 |
325 float v23; // [sp+10h] [bp-10h]@20 | |
326 int v24; // [sp+14h] [bp-Ch]@1 | |
327 RenderVertexSoft *v25; // [sp+18h] [bp-8h]@2 | |
328 char v26; // [sp+1Eh] [bp-2h]@17 | |
329 char v27; // [sp+1Fh] [bp-1h]@17 | |
330 | |
2325 | 331 //__debugbreak();//Ritor1: needed cleaning |
2316 | 332 |
0 | 333 v4 = pLightmap; |
334 v5 = 0; | |
335 v6 = pLightmap->uNumVertices; | |
336 v24 = 0; | |
337 if ( v6 > 0 ) | |
338 { | |
339 v7 = pLightmap->pVertices; | |
340 v25 = pLightmap->pVertices; | |
341 do | |
342 { | |
343 v20 = v5 + 1; | |
344 v8 = (v5 + 1) % v6; | |
345 v9 = &v4->pVertices[v8]; | |
346 if ( v7->vWorldPosition.x != v9->vWorldPosition.x | |
347 || v7->vWorldPosition.y != v4->pVertices[v8].vWorldPosition.y | |
348 || v7->vWorldPosition.z != v4->pVertices[v8].vWorldPosition.z ) | |
349 { | |
2316 | 350 //v10 = 0; |
0 | 351 if ( a2 > 0 ) |
352 { | |
2316 | 353 //v11 = (char *)&a3->vWorldPosition.z; |
354 for ( v10 = 1; v10 <= a2; ++v10 ) | |
0 | 355 { |
2316 | 356 //v21 = v10 + 1; |
357 v12 = &a3[v10 % a2]; | |
358 if ((a3[v10].vWorldPosition.x != v12->vWorldPosition.x | |
359 || a3[v10].vWorldPosition.y != v12->vWorldPosition.y || a3[v10].vWorldPosition.z != v12->vWorldPosition.z) | |
360 && v7->vWorldPosition.x == a3[v10].vWorldPosition.x | |
361 && v7->vWorldPosition.y == a3[v10].vWorldPosition.y && v7->vWorldPosition.z == a3[v10].vWorldPosition.z | |
0 | 362 && (v9->vWorldPosition.x != v12->vWorldPosition.x |
2316 | 363 || v9->vWorldPosition.y != v12->vWorldPosition.y || v9->vWorldPosition.z != v12->vWorldPosition.z) ) |
0 | 364 { |
365 v13 = 0; | |
366 v14 = 0; | |
367 v27 = 0; | |
368 v26 = 0; | |
369 if ( v9->vWorldPosition.x <= (double)v12->vWorldPosition.x ) | |
370 v15 = v12->vWorldPosition.x - v9->vWorldPosition.x; | |
371 else | |
372 v15 = v9->vWorldPosition.x - v12->vWorldPosition.x; | |
373 v23 = v15; | |
2316 | 374 |
0 | 375 if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y ) |
376 v16 = v12->vWorldPosition.y - v9->vWorldPosition.y; | |
377 else | |
378 v16 = v9->vWorldPosition.y - v12->vWorldPosition.y; | |
379 v22 = v16; | |
2316 | 380 |
0 | 381 if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z ) |
382 v17 = v12->vWorldPosition.z - v9->vWorldPosition.z; | |
383 else | |
384 v17 = v9->vWorldPosition.z - v12->vWorldPosition.z; | |
385 if ( v23 < 1.0 ) | |
386 { | |
387 v13 = 1; | |
388 v14 = 1; | |
389 } | |
390 if ( v22 < 1.0 ) | |
391 { | |
392 v27 = 1; | |
393 ++v14; | |
394 } | |
395 if ( v17 < 1.0 ) | |
396 { | |
397 v26 = 1; | |
398 ++v14; | |
399 } | |
400 if ( v14 > 1 ) | |
401 { | |
402 v18 = 0; | |
403 if ( v13 && v9->vWorldPosition.x != v12->vWorldPosition.x ) | |
404 { | |
405 v18 = 1; | |
406 v9->vWorldPosition.x = v12->vWorldPosition.x; | |
407 } | |
408 if ( v27 && v9->vWorldPosition.y != v12->vWorldPosition.y ) | |
409 { | |
410 ++v18; | |
411 v9->vWorldPosition.y = v12->vWorldPosition.y; | |
412 } | |
413 if ( v26 && v9->vWorldPosition.z != v12->vWorldPosition.z ) | |
414 { | |
415 ++v18; | |
416 v9->vWorldPosition.z = v12->vWorldPosition.z; | |
417 } | |
418 if ( v18 > 0 ) | |
419 ++v24; | |
420 } | |
421 v7 = v25; | |
422 } | |
2316 | 423 //++v10; |
424 //v11 += 48; | |
0 | 425 } |
2316 | 426 //while ( v21 < a2 ); |
0 | 427 v4 = pLightmap; |
428 } | |
429 } | |
430 v5 = v20; | |
431 v6 = v4->uNumVertices; | |
432 ++v7; | |
433 v25 = v7; | |
434 } | |
435 while ( v20 < v6 ); | |
436 } | |
437 return v24; | |
438 } | |
439 | |
440 //----- (0045C6D6) -------------------------------------------------------- | |
441 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) | |
442 { | |
443 signed int v6; // esi@1 | |
444 double v9; // st7@6 | |
445 double v10; // st6@10 | |
446 double v11; // st5@14 | |
447 double v12; // st7@17 | |
448 int v15; // [sp+Ch] [bp-8h]@1 | |
449 float v16; // [sp+10h] [bp-4h]@1 | |
450 | |
451 v6 = -1; | |
452 v16 = 3.4028235e38; | |
453 v15 = 0; | |
454 if ( (signed int)pLightmap->uNumVertices > 0 ) | |
455 { | |
2245 | 456 for ( uint i = 0; i < (signed int)pLightmap->uNumVertices; ++i ) |
0 | 457 { |
458 if ( a2 > 0 ) | |
459 { | |
2245 | 460 for ( uint j = 0; j < a2; ++j ) |
0 | 461 { |
2245 | 462 if ( pLightmap->pVertices[i].vWorldPosition.x <= (double)a3[j].vWorldPosition.x ) |
463 v9 = a3[j].vWorldPosition.x - pLightmap->pVertices[i].vWorldPosition.x; | |
0 | 464 else |
2245 | 465 v9 = pLightmap->pVertices[i].vWorldPosition.x - a3[j].vWorldPosition.x; |
0 | 466 if ( v9 < 2.0 ) |
467 { | |
2245 | 468 v10 = pLightmap->pVertices[i].vWorldPosition.y <= (double)a3[j].vWorldPosition.y |
469 ? a3[j].vWorldPosition.y - pLightmap->pVertices[i].vWorldPosition.y | |
470 : pLightmap->pVertices[i].vWorldPosition.y - a3[j].vWorldPosition.y; | |
0 | 471 if ( v10 < 2.0 ) |
472 { | |
2245 | 473 v11 = pLightmap->pVertices[i].vWorldPosition.z <= (double)a3[j].vWorldPosition.z |
474 ? a3[j].vWorldPosition.z - pLightmap->pVertices[i].vWorldPosition.z | |
475 : pLightmap->pVertices[i].vWorldPosition.z - a3[j].vWorldPosition.z; | |
0 | 476 if ( v11 < 2.0 ) |
477 { | |
2325 | 478 v12 = v9 + v11 + v10; |
0 | 479 if ( v12 < v16 ) |
480 { | |
481 v16 = v12; | |
2245 | 482 v6 = j; |
0 | 483 } |
484 } | |
485 } | |
486 } | |
487 } | |
488 if ( v6 != -1 ) | |
489 { | |
490 ++v15; | |
2245 | 491 pLightmap->pVertices[i].vWorldPosition.x = a3[v6].vWorldPosition.x; |
492 pLightmap->pVertices[i].vWorldPosition.y = a3[v6].vWorldPosition.y; | |
493 pLightmap->pVertices[i].vWorldPosition.z = a3[v6].vWorldPosition.z; | |
0 | 494 } |
495 } | |
496 v6 = -1; | |
497 v16 = 3.4028235e38; | |
498 } | |
499 } | |
500 return v15; | |
501 } | |
502 | |
503 //----- (0045C7F6) -------------------------------------------------------- | |
504 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID) | |
505 { | |
1980 | 506 BLVFace* pFace = &pIndoor->pFaces[uFaceID]; |
507 BLVSector* pSector = &pIndoor->pSectors[pFace->uSectorID]; | |
0 | 508 |
509 stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16; | |
510 | |
511 uint uNumLightsApplied = 0; | |
512 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) | |
513 { | |
514 if (uNumLightsApplied >= 20) | |
515 break; | |
516 | |
517 ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0); | |
518 } | |
519 | |
520 for (uint i = 0; i < pSector->uNumLights; ++i) | |
521 { | |
522 if (uNumLightsApplied >= 20 ) | |
523 break; | |
524 | |
1980 | 525 BLVLightMM7* pLight = &pIndoor->pLights[pSector->pLights[i]]; |
0 | 526 if (~pLight->uAtributes & 0x08) |
2154 | 527 ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &_4E94D0_light_type); |
0 | 528 } |
529 | |
530 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | |
531 { | |
532 if (uNumLightsApplied >= 20) | |
533 break; | |
534 | |
2154 | 535 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type); |
0 | 536 } |
537 | |
538 stru_F8AD28.uNumLightsApplied = uNumLightsApplied; | |
539 return true; | |
540 } | |
541 | |
542 //----- (0045C911) -------------------------------------------------------- | |
543 bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5) | |
544 { | |
545 double v13; // st7@8 | |
546 | |
547 if (!pLight->uRadius) | |
548 return false; | |
549 | |
550 if (pLight->vPosition.x > a2->pBounding.x1 - pLight->uRadius && | |
551 pLight->vPosition.x < a2->pBounding.x2 + pLight->uRadius && | |
552 pLight->vPosition.y > a2->pBounding.y1 - pLight->uRadius && | |
553 pLight->vPosition.y < a2->pBounding.y2 + pLight->uRadius && | |
554 pLight->vPosition.z > a2->pBounding.z1 - pLight->uRadius && | |
555 pLight->vPosition.z < a2->pBounding.z2 + pLight->uRadius) | |
556 { | |
557 v13 = (double)pLight->vPosition.z * a2->pFacePlane.vNormal.z + | |
558 (double)pLight->vPosition.y * a2->pFacePlane.vNormal.y + | |
559 (double)pLight->vPosition.x * a2->pFacePlane.vNormal.x + | |
560 a2->pFacePlane.dist; | |
561 if ((bLightBackfaces || v13 >= 0.0f) && fabsf(v13) <= pLight->uRadius) | |
562 { | |
1980 | 563 unsigned int slot = *pSlot; |
0 | 564 |
565 stru_F8AD28._blv_lights_radii[slot] = pLight->uRadius; | |
566 stru_F8AD28._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius; | |
567 stru_F8AD28._blv_lights_xs[slot] = pLight->vPosition.x; | |
568 stru_F8AD28._blv_lights_ys[slot] = pLight->vPosition.y; | |
569 stru_F8AD28._blv_lights_zs[slot] = pLight->vPosition.z; | |
570 stru_F8AD28._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f; | |
571 stru_F8AD28._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f; | |
572 stru_F8AD28._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f; | |
573 stru_F8AD28._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f)); | |
574 stru_F8AD28._blv_lights_types[slot] = pLight->uLightType; | |
575 | |
576 *pSlot += 1; | |
577 return true; | |
578 } | |
579 } | |
580 | |
581 return false; | |
582 } | |
583 | |
584 //----- (0045CA88) -------------------------------------------------------- | |
585 int LightmapBuilder::_45CA88(stru320 *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal) | |
586 { | |
587 int result; // eax@1 | |
588 stru320 *v6; // ecx@2 | |
589 RenderVertexSoft *v7; // ebx@2 | |
590 double v8; // st7@2 | |
591 double v9; // st6@2 | |
592 char *v10; // eax@3 | |
593 double v11; // st7@5 | |
594 __int64 v12; // ST2C_8@5 | |
595 float v13; // edx@5 | |
596 int v14; // eax@5 | |
597 float v15; // ST10_4@5 | |
598 Vec3_float_ v16; // ST00_12@5 | |
599 double v17; // st7@5 | |
600 int a5; // [sp+2Ch] [bp-1Ch]@1 | |
601 float v19; // [sp+30h] [bp-18h]@1 | |
602 float v20; // [sp+34h] [bp-14h]@1 | |
2316 | 603 //LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1 |
0 | 604 int v22; // [sp+3Ch] [bp-Ch]@1 |
605 int *j; // [sp+40h] [bp-8h]@3 | |
606 int i; // [sp+44h] [bp-4h]@1 | |
607 int a3a; // [sp+58h] [bp+10h]@2 | |
608 | |
2316 | 609 __debugbreak();//Ritor1: needed cleaning |
610 | |
0 | 611 *(float *)&a5 = 0.0; |
612 v19 = 0.0; | |
2316 | 613 //thisa = this; |
0 | 614 v20 = 0.0; |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1089
diff
changeset
|
615 result = _45CBD4(a3, a4, dword_69B010.data(), &v22); |
0 | 616 for ( i = 0; i < v22; result = i ) |
617 { | |
618 v6 = a2; | |
619 a3a = 0; | |
620 v7 = &a3[dword_69B010[i]]; | |
621 v8 = v7->vWorldPosition.z; | |
622 v9 = v7->vWorldPosition.y; | |
623 *(float *)&a5 = v7->vWorldPosition.x; | |
624 v19 = v9; | |
625 v20 = v8; | |
626 v7->flt_2C = 0.0; | |
627 if ( a2->uNumLightsApplied > 0 ) | |
628 { | |
629 v10 = (char *)a2->_blv_lights_ys; | |
630 for ( j = a2->_blv_lights_ys; ; v10 = (char *)j ) | |
631 { | |
632 v11 = (double)*((signed int *)v10 - 60); | |
633 LODWORD(v12) = *((unsigned int *)v10 - 20); | |
634 HIDWORD(v12) = *(unsigned int *)v10; | |
635 LODWORD(v13) = *((unsigned int *)v10 + 60); | |
636 v14 = a3a; | |
637 LOBYTE(v14) = v6->_blv_lights_types[a3a]; | |
638 v15 = v11; | |
639 *(_QWORD *)&v16.x = v12; | |
640 v16.z = v13; | |
641 v17 = _45CC0C_light(v16/*COERCE_VEC3_FLOAT_(v16.x)*/, 1.0, v15, pNormal, *(float *)&a5/*COERCE_FLOAT(&a5)*/, v14) | |
642 + v7->flt_2C; | |
643 ++a3a; | |
644 ++j; | |
645 v7->flt_2C = v17; | |
646 if ( a3a >= a2->uNumLightsApplied ) | |
647 break; | |
648 v6 = a2; | |
649 } | |
650 } | |
651 ++i; | |
652 } | |
653 return result; | |
654 } | |
655 | |
656 //----- (0045CB89) -------------------------------------------------------- | |
657 int LightmapBuilder::_45CB89(RenderVertexSoft *a1, int a2) | |
658 { | |
659 int v3; // edx@1 | |
660 int result; // eax@2 | |
661 char *v5; // ecx@2 | |
662 double v6; // st7@4 | |
663 __int16 v7; // fps@4 | |
664 char v8; // c0@4 | |
665 char v9; // c2@4 | |
666 char v10; // c3@4 | |
667 double v11; // st7@5 | |
668 double v12; // st7@6 | |
669 __int16 v13; // fps@6 | |
670 char v14; // c0@6 | |
671 char v15; // c2@6 | |
672 char v16; // c3@6 | |
673 | |
674 v3 = a2; | |
675 if ( a2 > 0 ) | |
676 { | |
677 HIWORD(result) = HIWORD(a1); | |
678 v5 = (char *)&a1->flt_2C; | |
679 do | |
680 { | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
681 __debugbreak(); // warning C4700: uninitialized local variable 'v7' used |
0 | 682 if ( *(float *)v5 < 0.0 |
683 || (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0, v10 = 1.0 == v6, LOWORD(result) = v7, v6 <= 1.0) ) | |
684 { | |
685 v12 = *(float *)v5; | |
686 //UNDEF(v13); | |
687 v14 = 0.0 < v12; | |
688 v15 = 0; | |
689 v16 = 0.0 == v12; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
690 __debugbreak(); // warning C4700: uninitialized local variable 'v13' used |
0 | 691 LOWORD(result) = v13; |
692 if ( v12 >= 0.0 ) | |
693 v11 = *(float *)v5; | |
694 else | |
695 v11 = 0.0; | |
696 } | |
697 else | |
698 { | |
699 v11 = 1.0; | |
700 } | |
701 *(float *)v5 = v11; | |
702 v5 += 48; | |
703 --v3; | |
704 } | |
705 while ( v3 ); | |
706 } | |
707 return result; | |
708 } | |
709 | |
710 //----- (0045CBD4) -------------------------------------------------------- | |
711 int LightmapBuilder::_45CBD4(RenderVertexSoft *a2, int a3, int *a4, int *a5) | |
712 { | |
713 int result; // eax@1 | |
714 int v6; // edx@1 | |
715 int v7; // ecx@2 | |
716 int v8; // esi@2 | |
717 | |
718 result = (int)a5; | |
719 v6 = 0; | |
720 for ( *a5 = 0; v6 < a3; ++v6 ) | |
721 { | |
722 v7 = *a5; | |
723 v8 = 0; | |
724 if ( *a5 <= 0 ) | |
725 { | |
726 LABEL_5: | |
727 a4[v7] = v6; | |
728 ++*a5; | |
729 } | |
730 else | |
731 { | |
732 while ( a4[v8] != v6 ) | |
733 { | |
734 ++v8; | |
735 if ( v8 >= v7 ) | |
736 goto LABEL_5; | |
737 } | |
738 } | |
739 } | |
740 return result; | |
741 } | |
742 | |
743 //----- (0045CC0C) -------------------------------------------------------- | |
744 double LightmapBuilder::_45CC0C_light(Vec3_float_ a1, float a2, float a3, Vec3_float_ *pNormal, float a5, int uLightType) | |
745 { | |
746 float v7; // esi@1 | |
747 int v8; // eax@1 | |
2334 | 748 // int v9; // ebx@1 |
749 // unsigned int v10; // ecx@1 | |
750 // int v11; // edx@2 | |
751 // int v12; // edx@4 | |
752 // unsigned int v13; // edx@6 | |
0 | 753 double v14; // st7@7 |
754 double result; // st7@8 | |
755 double v16; // st7@9 | |
756 int v17; // esi@9 | |
757 const char *v18; // ecx@9 | |
758 double v19; // st7@10 | |
759 double v20; // st7@10 | |
760 std::string v21; // [sp-10h] [bp-40h]@13 | |
761 const char *v22[6]; // [sp+0h] [bp-30h]@10 | |
762 double v23; // [sp+18h] [bp-18h]@1 | |
2334 | 763 // double v24; // [sp+20h] [bp-10h]@1 |
0 | 764 int v25; // [sp+28h] [bp-8h]@1 |
765 int v26; // [sp+2Ch] [bp-4h]@1 | |
766 | |
767 v7 = a5; | |
768 LODWORD(a5) = *(unsigned int *)(LODWORD(a5) + 8); | |
769 //v24 = a5 + 6.7553994e15; | |
770 v26 = floorf(a5 + 0.5f);//LODWORD(v24); | |
771 LODWORD(a5) = *(unsigned int *)(LODWORD(v7) + 4); | |
772 //v24 = a5 + 6.7553994e15; | |
773 auto _v24 = floorf(a5 + 0.5f); | |
774 LODWORD(a5) = *(unsigned int *)LODWORD(v7); | |
775 //v23 = a5 + 6.7553994e15; | |
776 auto _v23 = floorf(a5 + 0.5f); | |
777 //*(_QWORD *)((char *)&v24 + 4) = __PAIR__(LODWORD(v24), LODWORD(v23)); | |
778 v26 = abs((signed)LODWORD(a1.z) - v26); | |
779 //v25 = abs((signed)LODWORD(a1.y) - (signed)LODWORD(v24)); | |
780 //v8 = abs((int)a1.x - (signed)LODWORD(v23)); | |
781 v25 = abs((signed)LODWORD(a1.y) - (signed)_v24); | |
782 v8 = abs((int)a1.x - (signed)_v23); | |
2235
6ab7d7c112bb
adding int_get_vector_length calls where the calls were inlined
Grumpy7
parents:
2155
diff
changeset
|
783 v14 = int_get_vector_length(v26, v25, v8); |
0 | 784 if ( v14 <= a3 ) |
785 { | |
786 a5 = v14 / a3; | |
787 v16 = (double)(signed int)a1.x; | |
788 *(float *)&v23 = (double)SLODWORD(a1.y); | |
789 LODWORD(a1.x) = *(unsigned int *)LODWORD(v7); | |
790 v17 = LODWORD(v7) + 4; | |
791 *((float *)&v23 + 1) = (double)SLODWORD(a1.z); | |
792 LODWORD(a1.y) = *(unsigned int *)v17; | |
793 LODWORD(a1.z) = *(unsigned int *)(v17 + 4); | |
794 a3 = *((float *)&v23 + 1) - a1.z; | |
795 a1.z = a3; | |
796 a1.x = v16 - a1.x; | |
797 a1.y = (float)v23 - a1.y; | |
798 a1.Normalize(); | |
799 if ( uLightType & 4 ) | |
800 { | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1394
diff
changeset
|
801 __debugbreak(); // warning C4700: uninitialized local variable 'v18' used |
0 | 802 v22[1] = v18; |
803 uLightType = dword_4D86D8; | |
804 v22[0] = v18; | |
805 v19 = fabs(a1.z * pNormal->z + a1.y * pNormal->y + a1.x * pNormal->x); | |
806 v20 = v19 * *(float *)&uLightType * a2; | |
807 } | |
808 else | |
809 { | |
810 if ( uLightType & 8 ) | |
811 { | |
812 v20 = 1.3 * a2; | |
813 } | |
814 else | |
815 { | |
816 MessageBoxW(nullptr, L"Invalid light type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:783", 0); | |
817 v20 = *(float *)&uLightType; | |
818 } | |
819 } | |
820 result = v20 - a5 * v20; | |
821 } | |
822 else | |
823 { | |
824 result = 0.0; | |
825 } | |
826 return result; | |
827 } | |
828 // 4D86D8: using guessed type int dword_4D86D8; | |
829 | |
830 //----- (0045CDB7) -------------------------------------------------------- | |
831 bool LightmapBuilder::ApplyLights_OutdoorFace(ODMFace *pFace) | |
832 { | |
833 int v3; // eax@1 | |
834 bool result; // eax@9 | |
835 int pSlot; // [sp+10h] [bp-4h]@1 | |
836 | |
837 v3 = stru_F8AD28.uDefaultAmbientLightLevel + pFace->uShadeType; | |
838 pSlot = 0; | |
839 stru_F8AD28.uCurrentAmbientLightLevel = v3 << 16; | |
2251 | 840 for ( uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i ) |
0 | 841 { |
2251 | 842 if ( pSlot >= 20 ) |
843 break; | |
844 ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, 1); | |
0 | 845 } |
2251 | 846 for ( uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i ) |
0 | 847 { |
2251 | 848 if ( pSlot >= 20 ) |
849 break; | |
2274 | 850 ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0); |
0 | 851 } |
852 result = pSlot; | |
853 stru_F8AD28.uNumLightsApplied = pSlot; | |
854 return true; | |
855 } | |
856 | |
857 //----- (0045CE50) -------------------------------------------------------- | |
858 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4) | |
859 { | |
860 int result; // eax@0 | |
861 int v10; // ecx@8 | |
2251 | 862 //unsigned int v12; // ebx@11 |
2153 | 863 //RenderD3D *v13; // ecx@11 |
0 | 864 char v14; // dl@11 |
865 | |
62 | 866 //__debugbreak(); |
0 | 867 |
2251 | 868 result = (int)pFace; |
869 v10 = (pFace->pFacePlane.dist | |
0 | 870 + pLight->vPosition.x * pFace->pFacePlane.vNormal.x |
2251 | 871 + pLight->vPosition.y * pFace->pFacePlane.vNormal.y |
872 + pLight->vPosition.z * pFace->pFacePlane.vNormal.z) >> 16; | |
873 if ( pLight->uRadius > 0 | |
874 && (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 | |
875 && (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2 | |
876 && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2 | |
877 && ((a4) || v10 >= 0) && v10 <= pLight->uRadius ) | |
0 | 878 { |
2251 | 879 stru_F8AD28._blv_lights_radii[*pSlot] = pLight->uRadius; |
880 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; | |
0 | 881 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; |
882 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; | |
883 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; | |
884 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; | |
885 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; | |
886 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; | |
2251 | 887 //v11 = abs(v10); |
888 //v12 = pRenderer->bUsingSpecular; | |
889 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(v10); | |
0 | 890 stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; |
2153 | 891 //v13 = pRenderer->pRenderD3D; |
0 | 892 v14 = stru_F8AD28._blv_lights_types[*pSlot]; |
2251 | 893 if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 ) |
0 | 894 v14 = _4E94D2_light_type; |
895 stru_F8AD28._blv_lights_types[*pSlot] = v14; | |
896 result = 4 * *pSlot; | |
2251 | 897 if ( /*v13*/true && pRenderer->bUsingSpecular ) |
0 | 898 { |
899 if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) | |
900 { | |
901 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) | |
902 * 0.33000001; | |
903 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result) | |
904 * 0.33000001; | |
905 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result) | |
906 * 0.33000001; | |
907 } | |
908 } | |
909 ++*pSlot; | |
910 LOBYTE(result) = 1; | |
911 } | |
912 else | |
913 LOBYTE(result) = 0; | |
914 return result; | |
915 } | |
916 // 4E94D2: using guessed type char _4E94D2_light_type; | |
917 | |
918 //----- (0045D036) -------------------------------------------------------- | |
86 | 919 bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a2, RenderVertexSoft *a3, unsigned int uStripType, bool bLightBackfaces) |
0 | 920 { |
86 | 921 /*int v6; // esi@1 |
0 | 922 //LightmapBuilder *v7; // edi@1 |
923 MobileLight *v8; // ebx@2 | |
924 int v9; // esi@5 | |
925 StationaryLight *v10; // ebx@6 | |
926 //bool result; // eax@9 | |
927 unsigned int a7; // [sp+Ch] [bp-4h]@1 | |
928 | |
929 v6 = 0; | |
930 //v7 = this; | |
931 a7 = 0; | |
932 stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type; | |
933 if ( pMobileLightsStack->uNumLightsActive > 0 ) | |
934 { | |
935 v8 = pMobileLightsStack->pLights; | |
936 do | |
937 { | |
938 if ( (signed int)a7 >= 20 ) | |
939 break; | |
940 StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, bLightBackfaces, &a7); | |
941 ++v6; | |
942 ++v8; | |
943 } | |
944 while ( v6 < pMobileLightsStack->uNumLightsActive ); | |
945 } | |
946 v9 = 0; | |
947 if ( pStationaryLightsStack->uNumLightsActive > 0 ) | |
948 { | |
949 v10 = pStationaryLightsStack->pLights; | |
950 do | |
951 { | |
952 if ( (signed int)a7 >= 20 ) | |
953 break; | |
954 StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, bLightBackfaces, &a7); | |
955 ++v9; | |
956 ++v10; | |
957 } | |
958 while ( v9 < pStationaryLightsStack->uNumLightsActive ); | |
959 } | |
960 | |
961 stru_F8AD28.uNumLightsApplied = a7; | |
86 | 962 return true;*/ |
963 // bool __stdcall sub_45D036(struct Vec3<float> *pNormal, int a2, struct RenderVertex *a3, int a4, signed int X) | |
964 //{ | |
2334 | 965 // float v6; // ebx@2 |
86 | 966 unsigned int v10; // [sp+Ch] [bp-4h]@1 |
967 int i; | |
968 | |
969 v10 = 0; | |
638 | 970 stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level; |
86 | 971 for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) |
972 { | |
973 if ( v10 >= 20 ) | |
974 break; | |
975 StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10); | |
976 } | |
977 | |
978 for (i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | |
979 { | |
980 if ( v10 >= 20 ) | |
981 break; | |
982 StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10); | |
983 } | |
984 | |
985 stru_F8AD28.uNumLightsApplied = v10; | |
0 | 986 return true; |
86 | 987 |
0 | 988 } |
989 // 519AB4: using guessed type int uNumStationaryLightsApplied; | |
990 | |
991 //----- (0045D0D5) -------------------------------------------------------- | |
992 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot) | |
993 { | |
994 StationaryLight *v8; // edi@1 | |
995 bool result; // eax@1 | |
2334 | 996 // unsigned int v10; // esi@2 |
0 | 997 RenderVertexSoft *v11; // ebx@2 |
998 float v12; // eax@3 | |
999 float v13; // eax@4 | |
2334 | 1000 // double v14; // st7@11 |
0 | 1001 double maxz; // st7@11 |
1002 double v16; // st7@11 | |
1003 double v17; // st6@11 | |
2334 | 1004 // __int16 v18; // fps@11 |
1005 // char v19; // c0@11 | |
0 | 1006 char v20; // c2@11 |
2334 | 1007 // char v21; // c3@11 |
1008 // double v22; // st6@12 | |
1009 // __int16 v23; // fps@12 | |
1010 // char v24; // c0@12 | |
1011 // char v25; // c2@12 | |
1012 // char v26; // c3@12 | |
1013 // double v27; // st7@13 | |
1014 // double v28; // st6@13 | |
1015 // __int16 v29; // fps@13 | |
1016 // char v30; // c0@13 | |
1017 // char v31; // c2@13 | |
1018 // char v32; // c3@13 | |
1019 // double v33; // st6@14 | |
1020 // __int16 v34; // fps@14 | |
1021 // char v35; // c0@14 | |
1022 // char v36; // c2@14 | |
1023 // char v37; // c3@14 | |
1024 // double v38; // st7@15 | |
1025 // double v39; // st6@15 | |
1026 // __int16 v40; // fps@15 | |
1027 // char v41; // c0@15 | |
1028 // char v42; // c2@15 | |
1029 // char v43; // c3@15 | |
1030 // double v44; // st6@16 | |
1031 // __int16 v45; // fps@16 | |
1032 // char v46; // c0@16 | |
1033 // char v47; // c2@16 | |
1034 // char v48; // c3@16 | |
0 | 1035 Vec3_float_ *v49; // esi@17 |
2334 | 1036 // double v50; // st7@17 |
1037 // double v51; // st6@17 | |
0 | 1038 signed int v52; // ecx@17 |
1039 unsigned int *v53; // esi@18 | |
1040 int v54; // eax@18 | |
1041 unsigned int v55; // ebx@18 | |
2154 | 1042 //RenderD3D *v56; // ecx@18 |
0 | 1043 char v57; // dl@18 |
1044 std::string v58; // [sp-18h] [bp-38h]@10 | |
1045 const char *v59; // [sp-8h] [bp-28h]@10 | |
1046 signed int v60; // [sp-4h] [bp-24h]@10 | |
1047 double v61; // [sp+Ch] [bp-14h]@11 | |
1048 float minz; // [sp+14h] [bp-Ch]@11 | |
1049 int v63; // [sp+18h] [bp-8h]@1 | |
1050 float v64; // [sp+1Ch] [bp-4h]@5 | |
1051 | |
1052 v8 = pLight; | |
1053 result = pLight->uRadius; | |
1054 v63 = pLight->uRadius; | |
1055 if ( result <= 0 ) | |
86 | 1056 return 0; |
1057 //v10 = uStripType; | |
0 | 1058 v11 = a1; |
1059 if ( uStripType == 4 ) | |
1060 { | |
1061 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x); | |
1062 v12 = a1[3].vWorldPosition.x; | |
1063 } | |
1064 else | |
1065 { | |
1066 if ( uStripType != 3 ) | |
1067 { | |
1068 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0); | |
1069 goto LABEL_11; | |
1070 } | |
1071 if ( (unsigned char)X ) | |
1072 { | |
1073 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x); | |
1074 uStripType = LODWORD(a1[2].vWorldPosition.x); | |
1075 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); | |
1076 v13 = v11[2].vWorldPosition.y; | |
1077 goto LABEL_5; | |
1078 } | |
1079 pLight = (StationaryLight *)LODWORD(a1[1].vWorldPosition.x); | |
1080 v12 = a1[2].vWorldPosition.x; | |
1081 } | |
2274 | 1082 //uStripType = LODWORD(v12); |
0 | 1083 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); |
1084 v13 = v11->vWorldPosition.y; | |
1085 LABEL_5: | |
1086 v64 = v13; | |
1087 LABEL_11: | |
86 | 1088 //v60 = v10; |
0 | 1089 v59 = (const char *)v11; |
2274 | 1090 v60 = v12;//uStripType; |
86 | 1091 minz = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, uStripType); |
1092 maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, uStripType); | |
0 | 1093 result = v8->vPosition.x; |
1094 *((float *)&v61 + 1) = maxz; | |
1095 v16 = (double)result; | |
1096 *(float *)&X = (double)v63; | |
1097 v17 = *(float *)&pLight - *(float *)&X; | |
1098 //UNDEF(v18); | |
86 | 1099 //v19 = v16 < v17; |
0 | 1100 v20 = 0; |
86 | 1101 //v21 = v16 == v17; |
1102 /* BYTE1(result) = HIBYTE(v18); | |
0 | 1103 if ( v16 <= v17 |
1104 || (v22 = *(float *)&X + *(float *)&uStripType, | |
1105 //UNDEF(v23), | |
1106 v24 = v16 < v22, | |
1107 v25 = 0, | |
1108 v26 = v16 == v22, | |
1109 BYTE1(result) = HIBYTE(v23), | |
1110 v16 >= v22) | |
1111 || (result = v8->vPosition.y, | |
1112 pLight = (StationaryLight *)v8->vPosition.y, | |
1113 v27 = (double)(signed int)pLight, | |
1114 v28 = *(float *)&a1 - *(float *)&X, | |
1115 //UNDEF(v29), | |
1116 v30 = v27 < v28, | |
1117 v31 = 0, | |
1118 v32 = v27 == v28, | |
1119 BYTE1(result) = HIBYTE(v29), | |
1120 v27 <= v28) | |
1121 || (v33 = *(float *)&X + v64, | |
1122 //UNDEF(v34), | |
1123 v35 = v27 < v33, | |
1124 v36 = 0, | |
1125 v37 = v27 == v33, | |
1126 BYTE1(result) = HIBYTE(v34), | |
1127 v27 >= v33) | |
1128 || (result = v8->vPosition.z, | |
1129 pLight = (StationaryLight *)v8->vPosition.z, | |
1130 v38 = (double)(signed int)pLight, | |
1131 v39 = minz - *(float *)&X, | |
1132 //UNDEF(v40), | |
1133 v41 = v38 < v39, | |
1134 v42 = 0, | |
1135 v43 = v38 == v39, | |
1136 BYTE1(result) = HIBYTE(v40), | |
1137 v38 <= v39) | |
1138 || (v44 = *(float *)&X + *((float *)&v61 + 1), | |
1139 //UNDEF(v45), | |
1140 v46 = v38 < v44, | |
1141 v47 = 0, | |
1142 v48 = v38 == v44, | |
1143 BYTE1(result) = HIBYTE(v45), | |
1144 v38 >= v44) | |
1145 || (v49 = pNormal, | |
1146 Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3), | |
1147 X = v8->vPosition.y, | |
1148 v50 = (double)X * v49->y, | |
1149 X = v8->vPosition.z, | |
1150 v51 = (double)X * v49->z, | |
1151 X = v8->vPosition.x, | |
1152 *(float *)&a3 = v50 + v51 + (double)X * v49->x + *a3, | |
1153 v61 = *(float *)&a3 + 6.7553994e15, | |
1154 result = LODWORD(v61), | |
1155 X = LODWORD(v61), | |
1156 v52 = v63, | |
86 | 1157 SLODWORD(v61) > v63) )*/ |
2322 | 1158 v49 = pNormal; |
1159 Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3); | |
1160 *(float *)a3 = (double)v8->vPosition.x * v49->x | |
1161 + (double)v8->vPosition.y * v49->y | |
1162 + (double)v8->vPosition.z * v49->z + *a3; | |
1163 v61 = *(float *)a3 + 6.7553994e15; | |
1164 result = LODWORD(v61); | |
1165 X = LODWORD(v61); | |
1166 v52 = v63; | |
1167 if ( SLODWORD(v61) > v63) | |
86 | 1168 return 0; |
0 | 1169 v53 = pSlot; |
1170 v60 = X; | |
1171 stru_F8AD28._blv_lights_radii[*pSlot] = v63; | |
86 | 1172 stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v63; |
0 | 1173 stru_F8AD28._blv_lights_xs[*v53] = v8->vPosition.x; |
1174 stru_F8AD28._blv_lights_ys[*v53] = v8->vPosition.y; | |
1175 stru_F8AD28._blv_lights_zs[*v53] = v8->vPosition.z; | |
2274 | 1176 //a3 = (float *)v8->uLightColorR; |
1177 stru_F8AD28._blv_lights_rs[*v53] = v8->uLightColorR / 255.0f; | |
1178 //a3 = (float *)v8->uLightColorG; | |
1179 stru_F8AD28._blv_lights_gs[*v53] = v8->uLightColorG / 255.0f; | |
1180 //a3 = (float *)v8->uLightColorB; | |
1181 stru_F8AD28._blv_lights_bs[*v53] = v8->uLightColorB / 255.0f; | |
1182 v54 = abs(v63); | |
0 | 1183 v55 = pRenderer->bUsingSpecular; |
1184 stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54; | |
1185 stru_F8AD28._blv_lights_types[*v53] = v8->uLightType; | |
2154 | 1186 //v56 = pRenderer->pRenderD3D; |
0 | 1187 v57 = stru_F8AD28._blv_lights_types[*v53]; |
2154 | 1188 if ( /*pRenderer->pRenderD3D &&*/ v55 && v57 & 4 ) |
0 | 1189 v57 = _4E94D2_light_type; |
1190 stru_F8AD28._blv_lights_types[*v53] = v57; | |
1191 result = 4 * *v53; | |
2154 | 1192 if ( /*v56 &&*/ v55 ) |
0 | 1193 { |
1194 if ( stru_F8AD28._blv_lights_types[*v53] & 4 ) | |
1195 { | |
2274 | 1196 stru_F8AD28._blv_lights_rs[result] = stru_F8AD28._blv_lights_rs[result] * 0.3300000131130219; |
1197 stru_F8AD28._blv_lights_gs[result] = stru_F8AD28._blv_lights_gs[result] * 0.3300000131130219; | |
1198 stru_F8AD28._blv_lights_bs[result] = stru_F8AD28._blv_lights_bs[result] * 0.3300000131130219; | |
0 | 1199 } |
1200 } | |
1201 ++*v53; | |
86 | 1202 return 1; |
0 | 1203 } |
1204 | |
1205 //----- (0045D698) -------------------------------------------------------- | |
1206 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2) | |
1207 { | |
1208 bool result; // eax@1 | |
1209 LightmapBuilder *v3; // esi@1 | |
1210 RenderVertexSoft *v4; // edi@3 | |
1211 RenderVertexSoft *v5; // edi@7 | |
1212 IndoorCameraD3D *thisa; // [sp+10h] [bp-8h]@1 | |
1213 bool v7; // [sp+14h] [bp-4h]@2 | |
1214 bool a2a; // [sp+20h] [bp+8h]@6 | |
1215 | |
1216 result = (bool)pGame->pIndoorCameraD3D; | |
1217 v3 = this; | |
1218 thisa = pGame->pIndoorCameraD3D; | |
1219 if ( bit_one_for_list1__bit_two_for_list2 & 1 ) | |
1220 { | |
1221 v7 = 0; | |
1222 if ( (signed int)this->std__vector_000004_size > 0 ) | |
1223 { | |
1224 v4 = this->std__vector_000004[0].pVertices; | |
1225 do | |
1226 { | |
1227 pGame->pIndoorCameraD3D->debug_outline_sw(v4, *((unsigned int *)v4 - 1), 0xFF00u, 0.0); | |
1228 ++v7; | |
1229 v4 = (RenderVertexSoft *)((char *)v4 + 3100); | |
1230 result = v7; | |
1231 } | |
1232 while ( v7 < (signed int)v3->std__vector_000004_size ); | |
1233 } | |
1234 } | |
1235 if ( bit_one_for_list1__bit_two_for_list2 & 2 ) | |
1236 { | |
1237 a2a = 0; | |
1238 if ( (signed int)v3->std__vector_183808_size > 0 ) | |
1239 { | |
1240 v5 = v3->std__vector_183808[0].pVertices; | |
1241 do | |
1242 { | |
1243 pGame->pIndoorCameraD3D->debug_outline_sw(v5, *((unsigned int *)v5 - 1), 0xC04000u, 0.00019999999); | |
1244 ++a2a; | |
1245 v5 = (RenderVertexSoft *)((char *)v5 + 3100); | |
1246 result = a2a; | |
1247 } | |
1248 while ( a2a < (signed int)v3->std__vector_183808_size ); | |
1249 } | |
1250 } | |
1251 LOBYTE(result) = 1; | |
1252 return result; | |
1253 } | |
1254 | |
1255 //----- (0045D73F) -------------------------------------------------------- | |
1394 | 1256 void LightmapBuilder::DrawLightmapsType(int type) |
0 | 1257 { |
1394 | 1258 if (type == 2) |
1259 Draw_183808_Lightmaps(); | |
0 | 1260 } |
1261 | |
1262 //----- (0045D74F) -------------------------------------------------------- | |
1394 | 1263 bool LightmapBuilder::DrawLightmaps(int *indices) |
0 | 1264 { |
1390 | 1265 //char v3; // zf@1 |
2334 | 1266 // IDirect3DDevice3 *v4; // eax@2 |
1267 // HRESULT v5; // eax@2 | |
0 | 1268 //char *v6; // eax@2 |
2155 | 1269 //struct IDirect3DTexture2 *v7; // edi@4 |
2334 | 1270 // HRESULT v8; // eax@8 |
1271 // HRESULT v9; // eax@8 | |
1272 // HRESULT v10; // eax@8 | |
1273 // HRESULT v11; // eax@8 | |
1274 // HRESULT v12; // eax@8 | |
1394 | 1275 //int *v13; // eax@8 |
1390 | 1276 //float v14; // ecx@15 |
1277 //IDirect3DDevice3 *v15; // eax@21 | |
1278 //HRESULT v16; // eax@21 | |
1279 //IDirect3DDevice3 *v17; // eax@21 | |
1280 //HRESULT v18; // eax@21 | |
1281 //IDirect3DDevice3 *v19; // eax@21 | |
1282 //HRESULT v20; // eax@21 | |
1283 //IDirect3DDevice3 *v21; // eax@21 | |
1284 //HRESULT v22; // eax@21 | |
0 | 1285 //IDirect3DDevice3 *v23; // eax@23 |
1286 std::string v25; // [sp+44h] [bp-44h]@12 | |
2334 | 1287 // signed int v26; // [sp+48h] [bp-40h]@21 |
1288 // signed int v27; // [sp+4Ch] [bp-3Ch]@21 | |
0 | 1289 Lightmap *v28; // [sp+50h] [bp-38h]@2 |
2334 | 1290 // int v29; // [sp+54h] [bp-34h]@2 |
0 | 1291 //float v30; // [sp+58h] [bp-30h]@2 |
1394 | 1292 Vec3_float_ arg4; |
1293 //int arg4; // [sp+68h] [bp-20h]@8 | |
1294 //float v32; // [sp+6Ch] [bp-1Ch]@8 | |
1295 //float v33; // [sp+70h] [bp-18h]@8 | |
2334 | 1296 // int v34; // [sp+74h] [bp-14h]@19 |
1297 // int v35; // [sp+78h] [bp-10h]@2 | |
1394 | 1298 //int *v36; // [sp+7Ch] [bp-Ch]@10 |
1390 | 1299 //int a1; // [sp+80h] [bp-8h]@12 |
1300 //float v38; // [sp+84h] [bp-4h]@1 | |
0 | 1301 |
1390 | 1302 if (std__vector_000004_size == 0) |
2155 | 1303 return true; |
1304 | |
1305 if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) | |
1306 return true; | |
1394 | 1307 |
2155 | 1308 pRenderer->BeginLightmaps(); |
1394 | 1309 |
1310 arg4.x = 1.0f; | |
1311 arg4.y = 1.0f; | |
1312 arg4.z = 1.0f; | |
1313 if (indices) | |
0 | 1314 { |
1980 | 1315 for (int* i = indices; *i != -1; ++i) |
0 | 1316 { |
1394 | 1317 v28 = &std__vector_000004[*i]; |
2155 | 1318 if ( !pRenderer->DrawLightmap(v28, &arg4, 0.0) ) |
1545 | 1319 Error("Invalid lightmap detected! (%u)", *i); |
0 | 1320 } |
1321 } | |
1322 else | |
1323 { | |
1980 | 1324 for (unsigned int i = 0; i < std__vector_000004_size; ++i) |
0 | 1325 { |
1980 | 1326 Lightmap* _a1 = &std__vector_000004[(int)i]; |
2155 | 1327 if ( !pRenderer->DrawLightmap(_a1, &arg4, 0.0) ) |
1328 Error("Invalid lightmap detected! (%u)", i); | |
0 | 1329 } |
1330 } | |
1394 | 1331 |
2155 | 1332 pRenderer->EndLightmaps(); |
1333 | |
1394 | 1334 return true; |
0 | 1335 } |
1336 | |
1337 | |
1338 //----- (0045DA56) -------------------------------------------------------- | |
1394 | 1339 bool LightmapBuilder::DoDraw_183808_Lightmaps(float z_bias) |
0 | 1340 { |
1341 Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2 | |
1342 v.z = 1.0; | |
1343 v.y = 1.0; | |
1344 v.x = 1.0; | |
1345 | |
1346 for (uint i = 0; i < std__vector_183808_size; ++i) | |
2155 | 1347 if (!pRenderer->DrawLightmap(std__vector_183808 + i, &v, z_bias)) |
1348 Error("Invalid lightmap detected! (%u)", i); | |
0 | 1349 |
1350 return true; | |
1351 } | |
1352 | |
1353 //----- (0045DAE8) -------------------------------------------------------- | |
2155 | 1354 bool Render::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias) |
0 | 1355 { |
1356 double v10; // st7@4 | |
1357 double v14; // st7@7 | |
2334 | 1358 // __int16 v15; // fps@8 |
0 | 1359 double v18; // st3@8 |
1360 signed int v24; // [sp-1Ch] [bp-670h]@13 | |
2334 | 1361 // const char *v25; // [sp-18h] [bp-66Ch]@13 |
1362 // int v26; // [sp-14h] [bp-668h]@13 | |
0 | 1363 RenderVertexD3D3 a2[32]; // [sp+0h] [bp-654h]@7 |
1364 | |
1365 | |
1366 if (pLightmap->uNumVertices < 3) | |
1367 { | |
1368 Log::Warning(L"Lightmap uNumVertices < 3"); | |
1369 return false; | |
1370 } | |
1371 | |
1372 uint uLightmapColorMaskR = (pLightmap->uColorMask >> 16) & 0xFF; | |
1373 uint uLightmapColorR = floorf(uLightmapColorMaskR * pLightmap->fBrightness * pColorMult->x + 0.5f); | |
1374 | |
1375 uint uLightmapColorMaskG = (pLightmap->uColorMask >> 8) & 0xFF; | |
1376 uint uLightmapColorG = floorf(uLightmapColorMaskG * pLightmap->fBrightness * pColorMult->y + 0.5f); | |
1377 | |
1378 uint uLightmapColorMaskB = pLightmap->uColorMask & 0xFF; | |
1379 uint uLightmapColorB = floorf(uLightmapColorMaskB * pLightmap->fBrightness * pColorMult->z + 0.5f); | |
1380 | |
1381 uint uLightmapColor = uLightmapColorB | (uLightmapColorMaskG << 8) | (uLightmapColorMaskR << 16); | |
1382 | |
1383 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1637 | 1384 v10 = (double)pODMRenderParams->shading_dist_mist; |
0 | 1385 else |
1386 v10 = 16192.0; | |
1387 v14 = 1.0 / v10; | |
1388 | |
1389 for (uint i = 0; i < pLightmap->uNumVertices; ++i) | |
1390 { | |
1391 v18 = 1.0 - 1.0 / (v14 * pLightmap->pVertices[i].vWorldViewPosition.x * 1000.0); | |
1392 if (fabsf(z_bias) < 1e-5f) | |
1393 { | |
1394 v18 = v18 - z_bias; | |
1395 if (v18 < 0.000099999997) | |
1396 v18 = 0.000099999997; | |
1397 } | |
1398 | |
1399 a2[i].pos.x = pLightmap->pVertices[i].vWorldViewProjX; | |
1400 a2[i].pos.z = v18; | |
1401 a2[i].pos.y = pLightmap->pVertices[i].vWorldViewProjY; | |
1402 a2[i].rhw = 1.0 / pLightmap->pVertices[i].vWorldViewPosition.x; | |
1403 a2[i].diffuse = uLightmapColor; | |
1404 a2[i].specular = 0; | |
1405 a2[i].texcoord.x = pLightmap->pVertices[i].u; | |
1406 a2[i].texcoord.y = pLightmap->pVertices[i].v; | |
1407 } | |
1408 | |
1409 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1410 v24 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; | |
1411 else | |
1412 v24 = D3DDP_DONOTLIGHT; | |
1413 | |
1414 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
1415 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
1416 a2, | |
1417 pLightmap->uNumVertices, | |
1418 v24)); | |
1419 | |
1420 return true; | |
1421 } | |
1422 | |
1423 //----- (0045DCA9) -------------------------------------------------------- | |
1394 | 1424 void LightmapBuilder::Draw_183808_Lightmaps() |
0 | 1425 { |
1426 if (!std__vector_183808_size) | |
1427 return; | |
1428 | |
2155 | 1429 pRenderer->BeginLightmaps2(); |
0 | 1430 |
1394 | 1431 DoDraw_183808_Lightmaps(0.00050000002); |
0 | 1432 |
2155 | 1433 pRenderer->EndLightmaps2(); |
0 | 1434 } |