World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
LightmapBuilder.cpp
См. документацию.
1 #include "Engine/Engine.h"
2 #include "Engine/stru314.h"
3 
8 
10 
12 // StationaryLight pStationaryLights[400];
13 // int uNumStationaryLightsApplied;
15 // MobileLight pMobileLights[400];
16 // int uNumMobileLightsApplied;
17 
18 //----- (0045DF13) --------------------------------------------------------
20  // For initialization step(I)
21 
22  NumVertices = -1;
23  for (uint i = 0; i < 64; ++i) pVertices[i].flt_2C = 0.0f;
24  this->field_C18 = 0;
25  // this->vdestructor_ptr = &Lightmap_pvdtor;
26 }
27 
28 //----- (0045BB06) --------------------------------------------------------
30  this->log = EngineIoc::ResolveLogger();
31 
32  // For initialization step(II)
33 
34  for (int i = 0; i < 512; ++i) // for light type 1
35  this->StationaryLights[i] = Lightmap();
36  this->StationaryLightsCount = 0;
37 
38  for (int i = 0; i < 768; ++i) // for light type 2
39  this->MobileLights[i] = Lightmap();
40  this->MobileLightsCount = 0;
41 
42  for (int i = 0; i < 256; i++)
43  this->field_3C8C34[i].flt_2C = 0.0f;
44 }
45 
46 // ////////////////////////OUTDOOR/LIGHT////////////////////////////////////////////
47 // ----- (0045CDB7) --------------------------------------------------------
49  // For outdoor light (I)
50  int v3; // eax@1
51  bool result; // eax@9
52  int pSlot; // [sp+10h] [bp-4h]@1
53 
55  pSlot = 0;
57  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) {
58  if (pSlot >= 20) break;
60  (unsigned int *)&pSlot, false);
61  }
62  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) {
63  if (pSlot >= 20) break;
65  (unsigned int *)&pSlot, false);
66  }
67 
68  result = pSlot;
69  Lights.uNumLightsApplied = pSlot;
70  return true;
71 }
72 
73 //----- (0045D0D5) --------------------------------------------------------
75  Vec3_float_ *pNormal,
76  float *light_tile_dist,
77  RenderVertexSoft *TerrainVertices,
78  unsigned int uStripType, int X,
79  unsigned int *pSlot) {
80  // For outdoor terrain light (II)
81  // bool result; // eax@1
82  double maxz; // st7@11
83  // char v20; // c2@11
84  // signed int v52; // ecx@17
85  char v57; // dl@18
86  // String v58; // [sp-18h] [bp-38h]@10
87  // double v61; // [sp+Ch] [bp-14h]@11
88  float minz; // [sp+14h] [bp-Ch]@11
89  float tX_0 = 0;
90  float tX_1 = 0;
91  float tY_0 = 0;
92  float tY_1 = 0; // [sp+1Ch] [bp-4h]@5
93 
94  // x0,y0 x1,y1 // this is actuall ccw??
95  // .____________.
96  // | |
97  // | |
98  // | |
99  // .____________.
100  // x3,y3 x2,y2
101 
102  if (pLight->uRadius <= 0) return false;
103  if (uStripType == 4) {
104  tX_0 = TerrainVertices[0].vWorldPosition.x;
105  tX_1 = TerrainVertices[3].vWorldPosition.x;
106 
107  tY_0 = TerrainVertices[1].vWorldPosition.y;
108  tY_1 = TerrainVertices[0].vWorldPosition.y;
109  } else if (uStripType == 3) {
110  // __debugbreak();
111  if ((unsigned char)X) {
112  tX_0 = TerrainVertices[0].vWorldPosition.x;
113  tX_1 = TerrainVertices[2].vWorldPosition.x;
114 
115  tY_0 = TerrainVertices[1].vWorldPosition.y;
116  tY_1 = TerrainVertices[2].vWorldPosition.y;
117  } else {
118  tX_0 = TerrainVertices[1].vWorldPosition.x;
119  tX_1 = TerrainVertices[2].vWorldPosition.x;
120 
121  tY_0 = TerrainVertices[1].vWorldPosition.y;
122  tY_1 = TerrainVertices[0].vWorldPosition.y;
123  }
124  } else {
125  log->Warning(L"Uknown strip type detected!");
126  }
127 
128  minz = pIndoorCameraD3D->GetPolygonMinZ(TerrainVertices, uStripType);
129  maxz = pIndoorCameraD3D->GetPolygonMaxZ(TerrainVertices, uStripType);
130 
131  float bounding_x1 = tX_0 - (float)pLight->uRadius; // 13 976 - 128 =
132  // 13848.0
133  float bounding_y1 = tY_0 - (float)pLight->uRadius; // 3 800 - 128 = 3672.0
134  float bounding_z1 = minz - (float)pLight->uRadius; // -26.0
135 
136  float bounding_x2 =
137  (float)pLight->uRadius + tX_1; // 13 877 + 128 = 14005.0
138  float bounding_y2 = (float)pLight->uRadius + tY_1; // 3 792 + 128 = 3920.0
139  float bounding_z2 = (float)pLight->uRadius + maxz; // 260.0
140 
141  //проверяем вершины
142  if ((float)pLight->vPosition.x <= bounding_x1 ||
143  (float)pLight->vPosition.x >= bounding_x2 ||
144  (float)pLight->vPosition.y <= bounding_y1 ||
145  (float)pLight->vPosition.y >= bounding_y2 ||
146  (float)pLight->vPosition.z <= bounding_z1 ||
147  (float)pLight->vPosition.z >= bounding_z2)
148  return false;
149 
150  Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal,
151  light_tile_dist);
152  float p_dot = ((float)pLight->vPosition.x * pNormal->x +
153  (float)pLight->vPosition.y * pNormal->y +
154  (float)pLight->vPosition.z * pNormal->z + *light_tile_dist) +
155  0.5f;
156  if (p_dot > pLight->uRadius) return false;
157 
158  Lights._blv_lights_radii[*pSlot] = pLight->uRadius;
159  Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius;
160  Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x;
161  Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y;
162  Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z;
163 
164  Lights._blv_lights_rs[*pSlot] = pLight->uLightColorR / 255.0f;
165  Lights._blv_lights_gs[*pSlot] = pLight->uLightColorG / 255.0f;
166  Lights._blv_lights_bs[*pSlot] = pLight->uLightColorB / 255.0f;
167 
168  Lights._blv_lights_light_dot_faces[*pSlot] = abs(p_dot);
169  Lights._blv_lights_types[*pSlot] = pLight->uLightType;
170 
171  v57 = Lights._blv_lights_types[*pSlot];
172  if (render->config->is_using_specular && Lights._blv_lights_types[*pSlot] & 4)
173  v57 = _4E94D2_light_type;
174  Lights._blv_lights_types[*pSlot] = v57;
175 
176  int id = 4 * *pSlot;
177  if (render->config->is_using_specular) {
178  if (Lights._blv_lights_types[*pSlot] & 4) {
180  Lights._blv_lights_rs[id] * 0.3300000131130219;
182  Lights._blv_lights_gs[id] * 0.3300000131130219;
184  Lights._blv_lights_bs[id] * 0.3300000131130219;
185  }
186  }
187  ++*pSlot;
188  return true;
189 }
190 
191 //----- (0045CE50) --------------------------------------------------------
193  unsigned int *pSlot,
194  bool bLightBackfaces) {
195  // For outdoor light (IV)
196  int result; // eax@0
197  double v10; // ecx@8
198  char v14; // dl@11
199 
200  if (!pLight->uRadius) return false;
201 
202  if ((pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) &&
203  pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 &&
204  (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) &&
205  pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2 &&
206  (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) &&
207  pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2) {
208  v10 = (double)(pLight->vPosition.x * pFace->pFacePlane.vNormal.x +
209  pLight->vPosition.y * pFace->pFacePlane.vNormal.y +
210  pLight->vPosition.z * pFace->pFacePlane.vNormal.z +
211  pFace->pFacePlane.dist);
212  v10 = v10 / 65536;
213 
214  if (((bLightBackfaces) || v10 >= 0.0f) &&
215  fabsf(v10) <= pLight->uRadius) {
216  Lights._blv_lights_radii[*pSlot] = pLight->uRadius;
217  Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius;
218  Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x;
219  Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y;
220  Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z;
221  Lights._blv_lights_rs[*pSlot] =
222  (double)pLight->uLightColorR / 255.0f;
223  Lights._blv_lights_gs[*pSlot] =
224  (double)pLight->uLightColorG / 255.0f;
225  Lights._blv_lights_bs[*pSlot] =
226  (double)pLight->uLightColorB / 255.0f;
228  abs((int)floorf(v10 + 0.5f));
229  Lights._blv_lights_types[*pSlot] = pLight->uLightType;
230  v14 = Lights._blv_lights_types[*pSlot];
231  if (render->config->is_using_specular && Lights._blv_lights_types[*pSlot] & 4)
232  v14 = _4E94D2_light_type;
233  Lights._blv_lights_types[*pSlot] = v14;
234  result = 4 * *pSlot;
235  if (render->config->is_using_specular) {
236  __debugbreak();
237  if (Lights._blv_lights_types[*pSlot] & 4) {
238  *(float *)((char *)Lights._blv_lights_rs + result) =
239  *(float *)((char *)Lights._blv_lights_rs + result) *
240  0.33000001;
241  *(float *)((char *)Lights._blv_lights_gs + result) =
242  *(float *)((char *)Lights._blv_lights_gs + result) *
243  0.33000001;
244  *(float *)((char *)Lights._blv_lights_bs + result) =
245  *(float *)((char *)Lights._blv_lights_bs + result) *
246  0.33000001;
247  }
248  }
249 
250  ++*pSlot;
251  return true;
252  }
253  } else {
254  return false;
255  }
256 }
257 
258 // ////////////////////////INDOOR
259 // /LIGHT////////////////////////////////////////////
260 // ----- (0045C7F6) --------------------------------------------------------
261 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID) {
262  // For Indoor light (I)
263  BLVFace *pFace = &pIndoor->pFaces[uFaceID];
264  BLVSector *pSector = &pIndoor->pSectors[pFace->uSectorID];
265 
268  << 16; // 0x00180000
269 
270  uint uNumLightsApplied = 0;
271  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) {
272  if (uNumLightsApplied >= 20) break;
273 
275  pFace, &uNumLightsApplied, true, 0);
276  }
277 
278  for (uint i = 0; i < pSector->uNumLights; ++i) {
279  if (uNumLightsApplied >= 20) break;
280 
281  BLVLightMM7 *pLight = &pIndoor->pLights[pSector->pLights[i]];
282  if (~pLight->uAtributes & 0x08)
283  ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false,
285  }
286 
287  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) {
288  if (uNumLightsApplied >= 20) break;
289 
291  &uNumLightsApplied, false, &_4E94D0_light_type);
292  }
293 
294  Lights.uNumLightsApplied = uNumLightsApplied;
295  return true;
296 }
297 
298 //----- (0045C911) --------------------------------------------------------
300  unsigned int *pSlot, bool bLightBackfaces,
301  char *LightType) {
302  // For indoor light (II)
303  double Distance; // st7@8
304 
305  if (!pLight->uRadius) // 800
306  return false;
307 
308  if (pLight->vPosition.x > pFace->pBounding.x1 - pLight->uRadius &&
309  pLight->vPosition.x < pFace->pBounding.x2 + pLight->uRadius &&
310  pLight->vPosition.y > pFace->pBounding.y1 - pLight->uRadius &&
311  pLight->vPosition.y < pFace->pBounding.y2 + pLight->uRadius &&
312  pLight->vPosition.z > pFace->pBounding.z1 - pLight->uRadius &&
313  pLight->vPosition.z < pFace->pBounding.z2 + pLight->uRadius) {
314  Distance = (double)pLight->vPosition.z * pFace->pFacePlane.vNormal.z +
315  (double)pLight->vPosition.y * pFace->pFacePlane.vNormal.y +
316  (double)pLight->vPosition.x * pFace->pFacePlane.vNormal.x +
317  pFace->pFacePlane.dist;
318 
319 
320  if ((bLightBackfaces || Distance >= 0.0f) && fabsf(Distance) <= pLight->uRadius) {
321  unsigned int slot = *pSlot;
322 
323  Lights._blv_lights_radii[slot] = pLight->uRadius;
324  Lights._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius;
325  Lights._blv_lights_xs[slot] = pLight->vPosition.x;
326  Lights._blv_lights_ys[slot] = pLight->vPosition.y;
327  Lights._blv_lights_zs[slot] = pLight->vPosition.z;
328  Lights._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f;
329  Lights._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f;
330  Lights._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f;
332  abs((int)floorf(Distance + 0.5f));
333  Lights._blv_lights_types[slot] = pLight->uLightType;
334 
335  *pSlot += 1;
336  return true;
337  }
338  }
339 
340  return false;
341 }
342 
343 //----- (0045DA56) --------------------------------------------------------
345  // For indoor light (X)
346  Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2
347  v.z = 1.0;
348  v.y = 1.0;
349  v.x = 1.0;
350 
351  for (uint i = 0; i < MobileLightsCount; ++i)
352  if (!render->DrawLightmap(&MobileLights[i], &v, z_bias))
353  Error("Invalid lightmap detected! (%u)", i);
354 
355  return true;
356 }
357 
358 //----- (0045C4B9) --------------------------------------------------------
360  Lightmap *pLightmap) {
361  // For indoor light (?)
362  RenderVertexSoft *v9; // esi@3
363  RenderVertexSoft *v12; // ecx@8
364  char v13; // bl@17
365  signed int v14; // edx@17
366  double v15; // st6@18
367  double v16; // st6@21
368  double v17; // st6@24
369  signed int v18; // edx@33
370  float v22; // [sp+Ch] [bp-14h]@23
371  float v23; // [sp+10h] [bp-10h]@20
372  int v24; // [sp+14h] [bp-Ch]@1
373  char v26; // [sp+1Eh] [bp-2h]@17
374  char v27; // [sp+1Fh] [bp-1h]@17
375 
376  v24 = 0;
377  for (uint i = 0; i < pLightmap->NumVertices; i++) {
378  v9 = &pLightmap->pVertices[(i + 1) % pLightmap->NumVertices];
379  if (pLightmap->pVertices[i].vWorldPosition.x != v9->vWorldPosition.x ||
380  pLightmap->pVertices[i].vWorldPosition.y != v9->vWorldPosition.y ||
381  pLightmap->pVertices[i].vWorldPosition.z != v9->vWorldPosition.z) {
382  for (uint j = 0; j < a2; ++j) {
383  v12 = &a3[(j + 1) % a2];
384  if ((a3[j].vWorldPosition.x != v12->vWorldPosition.x ||
385  a3[j].vWorldPosition.y != v12->vWorldPosition.y ||
386  a3[j].vWorldPosition.z != v12->vWorldPosition.z) &&
387  pLightmap->pVertices[i].vWorldPosition.x ==
388  a3[j].vWorldPosition.x &&
389  pLightmap->pVertices[i].vWorldPosition.y ==
390  a3[j].vWorldPosition.y &&
391  pLightmap->pVertices[i].vWorldPosition.z ==
392  a3[j].vWorldPosition.z &&
393  (v9->vWorldPosition.x != v12->vWorldPosition.x ||
394  v9->vWorldPosition.y != v12->vWorldPosition.y ||
395  v9->vWorldPosition.z != v12->vWorldPosition.z)) {
396  v13 = 0;
397  v14 = 0;
398  v27 = 0;
399  v26 = 0;
400 
401  if (v9->vWorldPosition.x <= (double)v12->vWorldPosition.x)
402  v15 = v12->vWorldPosition.x - v9->vWorldPosition.x;
403  else
404  v15 = v9->vWorldPosition.x - v12->vWorldPosition.x;
405  v23 = v15;
406 
407  if (v9->vWorldPosition.y <= (double)v12->vWorldPosition.y)
408  v16 = v12->vWorldPosition.y - v9->vWorldPosition.y;
409  else
410  v16 = v9->vWorldPosition.y - v12->vWorldPosition.y;
411  v22 = v16;
412 
413  if (v9->vWorldPosition.z <= (double)v12->vWorldPosition.z)
414  v17 = v12->vWorldPosition.z - v9->vWorldPosition.z;
415  else
416  v17 = v9->vWorldPosition.z - v12->vWorldPosition.z;
417 
418  if (v23 < 1.0) {
419  v13 = 1;
420  v14 = 1;
421  }
422 
423  if (v22 < 1.0) {
424  v27 = 1;
425  ++v14;
426  }
427 
428  if (v17 < 1.0) {
429  v26 = 1;
430  ++v14;
431  }
432 
433  if (v14 > 1) {
434  v18 = 0;
435  if (v13 &&
436  v9->vWorldPosition.x != v12->vWorldPosition.x) {
437  v18 = 1;
438  v9->vWorldPosition.x = v12->vWorldPosition.x;
439  }
440 
441  if (v27 &&
442  v9->vWorldPosition.y != v12->vWorldPosition.y) {
443  ++v18;
444  v9->vWorldPosition.y = v12->vWorldPosition.y;
445  }
446 
447  if (v26 &&
448  v9->vWorldPosition.z != v12->vWorldPosition.z) {
449  ++v18;
450  v9->vWorldPosition.z = v12->vWorldPosition.z;
451  }
452 
453  if (v18 > 0) ++v24;
454  }
455  }
456  }
457  }
458  }
459  return v24;
460 }
461 
462 // //////////////////////FOR OUTDOOR
463 // /TERRAIN//////////////////////////////////////////
464 // ----- (0045D036) --------------------------------------------------------
466  float *Light_tile_dist,
467  RenderVertexSoft *VertList,
468  unsigned int uStripType,
469  bool bLightBackfaces) {
470  // For outdoor terrain light(I)
471  unsigned int num_lights = 0; // [sp+Ch] [bp-4h]@1
473 
474  for (int i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) {
475  if (num_lights >= 20) break;
477  (StationaryLight *)&pMobileLightsStack->pLights[i], pNormal,
478  Light_tile_dist, VertList, uStripType, bLightBackfaces, &num_lights);
479  }
480 
481  for (int i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) {
482  if (num_lights >= 20) break;
484  Light_tile_dist, VertList, uStripType, bLightBackfaces,
485  &num_lights);
486  }
487 
488  Lights.uNumLightsApplied = num_lights;
489  return true;
490 }
491 
492 // ///////////////////////TOGETHER///////////////////////////////////////////////////////
493 // ----- (0045BC07) --------------------------------------------------------
494 bool LightmapBuilder::ApplyLights(LightsData *pLights, stru154 *FacePlane, unsigned int uNumVertices,
495  RenderVertexSoft *FaceVertexList, IndoorCameraD3D_Vec4 *a6, char uClipFlag) {
496  // a6 - portal frustum ??
497 
498  // lightmap_builder->ApplyLights(&Lights, &faceplane, uNumVerticesa, VertsTransformed, pVertices, 0);
499 
500  // For outdoor terrain and indoor light (III)(III)
501  Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21
502  RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8
503 
504  if (!uNumVertices) return false;
505 
506  static RenderVertexSoft static_69B140[64];
507 
508  a9 = FaceVertexList;
509  if (a6) {
510  for (uint i = 0; i < uNumVertices; ++i)
511  memcpy(&static_69B140[i], FaceVertexList + i,
512  sizeof(RenderVertexSoft));
513 
514  if (pIndoorCameraD3D->_437376(FacePlane, static_69B140, &uNumVertices) == 1) {
515  if (!uNumVertices) return false;
516  a9 = static_69B140;
517  }
518  }
519 
520  static stru314 static_69B110;
521  static_69B110.Normal.x = FacePlane->face_plane.vNormal.x;
522  static_69B110.Normal.y = FacePlane->face_plane.vNormal.y;
523  static_69B110.Normal.z = FacePlane->face_plane.vNormal.z;
524  static_69B110.dist = FacePlane->face_plane.dist;
526  FacePlane->polygonType, &static_69B110.Normal, &static_69B110.field_10,
527  &static_69B110.field_1C)) {
528  log->Warning(L"Error: Failed to get the facet orientation");
530  }
531 
532  for (uint i = 0; i < pLights->uNumLightsApplied; ++i) {
533  pos.x = pLights->_blv_lights_xs[i];
534  pos.y = pLights->_blv_lights_ys[i];
535  pos.z = pLights->_blv_lights_zs[i];
536 
537  uint uColorR =
538  (uint)floorf(pLights->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF,
539  uColorG =
540  (uint)floorf(pLights->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF,
541  uColorB =
542  (uint)floorf(pLights->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF;
543  uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB;
544 
545  if (!uColor) {
546  uColor = 0x00FFFFFF; // 0x00FFFFF;
547  }
548 
550  &pos, pLights->_blv_lights_radii[i], uColor,
551  pLights->_blv_lights_light_dot_faces[i],
552  pLights->_blv_lights_types[i], &static_69B110, uNumVertices, a9,
553  uClipFlag)) {
554  log->Warning(L"Error: Failed to build light polygon");
555  }
556  }
557  return true;
558 }
559 
560 //----- (0045BE86) --------------------------------------------------------
561 bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist,
562  int uLightType, stru314 *FacePlaneNormals, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag) {
563 
564  // For outdoor terrain and indoor light (IV)(IV)
565  Lightmap *lightmap; // edi@3
566  // double v17; // st7@5
567  double v24; // st7@6
568  double v38; // st7@14
569  double v39; // st7@16
570  double v40; // st7@16
571  int v45; // eax@24
572 
573  if (radius < 0.0f) return true;
574 
575  lightmap = /*uLightType & 1 ?*/ &StationaryLights[StationaryLightsCount];
576  /* :*/ // stationary
577  /* &MobileLights[MobileLightsCount];*/ // mobile
578  tex_light_radius = radius - dot_dist;
579  // flt_3C8C28 = sqrt((radius + radius - tex_light_radius) * tex_light_radius);
580  flt_3C8C28 = sqrt(radius * radius - dot_dist * dot_dist);
581  flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius;
582 
583 
584  lightmap->position_x = (double)pos->x - dot_dist * FacePlaneNormals->Normal.x;
585  lightmap->position_y = (double)pos->y - dot_dist * FacePlaneNormals->Normal.y;
586  lightmap->position_z = (double)pos->z - dot_dist * FacePlaneNormals->Normal.z;
587 
589  light_length_x = light_radius * FacePlaneNormals->field_10.x;
590  light_length_y = light_radius * FacePlaneNormals->field_10.y;
591  light_length_z = light_radius * FacePlaneNormals->field_10.z;
592 
593  light_length_x2 = light_radius * FacePlaneNormals->field_1C.x;
594  light_length_y2 = light_radius * FacePlaneNormals->field_1C.y;
595  light_length_z2 = light_radius * FacePlaneNormals->field_1C.z;
596 
597  lightmap->pVertices[0].vWorldPosition.x =
599  lightmap->pVertices[0].vWorldPosition.y =
601  lightmap->pVertices[0].vWorldPosition.z =
603  lightmap->pVertices[0].u = 0.0;
604  lightmap->pVertices[0].v = 0.0;
605 
606  lightmap->pVertices[1].vWorldPosition.x =
608  lightmap->pVertices[1].vWorldPosition.y =
610  lightmap->pVertices[1].vWorldPosition.z =
612  lightmap->pVertices[1].u = 0.0;
613  lightmap->pVertices[1].v = 1.0;
614 
615  lightmap->pVertices[2].vWorldPosition.x =
617  lightmap->pVertices[2].vWorldPosition.y =
619  lightmap->pVertices[2].vWorldPosition.z =
621  lightmap->pVertices[2].u = 1.0;
622  lightmap->pVertices[2].v = 1.0;
623 
624  lightmap->pVertices[3].vWorldPosition.x =
626  lightmap->pVertices[3].vWorldPosition.y =
628  lightmap->pVertices[3].vWorldPosition.z =
630  lightmap->pVertices[3].u = 1.0;
631  lightmap->pVertices[3].v = 0.0;
632 
633  for (uint i = 0; i < 4; ++i) {
634  v24 = FacePlaneNormals->Normal.y * lightmap->pVertices[i].vWorldPosition.y +
635  FacePlaneNormals->Normal.z * lightmap->pVertices[i].vWorldPosition.z +
636  FacePlaneNormals->Normal.x * lightmap->pVertices[i].vWorldPosition.x + FacePlaneNormals->dist;
637 
638  lightmap->pVertices[i].vWorldPosition.x -= v24 * FacePlaneNormals->Normal.x;
639  lightmap->pVertices[i].vWorldPosition.y -= v24 * FacePlaneNormals->Normal.y;
640  lightmap->pVertices[i].vWorldPosition.z -= v24 * FacePlaneNormals->Normal.z;
641  }
642 
643  lightmap->uColorMask = uColorMask;
644  lightmap->NumVertices = 4;
645 
646  // Brightness(яркость)/////////////////////////////////
647  if (!engine->config->AllowDynamicBrigtness()) {
649  } else {
650  Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
651  a1.x = (double)pos->x - lightmap->position_x;
652  a1.y = (double)pos->y - lightmap->position_y;
653  a1.z = (double)pos->z - lightmap->position_z;
654  a1.Normalize();
655 
656  auto temp1 = lightmap->position_x + 0.5f,
657  temp2 = lightmap->position_y + 0.5f,
658  temp3 = lightmap->position_z + 0.5f;
659 
660  auto dist_x = abs(pos->x - temp1), // v31
661  dist_y = abs(pos->y - temp2), // v32 arg0a
662  dist_z = abs(pos->z - temp3); // v33 _v64
663  v38 = int_get_vector_length(dist_x, dist_y, dist_z);
664  if (v38 > radius) return true;
665  // radius = (1 / radius) * v38;
666  if (uLightType & 4) { // LIGHT_ATTR_POINT
667  v39 = fabs(a1.x * FacePlaneNormals->Normal.x + a1.z * FacePlaneNormals->Normal.z +
668  a1.y * FacePlaneNormals->Normal.y);
669  v40 = v39 * 1.0 * flt_4D86CC;
670 
671  lightmap->fBrightness = v40 - ((1 / radius) * v38) * v40;
672  } else if (uLightType & 8) { // LIGHT_ATTR_SPOTLIGHT
673  v40 = 1.0 * 1.0;
674  lightmap->fBrightness = v40 - ((1 / radius) * v38);
675  } else {
676  log->Warning(L"Invalid light type!");
677  }
678  }
679  // Brightness(яркость)/////////////////////////////////////////////////////
680 
681  // trim to surface
682  if (!engine->pStru9Instance->_4980B9(
683  a9, uNumVertices, FacePlaneNormals->Normal.x, FacePlaneNormals->Normal.y, FacePlaneNormals->Normal.z,
684  lightmap->pVertices, &lightmap->NumVertices))
685  return false;
686 
687  if (!lightmap->NumVertices)
688  return true;
689 
690  v45 = _45C6D6(uNumVertices, a9, lightmap);
691  if (v45 != uNumVertices && v45 > 0) _45C4B9(uNumVertices, a9, lightmap);
692 
693  pIndoorCameraD3D->ViewTransform(lightmap->pVertices, lightmap->NumVertices);
694  pIndoorCameraD3D->Project(lightmap->pVertices, lightmap->NumVertices, 0);
695 
696  unsigned int _a4 = 0;
697  if (!(uClipFlag & 1)) { // NoClipFlag
698  _a4 = 1;
700  if (uClipFlag & 2) { // NeerClipFlag
702  lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4);
704  &lightmap->NumVertices);
705  } else if (uClipFlag & 4) { // FarClipFlag
707  lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4);
709  &lightmap->NumVertices);
710  } else {
711  log->Warning(L"Undefined clip flag specified");
712  }
713  } else {
714  log->Warning(
715  L"Lightpoly builder native indoor clipping not implemented");
716  }
717 
718  if (_a4) {
719  /*if (uLightType & 1) {*/
721  /*} else {
722  if (MobileLightsCount < 768 - 1) ++MobileLightsCount;
723  }*/
724  // if ( v50 ^ v51 )
725  // *(unsigned int *)v48 = v49 + 1;
726  }
727  return true;
728 }
729 
730 //----- (0045C6D6) --------------------------------------------------------
731 int LightmapBuilder::_45C6D6(int uNumVertices, RenderVertexSoft *a3,
732  Lightmap *pLightmap) {
733  // For outdoor terrain and indoor light (V)(V)
734  signed int v6; // esi@1
735  float temp_x; // st7@6
736  float temp_y; // st6@10
737  float temp_z; // st5@14
738  float v12; // st7@17
739  int v15; // [sp+Ch] [bp-8h]@1
740 
741  v6 = -1;
742  v15 = 0;
743  if ((signed int)pLightmap->NumVertices > 0) {
744  for (uint i = 0; i < (signed int)pLightmap->NumVertices; ++i) {
745  if (uNumVertices > 0) {
746  for (uint j = 0; j < uNumVertices; ++j) {
747  if (pLightmap->pVertices[i].vWorldPosition.x <=
748  (double)a3[j].vWorldPosition.x)
749  temp_x = a3[j].vWorldPosition.x -
750  pLightmap->pVertices[i].vWorldPosition.x;
751  else
752  temp_x = pLightmap->pVertices[i].vWorldPosition.x -
753  a3[j].vWorldPosition.x;
754  if (temp_x < 2.0) {
755  if (pLightmap->pVertices[i].vWorldPosition.y <=
756  (double)a3[j].vWorldPosition.y)
757  temp_y = a3[j].vWorldPosition.y -
758  pLightmap->pVertices[i].vWorldPosition.y;
759  else
760  temp_y = pLightmap->pVertices[i].vWorldPosition.y -
761  a3[j].vWorldPosition.y;
762  if (temp_y < 2.0) {
763  if (pLightmap->pVertices[i].vWorldPosition.z <=
764  (double)a3[j].vWorldPosition.z)
765  temp_z =
766  a3[j].vWorldPosition.z -
767  pLightmap->pVertices[i].vWorldPosition.z;
768  else
769  temp_z =
770  pLightmap->pVertices[i].vWorldPosition.z -
771  a3[j].vWorldPosition.z;
772  if (temp_z < 2.0) {
773  v12 = temp_x + temp_y + temp_z;
774  if (v12 < FLT_MAX) v6 = j;
775  }
776  }
777  }
778  } // For
779  if (v6 != -1) {
780  ++v15;
781  pLightmap->pVertices[i].vWorldPosition.x =
782  a3[v6].vWorldPosition.x;
783  pLightmap->pVertices[i].vWorldPosition.y =
784  a3[v6].vWorldPosition.y;
785  pLightmap->pVertices[i].vWorldPosition.z =
786  a3[v6].vWorldPosition.z;
787  }
788  }
789  v6 = -1;
790  } // For
791  }
792  return v15;
793 }
794 
795 //----- (0045D73F) --------------------------------------------------------
797  // For outdoor and indoor light (II)(VIII)
798  if (type == 2) Draw_183808_Lightmaps();
799 }
800 
801 //----- (0045D74F) --------------------------------------------------------
803  // For outdoor terrain and indoor light (VI)(VI)
804 
805  if (StationaryLightsCount > 0) {
806  if (_4D864C_force_sw_render_rules && engine->config->Flag1_1()) {
807  __debugbreak();
808  return;
809  }
810 
811 
812  render->BeginLightmaps();
813 
814  Vec3_float_ arg4;
815  arg4.x = 1.0f;
816  arg4.y = 1.0f;
817  arg4.z = 1.0f;
818 
819  if (indices != -1) {
820  for (unsigned int i = 0; i < MobileLightsCount; ++i) {
821  if (!render->DrawLightmap(&MobileLights[i], &arg4, 0.0))
822  Error("Invalid lightmap detected! (%u)", i);
823  }
824  } else {
825  for (unsigned int i = 0; i < StationaryLightsCount; ++i)
826  if (!render->DrawLightmap(&StationaryLights[i], &arg4, 0.0))
827  Error("Invalid lightmap detected! (%u)", i);
828  }
829 
830  render->EndLightmaps();
831  }
832 }
833 
834 //----- (0045DCA9) --------------------------------------------------------
836  // For outdoor and indoor light (III)(IX)
837  if (!MobileLightsCount) return;
838 
839  render->BeginLightmaps2();
840 
841  DoDraw_183808_Lightmaps(0.0/*0.00050000002*/);
842 
843  render->EndLightmaps2();
844 }
845 
846 // //////////////////////OTHER////////////////////////////////////////////////////////
847 // ----- (0045CA88) --------------------------------------------------------
849  Vec3_float_ *pNormal) {
850  int result; // eax@1
851  LightsData *v6; // ecx@2
852  RenderVertexSoft *v7; // ebx@2
853  double v8; // st7@2
854  double v9; // st6@2
855  char *v10; // eax@3
856  double v11; // st7@5
857  __int64 v12; // ST2C_8@5
858  float v13; // edx@5
859  int v14; // eax@5
860  float v15; // ST10_4@5
861  Vec3_float_ v16; // ST00_12@5
862  double v17; // st7@5
863  int a5; // [sp+2Ch] [bp-1Ch]@1
864  float v19; // [sp+30h] [bp-18h]@1
865  float v20; // [sp+34h] [bp-14h]@1
866  // LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1
867  int v22; // [sp+3Ch] [bp-Ch]@1
868  int *j; // [sp+40h] [bp-8h]@3
869  int i; // [sp+44h] [bp-4h]@1
870  int a3a; // [sp+58h] [bp+10h]@2
871 
872  __debugbreak(); // Not used?
873 
874  *(float *)&a5 = 0.0;
875  v19 = 0.0;
876  // thisa = this;
877  v20 = 0.0;
878  result = _45CBD4(a3, a4, dword_69B010.data(), &v22);
879  for (i = 0; i < v22; result = i) {
880  v6 = a2;
881  a3a = 0;
882  v7 = &a3[dword_69B010[i]];
883  v8 = v7->vWorldPosition.z;
884  v9 = v7->vWorldPosition.y;
885  *(float *)&a5 = v7->vWorldPosition.x;
886  v19 = v9;
887  v20 = v8;
888  v7->flt_2C = 0.0;
889  if (a2->uNumLightsApplied > 0) {
890  v10 = (char *)a2->_blv_lights_ys;
891  for (j = a2->_blv_lights_ys;; v10 = (char *)j) {
892  v11 = (double)*((signed int *)v10 - 60);
893  HEXRAYS_LODWORD(v12) = *((unsigned int *)v10 - 20);
894  HEXRAYS_HIDWORD(v12) = *(unsigned int *)v10;
895  HEXRAYS_LODWORD(v13) = *((unsigned int *)v10 + 60);
896  v14 = a3a;
897  HEXRAYS_LOBYTE(v14) = v6->_blv_lights_types[a3a];
898  v15 = v11;
899  *(_QWORD *)&v16.x = v12;
900  v16.z = v13;
901  v17 = _45CC0C_light(v16 /*COERCE_VEC3_FLOAT_(v16.x)*/, 1.0, v15,
902  pNormal,
903  *(float *)&a5 /*COERCE_FLOAT(&a5)*/, v14) +
904  v7->flt_2C;
905  ++a3a;
906  ++j;
907  v7->flt_2C = v17;
908  if (a3a >= a2->uNumLightsApplied) break;
909  v6 = a2;
910  }
911  }
912  ++i;
913  }
914  return result;
915 }
916 
917 //----- (0045CB89) --------------------------------------------------------
919  int v3; // edx@1
920  int result; // eax@2
921  char *v5; // ecx@2
922  double v6; // st7@4
923  __int16 v7 = 0; // fps@4
924  char v8; // c0@4
925  char v9; // c2@4
926  char v10; // c3@4
927  double v11; // st7@5
928  double v12; // st7@6
929  __int16 v13 = 0; // fps@6
930  char v14; // c0@6
931  char v15; // c2@6
932  char v16; // c3@6
933 
934  __debugbreak(); // Not used?
935  v3 = a2;
936  if (a2 > 0) {
937  HEXRAYS_HIWORD(result) = HEXRAYS_HIWORD(a1);
938  v5 = (char *)&a1->flt_2C;
939  do {
940  __debugbreak(); // warning C4700: uninitialized local variable 'v7'
941  // used
942  if (*(float *)v5 < 0.0 ||
943  (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0,
944  v10 = 1.0 == v6, HEXRAYS_LOWORD(result) = v7, v6 <= 1.0)) {
945  v12 = *(float *)v5;
946  // UNDEF(v13);
947  v14 = 0.0 < v12;
948  v15 = 0;
949  v16 = 0.0 == v12;
950  __debugbreak(); // warning C4700: uninitialized local variable
951  // 'v13' used
952  HEXRAYS_LOWORD(result) = v13;
953  if (v12 >= 0.0)
954  v11 = *(float *)v5;
955  else
956  v11 = 0.0;
957  } else {
958  v11 = 1.0;
959  }
960  *(float *)v5 = v11;
961  v5 += 48;
962  --v3;
963  } while (v3);
964  }
965  return result;
966 }
967 
968 //----- (0045CBD4) --------------------------------------------------------
969 int LightmapBuilder::_45CBD4(RenderVertexSoft *a2, int a3, int *a4, int *a5) {
970  int result; // eax@1
971  int v6; // edx@1
972  int v7; // ecx@2
973  int v8; // esi@2
974 
975  __debugbreak(); // Not used?
976  result = (int)a5;
977  v6 = 0;
978  for (*a5 = 0; v6 < a3; ++v6) {
979  v7 = *a5;
980  v8 = 0;
981  if (*a5 <= 0) {
982  // LABEL_5:
983  a4[v7] = v6;
984  ++*a5;
985  } else {
986  while (a4[v8] != v6) {
987  ++v8;
988  if (v8 >= v7) {
989  a4[v7] = v6;
990  ++*a5;
991  break;
992  // goto LABEL_5;
993  }
994  }
995  }
996  }
997  return result;
998 }
999 
1000 //----- (0045CC0C) --------------------------------------------------------
1001 double LightmapBuilder::_45CC0C_light(Vec3_float_ a1, float a2, float a3,
1002  Vec3_float_ *pNormal, float a5,
1003  int uLightType) {
1004  float v7; // esi@1
1005  int v8; // eax@1
1006  double v14; // st7@7
1007  double result; // st7@8
1008  double v16; // st7@9
1009  int v17; // esi@9
1010  const char *v18 = nullptr; // ecx@9
1011  double v19; // st7@10
1012  double v20; // st7@10
1013  String v21; // [sp-10h] [bp-40h]@13
1014  const char *v22[6]; // [sp+0h] [bp-30h]@10
1015  double v23; // [sp+18h] [bp-18h]@1
1016  // double v24; // [sp+20h] [bp-10h]@1
1017  int v25; // [sp+28h] [bp-8h]@1
1018  int v26; // [sp+2Ch] [bp-4h]@1
1019 
1020  __debugbreak(); // Not used?
1021  v7 = a5;
1022  HEXRAYS_LODWORD(a5) = *(unsigned int *)(HEXRAYS_LODWORD(a5) + 8);
1023  // v24 = a5 + 6.7553994e15;
1024  v26 = floorf(a5 + 0.5f); // LODWORD(v24);
1025  HEXRAYS_LODWORD(a5) = *(unsigned int *)(HEXRAYS_LODWORD(v7) + 4);
1026  // v24 = a5 + 6.7553994e15;
1027  auto _v24 = floorf(a5 + 0.5f);
1028  HEXRAYS_LODWORD(a5) = *(unsigned int *)HEXRAYS_LODWORD(v7);
1029  // v23 = a5 + 6.7553994e15;
1030  auto _v23 = floorf(a5 + 0.5f);
1031  // *(_QWORD *)((char *)&v24 + 4) = __PAIR__(LODWORD(v24), LODWORD(v23));
1032  v26 = abs((signed)HEXRAYS_LODWORD(a1.z) - v26);
1033  // v25 = abs((signed)LODWORD(a1.y) - (signed)LODWORD(v24));
1034  // v8 = abs((int)a1.x - (signed)LODWORD(v23));
1035  v25 = abs((signed)HEXRAYS_LODWORD(a1.y) - (signed)_v24);
1036  v8 = abs((int)a1.x - (signed)_v23);
1037  v14 = int_get_vector_length(v26, v25, v8);
1038  if (v14 <= a3) {
1039  a5 = v14 / a3;
1040  v16 = (double)(signed int)a1.x;
1041  *(float *)&v23 = (double)HEXRAYS_SLODWORD(a1.y);
1042  HEXRAYS_LODWORD(a1.x) = *(unsigned int *)HEXRAYS_LODWORD(v7);
1043  v17 = HEXRAYS_LODWORD(v7) + 4;
1044  *((float *)&v23 + 1) = (double)HEXRAYS_SLODWORD(a1.z);
1045  HEXRAYS_LODWORD(a1.y) = *(unsigned int *)v17;
1046  HEXRAYS_LODWORD(a1.z) = *(unsigned int *)(v17 + 4);
1047  a3 = *((float *)&v23 + 1) - a1.z;
1048  a1.z = a3;
1049  a1.x = v16 - a1.x;
1050  a1.y = (float)v23 - a1.y;
1051  a1.Normalize();
1052  if (uLightType & 4) {
1053  __debugbreak(); // warning C4700: uninitialized local variable
1054  // 'v18' used
1055  v22[1] = v18;
1056  uLightType = dword_4D86D8;
1057  v22[0] = v18;
1058  v19 =
1059  fabs(a1.z * pNormal->z + a1.y * pNormal->y + a1.x * pNormal->x);
1060  v20 = v19 * *(float *)&uLightType * a2;
1061  } else {
1062  if (uLightType & 8) {
1063  v20 = 1.3 * a2;
1064  } else {
1065  log->Warning(L"Invalid light type detected!");
1066  v20 = *(float *)&uLightType;
1067  }
1068  }
1069  result = v20 - a5 * v20;
1070  } else {
1071  result = 0.0;
1072  }
1073  return result;
1074 }
1075 
1076 //----- (0045D698) --------------------------------------------------------
1078  char bit_one_for_list1__bit_two_for_list2) {
1079  if (bit_one_for_list1__bit_two_for_list2 & 1) {
1080  for (int i = 0; i < this->StationaryLightsCount; ++i)
1082  this->StationaryLights[i].pVertices,
1083  this->StationaryLights[i].NumVertices, 0xFF00, 0.0f);
1084  }
1085  if (bit_one_for_list1__bit_two_for_list2 & 2) {
1086  for (uint i = 0; i < this->MobileLightsCount; ++i)
1088  this->MobileLights[i].pVertices,
1089  this->MobileLights[i].NumVertices, 0xC04000, 0.00019999999f);
1090  }
1091 }
LightsStack_StationaryLight_::uNumLightsActive
unsigned int uNumLightsActive
Definition: Lights.h:65
LightmapBuilder::light_length_z
float light_length_z
Definition: LightmapBuilder.h:88
LightmapBuilder::_45BE86_build_light_polygon
bool _45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, struct stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag)
Definition: LightmapBuilder.cpp:561
Lightmap::position_y
__int16 position_y
Definition: LightmapBuilder.h:20
LightmapBuilder::_45C6D6
int _45C6D6(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap)
Definition: LightmapBuilder.cpp:731
Lightmap::Lightmap
Lightmap()
Definition: LightmapBuilder.cpp:19
stru314::Normal
Vec3_float_ Normal
Definition: stru314.h:26
LightsData::_blv_lights_ys
int _blv_lights_ys[20]
Definition: Indoor.h:43
Vec3_float_
Definition: VectorTypes.h:74
LightmapBuilder::light_length_y2
float light_length_y2
Definition: LightmapBuilder.h:90
Engine_::IocContainer
Definition: IocContainer.h:15
stru314::field_1C
Vec3_float_ field_1C
Definition: stru314.h:28
stru154
Definition: Indoor.h:229
int_get_vector_length
uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z)
Definition: VectorTypes.cpp:8
v
const GLdouble * v
Definition: SDL_opengl.h:2064
Lights
LightsData Lights
Definition: Indoor.cpp:54
flt_4D86CC
float flt_4D86CC
Definition: mm7_data.cpp:209
IndoorLocation::pSectors
struct BLVSector * pSectors
Definition: Indoor.h:634
Lightmap::NumVertices
signed int NumVertices
Definition: LightmapBuilder.h:17
LightsData::uDefaultAmbientLightLevel
unsigned int uDefaultAmbientLightLevel
Definition: Indoor.h:75
LightmapBuilder::ApplyLights_IndoorFace
bool ApplyLights_IndoorFace(unsigned int uFaceID)
Definition: LightmapBuilder.cpp:261
Vec3_float_::x
float x
Definition: VectorTypes.h:89
LightmapBuilder::DoDraw_183808_Lightmaps
bool DoDraw_183808_Lightmaps(float a2)
Definition: LightmapBuilder.cpp:344
StationaryLight::uLightColorR
uint8_t uLightColorR
Definition: Lights.h:13
dword_4D86D8
int dword_4D86D8
Definition: mm7_data.cpp:210
Engine_::IocContainer::ResolveLogger
static Log * ResolveLogger()
Definition: IocContainer.cpp:51
RenderVertexSoft::u
float u
Definition: IRender.h:121
LightmapBuilder::DrawLightmapsType
void DrawLightmapsType(int type)
Definition: LightmapBuilder.cpp:796
LightmapBuilder::ApplyLight_BLV
bool ApplyLight_BLV(struct StationaryLight *pLight, struct BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5)
Definition: LightmapBuilder.cpp:299
LightmapBuilder::log
Log * log
Definition: LightmapBuilder.h:99
BBox_short_::x1
int16_t x1
Definition: VectorTypes.h:114
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
LightmapBuilder::light_length_z2
float light_length_z2
Definition: LightmapBuilder.h:91
stru314::field_10
Vec3_float_ field_10
Definition: stru314.h:27
BBox_short_::y1
int16_t y1
Definition: VectorTypes.h:116
LightmapBuilder.h
Lightmap::uColorMask
unsigned int uColorMask
Definition: LightmapBuilder.h:23
stru9.h
LightsData::_blv_lights_gs
float _blv_lights_gs[20]
Definition: Indoor.h:67
IndoorCameraD3D_Vec4
Definition: IndoorCameraD3D.h:32
LightmapBuilder::light_length_y
float light_length_y
Definition: LightmapBuilder.h:87
IndoorLocation::pLights
struct BLVLightMM7 * pLights
Definition: Indoor.h:636
Lightmap
Definition: LightmapBuilder.h:12
dword_69B010
std::array< int, 64 > dword_69B010
Definition: mm7_data.cpp:689
Vec3_float_::y
float y
Definition: VectorTypes.h:90
Vec3_float_::z
float z
Definition: VectorTypes.h:91
LightmapBuilder::MobileLightsCount
unsigned int MobileLightsCount
Definition: LightmapBuilder.h:85
LightmapBuilder::flt_3C8C28
float flt_3C8C28
Definition: LightmapBuilder.h:93
stru314::dist
float dist
Definition: stru314.h:29
BBox_short_::z2
int16_t z2
Definition: VectorTypes.h:119
pIndoor
IndoorLocation * pIndoor
Definition: Indoor.cpp:49
BLVSector::pLights
uint16_t * pLights
Definition: Indoor.h:556
Engine.h
Lightmap::position_x
__int16 position_x
Definition: LightmapBuilder.h:19
LightmapBuilder::DrawDebugOutlines
void DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2)
Definition: LightmapBuilder.cpp:1077
Lights.h
LightmapBuilder::DrawLightmaps
void DrawLightmaps(int indices)
Definition: LightmapBuilder.cpp:802
Vec3_float_::Normalize
void Normalize()
Definition: VectorTypes.cpp:22
Plane_float_::vNormal
struct Vec3_float_ vNormal
Definition: VectorTypes.h:136
Plane_int_::vNormal
Vec3_int_ vNormal
Definition: VectorTypes.h:107
LightsData::_blv_lights_zs
int _blv_lights_zs[20]
Definition: Indoor.h:65
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
StationaryLight::uLightType
char uLightType
Definition: Lights.h:16
ODMFace::pBoundingBox
struct BBox_short_ pBoundingBox
Definition: BSPModel.h:145
LightsData::_blv_lights_radii
int _blv_lights_radii[20]
Definition: Indoor.h:40
_4E94D0_light_type
char _4E94D0_light_type
Definition: mm7_data.cpp:305
StationaryLight
Definition: Lights.h:10
Plane_float_::dist
float dist
Definition: VectorTypes.h:137
Lightmap::position_z
__int16 position_z
Definition: LightmapBuilder.h:21
IndoorCameraD3D::LightmapNeerClip
void LightmapNeerClip(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:958
LightsData::uCurrentAmbientLightLevel
unsigned int uCurrentAmbientLightLevel
Definition: Indoor.h:21
BLVSector::uNumLights
uint16_t uNumLights
Definition: Indoor.h:554
IndoorCameraD3D::debug_outline_sw
void debug_outline_sw(struct RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5)
Definition: IndoorCameraD3D.cpp:402
BBox_short_::y2
int16_t y2
Definition: VectorTypes.h:117
BLVFace::uSectorID
uint16_t uSectorID
Definition: Indoor.h:484
BLVLightMM7::uAtributes
int16_t uAtributes
Definition: Indoor.h:364
LightmapBuilder::flt_3C8C2C_lightmaps_brightness
float flt_3C8C2C_lightmaps_brightness
Definition: LightmapBuilder.h:94
BLVFace
Definition: Indoor.h:424
LightmapBuilder::StationaryLights
Lightmap StationaryLights[512]
Definition: LightmapBuilder.h:82
Vec3_float_::NegDot
static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3)
Definition: VectorTypes.h:85
BLVFace::pFacePlane
struct Plane_float_ pFacePlane
Definition: Indoor.h:470
Log::Warning
void Warning(const wchar_t *pFormat,...)
Definition: Log.cpp:28
IndoorCameraD3D::Project
void Project(int x, int y, int z, int *screenspace_x, int *screenspace_y)
Definition: IndoorCameraD3D.cpp:1137
LightmapBuilder::_45CA88
int _45CA88(struct LightsData *a2, struct RenderVertexSoft *a3, int a4, struct Vec3_float_ *pNormal)
Definition: LightmapBuilder.cpp:848
LightsStack_MobileLight_::pLights
MobileLight pLights[400]
Definition: Lights.h:87
LightmapBuilder::light_length_x
float light_length_x
Definition: LightmapBuilder.h:86
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
type
EGLenum type
Definition: SDL_egl.h:850
Lightmap::field_C18
int field_C18
Definition: LightmapBuilder.h:25
ODMFace::uShadeType
uint8_t uShadeType
Definition: BSPModel.h:157
LightsData::_blv_lights_light_dot_faces
int _blv_lights_light_dot_faces[20]
Definition: Indoor.h:44
LEVEL_Outdoor
@ LEVEL_Outdoor
Definition: Indoor.h:287
IndoorCameraD3D::_437143
void _437143(unsigned int uNumInVertices, struct RenderVertexSoft *pOutVertices, struct RenderVertexSoft *pInVertices, signed int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:823
LightmapBuilder::light_radius
float light_radius
Definition: LightmapBuilder.h:95
_4E94D2_light_type
char _4E94D2_light_type
Definition: mm7_data.cpp:306
Lightmap::fBrightness
float fBrightness
Definition: LightmapBuilder.h:24
IndoorCameraD3D::GetPolygonMinZ
double GetPolygonMinZ(struct RenderVertexSoft *pVertices, unsigned int uStripType)
Definition: IndoorCameraD3D.cpp:1156
LightmapBuilder::LightmapBuilder
LightmapBuilder()
Definition: LightmapBuilder.cpp:29
RenderVertexSoft::flt_2C
float flt_2C
Definition: IRender.h:123
BLVFace::pBounding
struct BBox_short_ pBounding
Definition: Indoor.h:486
stru154::face_plane
Plane_float_ face_plane
Definition: Indoor.h:243
OutdoorLocation::max_terrain_dimming_level
int max_terrain_dimming_level
Definition: Outdoor.h:140
LightmapBuilder::light_length_x2
float light_length_x2
Definition: LightmapBuilder.h:89
Engine_DeinitializeAndTerminate
void Engine_DeinitializeAndTerminate(int exitCode)
Definition: Engine.cpp:157
Outdoor.h
id
GLuint id
Definition: SDL_opengl_glext.h:531
Lightmap::pVertices
RenderVertexSoft pVertices[64]
Definition: LightmapBuilder.h:18
Plane_int_::dist
int dist
Definition: VectorTypes.h:108
IndoorCameraD3D::GetFacetOrientation
bool GetFacetOrientation(char polyType, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4)
Definition: IndoorCameraD3D.cpp:237
LightmapBuilder::tex_light_radius
float tex_light_radius
Definition: LightmapBuilder.h:92
LightmapBuilder::_45CC0C_light
double _45CC0C_light(struct Vec3_float_ a1, float a2, float a3, struct Vec3_float_ *pNormal, float a5, int uLightType)
Definition: LightmapBuilder.cpp:1001
_4D864C_force_sw_render_rules
char _4D864C_force_sw_render_rules
Definition: mm7_data.cpp:208
LightsStack_MobileLight_::uNumLightsActive
unsigned int uNumLightsActive
Definition: Lights.h:88
StationaryLight::vPosition
Vec3_short_ vPosition
Definition: Lights.h:11
StationaryLight::uLightColorG
uint8_t uLightColorG
Definition: Lights.h:14
LightmapBuilder::ApplyLight_ODM
bool ApplyLight_ODM(struct StationaryLight *pLight, struct ODMFace *pFace, unsigned int *pSlot, bool bLightBackfaces)
Definition: LightmapBuilder.cpp:192
LightsData
Definition: Indoor.h:16
LightmapBuilder::_45CBD4
int _45CBD4(struct RenderVertexSoft *a2, int a3, int *a4, int *a5)
Definition: LightmapBuilder.cpp:969
LightsStack_StationaryLight_::pLights
StationaryLight pLights[400]
Definition: Lights.h:64
LightsStack_StationaryLight_
Definition: Lights.h:46
LightsData::_blv_lights_xs
int _blv_lights_xs[20]
Definition: Indoor.h:42
RenderVertexSoft::v
float v
Definition: IRender.h:122
IndoorCameraD3D::_437376
char _437376(struct stru154 *thisa, struct RenderVertexSoft *a2, unsigned int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:629
uint
unsigned int uint
Definition: MM7.h:4
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
pStationaryLightsStack
LightsStack_StationaryLight_ * pStationaryLightsStack
Definition: LightmapBuilder.cpp:11
__debugbreak
void __cdecl __debugbreak(void)
RenderVertexSoft::vWorldPosition
Vec3_float_ vWorldPosition
Definition: IRender.h:116
ODMFace
Definition: BSPModel.h:93
LightmapBuilder::ApplyLights_OutdoorFace
bool ApplyLights_OutdoorFace(struct ODMFace *pFace)
Definition: LightmapBuilder.cpp:48
stru154::polygonType
PolygonType polygonType
Definition: Indoor.h:244
BLVLightMM7
Definition: Indoor.h:357
ODMFace::pFacePlane
struct Plane_int_ pFacePlane
Definition: BSPModel.h:131
LightmapBuilder::_45C4B9
int _45C4B9(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap)
Definition: LightmapBuilder.cpp:359
LightmapBuilder::MobileLights
Lightmap MobileLights[768]
Definition: LightmapBuilder.h:84
stru314
Definition: stru314.h:5
LightsData::uNumLightsApplied
unsigned int uNumLightsApplied
Definition: Indoor.h:39
LightsStack_MobileLight_
Definition: Lights.h:73
uCurrentlyLoadedLevelType
LEVEL_TYPE uCurrentlyLoadedLevelType
Definition: Indoor.cpp:52
StationaryLight::uRadius
int16_t uRadius
Definition: Lights.h:12
LightmapBuilder::ApplyLights
bool ApplyLights(struct LightsData *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char uClipFlag)
Definition: LightmapBuilder.cpp:494
IndoorLocation::pFaces
struct BLVFace * pFaces
Definition: Indoor.h:630
LightmapBuilder::Draw_183808_Lightmaps
void Draw_183808_Lightmaps()
Definition: LightmapBuilder.cpp:835
IndoorCameraD3D::ViewTransform
void ViewTransform(int x, int y, int z, int *transformed_x, int *transformed_y, int *transformed_z)
Definition: IndoorCameraD3D.cpp:184
BBox_short_::x2
int16_t x2
Definition: VectorTypes.h:115
LightsData::_blv_lights_rs
float _blv_lights_rs[20]
Definition: Indoor.h:66
LightsData::_blv_lights_bs
float _blv_lights_bs[20]
Definition: Indoor.h:68
BLVSector
Definition: Indoor.h:522
RenderVertexSoft
Definition: IRender.h:113
pMobileLightsStack
LightsStack_MobileLight_ * pMobileLightsStack
Definition: LightmapBuilder.cpp:14
LightmapBuilder::_45CB89
int _45CB89(struct RenderVertexSoft *a1, int a2)
Definition: LightmapBuilder.cpp:918
LightsData::_blv_lights_inv_radii
int _blv_lights_inv_radii[20]
Definition: Indoor.h:41
StationaryLight::uLightColorB
uint8_t uLightColorB
Definition: Lights.h:15
indices
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: SDL_opengl.h:1571
LightmapBuilder::StationaryLightsCount
unsigned int StationaryLightsCount
Definition: LightmapBuilder.h:83
pOutdoor
OutdoorLocation * pOutdoor
Definition: Outdoor.cpp:48
LightmapBuilder::StackLights_TerrainFace
bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces)
Definition: LightmapBuilder.cpp:465
BBox_short_::z1
int16_t z1
Definition: VectorTypes.h:118
stru314.h
pIndoorCameraD3D
IndoorCameraD3D * pIndoorCameraD3D
Definition: IndoorCameraD3D.cpp:21
IndoorCameraD3D::LightmapFarClip
void LightmapFarClip(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
Definition: IndoorCameraD3D.cpp:848
LightsData::_blv_lights_types
char _blv_lights_types[20]
Definition: Indoor.h:69
String
std::string String
Definition: Strings.h:10
LightmapBuilder::field_3C8C34
RenderVertexSoft field_3C8C34[256]
Definition: LightmapBuilder.h:96
BLVSector::uMinAmbientLightLevel
int16_t uMinAmbientLightLevel
Definition: Indoor.h:560
IndoorCameraD3D::GetPolygonMaxZ
double GetPolygonMaxZ(struct RenderVertexSoft *pVertex, unsigned int uStripType)
Definition: IndoorCameraD3D.cpp:1168
LightmapBuilder::StackLight_TerrainFace
bool StackLight_TerrainFace(struct StationaryLight *pLight, struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot)
Definition: LightmapBuilder.cpp:74
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52