annotate Engine/Graphics/LightmapBuilder.cpp @ 2542:bacf9809126a

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