comparison Engine/Graphics/LightmapBuilder.cpp @ 2562:b8a56afc6ba1

new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
author Ritor1
date Sun, 17 May 2015 22:42:13 +0600
parents 98057834c9a0
children f2f2595fe308
comparison
equal deleted inserted replaced
2561:98057834c9a0 2562:b8a56afc6ba1
36 LightmapBuilder::LightmapBuilder() 36 LightmapBuilder::LightmapBuilder()
37 { 37 {
38 // For initialization step(II) 38 // For initialization step(II)
39 39
40 for ( int i = 0; i < 512; ++i )//for light type 1 40 for ( int i = 0; i < 512; ++i )//for light type 1
41 this->std__vector_000004[i] = Lightmap(); 41 this->StationaryLights[i] = Lightmap();
42 this->std__vector_000004_size = 0; 42 this->StationaryLightsCount = 0;
43 43
44 for ( int i = 0; i < 768; ++i )//for light type 2 44 for ( int i = 0; i < 768; ++i )//for light type 2
45 this->std__vector_183808[i] = Lightmap(); 45 this->MobileLights[i] = Lightmap();
46 this->std__vector_183808_size = 0; 46 this->MobileLightsCount = 0;
47 47
48 for ( int i = 0; i < 256; i++ ) 48 for ( int i = 0; i < 256; i++ )
49 this->field_3C8C34[i].flt_2C = 0.0f; 49 this->field_3C8C34[i].flt_2C = 0.0f;
50 } 50 }
51 51
56 //For outdoor light (I) 56 //For outdoor light (I)
57 int v3; // eax@1 57 int v3; // eax@1
58 bool result; // eax@9 58 bool result; // eax@9
59 int pSlot; // [sp+10h] [bp-4h]@1 59 int pSlot; // [sp+10h] [bp-4h]@1
60 60
61 v3 = stru_F8AD28.uDefaultAmbientLightLevel + pFace->uShadeType; 61 v3 = Lights.uDefaultAmbientLightLevel + pFace->uShadeType;
62 pSlot = 0; 62 pSlot = 0;
63 stru_F8AD28.uCurrentAmbientLightLevel = v3 << 16; 63 Lights.uCurrentAmbientLightLevel = v3 << 16;
64 for ( uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i ) 64 for ( uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i )
65 { 65 {
66 if ( pSlot >= 20 ) 66 if ( pSlot >= 20 )
67 break; 67 break;
68 ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, 1); 68 ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, 1);
72 if ( pSlot >= 20 ) 72 if ( pSlot >= 20 )
73 break; 73 break;
74 ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0); 74 ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0);
75 } 75 }
76 result = pSlot; 76 result = pSlot;
77 stru_F8AD28.uNumLightsApplied = pSlot; 77 Lights.uNumLightsApplied = pSlot;
78 return true; 78 return true;
79 } 79 }
80 80
81 //----- (0045D0D5) -------------------------------------------------------- 81 //----- (0045D0D5) --------------------------------------------------------
82 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot) 82 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot)
152 || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2 152 || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2
153 || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 ) 153 || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 )
154 return false; 154 return false;
155 155
156 Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3); 156 Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3);
157 float p_dot = (float)pLight->vPosition.x * pNormal->x 157 float p_dot = ((float)pLight->vPosition.x * pNormal->x
158 + (float)pLight->vPosition.y * pNormal->y 158 + (float)pLight->vPosition.y * pNormal->y
159 + (float)pLight->vPosition.z * pNormal->z + *a3; 159 + (float)pLight->vPosition.z * pNormal->z + *a3)+0.5f;
160 p_dot = p_dot + 0.5f; 160 if ( p_dot > pLight->uRadius )
161 if ( (//v49 = pNormal,
162 //Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3),
163 //X = v8->vPosition.y,
164 //v50 = (double)v8->vPosition.y * v49->y,
165 //X = v8->vPosition.z,
166 //v51 = (double)v8->vPosition.z * v49->z,
167 //X = v8->vPosition.x,
168 //*(float *)&a3 = (double)pLight->vPosition.y * pNormal->y
169 //+ (double)pLight->vPosition.z * pNormal->z
170 //+ (double)pLight->vPosition.x * pNormal->x + *a3,
171 //v61 = *(float *)&a3 + 0.5f,
172 //result = LODWORD(v61),
173 //X = LODWORD(v61),
174 //v52 = v63,
175 p_dot > pLight->uRadius) )
176 return false; 161 return false;
177 /* 162
178 v49 = pNormal; 163 Lights._blv_lights_radii[*pSlot] = pLight->uRadius;
179 Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3); 164 Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius;
180 *(float *)a3 = (double)v8->vPosition.x * v49->x 165 Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x;
181 + (double)v8->vPosition.y * v49->y 166 Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y;
182 + (double)v8->vPosition.z * v49->z + *a3; 167 Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z;
183 v61 = *(float *)a3 + 6.7553994e15; 168
184 result = LODWORD(v61); 169 Lights._blv_lights_rs[*pSlot] = pLight->uLightColorR / 255.0f;
185 X = LODWORD(v61); 170 Lights._blv_lights_gs[*pSlot] = pLight->uLightColorG / 255.0f;
186 v52 = radius_1; 171 Lights._blv_lights_bs[*pSlot] = pLight->uLightColorB / 255.0f;
187 if ( SLODWORD(v61) > radius_1)*/ 172
188 //v53 = pSlot; 173 Lights._blv_lights_light_dot_faces[*pSlot] = abs(p_dot);
189 //v60 = X; 174 Lights._blv_lights_types[*pSlot] = pLight->uLightType;
190 stru_F8AD28._blv_lights_radii[*pSlot] = pLight->uRadius; 175
191 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; 176 v57 = Lights._blv_lights_types[*pSlot];
192 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; 177 if ( pRenderer->bUsingSpecular && Lights._blv_lights_types[*pSlot] & 4 )
193 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y;
194 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z;
195
196 stru_F8AD28._blv_lights_rs[*pSlot] = pLight->uLightColorR / 255.0f;
197 stru_F8AD28._blv_lights_gs[*pSlot] = pLight->uLightColorG / 255.0f;
198 stru_F8AD28._blv_lights_bs[*pSlot] = pLight->uLightColorB / 255.0f;
199
200 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(p_dot);
201 stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType;
202
203 v57 = stru_F8AD28._blv_lights_types[*pSlot];
204 if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && stru_F8AD28._blv_lights_types[*pSlot] & 4 )
205 v57 = _4E94D2_light_type; 178 v57 = _4E94D2_light_type;
206 stru_F8AD28._blv_lights_types[*pSlot] = v57; 179 Lights._blv_lights_types[*pSlot] = v57;
207 180
208 int id = 4 * *pSlot; 181 int id = 4 * *pSlot;
209 if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular ) 182 if ( pRenderer->bUsingSpecular )
210 { 183 {
211 if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) 184 if ( Lights._blv_lights_types[*pSlot] & 4 )
212 { 185 {
213 stru_F8AD28._blv_lights_rs[id] = stru_F8AD28._blv_lights_rs[id] * 0.3300000131130219; 186 Lights._blv_lights_rs[id] = Lights._blv_lights_rs[id] * 0.3300000131130219;
214 stru_F8AD28._blv_lights_gs[id] = stru_F8AD28._blv_lights_gs[id] * 0.3300000131130219; 187 Lights._blv_lights_gs[id] = Lights._blv_lights_gs[id] * 0.3300000131130219;
215 stru_F8AD28._blv_lights_bs[id] = stru_F8AD28._blv_lights_bs[id] * 0.3300000131130219; 188 Lights._blv_lights_bs[id] = Lights._blv_lights_bs[id] * 0.3300000131130219;
216 } 189 }
217 } 190 }
218 ++*pSlot; 191 ++*pSlot;
219 return true; 192 return true;
220 } 193 }
235 && (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 208 && (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2
236 && (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2 209 && (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2
237 && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2 210 && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2
238 && ((a4) || v10 >= 0) && v10 <= pLight->uRadius ) 211 && ((a4) || v10 >= 0) && v10 <= pLight->uRadius )
239 { 212 {
240 stru_F8AD28._blv_lights_radii[*pSlot] = pLight->uRadius; 213 Lights._blv_lights_radii[*pSlot] = pLight->uRadius;
241 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; 214 Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius;
242 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; 215 Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x;
243 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; 216 Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y;
244 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; 217 Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z;
245 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; 218 Lights._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689;
246 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; 219 Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
247 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; 220 Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
248 //v11 = abs(v10); 221 //v11 = abs(v10);
249 //v12 = pRenderer->bUsingSpecular; 222 //v12 = pRenderer->bUsingSpecular;
250 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(v10); 223 Lights._blv_lights_light_dot_faces[*pSlot] = abs(v10);
251 stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; 224 Lights._blv_lights_types[*pSlot] = pLight->uLightType;
252 //v13 = pRenderer->pRenderD3D; 225 //v13 = pRenderer->pRenderD3D;
253 v14 = stru_F8AD28._blv_lights_types[*pSlot]; 226 v14 = Lights._blv_lights_types[*pSlot];
254 if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 ) 227 if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 )
255 v14 = _4E94D2_light_type; 228 v14 = _4E94D2_light_type;
256 stru_F8AD28._blv_lights_types[*pSlot] = v14; 229 Lights._blv_lights_types[*pSlot] = v14;
257 result = 4 * *pSlot; 230 result = 4 * *pSlot;
258 if ( /*v13*/true && pRenderer->bUsingSpecular ) 231 if ( /*v13*/true && pRenderer->bUsingSpecular )
259 { 232 {
260 if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) 233 if ( Lights._blv_lights_types[*pSlot] & 4 )
261 { 234 {
262 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) 235 *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result)
263 * 0.33000001; 236 * 0.33000001;
264 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result) 237 *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result)
265 * 0.33000001; 238 * 0.33000001;
266 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result) 239 *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result)
267 * 0.33000001; 240 * 0.33000001;
268 } 241 }
269 } 242 }
270 ++*pSlot; 243 ++*pSlot;
271 return true; 244 return true;
281 { 254 {
282 //For Indoor light (I) 255 //For Indoor light (I)
283 BLVFace* pFace = &pIndoor->pFaces[uFaceID]; 256 BLVFace* pFace = &pIndoor->pFaces[uFaceID];
284 BLVSector* pSector = &pIndoor->pSectors[pFace->uSectorID]; 257 BLVSector* pSector = &pIndoor->pSectors[pFace->uSectorID];
285 258
286 stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;//0x00180000 259 Lights.uCurrentAmbientLightLevel = (Lights.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;//0x00180000
287 260
288 uint uNumLightsApplied = 0; 261 uint uNumLightsApplied = 0;
289 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) 262 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
290 { 263 {
291 if (uNumLightsApplied >= 20) 264 if (uNumLightsApplied >= 20)
310 break; 283 break;
311 284
312 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type); 285 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type);
313 } 286 }
314 287
315 stru_F8AD28.uNumLightsApplied = uNumLightsApplied; 288 Lights.uNumLightsApplied = uNumLightsApplied;
316 return true; 289 return true;
317 } 290 }
318 291
319 //----- (0045C911) -------------------------------------------------------- 292 //----- (0045C911) --------------------------------------------------------
320 bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5) 293 bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5)
335 a2->pFacePlane.dist; 308 a2->pFacePlane.dist;
336 if ((bLightBackfaces || v13 >= 0.0f) && fabsf(v13) <= pLight->uRadius) 309 if ((bLightBackfaces || v13 >= 0.0f) && fabsf(v13) <= pLight->uRadius)
337 { 310 {
338 unsigned int slot = *pSlot; 311 unsigned int slot = *pSlot;
339 312
340 stru_F8AD28._blv_lights_radii[slot] = pLight->uRadius; 313 Lights._blv_lights_radii[slot] = pLight->uRadius;
341 stru_F8AD28._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius; 314 Lights._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius;
342 stru_F8AD28._blv_lights_xs[slot] = pLight->vPosition.x; 315 Lights._blv_lights_xs[slot] = pLight->vPosition.x;
343 stru_F8AD28._blv_lights_ys[slot] = pLight->vPosition.y; 316 Lights._blv_lights_ys[slot] = pLight->vPosition.y;
344 stru_F8AD28._blv_lights_zs[slot] = pLight->vPosition.z; 317 Lights._blv_lights_zs[slot] = pLight->vPosition.z;
345 stru_F8AD28._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f; 318 Lights._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f;
346 stru_F8AD28._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f; 319 Lights._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f;
347 stru_F8AD28._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f; 320 Lights._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f;
348 stru_F8AD28._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f)); 321 Lights._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f));
349 stru_F8AD28._blv_lights_types[slot] = pLight->uLightType; 322 Lights._blv_lights_types[slot] = pLight->uLightType;
350 323
351 *pSlot += 1; 324 *pSlot += 1;
352 return true; 325 return true;
353 } 326 }
354 } 327 }
363 Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2 336 Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2
364 v.z = 1.0; 337 v.z = 1.0;
365 v.y = 1.0; 338 v.y = 1.0;
366 v.x = 1.0; 339 v.x = 1.0;
367 340
368 for (uint i = 0; i < std__vector_183808_size; ++i) 341 for (uint i = 0; i < MobileLightsCount; ++i)
369 if (!pRenderer->DrawLightmap(std__vector_183808 + i, &v, z_bias)) 342 if (!pRenderer->DrawLightmap(&MobileLights[i], &v, z_bias))
370 Error("Invalid lightmap detected! (%u)", i); 343 Error("Invalid lightmap detected! (%u)", i);
371 344
372 return true; 345 return true;
373 } 346 }
374 347
495 unsigned int a7; // [sp+Ch] [bp-4h]@1 468 unsigned int a7; // [sp+Ch] [bp-4h]@1
496 469
497 v6 = 0; 470 v6 = 0;
498 //v7 = this; 471 //v7 = this;
499 a7 = 0; 472 a7 = 0;
500 stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type; 473 Lights.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type;
501 if ( pMobileLightsStack->uNumLightsActive > 0 ) 474 if ( pMobileLightsStack->uNumLightsActive > 0 )
502 { 475 {
503 v8 = pMobileLightsStack->pLights; 476 v8 = pMobileLightsStack->pLights;
504 do 477 do
505 { 478 {
524 ++v10; 497 ++v10;
525 } 498 }
526 while ( v9 < pStationaryLightsStack->uNumLightsActive ); 499 while ( v9 < pStationaryLightsStack->uNumLightsActive );
527 } 500 }
528 501
529 stru_F8AD28.uNumLightsApplied = a7; 502 Lights.uNumLightsApplied = a7;
530 return true;*/ 503 return true;*/
531 // bool __stdcall sub_45D036(struct Vec3<float> *pNormal, int a2, struct RenderVertex *a3, int a4, signed int X) 504 // bool __stdcall sub_45D036(struct Vec3<float> *pNormal, int a2, struct RenderVertex *a3, int a4, signed int X)
532 //{ 505 //{
533 // float v6; // ebx@2 506 // float v6; // ebx@2
534 507
535 //For outdoor terrain light(I) 508 //For outdoor terrain light(I)
536 unsigned int num_lights; // [sp+Ch] [bp-4h]@1 509 unsigned int num_lights; // [sp+Ch] [bp-4h]@1
537 int i; 510 int i;
538 511
539 num_lights = 0; 512 num_lights = 0;
540 stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level; 513 Lights.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level;
541 for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) 514 for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
542 { 515 {
543 if ( num_lights >= 20 ) 516 if ( num_lights >= 20 )
544 break; 517 break;
545 StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights); 518 StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights);
550 if ( num_lights >= 20 ) 523 if ( num_lights >= 20 )
551 break; 524 break;
552 StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights); 525 StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights);
553 } 526 }
554 527
555 stru_F8AD28.uNumLightsApplied = num_lights; 528 Lights.uNumLightsApplied = num_lights;
556 return true; 529 return true;
557 530
558 } 531 }
559 532
560 533
561 /////////////////////////TOGETHER/////////////////////////////////////////////////////// 534 /////////////////////////TOGETHER///////////////////////////////////////////////////////
562 //----- (0045BC07) -------------------------------------------------------- 535 //----- (0045BC07) --------------------------------------------------------
563 bool LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char uClipFlag) 536 bool LightmapBuilder::ApplyLights(LightsData *pLights, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *VertexRenderList, IndoorCameraD3D_Vec4 *a6, char uClipFlag)
564 { 537 {
565 //For outdoor terrain and indoor light (III)(III) 538 //For outdoor terrain and indoor light (III)(III)
566 Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21 539 Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21
567 RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8 540 RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8
568 541
569 if (!uNumVertices) 542 if (!uNumVertices)
570 return false; 543 return false;
571 544
572 static RenderVertexSoft static_69B140[64]; 545 static RenderVertexSoft static_69B140[64];
573 546
574 a9 = a5; 547 a9 = VertexRenderList;
575 if (a6) 548 if (a6)
576 { 549 {
577 for (uint i = 0; i < uNumVertices; ++i) 550 for (uint i = 0; i < uNumVertices; ++i)
578 memcpy(&static_69B140[i], a5 + i, sizeof(RenderVertexSoft)); 551 memcpy(&static_69B140[i], VertexRenderList + i, sizeof(RenderVertexSoft));
579 552
580 if (pIndoorCameraD3D->_437376(a3, static_69B140, &uNumVertices) == 1) 553 if (pIndoorCameraD3D->_437376(a3, static_69B140, &uNumVertices) == 1)
581 { 554 {
582 if ( !uNumVertices ) 555 if ( !uNumVertices )
583 return false; 556 return false;
584 a9 = static_69B140; 557 a9 = static_69B140;
585 } 558 }
586 } 559 }
587 560
588 static stru314 static_69B110; 561 static stru314 static_69B110;
589 static_69B110.field_4.x = a3->face_plane.vNormal.x; 562 static_69B110.Normal.x = a3->face_plane.vNormal.x;
590 static_69B110.field_4.y = a3->face_plane.vNormal.y; 563 static_69B110.Normal.y = a3->face_plane.vNormal.y;
591 static_69B110.field_4.z = a3->face_plane.vNormal.z; 564 static_69B110.Normal.z = a3->face_plane.vNormal.z;
592 static_69B110.dist = a3->face_plane.dist; 565 static_69B110.dist = a3->face_plane.dist;
593 if (!pIndoorCameraD3D->GetFacetOrientation(a3->polygonType, &static_69B110.field_4, 566 if (!pIndoorCameraD3D->GetFacetOrientation(a3->polygonType, &static_69B110.Normal,
594 &static_69B110.field_10, &static_69B110.field_1C)) 567 &static_69B110.field_10, &static_69B110.field_1C))
595 { 568 {
596 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0); 569 MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0);
597 ExitProcess(0); 570 ExitProcess(0);
598 } 571 }
599 572
600 for (uint i = 0; i < a2->uNumLightsApplied; ++i) 573 for (uint i = 0; i < pLights->uNumLightsApplied; ++i)
601 { 574 {
602 pos.x = a2->_blv_lights_xs[i]; 575 pos.x = pLights->_blv_lights_xs[i];
603 pos.y = a2->_blv_lights_ys[i]; 576 pos.y = pLights->_blv_lights_ys[i];
604 pos.z = a2->_blv_lights_zs[i]; 577 pos.z = pLights->_blv_lights_zs[i];
605 578
606 uint uColorR = (uint)floorf(a2->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF, 579 uint uColorR = (uint)floorf(pLights->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF,
607 uColorG = (uint)floorf(a2->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF, 580 uColorG = (uint)floorf(pLights->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF,
608 uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF; 581 uColorB = (uint)floorf(pLights->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF;
609 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB; 582 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB;
610 if (!uColor) 583 if (!uColor)
611 uColor = 0x0FFFFF;//0x00FFFFF; 584 uColor = 0x0FFFFF;//0x00FFFFF;
612 585
613 if (!_45BE86_build_light_polygon(&pos, a2->_blv_lights_radii[i], uColor, a2->_blv_lights_light_dot_faces[i], 586 if (!_45BE86_build_light_polygon(&pos, pLights->_blv_lights_radii[i], uColor, pLights->_blv_lights_light_dot_faces[i],
614 a2->_blv_lights_types[i], &static_69B110, uNumVertices, a9, uClipFlag) ) 587 pLights->_blv_lights_types[i], &static_69B110, uNumVertices, a9, uClipFlag) )
615 { 588 {
616 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0); 589 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
617 } 590 }
618 } 591 }
619 return true; 592 return true;
632 int v45; // eax@24 605 int v45; // eax@24
633 606
634 if (radius < 0.0f) 607 if (radius < 0.0f)
635 return true; 608 return true;
636 609
637 lightmap = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] ://stationary 610 lightmap = uLightType & 1 ? &StationaryLights[StationaryLightsCount] ://stationary
638 &std__vector_183808[std__vector_183808_size];//mobile 611 &MobileLights[MobileLightsCount];//mobile
639 tex_light_radius = radius - dot_dist; 612 tex_light_radius = radius - dot_dist;
640 flt_3C8C28 = sqrt((radius + radius - tex_light_radius) * tex_light_radius); 613 flt_3C8C28 = sqrt((radius + radius - tex_light_radius) * tex_light_radius);
641 //flt_3C8C28 = sqrt(tex_light_radius * tex_light_radius); 614 //flt_3C8C28 = sqrt(tex_light_radius * tex_light_radius);
642 flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius; 615 flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius;
643 lightmap->position_x = (double)pos->x - dot_dist * a7->field_4.x; 616 lightmap->position_x = (double)pos->x - dot_dist * a7->Normal.x;
644 lightmap->position_y = (double)pos->y - dot_dist * a7->field_4.y; 617 lightmap->position_y = (double)pos->y - dot_dist * a7->Normal.y;
645 lightmap->position_z = (double)pos->z - dot_dist * a7->field_4.z; 618 lightmap->position_z = (double)pos->z - dot_dist * a7->Normal.z;
646 619
647 flt_3C8C30 = radius * flt_3C8C2C_lightmaps_brightness; 620 light_radius = radius * flt_3C8C2C_lightmaps_brightness;
648 flt_3C8C0C = flt_3C8C30 * a7->field_10.x; 621 light_length_x = light_radius * a7->field_10.x;
649 flt_3C8C10 = flt_3C8C30 * a7->field_10.y; 622 light_length_y = light_radius * a7->field_10.y;
650 flt_3C8C14 = flt_3C8C30 * a7->field_10.z; 623 light_length_z = light_radius * a7->field_10.z;
651 624
652 flt_3C8C18 = flt_3C8C30 * a7->field_1C.x; 625 light_length_x2 = light_radius * a7->field_1C.x;
653 flt_3C8C1C = flt_3C8C30 * a7->field_1C.y; 626 light_length_y2 = light_radius * a7->field_1C.y;
654 flt_3C8C20 = flt_3C8C30 * a7->field_1C.z; 627 light_length_z2 = light_radius * a7->field_1C.z;
655 628
656 lightmap->pVertices[0].vWorldPosition.x = lightmap->position_x - flt_3C8C18 + flt_3C8C0C; 629 lightmap->pVertices[0].vWorldPosition.x = lightmap->position_x - light_length_x2 + light_length_x;
657 lightmap->pVertices[0].vWorldPosition.y = lightmap->position_y - flt_3C8C1C + flt_3C8C10; 630 lightmap->pVertices[0].vWorldPosition.y = lightmap->position_y - light_length_y2 + light_length_y;
658 lightmap->pVertices[0].vWorldPosition.z = lightmap->position_z - flt_3C8C20 + flt_3C8C14; 631 lightmap->pVertices[0].vWorldPosition.z = lightmap->position_z - light_length_z2 + light_length_z;
659 lightmap->pVertices[0].u = 0.0; 632 lightmap->pVertices[0].u = 0.0;
660 lightmap->pVertices[0].v = 0.0; 633 lightmap->pVertices[0].v = 0.0;
661 634
662 lightmap->pVertices[1].vWorldPosition.x = lightmap->position_x - flt_3C8C18 - flt_3C8C0C; 635 lightmap->pVertices[1].vWorldPosition.x = lightmap->position_x - light_length_x2 - light_length_x;
663 lightmap->pVertices[1].vWorldPosition.y = lightmap->position_y - flt_3C8C1C - flt_3C8C10; 636 lightmap->pVertices[1].vWorldPosition.y = lightmap->position_y - light_length_y2 - light_length_y;
664 lightmap->pVertices[1].vWorldPosition.z = lightmap->position_z - flt_3C8C20 - flt_3C8C14; 637 lightmap->pVertices[1].vWorldPosition.z = lightmap->position_z - light_length_z2 - light_length_z;
665 lightmap->pVertices[1].u = 0.0; 638 lightmap->pVertices[1].u = 0.0;
666 lightmap->pVertices[1].v = 1.0; 639 lightmap->pVertices[1].v = 1.0;
667 640
668 lightmap->pVertices[2].vWorldPosition.x = lightmap->position_x + flt_3C8C18 - flt_3C8C0C; 641 lightmap->pVertices[2].vWorldPosition.x = lightmap->position_x + light_length_x2 - light_length_x;
669 lightmap->pVertices[2].vWorldPosition.y = lightmap->position_y + flt_3C8C1C - flt_3C8C10; 642 lightmap->pVertices[2].vWorldPosition.y = lightmap->position_y + light_length_y2 - light_length_y;
670 lightmap->pVertices[2].vWorldPosition.z = lightmap->position_z + flt_3C8C20 - flt_3C8C14; 643 lightmap->pVertices[2].vWorldPosition.z = lightmap->position_z + light_length_z2 - light_length_z;
671 lightmap->pVertices[2].u = 1.0; 644 lightmap->pVertices[2].u = 1.0;
672 lightmap->pVertices[2].v = 1.0; 645 lightmap->pVertices[2].v = 1.0;
673 646
674 lightmap->pVertices[3].vWorldPosition.x = lightmap->position_x + flt_3C8C18 + flt_3C8C0C; 647 lightmap->pVertices[3].vWorldPosition.x = lightmap->position_x + light_length_x2 + light_length_x;
675 lightmap->pVertices[3].vWorldPosition.y = lightmap->position_y + flt_3C8C1C + flt_3C8C10; 648 lightmap->pVertices[3].vWorldPosition.y = lightmap->position_y + light_length_y2 + light_length_y;
676 lightmap->pVertices[3].vWorldPosition.z = lightmap->position_z + flt_3C8C20 + flt_3C8C14; 649 lightmap->pVertices[3].vWorldPosition.z = lightmap->position_z + light_length_z2 + light_length_z;
677 lightmap->pVertices[3].u = 1.0; 650 lightmap->pVertices[3].u = 1.0;
678 lightmap->pVertices[3].v = 0.0; 651 lightmap->pVertices[3].v = 0.0;
679 652
680 for (uint i = 0; i < 4; ++i) 653 for (uint i = 0; i < 4; ++i)
681 { 654 {
682 v24 = a7->field_4.y * lightmap->pVertices[i].vWorldPosition.y 655 v24 = a7->Normal.y * lightmap->pVertices[i].vWorldPosition.y
683 + a7->field_4.z * lightmap->pVertices[i].vWorldPosition.z 656 + a7->Normal.z * lightmap->pVertices[i].vWorldPosition.z
684 + a7->field_4.x * lightmap->pVertices[i].vWorldPosition.x 657 + a7->Normal.x * lightmap->pVertices[i].vWorldPosition.x
685 + a7->dist; 658 + a7->dist;
686 659
687 lightmap->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x; 660 lightmap->pVertices[i].vWorldPosition.x -= v24 * a7->Normal.x;
688 lightmap->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y; 661 lightmap->pVertices[i].vWorldPosition.y -= v24 * a7->Normal.y;
689 lightmap->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z; 662 lightmap->pVertices[i].vWorldPosition.z -= v24 * a7->Normal.z;
690 } 663 }
691 664
692 lightmap->uColorMask = uColorMask; 665 lightmap->uColorMask = uColorMask;
693 lightmap->NumVertices = 4; 666 lightmap->NumVertices = 4;
694 667
712 dist_z = abs(pos->z - temp3); //v33 _v64 685 dist_z = abs(pos->z - temp3); //v33 _v64
713 v38 = int_get_vector_length(dist_x, dist_y, dist_z); 686 v38 = int_get_vector_length(dist_x, dist_y, dist_z);
714 if (v38 > radius) 687 if (v38 > radius)
715 return true; 688 return true;
716 //radius = (1 / radius) * v38; 689 //radius = (1 / radius) * v38;
717 if ( uLightType & 4 ) 690 if ( uLightType & 4 )//LIGHT_ATTR_POINT
718 { 691 {
719 v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y); 692 v39 = fabs(a1.x * a7->Normal.x + a1.z * a7->Normal.z + a1.y * a7->Normal.y);
720 v40 = v39 * 1.0 * flt_4D86CC; 693 v40 = v39 * 1.0 * flt_4D86CC;
721 694
722 lightmap->fBrightness = v40 - ((1 / radius) * v38) * v40; 695 lightmap->fBrightness = v40 - ((1 / radius) * v38) * v40;
723 } 696 }
724 else if ( uLightType & 8 ) 697 else if ( uLightType & 8 )//LIGHT_ATTR_SPOTLIGHT
725 { 698 {
726 v40 = 1.0 * 1.0; 699 v40 = 1.0 * 1.0;
727 lightmap->fBrightness = v40 - ((1 / radius) * v38); 700 lightmap->fBrightness = v40 - ((1 / radius) * v38);
728 } 701 }
729 else 702 else
730 MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0); 703 MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0);
731 } 704 }
732 //Brightness(ÿðêîñòü)///////////////////////////////////////////////////// 705 //Brightness(ÿðêîñòü)/////////////////////////////////////////////////////
733 706
734 if (!pEngine->pStru9Instance->_4980B9(a9, uNumVertices, 707 if (!pEngine->pStru9Instance->_4980B9(a9, uNumVertices,
735 a7->field_4.x, a7->field_4.y, a7->field_4.z, 708 a7->Normal.x, a7->Normal.y, a7->Normal.z,
736 lightmap->pVertices, &lightmap->NumVertices)) 709 lightmap->pVertices, &lightmap->NumVertices))
737 return false; 710 return false;
738 711
739 if (!lightmap->NumVertices) 712 if (!lightmap->NumVertices)
740 return true; 713 return true;
745 718
746 pIndoorCameraD3D->ViewTransform(lightmap->pVertices, lightmap->NumVertices); 719 pIndoorCameraD3D->ViewTransform(lightmap->pVertices, lightmap->NumVertices);
747 pIndoorCameraD3D->Project(lightmap->pVertices, lightmap->NumVertices, 0); 720 pIndoorCameraD3D->Project(lightmap->pVertices, lightmap->NumVertices, 0);
748 721
749 unsigned int _a4 = 0; 722 unsigned int _a4 = 0;
750 if ( !(uClipFlag & 1) ) 723 if ( !(uClipFlag & 1) )//NoClipFlag
751 _a4 = 1; 724 _a4 = 1;
752 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) 725 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
753 { 726 {
754 if ( uClipFlag & 2 ) 727 if ( uClipFlag & 2 )//NeerClipFlag
755 { 728 {
756 pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4); 729 pIndoorCameraD3D->LightmapNeerClip(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4);
757 pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->NumVertices); 730 pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->NumVertices);
758 } 731 }
759 else if ( uClipFlag & 4 ) 732 else if ( uClipFlag & 4 )//FarClipFlag
760 { 733 {
761 pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4); 734 pIndoorCameraD3D->LightmapFarClip(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4);
762 pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->NumVertices); 735 pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->NumVertices);
763 } 736 }
764 else 737 else
765 MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0); 738 MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0);
766 } 739 }
769 742
770 if (_a4) 743 if (_a4)
771 { 744 {
772 if (uLightType & 1) 745 if (uLightType & 1)
773 { 746 {
774 if (std__vector_000004_size < 512 - 1) 747 if (StationaryLightsCount < 512 - 1)
775 ++std__vector_000004_size; 748 ++StationaryLightsCount;
776 } 749 }
777 else 750 else
778 { 751 {
779 if (std__vector_183808_size < 768 - 1) 752 if (MobileLightsCount < 768 - 1)
780 ++std__vector_183808_size; 753 ++MobileLightsCount;
781 } 754 }
782 //if ( v50 ^ v51 ) 755 //if ( v50 ^ v51 )
783 // *(unsigned int *)v48 = v49 + 1; 756 // *(unsigned int *)v48 = v49 + 1;
784 } 757 }
785 return true; 758 return true;
786 } 759 }
787 760
788 //----- (0045C6D6) -------------------------------------------------------- 761 //----- (0045C6D6) --------------------------------------------------------
789 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) 762 int LightmapBuilder::_45C6D6(int uNumVertices, RenderVertexSoft *a3, Lightmap *pLightmap)
790 { 763 {
791 //For outdoor terrain and indoor light (V)(V) 764 //For outdoor terrain and indoor light (V)(V)
792 signed int v6; // esi@1 765 signed int v6; // esi@1
793 float temp_x; // st7@6 766 float temp_x; // st7@6
794 float temp_y; // st6@10 767 float temp_y; // st6@10
800 v15 = 0; 773 v15 = 0;
801 if ( (signed int)pLightmap->NumVertices > 0 ) 774 if ( (signed int)pLightmap->NumVertices > 0 )
802 { 775 {
803 for ( uint i = 0; i < (signed int)pLightmap->NumVertices; ++i ) 776 for ( uint i = 0; i < (signed int)pLightmap->NumVertices; ++i )
804 { 777 {
805 if ( a2 > 0 ) 778 if ( uNumVertices > 0 )
806 { 779 {
807 for ( uint j = 0; j < a2; ++j ) 780 for ( uint j = 0; j < uNumVertices; ++j )
808 { 781 {
809 if ( pLightmap->pVertices[i].vWorldPosition.x <= (double)a3[j].vWorldPosition.x ) 782 if ( pLightmap->pVertices[i].vWorldPosition.x <= (double)a3[j].vWorldPosition.x )
810 temp_x = a3[j].vWorldPosition.x - pLightmap->pVertices[i].vWorldPosition.x; 783 temp_x = a3[j].vWorldPosition.x - pLightmap->pVertices[i].vWorldPosition.x;
811 else 784 else
812 temp_x = pLightmap->pVertices[i].vWorldPosition.x - a3[j].vWorldPosition.x; 785 temp_x = pLightmap->pVertices[i].vWorldPosition.x - a3[j].vWorldPosition.x;
852 if (type == 2) 825 if (type == 2)
853 Draw_183808_Lightmaps(); 826 Draw_183808_Lightmaps();
854 } 827 }
855 828
856 //----- (0045D74F) -------------------------------------------------------- 829 //----- (0045D74F) --------------------------------------------------------
857 bool LightmapBuilder::DrawLightmaps(int *indices) 830 bool LightmapBuilder::DrawLightmaps(int indices)
858 { 831 {
859 //For outdoor terrain and indoor light (VI)(VI) 832 //For outdoor terrain and indoor light (VI)(VI)
860 Lightmap *v28; // [sp+50h] [bp-38h]@2 833 Lightmap *v28; // [sp+50h] [bp-38h]@2
861 Vec3_float_ arg4; 834 Vec3_float_ arg4;
862 835
863 if (std__vector_000004_size == 0) 836 if (StationaryLightsCount == 0)
864 return true; 837 return true;
865 838
866 if (byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) 839 if (byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related)
867 return true; 840 return true;
868 841
869 pRenderer->BeginLightmaps(); 842 pRenderer->BeginLightmaps();
870 843
871 arg4.x = 1.0f; 844 arg4.x = 1.0f;
872 arg4.y = 1.0f; 845 arg4.y = 1.0f;
873 arg4.z = 1.0f; 846 arg4.z = 1.0f;
874 if (indices) 847 if (lights_flag)
875 { 848 {
876 for (int* i = indices; *i != -1; ++i) 849 if (indices != -1)
877 { 850 {
878 __debugbreak();//Not used? 851 for (unsigned int i = 0; i < MobileLightsCount; ++i)
879 v28 = &std__vector_000004[*i]; 852 {
880 if ( !pRenderer->DrawLightmap(v28, &arg4, 0.0) ) 853 if ( !pRenderer->DrawLightmap(&MobileLights[i], &arg4, 0.0) )
881 Error("Invalid lightmap detected! (%u)", *i); 854 Error("Invalid lightmap detected! (%u)", i);
882 } 855 }
883 } 856 }
884 else 857 else
885 if (for_refactoring) 858 {
886 { 859 for (unsigned int i = 0; i < StationaryLightsCount; ++i)
887 for (unsigned int i = 0; i < std__vector_000004_size; ++i) 860 if ( !pRenderer->DrawLightmap(&StationaryLights[i], &arg4, 0.0) )
888 if ( !pRenderer->DrawLightmap(std__vector_000004 + i, &arg4, 0.0) ) 861 Error("Invalid lightmap detected! (%u)", i);
889 Error("Invalid lightmap detected! (%u)", i); 862 }
890 } 863 }
891 864
892 pRenderer->EndLightmaps(); 865 pRenderer->EndLightmaps();
893 866
894 return true; 867 return true;
895 } 868 }
953 926
954 //----- (0045DCA9) -------------------------------------------------------- 927 //----- (0045DCA9) --------------------------------------------------------
955 void LightmapBuilder::Draw_183808_Lightmaps() 928 void LightmapBuilder::Draw_183808_Lightmaps()
956 { 929 {
957 //For outdoor and indoor light (III)(IX) 930 //For outdoor and indoor light (III)(IX)
958 if (!std__vector_183808_size) 931 if (!MobileLightsCount)
959 return; 932 return;
960 933
961 pRenderer->BeginLightmaps2(); 934 pRenderer->BeginLightmaps2();
962 935
963 DoDraw_183808_Lightmaps(0.00050000002); 936 DoDraw_183808_Lightmaps(0.00050000002);
966 } 939 }
967 940
968 941
969 ////////////////////////OTHER//////////////////////////////////////////////////////// 942 ////////////////////////OTHER////////////////////////////////////////////////////////
970 //----- (0045CA88) -------------------------------------------------------- 943 //----- (0045CA88) --------------------------------------------------------
971 int LightmapBuilder::_45CA88(stru320 *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal) 944 int LightmapBuilder::_45CA88(LightsData *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal)
972 { 945 {
973 int result; // eax@1 946 int result; // eax@1
974 stru320 *v6; // ecx@2 947 LightsData *v6; // ecx@2
975 RenderVertexSoft *v7; // ebx@2 948 RenderVertexSoft *v7; // ebx@2
976 double v8; // st7@2 949 double v8; // st7@2
977 double v9; // st6@2 950 double v9; // st6@2
978 char *v10; // eax@3 951 char *v10; // eax@3
979 double v11; // st7@5 952 double v11; // st7@5
1218 // 4D86D8: using guessed type int dword_4D86D8; 1191 // 4D86D8: using guessed type int dword_4D86D8;
1219 // 4E94D2: using guessed type char _4E94D2_light_type; 1192 // 4E94D2: using guessed type char _4E94D2_light_type;
1220 // 519AB4: using guessed type int uNumStationaryLightsApplied; 1193 // 519AB4: using guessed type int uNumStationaryLightsApplied;
1221 1194
1222 //----- (0045D698) -------------------------------------------------------- 1195 //----- (0045D698) --------------------------------------------------------
1223 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2) 1196 void LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2)
1224 { 1197 {
1225 bool result; // eax@1
1226 LightmapBuilder *v3; // esi@1
1227 RenderVertexSoft *v4; // edi@3
1228 RenderVertexSoft *v5; // edi@7
1229 IndoorCameraD3D *thisa; // [sp+10h] [bp-8h]@1
1230 bool v7; // [sp+14h] [bp-4h]@2
1231 bool a2a; // [sp+20h] [bp+8h]@6
1232
1233 __debugbreak();//Not used?
1234 result = (bool)pIndoorCameraD3D;
1235 v3 = this;
1236 thisa = pIndoorCameraD3D;
1237 if ( bit_one_for_list1__bit_two_for_list2 & 1 ) 1198 if ( bit_one_for_list1__bit_two_for_list2 & 1 )
1238 { 1199 {
1239 v7 = 0; 1200 for (int i = 0; i < this->StationaryLightsCount; ++i)
1240 if ( (signed int)this->std__vector_000004_size > 0 ) 1201 pIndoorCameraD3D->debug_outline_sw(this->StationaryLights[i].pVertices, this->StationaryLights[i].NumVertices, 0xFF00, 0.0f);
1241 {
1242 v4 = this->std__vector_000004[0].pVertices;
1243 do
1244 {
1245 pIndoorCameraD3D->debug_outline_sw(v4, *((unsigned int *)v4 - 1), 0xFF00u, 0.0);
1246 ++v7;
1247 v4 = (RenderVertexSoft *)((char *)v4 + 3100);
1248 result = v7;
1249 }
1250 while ( v7 < (signed int)v3->std__vector_000004_size );
1251 }
1252 } 1202 }
1253 if ( bit_one_for_list1__bit_two_for_list2 & 2 ) 1203 if ( bit_one_for_list1__bit_two_for_list2 & 2 )
1254 { 1204 {
1255 a2a = 0; 1205 for (uint i = 0; i < this->MobileLightsCount; ++i)
1256 if ( (signed int)v3->std__vector_183808_size > 0 ) 1206 pIndoorCameraD3D->debug_outline_sw(this->MobileLights[i].pVertices, this->MobileLights[i].NumVertices, 0xC04000, 0.00019999999f);
1257 { 1207 }
1258 v5 = v3->std__vector_183808[0].pVertices; 1208 }
1259 do
1260 {
1261 pIndoorCameraD3D->debug_outline_sw(v5, *((unsigned int *)v5 - 1), 0xC04000u, 0.00019999999);
1262 ++a2a;
1263 v5 = (RenderVertexSoft *)((char *)v5 + 3100);
1264 result = a2a;
1265 }
1266 while ( a2a < (signed int)v3->std__vector_183808_size );
1267 }
1268 }
1269 LOBYTE(result) = 1;
1270 return result;
1271 }