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