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