annotate LightmapBuilder.cpp @ 2480:24fd08aef81e

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