34 for (
int i = 0; i < 512; ++i)
38 for (
int i = 0; i < 768; ++i)
42 for (
int i = 0; i < 256; i++)
58 if (pSlot >= 20)
break;
60 (
unsigned int *)&pSlot,
false);
63 if (pSlot >= 20)
break;
65 (
unsigned int *)&pSlot,
false);
76 float *light_tile_dist,
78 unsigned int uStripType,
int X,
79 unsigned int *pSlot) {
102 if (pLight->
uRadius <= 0)
return false;
103 if (uStripType == 4) {
109 }
else if (uStripType == 3) {
111 if ((
unsigned char)X) {
131 float bounding_x1 = tX_0 - (float)pLight->
uRadius;
133 float bounding_y1 = tY_0 - (
float)pLight->
uRadius;
134 float bounding_z1 = minz - (float)pLight->
uRadius;
138 float bounding_y2 = (float)pLight->
uRadius + tY_1;
139 float bounding_z2 = (
float)pLight->
uRadius + maxz;
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)
152 float p_dot = ((float)pLight->
vPosition.x * pNormal->
x +
154 (float)pLight->
vPosition.z * pNormal->
z + *light_tile_dist) +
156 if (p_dot > pLight->
uRadius)
return false;
177 if (
render->config->is_using_specular) {
194 bool bLightBackfaces) {
200 if (!pLight->
uRadius)
return false;
214 if (((bLightBackfaces) || v10 >= 0.0
f) &&
215 fabsf(v10) <= pLight->
uRadius) {
228 abs((
int)floorf(v10 + 0.5
f));
235 if (
render->config->is_using_specular) {
270 uint uNumLightsApplied = 0;
272 if (uNumLightsApplied >= 20)
break;
275 pFace, &uNumLightsApplied,
true, 0);
279 if (uNumLightsApplied >= 20)
break;
288 if (uNumLightsApplied >= 20)
break;
300 unsigned int *pSlot,
bool bLightBackfaces,
320 if ((bLightBackfaces || Distance >= 0.0
f) && fabsf(Distance) <= pLight->
uRadius) {
321 unsigned int slot = *pSlot;
332 abs((
int)floorf(Distance + 0.5
f));
353 Error(
"Invalid lightmap detected! (%u)", i);
382 for (
uint j = 0; j < a2; ++j) {
383 v12 = &a3[(j + 1) % a2];
466 float *Light_tile_dist,
468 unsigned int uStripType,
469 bool bLightBackfaces) {
471 unsigned int num_lights = 0;
475 if (num_lights >= 20)
break;
478 Light_tile_dist, VertList, uStripType, bLightBackfaces, &num_lights);
482 if (num_lights >= 20)
break;
484 Light_tile_dist, VertList, uStripType, bLightBackfaces,
504 if (!uNumVertices)
return false;
510 for (
uint i = 0; i < uNumVertices; ++i)
511 memcpy(&static_69B140[i], FaceVertexList + i,
515 if (!uNumVertices)
return false;
528 log->
Warning(L
"Error: Failed to get the facet orientation");
543 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB;
554 log->
Warning(L
"Error: Failed to build light polygon");
573 if (radius < 0.0
f)
return true;
580 flt_3C8C28 = sqrt(radius * radius - dot_dist * dot_dist);
633 for (
uint i = 0; i < 4; ++i) {
647 if (!
engine->config->AllowDynamicBrigtness()) {
660 auto dist_x = abs(pos->x - temp1),
661 dist_y = abs(pos->y - temp2),
662 dist_z = abs(pos->z - temp3);
664 if (v38 > radius)
return true;
666 if (uLightType & 4) {
667 v39 = fabs(a1.
x * FacePlaneNormals->
Normal.
x + a1.
z * FacePlaneNormals->
Normal.
z +
671 lightmap->
fBrightness = v40 - ((1 / radius) * v38) * v40;
672 }
else if (uLightType & 8) {
674 lightmap->
fBrightness = v40 - ((1 / radius) * v38);
682 if (!
engine->pStru9Instance->_4980B9(
683 a9, uNumVertices, FacePlaneNormals->
Normal.
x, FacePlaneNormals->
Normal.
y, FacePlaneNormals->
Normal.
z,
690 v45 =
_45C6D6(uNumVertices, a9, lightmap);
691 if (v45 != uNumVertices && v45 > 0)
_45C4B9(uNumVertices, a9, lightmap);
696 unsigned int _a4 = 0;
697 if (!(uClipFlag & 1)) {
705 }
else if (uClipFlag & 4) {
711 log->
Warning(L
"Undefined clip flag specified");
715 L
"Lightpoly builder native indoor clipping not implemented");
745 if (uNumVertices > 0) {
746 for (
uint j = 0; j < uNumVertices; ++j) {
749 temp_x = a3[j].vWorldPosition.x -
757 temp_y = a3[j].vWorldPosition.y -
766 a3[j].vWorldPosition.z -
773 v12 = temp_x + temp_y + temp_z;
774 if (v12 < FLT_MAX) v6 = j;
822 Error(
"Invalid lightmap detected! (%u)", i);
827 Error(
"Invalid lightmap detected! (%u)", i);
839 render->BeginLightmaps2();
879 for (i = 0; i < v22;
result = i) {
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);
899 *(_QWORD *)&v16.
x = v12;
903 *(
float *)&a5 , v14) +
937 HEXRAYS_HIWORD(
result) = HEXRAYS_HIWORD(a1);
942 if (*(
float *)v5 < 0.0 ||
943 (v6 = *(
float *)v5, v8 = 1.0 < v6, v9 = 0,
944 v10 = 1.0 == v6, HEXRAYS_LOWORD(
result) = v7, v6 <= 1.0)) {
952 HEXRAYS_LOWORD(
result) = v13;
978 for (*a5 = 0; v6 < a3; ++v6) {
986 while (a4[v8] != v6) {
1010 const char *v18 =
nullptr;
1022 HEXRAYS_LODWORD(a5) = *(
unsigned int *)(HEXRAYS_LODWORD(a5) + 8);
1024 v26 = floorf(a5 + 0.5
f);
1025 HEXRAYS_LODWORD(a5) = *(
unsigned int *)(HEXRAYS_LODWORD(v7) + 4);
1027 auto _v24 = floorf(a5 + 0.5
f);
1028 HEXRAYS_LODWORD(a5) = *(
unsigned int *)HEXRAYS_LODWORD(v7);
1030 auto _v23 = floorf(a5 + 0.5
f);
1032 v26 = abs((
signed)HEXRAYS_LODWORD(a1.
z) - v26);
1035 v25 = abs((
signed)HEXRAYS_LODWORD(a1.
y) - (
signed)_v24);
1036 v8 = abs((
int)a1.
x - (
signed)_v23);
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;
1050 a1.
y = (float)v23 - a1.
y;
1052 if (uLightType & 4) {
1059 fabs(a1.
z * pNormal->
z + a1.
y * pNormal->
y + a1.
x * pNormal->
x);
1060 v20 = v19 * *(
float *)&uLightType * a2;
1062 if (uLightType & 8) {
1065 log->
Warning(L
"Invalid light type detected!");
1066 v20 = *(
float *)&uLightType;
1078 char bit_one_for_list1__bit_two_for_list2) {
1079 if (bit_one_for_list1__bit_two_for_list2 & 1) {
1082 this->StationaryLights[i].pVertices,
1083 this->StationaryLights[i].NumVertices, 0xFF00, 0.0f);
1085 if (bit_one_for_list1__bit_two_for_list2 & 2) {
1088 this->MobileLights[i].pVertices,
1089 this->MobileLights[i].NumVertices, 0xC04000, 0.00019999999f);