annotate LightmapBuilder.cpp @ 1400:9b091098c88c

m
author Ritor1
date Fri, 19 Jul 2013 12:50:29 +0600
parents 613c77e51e38
children cc9a3a24d61d
rev   line source
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1 #include <assert.h>
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
2
0
Ritor1
parents:
diff changeset
3 #include "LightmapBuilder.h"
Ritor1
parents:
diff changeset
4 #include "Game.h"
Ritor1
parents:
diff changeset
5 #include "stru314.h"
Ritor1
parents:
diff changeset
6 #include "Outdoor.h"
1277
1803172dffd9 header stuff
Grumpy7
parents: 1262
diff changeset
7 #include "Outdoor_stuff.h"
0
Ritor1
parents:
diff changeset
8 #include "Log.h"
Ritor1
parents:
diff changeset
9
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 687
diff changeset
10 #include "OutdoorCamera.h"
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1205
diff changeset
11 #include "Lights.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 687
diff changeset
12
0
Ritor1
parents:
diff changeset
13 #include "mm7_data.h"
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 687
diff changeset
17 #include "stru9.h"
0
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21
Ritor1
parents:
diff changeset
22 LightsStack_StationaryLight_ *pStationaryLightsStack = new LightsStack_StationaryLight_;
Ritor1
parents:
diff changeset
23 //StationaryLight pStationaryLights[400];
Ritor1
parents:
diff changeset
24 //int uNumStationaryLightsApplied; // weak
Ritor1
parents:
diff changeset
25 LightsStack_MobileLight_ *pMobileLightsStack = new LightsStack_MobileLight_;
Ritor1
parents:
diff changeset
26 //MobileLight pMobileLights[400];
Ritor1
parents:
diff changeset
27 //int uNumMobileLightsApplied;
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30
Ritor1
parents:
diff changeset
31
Ritor1
parents:
diff changeset
32
Ritor1
parents:
diff changeset
33 //----- (0045DF13) --------------------------------------------------------
Ritor1
parents:
diff changeset
34 Lightmap::Lightmap()
Ritor1
parents:
diff changeset
35 {
Ritor1
parents:
diff changeset
36 field_C18 = 0;
Ritor1
parents:
diff changeset
37 }
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39
Ritor1
parents:
diff changeset
40
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42
Ritor1
parents:
diff changeset
43 //----- (0045BB06) --------------------------------------------------------
Ritor1
parents:
diff changeset
44 LightmapBuilder::LightmapBuilder()
Ritor1
parents:
diff changeset
45 {
Ritor1
parents:
diff changeset
46 }
Ritor1
parents:
diff changeset
47
Ritor1
parents:
diff changeset
48
Ritor1
parents:
diff changeset
49
Ritor1
parents:
diff changeset
50
Ritor1
parents:
diff changeset
51
Ritor1
parents:
diff changeset
52 //----- (0045BC07) --------------------------------------------------------
Ritor1
parents:
diff changeset
53 bool LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char uClipFlag)
Ritor1
parents:
diff changeset
54 {
Ritor1
parents:
diff changeset
55 Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21
Ritor1
parents:
diff changeset
56 RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8
Ritor1
parents:
diff changeset
57
Ritor1
parents:
diff changeset
58 if (!uNumVertices)
Ritor1
parents:
diff changeset
59 return false;
Ritor1
parents:
diff changeset
60
Ritor1
parents:
diff changeset
61 static RenderVertexSoft static_69B140[64];
Ritor1
parents:
diff changeset
62
Ritor1
parents:
diff changeset
63 a9 = a5;
Ritor1
parents:
diff changeset
64 if (a6)
Ritor1
parents:
diff changeset
65 {
Ritor1
parents:
diff changeset
66 for (uint i = 0; i < uNumVertices; ++i)
Ritor1
parents:
diff changeset
67 memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft));
Ritor1
parents:
diff changeset
68
687
687b4365ee84 Indoor Portal
Ritor1
parents: 638
diff changeset
69 //__debugbreak();
0
Ritor1
parents:
diff changeset
70 if (pGame->pIndoorCameraD3D->_437376(
Ritor1
parents:
diff changeset
71 a3,
Ritor1
parents:
diff changeset
72 static_69B140,
Ritor1
parents:
diff changeset
73 &uNumVertices) == 1)
Ritor1
parents:
diff changeset
74 {
Ritor1
parents:
diff changeset
75 if ( !uNumVertices )
Ritor1
parents:
diff changeset
76 return false;
Ritor1
parents:
diff changeset
77 a9 = static_69B140;
Ritor1
parents:
diff changeset
78 }
Ritor1
parents:
diff changeset
79 }
Ritor1
parents:
diff changeset
80
Ritor1
parents:
diff changeset
81 static stru314 static_69B110;
Ritor1
parents:
diff changeset
82 static_69B110.field_4.x = a3->face_plane.vNormal.x;
Ritor1
parents:
diff changeset
83 static_69B110.field_4.y = a3->face_plane.vNormal.y;
Ritor1
parents:
diff changeset
84 static_69B110.field_4.z = a3->face_plane.vNormal.z;
Ritor1
parents:
diff changeset
85 static_69B110.dist = a3->face_plane.dist;
Ritor1
parents:
diff changeset
86 if (!pGame->pIndoorCameraD3D->GetFacetOrientation(
Ritor1
parents:
diff changeset
87 a3->polygonType,
Ritor1
parents:
diff changeset
88 &static_69B110.field_4,
Ritor1
parents:
diff changeset
89 &static_69B110.field_10,
Ritor1
parents:
diff changeset
90 &static_69B110.field_1C))
Ritor1
parents:
diff changeset
91 {
Ritor1
parents:
diff changeset
92 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
93 ExitProcess(0);
Ritor1
parents:
diff changeset
94 }
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 for (uint i = 0; i < a2->uNumLightsApplied; ++i)
Ritor1
parents:
diff changeset
97 {
Ritor1
parents:
diff changeset
98 pos.x = a2->_blv_lights_xs[i];
Ritor1
parents:
diff changeset
99 pos.y = a2->_blv_lights_ys[i];
Ritor1
parents:
diff changeset
100 pos.z = a2->_blv_lights_zs[i];
Ritor1
parents:
diff changeset
101
Ritor1
parents:
diff changeset
102 uint uColorR = (uint)floorf(a2->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF,
Ritor1
parents:
diff changeset
103 uColorG = (uint)floorf(a2->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF,
Ritor1
parents:
diff changeset
104 uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF;
Ritor1
parents:
diff changeset
105 uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB;
Ritor1
parents:
diff changeset
106 if (!uColor)
Ritor1
parents:
diff changeset
107 uColor = 0x00FFFFF;
Ritor1
parents:
diff changeset
108
Ritor1
parents:
diff changeset
109 if (!_45BE86_build_light_polygon(
Ritor1
parents:
diff changeset
110 &pos,
Ritor1
parents:
diff changeset
111 a2->_blv_lights_radii[i],
Ritor1
parents:
diff changeset
112 uColor,
Ritor1
parents:
diff changeset
113 a2->_blv_lights_light_dot_faces[i],
Ritor1
parents:
diff changeset
114 a2->_blv_lights_types[i],
Ritor1
parents:
diff changeset
115 &static_69B110,
Ritor1
parents:
diff changeset
116 uNumVertices,
Ritor1
parents:
diff changeset
117 a9,
Ritor1
parents:
diff changeset
118 uClipFlag) )
Ritor1
parents:
diff changeset
119 {
Ritor1
parents:
diff changeset
120 MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
Ritor1
parents:
diff changeset
121 }
Ritor1
parents:
diff changeset
122 }
Ritor1
parents:
diff changeset
123 return true;
Ritor1
parents:
diff changeset
124 }
Ritor1
parents:
diff changeset
125
Ritor1
parents:
diff changeset
126 //----- (0045BE86) --------------------------------------------------------
Ritor1
parents:
diff changeset
127 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
128 {
Ritor1
parents:
diff changeset
129 Lightmap *v11; // edi@3
Ritor1
parents:
diff changeset
130 double v17; // st7@5
Ritor1
parents:
diff changeset
131 double v24; // st7@6
Ritor1
parents:
diff changeset
132 int v31; // eax@8
Ritor1
parents:
diff changeset
133 int v32; // ebx@8
Ritor1
parents:
diff changeset
134 unsigned int v33; // ecx@8
Ritor1
parents:
diff changeset
135 int v34; // edx@9
Ritor1
parents:
diff changeset
136 int v35; // edx@11
Ritor1
parents:
diff changeset
137 unsigned int v36; // edx@13
Ritor1
parents:
diff changeset
138 int v37; // ecx@14
Ritor1
parents:
diff changeset
139 double v38; // st7@14
Ritor1
parents:
diff changeset
140 double v39; // st7@16
Ritor1
parents:
diff changeset
141 double v40; // st7@16
Ritor1
parents:
diff changeset
142 int v45; // eax@24
Ritor1
parents:
diff changeset
143 int v53; // [sp-8h] [bp-54h]@34
Ritor1
parents:
diff changeset
144
Ritor1
parents:
diff changeset
145 if (fabsf(radius) < 1e-6f)
Ritor1
parents:
diff changeset
146 return true;
Ritor1
parents:
diff changeset
147
Ritor1
parents:
diff changeset
148 v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] :
Ritor1
parents:
diff changeset
149 &std__vector_183808[std__vector_183808_size];
Ritor1
parents:
diff changeset
150 flt_3C8C24 = radius - dot_dist;
Ritor1
parents:
diff changeset
151 flt_3C8C28 = sqrt((radius + dot_dist) * (radius - dot_dist));
Ritor1
parents:
diff changeset
152 flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius;
Ritor1
parents:
diff changeset
153 v11->field_C08 = (double)pos->x - dot_dist * a7->field_4.x;
Ritor1
parents:
diff changeset
154 v11->field_C0A = (double)pos->y - dot_dist * a7->field_4.y;
Ritor1
parents:
diff changeset
155 v11->field_C0C = (double)pos->z - dot_dist * a7->field_4.z;
Ritor1
parents:
diff changeset
156
Ritor1
parents:
diff changeset
157 v17 = radius * flt_3C8C2C_lightmaps_brightness;
Ritor1
parents:
diff changeset
158 flt_3C8C30 = v17;
Ritor1
parents:
diff changeset
159 flt_3C8C0C = v17 * a7->field_10.x;
Ritor1
parents:
diff changeset
160 flt_3C8C10 = v17 * a7->field_10.y;
Ritor1
parents:
diff changeset
161 flt_3C8C14 = v17 * a7->field_10.z;
Ritor1
parents:
diff changeset
162 flt_3C8C18 = v17 * a7->field_1C.x;
Ritor1
parents:
diff changeset
163 flt_3C8C1C = v17 * a7->field_1C.y;
Ritor1
parents:
diff changeset
164 flt_3C8C20 = v17 * a7->field_1C.z;
Ritor1
parents:
diff changeset
165
Ritor1
parents:
diff changeset
166 /*
Ritor1
parents:
diff changeset
167 v11->pVertices[0].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C;
Ritor1
parents:
diff changeset
168 v11->pVertices[0].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10;
Ritor1
parents:
diff changeset
169 v11->pVertices[0].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14;
Ritor1
parents:
diff changeset
170 v11->pVertices[0].u = 0.0;
Ritor1
parents:
diff changeset
171 v11->pVertices[0].v = 0.0;
Ritor1
parents:
diff changeset
172
Ritor1
parents:
diff changeset
173 v11->pVertices[1].vWorldPosition.x = v11->field_C08 - flt_3C8C18 - flt_3C8C0C;
Ritor1
parents:
diff changeset
174 v11->pVertices[1].vWorldPosition.y = v11->field_C0A - flt_3C8C1C - flt_3C8C10;
Ritor1
parents:
diff changeset
175 v11->pVertices[1].vWorldPosition.z = v11->field_C0C - flt_3C8C20 - flt_3C8C14;
Ritor1
parents:
diff changeset
176 v11->pVertices[1].u = 0.0;
Ritor1
parents:
diff changeset
177 v11->pVertices[1].v = 1.0;
Ritor1
parents:
diff changeset
178
Ritor1
parents:
diff changeset
179 v11->pVertices[2].vWorldPosition.x = v11->field_C08 + flt_3C8C18 - flt_3C8C0C;
Ritor1
parents:
diff changeset
180 v11->pVertices[2].vWorldPosition.y = v11->field_C0A + flt_3C8C1C - flt_3C8C10;
Ritor1
parents:
diff changeset
181 v11->pVertices[2].vWorldPosition.z = v11->field_C0C + flt_3C8C20 - flt_3C8C14;
Ritor1
parents:
diff changeset
182 v11->pVertices[2].u = 1.0;
Ritor1
parents:
diff changeset
183 v11->pVertices[2].v = 1.0;
Ritor1
parents:
diff changeset
184
Ritor1
parents:
diff changeset
185 v11->pVertices[3].vWorldPosition.x = v11->field_C08 + flt_3C8C18 + flt_3C8C0C;
Ritor1
parents:
diff changeset
186 v11->pVertices[3].vWorldPosition.y = v11->field_C0A + flt_3C8C1C + flt_3C8C10;
Ritor1
parents:
diff changeset
187 v11->pVertices[3].vWorldPosition.z = v11->field_C0C + flt_3C8C20 + flt_3C8C14;
Ritor1
parents:
diff changeset
188 v11->pVertices[3].u = 1.0;
Ritor1
parents:
diff changeset
189 v11->pVertices[3].v = 0.0;
Ritor1
parents:
diff changeset
190 */
Ritor1
parents:
diff changeset
191
Ritor1
parents:
diff changeset
192 for (uint i = 0; i < 4; ++i)
Ritor1
parents:
diff changeset
193 {
Ritor1
parents:
diff changeset
194 v11->pVertices[i].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C;
Ritor1
parents:
diff changeset
195 v11->pVertices[i].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10;
Ritor1
parents:
diff changeset
196 v11->pVertices[i].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14;
Ritor1
parents:
diff changeset
197 v11->pVertices[i].u = 0.0;
Ritor1
parents:
diff changeset
198 v11->pVertices[i].v = 0.0;
Ritor1
parents:
diff changeset
199
Ritor1
parents:
diff changeset
200 v24 = a7->field_4.y * v11->pVertices[i].vWorldPosition.y
Ritor1
parents:
diff changeset
201 + a7->field_4.z * v11->pVertices[i].vWorldPosition.z
Ritor1
parents:
diff changeset
202 + a7->field_4.x * v11->pVertices[i].vWorldPosition.x
Ritor1
parents:
diff changeset
203 + a7->dist;
Ritor1
parents:
diff changeset
204
Ritor1
parents:
diff changeset
205 v11->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x;
Ritor1
parents:
diff changeset
206 v11->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y;
Ritor1
parents:
diff changeset
207 v11->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z;
Ritor1
parents:
diff changeset
208 }
Ritor1
parents:
diff changeset
209
Ritor1
parents:
diff changeset
210 v11->uColorMask = uColorMask;
Ritor1
parents:
diff changeset
211 v11->uNumVertices = 4;
Ritor1
parents:
diff changeset
212
Ritor1
parents:
diff changeset
213 if (~pGame->uFlags2 & 4)
Ritor1
parents:
diff changeset
214 v11->fBrightness = flt_3C8C2C_lightmaps_brightness;
Ritor1
parents:
diff changeset
215 else
Ritor1
parents:
diff changeset
216 {
Ritor1
parents:
diff changeset
217 Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
Ritor1
parents:
diff changeset
218 a1.x = (double)pos->x - v11->field_C08;
Ritor1
parents:
diff changeset
219 a1.y = (double)pos->y - v11->field_C0A;
Ritor1
parents:
diff changeset
220 a1.z = (double)pos->z - v11->field_C0C;
Ritor1
parents:
diff changeset
221 a1.Normalize();
Ritor1
parents:
diff changeset
222
Ritor1
parents:
diff changeset
223 auto dist_x = abs(pos->x - v11->field_C08), //v31
Ritor1
parents:
diff changeset
224 dist_y = abs(pos->y - v11->field_C0A), //v32 arg0a
Ritor1
parents:
diff changeset
225 dist_z = abs(pos->z - v11->field_C0C); //v33 _v64
Ritor1
parents:
diff changeset
226 v31 = dist_x;
Ritor1
parents:
diff changeset
227 v32 = dist_y;
Ritor1
parents:
diff changeset
228 v33 = dist_z;
Ritor1
parents:
diff changeset
229 if (v31 < dist_y)
Ritor1
parents:
diff changeset
230 {
Ritor1
parents:
diff changeset
231 v34 = v31;
Ritor1
parents:
diff changeset
232 v31 = dist_y;
Ritor1
parents:
diff changeset
233 v32 = v34;
Ritor1
parents:
diff changeset
234 }
Ritor1
parents:
diff changeset
235 if (v31 < dist_z)//SHIDWORD(v64) )
Ritor1
parents:
diff changeset
236 {
Ritor1
parents:
diff changeset
237 v35 = v31;
Ritor1
parents:
diff changeset
238 v31 = dist_z;//HIDWORD(v64);
Ritor1
parents:
diff changeset
239 v33 = v35;
Ritor1
parents:
diff changeset
240 }
Ritor1
parents:
diff changeset
241 if ( v32 < (signed int)v33 )
Ritor1
parents:
diff changeset
242 {
Ritor1
parents:
diff changeset
243 v36 = v33;
Ritor1
parents:
diff changeset
244 v33 = v32;
Ritor1
parents:
diff changeset
245 v32 = v36;
Ritor1
parents:
diff changeset
246 }
Ritor1
parents:
diff changeset
247 v37 = v33 >> 2;
Ritor1
parents:
diff changeset
248 //LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31;
Ritor1
parents:
diff changeset
249 v38 = (double)(signed)(((unsigned int)(11 * v32) >> 5) + v37 + v31);
Ritor1
parents:
diff changeset
250 if (v38 > radius)
Ritor1
parents:
diff changeset
251 return true;
Ritor1
parents:
diff changeset
252 //radius = (1 / radius) * v38;
Ritor1
parents:
diff changeset
253 if ( uLightType & 4 )
Ritor1
parents:
diff changeset
254 {
Ritor1
parents:
diff changeset
255 //v59 = (void *)v37;
Ritor1
parents:
diff changeset
256 //uLightType = flt_4D86CC;
Ritor1
parents:
diff changeset
257 //v58 = v37;
Ritor1
parents:
diff changeset
258 v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y);
Ritor1
parents:
diff changeset
259 v40 = v39 * 1.0 * flt_4D86CC;
Ritor1
parents:
diff changeset
260
Ritor1
parents:
diff changeset
261 v11->fBrightness = v40 - (1 / radius) * v38 * v40;
Ritor1
parents:
diff changeset
262 }
Ritor1
parents:
diff changeset
263 else if ( uLightType & 8 )
Ritor1
parents:
diff changeset
264 {
Ritor1
parents:
diff changeset
265 v40 = 1.0 * 1.0;
Ritor1
parents:
diff changeset
266 v11->fBrightness = v40 - (1 / radius) * v38;
Ritor1
parents:
diff changeset
267 }
Ritor1
parents:
diff changeset
268 else
Ritor1
parents:
diff changeset
269 {
Ritor1
parents:
diff changeset
270 MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0);
Ritor1
parents:
diff changeset
271 }
Ritor1
parents:
diff changeset
272 }
Ritor1
parents:
diff changeset
273
Ritor1
parents:
diff changeset
274 if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices,
Ritor1
parents:
diff changeset
275 a7->field_4.x, a7->field_4.y, a7->field_4.z,
Ritor1
parents:
diff changeset
276 v11->pVertices, &v11->uNumVertices))
Ritor1
parents:
diff changeset
277 return false;
Ritor1
parents:
diff changeset
278
Ritor1
parents:
diff changeset
279 //v44 = &v11->uNumVertices;
Ritor1
parents:
diff changeset
280 if (!v11->uNumVertices)
Ritor1
parents:
diff changeset
281 return true;
Ritor1
parents:
diff changeset
282
Ritor1
parents:
diff changeset
283 v45 = _45C6D6(uNumVertices, a9, v11);
Ritor1
parents:
diff changeset
284 if ( v45 != uNumVertices && v45 > 0 )
Ritor1
parents:
diff changeset
285 _45C4B9(uNumVertices, a9, v11);
Ritor1
parents:
diff changeset
286 //v59 = v11->uNumVertices;
Ritor1
parents:
diff changeset
287 //v46 = (RenderVertexSoft *)pLightmapVertices_;
Ritor1
parents:
diff changeset
288 pGame->pIndoorCameraD3D->ViewTransform(v11->pVertices, v11->uNumVertices);
Ritor1
parents:
diff changeset
289 //v59 = 0;
Ritor1
parents:
diff changeset
290 //v58 = v11->uNumVertices;
Ritor1
parents:
diff changeset
291 pGame->pIndoorCameraD3D->Project(v11->pVertices, v11->uNumVertices, 0);
Ritor1
parents:
diff changeset
292
Ritor1
parents:
diff changeset
293 unsigned int _a4 = 0;
Ritor1
parents:
diff changeset
294 if ( !(uClipFlag & 1) )
Ritor1
parents:
diff changeset
295 _a4 = 1;
Ritor1
parents:
diff changeset
296 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
Ritor1
parents:
diff changeset
297 {
Ritor1
parents:
diff changeset
298 if ( uClipFlag & 2 )
Ritor1
parents:
diff changeset
299 {
Ritor1
parents:
diff changeset
300 //v59 = &a4;
Ritor1
parents:
diff changeset
301 //v58 = (unsigned int)field_3C8C34;
Ritor1
parents:
diff changeset
302 //v57 = *v44;
Ritor1
parents:
diff changeset
303 pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4);
Ritor1
parents:
diff changeset
304
Ritor1
parents:
diff changeset
305 //v59 = v44;
Ritor1
parents:
diff changeset
306 //v58 = (unsigned int)field_3C8C34;
Ritor1
parents:
diff changeset
307 //v57 = (int)v46;
Ritor1
parents:
diff changeset
308 //v56 = a4;
Ritor1
parents:
diff changeset
309 pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices);
Ritor1
parents:
diff changeset
310 }
Ritor1
parents:
diff changeset
311 else if ( uClipFlag & 4 )
Ritor1
parents:
diff changeset
312 {
Ritor1
parents:
diff changeset
313 //v59 = &a4;
Ritor1
parents:
diff changeset
314 //v58 = (unsigned int)field_3C8C34;
Ritor1
parents:
diff changeset
315 //v57 = *v44;
Ritor1
parents:
diff changeset
316 pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4);
Ritor1
parents:
diff changeset
317
Ritor1
parents:
diff changeset
318 //v59 = v44;
Ritor1
parents:
diff changeset
319 //v58 = (unsigned int)field_3C8C34;
Ritor1
parents:
diff changeset
320 //v57 = (int)v46;
Ritor1
parents:
diff changeset
321 //v56 = a4;
Ritor1
parents:
diff changeset
322 pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices);
Ritor1
parents:
diff changeset
323 }
Ritor1
parents:
diff changeset
324 else
Ritor1
parents:
diff changeset
325 MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0);
Ritor1
parents:
diff changeset
326 }
Ritor1
parents:
diff changeset
327 else
Ritor1
parents:
diff changeset
328 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
329
Ritor1
parents:
diff changeset
330 if (_a4)
Ritor1
parents:
diff changeset
331 {
Ritor1
parents:
diff changeset
332 if (uLightType & 1)
Ritor1
parents:
diff changeset
333 {
Ritor1
parents:
diff changeset
334 //v48 = (char *)&std__vector_000004_size;
Ritor1
parents:
diff changeset
335 //v49 = std__vector_000004_size;
Ritor1
parents:
diff changeset
336 //v51 = __OFSUB__(std__vector_000004_size, 511);
Ritor1
parents:
diff changeset
337 //v50 = std__vector_000004_size - 511 < 0;
Ritor1
parents:
diff changeset
338 if (std__vector_000004_size < 512 - 1)
Ritor1
parents:
diff changeset
339 ++std__vector_000004_size;
Ritor1
parents:
diff changeset
340 }
Ritor1
parents:
diff changeset
341 else
Ritor1
parents:
diff changeset
342 {
Ritor1
parents:
diff changeset
343 //v48 = (char *)&std__vector_183808_size;
Ritor1
parents:
diff changeset
344 //v49 = std__vector_183808_size;
Ritor1
parents:
diff changeset
345 //v51 = __OFSUB__(std__vector_183808_size, 767);
Ritor1
parents:
diff changeset
346 //v50 = std__vector_183808_size - 767 < 0;
Ritor1
parents:
diff changeset
347 if (std__vector_183808_size < 768 - 1)
Ritor1
parents:
diff changeset
348 ++std__vector_183808_size;
Ritor1
parents:
diff changeset
349 }
Ritor1
parents:
diff changeset
350 //if ( v50 ^ v51 )
Ritor1
parents:
diff changeset
351 // *(unsigned int *)v48 = v49 + 1;
Ritor1
parents:
diff changeset
352 }
Ritor1
parents:
diff changeset
353 return true;
Ritor1
parents:
diff changeset
354 }
Ritor1
parents:
diff changeset
355
Ritor1
parents:
diff changeset
356 //----- (0045C4B9) --------------------------------------------------------
Ritor1
parents:
diff changeset
357 int LightmapBuilder::_45C4B9(int a2, RenderVertexSoft *a3, Lightmap *pLightmap)
Ritor1
parents:
diff changeset
358 {
Ritor1
parents:
diff changeset
359 Lightmap *v4; // edi@1
Ritor1
parents:
diff changeset
360 int v5; // eax@1
Ritor1
parents:
diff changeset
361 signed int v6; // ecx@1
Ritor1
parents:
diff changeset
362 RenderVertexSoft *v7; // ebx@2
Ritor1
parents:
diff changeset
363 int v8; // edx@3
Ritor1
parents:
diff changeset
364 RenderVertexSoft *v9; // esi@3
Ritor1
parents:
diff changeset
365 int v10; // eax@6
Ritor1
parents:
diff changeset
366 char *v11; // edi@7
Ritor1
parents:
diff changeset
367 RenderVertexSoft *v12; // ecx@8
Ritor1
parents:
diff changeset
368 char v13; // bl@17
Ritor1
parents:
diff changeset
369 signed int v14; // edx@17
Ritor1
parents:
diff changeset
370 double v15; // st6@18
Ritor1
parents:
diff changeset
371 double v16; // st6@21
Ritor1
parents:
diff changeset
372 double v17; // st6@24
Ritor1
parents:
diff changeset
373 signed int v18; // edx@33
Ritor1
parents:
diff changeset
374 int v20; // [sp+4h] [bp-1Ch]@3
Ritor1
parents:
diff changeset
375 int v21; // [sp+8h] [bp-18h]@8
Ritor1
parents:
diff changeset
376 float v22; // [sp+Ch] [bp-14h]@23
Ritor1
parents:
diff changeset
377 float v23; // [sp+10h] [bp-10h]@20
Ritor1
parents:
diff changeset
378 int v24; // [sp+14h] [bp-Ch]@1
Ritor1
parents:
diff changeset
379 RenderVertexSoft *v25; // [sp+18h] [bp-8h]@2
Ritor1
parents:
diff changeset
380 char v26; // [sp+1Eh] [bp-2h]@17
Ritor1
parents:
diff changeset
381 char v27; // [sp+1Fh] [bp-1h]@17
Ritor1
parents:
diff changeset
382
Ritor1
parents:
diff changeset
383 v4 = pLightmap;
Ritor1
parents:
diff changeset
384 v5 = 0;
Ritor1
parents:
diff changeset
385 v6 = pLightmap->uNumVertices;
Ritor1
parents:
diff changeset
386 v24 = 0;
Ritor1
parents:
diff changeset
387 if ( v6 > 0 )
Ritor1
parents:
diff changeset
388 {
Ritor1
parents:
diff changeset
389 v7 = pLightmap->pVertices;
Ritor1
parents:
diff changeset
390 v25 = pLightmap->pVertices;
Ritor1
parents:
diff changeset
391 do
Ritor1
parents:
diff changeset
392 {
Ritor1
parents:
diff changeset
393 v20 = v5 + 1;
Ritor1
parents:
diff changeset
394 v8 = (v5 + 1) % v6;
Ritor1
parents:
diff changeset
395 v9 = &v4->pVertices[v8];
Ritor1
parents:
diff changeset
396 if ( v7->vWorldPosition.x != v9->vWorldPosition.x
Ritor1
parents:
diff changeset
397 || v7->vWorldPosition.y != v4->pVertices[v8].vWorldPosition.y
Ritor1
parents:
diff changeset
398 || v7->vWorldPosition.z != v4->pVertices[v8].vWorldPosition.z )
Ritor1
parents:
diff changeset
399 {
Ritor1
parents:
diff changeset
400 v10 = 0;
Ritor1
parents:
diff changeset
401 if ( a2 > 0 )
Ritor1
parents:
diff changeset
402 {
Ritor1
parents:
diff changeset
403 v11 = (char *)&a3->vWorldPosition.z;
Ritor1
parents:
diff changeset
404 do
Ritor1
parents:
diff changeset
405 {
Ritor1
parents:
diff changeset
406 v21 = v10 + 1;
Ritor1
parents:
diff changeset
407 v12 = &a3[(v10 + 1) % a2];
Ritor1
parents:
diff changeset
408 if ( (*((float *)v11 - 2) != v12->vWorldPosition.x
Ritor1
parents:
diff changeset
409 || *((float *)v11 - 1) != v12->vWorldPosition.y
Ritor1
parents:
diff changeset
410 || *(float *)v11 != v12->vWorldPosition.z)
Ritor1
parents:
diff changeset
411 && v7->vWorldPosition.x == *((float *)v11 - 2)
Ritor1
parents:
diff changeset
412 && v7->vWorldPosition.y == *((float *)v11 - 1)
Ritor1
parents:
diff changeset
413 && v7->vWorldPosition.z == *(float *)v11
Ritor1
parents:
diff changeset
414 && (v9->vWorldPosition.x != v12->vWorldPosition.x
Ritor1
parents:
diff changeset
415 || v9->vWorldPosition.y != v12->vWorldPosition.y
Ritor1
parents:
diff changeset
416 || v9->vWorldPosition.z != v12->vWorldPosition.z) )
Ritor1
parents:
diff changeset
417 {
Ritor1
parents:
diff changeset
418 v13 = 0;
Ritor1
parents:
diff changeset
419 v14 = 0;
Ritor1
parents:
diff changeset
420 v27 = 0;
Ritor1
parents:
diff changeset
421 v26 = 0;
Ritor1
parents:
diff changeset
422 if ( v9->vWorldPosition.x <= (double)v12->vWorldPosition.x )
Ritor1
parents:
diff changeset
423 v15 = v12->vWorldPosition.x - v9->vWorldPosition.x;
Ritor1
parents:
diff changeset
424 else
Ritor1
parents:
diff changeset
425 v15 = v9->vWorldPosition.x - v12->vWorldPosition.x;
Ritor1
parents:
diff changeset
426 v23 = v15;
Ritor1
parents:
diff changeset
427 if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y )
Ritor1
parents:
diff changeset
428 v16 = v12->vWorldPosition.y - v9->vWorldPosition.y;
Ritor1
parents:
diff changeset
429 else
Ritor1
parents:
diff changeset
430 v16 = v9->vWorldPosition.y - v12->vWorldPosition.y;
Ritor1
parents:
diff changeset
431 v22 = v16;
Ritor1
parents:
diff changeset
432 if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z )
Ritor1
parents:
diff changeset
433 v17 = v12->vWorldPosition.z - v9->vWorldPosition.z;
Ritor1
parents:
diff changeset
434 else
Ritor1
parents:
diff changeset
435 v17 = v9->vWorldPosition.z - v12->vWorldPosition.z;
Ritor1
parents:
diff changeset
436 if ( v23 < 1.0 )
Ritor1
parents:
diff changeset
437 {
Ritor1
parents:
diff changeset
438 v13 = 1;
Ritor1
parents:
diff changeset
439 v14 = 1;
Ritor1
parents:
diff changeset
440 }
Ritor1
parents:
diff changeset
441 if ( v22 < 1.0 )
Ritor1
parents:
diff changeset
442 {
Ritor1
parents:
diff changeset
443 v27 = 1;
Ritor1
parents:
diff changeset
444 ++v14;
Ritor1
parents:
diff changeset
445 }
Ritor1
parents:
diff changeset
446 if ( v17 < 1.0 )
Ritor1
parents:
diff changeset
447 {
Ritor1
parents:
diff changeset
448 v26 = 1;
Ritor1
parents:
diff changeset
449 ++v14;
Ritor1
parents:
diff changeset
450 }
Ritor1
parents:
diff changeset
451 if ( v14 > 1 )
Ritor1
parents:
diff changeset
452 {
Ritor1
parents:
diff changeset
453 v18 = 0;
Ritor1
parents:
diff changeset
454 if ( v13 && v9->vWorldPosition.x != v12->vWorldPosition.x )
Ritor1
parents:
diff changeset
455 {
Ritor1
parents:
diff changeset
456 v18 = 1;
Ritor1
parents:
diff changeset
457 v9->vWorldPosition.x = v12->vWorldPosition.x;
Ritor1
parents:
diff changeset
458 }
Ritor1
parents:
diff changeset
459 if ( v27 && v9->vWorldPosition.y != v12->vWorldPosition.y )
Ritor1
parents:
diff changeset
460 {
Ritor1
parents:
diff changeset
461 ++v18;
Ritor1
parents:
diff changeset
462 v9->vWorldPosition.y = v12->vWorldPosition.y;
Ritor1
parents:
diff changeset
463 }
Ritor1
parents:
diff changeset
464 if ( v26 && v9->vWorldPosition.z != v12->vWorldPosition.z )
Ritor1
parents:
diff changeset
465 {
Ritor1
parents:
diff changeset
466 ++v18;
Ritor1
parents:
diff changeset
467 v9->vWorldPosition.z = v12->vWorldPosition.z;
Ritor1
parents:
diff changeset
468 }
Ritor1
parents:
diff changeset
469 if ( v18 > 0 )
Ritor1
parents:
diff changeset
470 ++v24;
Ritor1
parents:
diff changeset
471 }
Ritor1
parents:
diff changeset
472 v7 = v25;
Ritor1
parents:
diff changeset
473 }
Ritor1
parents:
diff changeset
474 ++v10;
Ritor1
parents:
diff changeset
475 v11 += 48;
Ritor1
parents:
diff changeset
476 }
Ritor1
parents:
diff changeset
477 while ( v21 < a2 );
Ritor1
parents:
diff changeset
478 v4 = pLightmap;
Ritor1
parents:
diff changeset
479 }
Ritor1
parents:
diff changeset
480 }
Ritor1
parents:
diff changeset
481 v5 = v20;
Ritor1
parents:
diff changeset
482 v6 = v4->uNumVertices;
Ritor1
parents:
diff changeset
483 ++v7;
Ritor1
parents:
diff changeset
484 v25 = v7;
Ritor1
parents:
diff changeset
485 }
Ritor1
parents:
diff changeset
486 while ( v20 < v6 );
Ritor1
parents:
diff changeset
487 }
Ritor1
parents:
diff changeset
488 return v24;
Ritor1
parents:
diff changeset
489 }
Ritor1
parents:
diff changeset
490
Ritor1
parents:
diff changeset
491 //----- (0045C6D6) --------------------------------------------------------
Ritor1
parents:
diff changeset
492 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap)
Ritor1
parents:
diff changeset
493 {
Ritor1
parents:
diff changeset
494 Lightmap *v4; // edi@1
Ritor1
parents:
diff changeset
495 signed int v5; // ebx@1
Ritor1
parents:
diff changeset
496 signed int v6; // esi@1
Ritor1
parents:
diff changeset
497 RenderVertexSoft *v7; // ecx@2
Ritor1
parents:
diff changeset
498 char *v8; // edx@4
Ritor1
parents:
diff changeset
499 double v9; // st7@6
Ritor1
parents:
diff changeset
500 double v10; // st6@10
Ritor1
parents:
diff changeset
501 double v11; // st5@14
Ritor1
parents:
diff changeset
502 double v12; // st7@17
Ritor1
parents:
diff changeset
503 RenderVertexSoft *v13; // eax@21
Ritor1
parents:
diff changeset
504 int v15; // [sp+Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
505 float v16; // [sp+10h] [bp-4h]@1
Ritor1
parents:
diff changeset
506 int pLightmapa; // [sp+24h] [bp+10h]@3
Ritor1
parents:
diff changeset
507
Ritor1
parents:
diff changeset
508 v4 = pLightmap;
Ritor1
parents:
diff changeset
509 v5 = 0;
Ritor1
parents:
diff changeset
510 v6 = -1;
Ritor1
parents:
diff changeset
511 v16 = 3.4028235e38;
Ritor1
parents:
diff changeset
512 v15 = 0;
Ritor1
parents:
diff changeset
513 if ( (signed int)pLightmap->uNumVertices > 0 )
Ritor1
parents:
diff changeset
514 {
Ritor1
parents:
diff changeset
515 v7 = pLightmap->pVertices;
Ritor1
parents:
diff changeset
516 do
Ritor1
parents:
diff changeset
517 {
Ritor1
parents:
diff changeset
518 pLightmapa = 0;
Ritor1
parents:
diff changeset
519 if ( a2 > 0 )
Ritor1
parents:
diff changeset
520 {
Ritor1
parents:
diff changeset
521 v8 = (char *)&a3->vWorldPosition.z;
Ritor1
parents:
diff changeset
522 do
Ritor1
parents:
diff changeset
523 {
Ritor1
parents:
diff changeset
524 if ( v7->vWorldPosition.x <= (double)*((float *)v8 - 2) )
Ritor1
parents:
diff changeset
525 v9 = *((float *)v8 - 2) - v7->vWorldPosition.x;
Ritor1
parents:
diff changeset
526 else
Ritor1
parents:
diff changeset
527 v9 = v7->vWorldPosition.x - *((float *)v8 - 2);
Ritor1
parents:
diff changeset
528 if ( v9 < 2.0 )
Ritor1
parents:
diff changeset
529 {
Ritor1
parents:
diff changeset
530 v10 = v7->vWorldPosition.y <= (double)*((float *)v8 - 1) ? *((float *)v8 - 1) - v7->vWorldPosition.y : v7->vWorldPosition.y - *((float *)v8 - 1);
Ritor1
parents:
diff changeset
531 if ( v10 < 2.0 )
Ritor1
parents:
diff changeset
532 {
Ritor1
parents:
diff changeset
533 v11 = v7->vWorldPosition.z <= (double)*(float *)v8 ? *(float *)v8 - v7->vWorldPosition.z : v7->vWorldPosition.z - *(float *)v8;
Ritor1
parents:
diff changeset
534 if ( v11 < 2.0 )
Ritor1
parents:
diff changeset
535 {
Ritor1
parents:
diff changeset
536 v12 = v9 + v11 + v10;
Ritor1
parents:
diff changeset
537 if ( v12 < v16 )
Ritor1
parents:
diff changeset
538 {
Ritor1
parents:
diff changeset
539 v16 = v12;
Ritor1
parents:
diff changeset
540 v6 = pLightmapa;
Ritor1
parents:
diff changeset
541 }
Ritor1
parents:
diff changeset
542 }
Ritor1
parents:
diff changeset
543 }
Ritor1
parents:
diff changeset
544 }
Ritor1
parents:
diff changeset
545 ++pLightmapa;
Ritor1
parents:
diff changeset
546 v8 += 48;
Ritor1
parents:
diff changeset
547 }
Ritor1
parents:
diff changeset
548 while ( pLightmapa < a2 );
Ritor1
parents:
diff changeset
549 if ( v6 != -1 )
Ritor1
parents:
diff changeset
550 {
Ritor1
parents:
diff changeset
551 v13 = &a3[v6];
Ritor1
parents:
diff changeset
552 ++v15;
Ritor1
parents:
diff changeset
553 v7->vWorldPosition.x = v13->vWorldPosition.x;
Ritor1
parents:
diff changeset
554 v7->vWorldPosition.y = v13->vWorldPosition.y;
Ritor1
parents:
diff changeset
555 v7->vWorldPosition.z = v13->vWorldPosition.z;
Ritor1
parents:
diff changeset
556 }
Ritor1
parents:
diff changeset
557 }
Ritor1
parents:
diff changeset
558 v6 = -1;
Ritor1
parents:
diff changeset
559 ++v5;
Ritor1
parents:
diff changeset
560 ++v7;
Ritor1
parents:
diff changeset
561 v16 = 3.4028235e38;
Ritor1
parents:
diff changeset
562 }
Ritor1
parents:
diff changeset
563 while ( v5 < (signed int)v4->uNumVertices );
Ritor1
parents:
diff changeset
564 }
Ritor1
parents:
diff changeset
565 return v15;
Ritor1
parents:
diff changeset
566 }
Ritor1
parents:
diff changeset
567
Ritor1
parents:
diff changeset
568 //----- (0045C7F6) --------------------------------------------------------
Ritor1
parents:
diff changeset
569 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID)
Ritor1
parents:
diff changeset
570 {
Ritor1
parents:
diff changeset
571 auto pFace = &pIndoor->pFaces[uFaceID];
Ritor1
parents:
diff changeset
572 auto pSector = pIndoor->pSectors + pFace->uSectorID;
Ritor1
parents:
diff changeset
573
Ritor1
parents:
diff changeset
574 stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;
Ritor1
parents:
diff changeset
575
Ritor1
parents:
diff changeset
576 uint uNumLightsApplied = 0;
Ritor1
parents:
diff changeset
577 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
Ritor1
parents:
diff changeset
578 {
Ritor1
parents:
diff changeset
579 if (uNumLightsApplied >= 20)
Ritor1
parents:
diff changeset
580 break;
Ritor1
parents:
diff changeset
581
Ritor1
parents:
diff changeset
582 ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0);
Ritor1
parents:
diff changeset
583 }
Ritor1
parents:
diff changeset
584
Ritor1
parents:
diff changeset
585 for (uint i = 0; i < pSector->uNumLights; ++i)
Ritor1
parents:
diff changeset
586 {
Ritor1
parents:
diff changeset
587 if (uNumLightsApplied >= 20 )
Ritor1
parents:
diff changeset
588 break;
Ritor1
parents:
diff changeset
589
Ritor1
parents:
diff changeset
590 auto pLight = &pIndoor->pLights[pSector->pLights[i]];
Ritor1
parents:
diff changeset
591 if (~pLight->uAtributes & 0x08)
Ritor1
parents:
diff changeset
592 ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &byte_4E94D0);
Ritor1
parents:
diff changeset
593 }
Ritor1
parents:
diff changeset
594
Ritor1
parents:
diff changeset
595 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
Ritor1
parents:
diff changeset
596 {
Ritor1
parents:
diff changeset
597 if (uNumLightsApplied >= 20)
Ritor1
parents:
diff changeset
598 break;
Ritor1
parents:
diff changeset
599
Ritor1
parents:
diff changeset
600 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &byte_4E94D0);
Ritor1
parents:
diff changeset
601 }
Ritor1
parents:
diff changeset
602
Ritor1
parents:
diff changeset
603 stru_F8AD28.uNumLightsApplied = uNumLightsApplied;
Ritor1
parents:
diff changeset
604 return true;
Ritor1
parents:
diff changeset
605 }
Ritor1
parents:
diff changeset
606
Ritor1
parents:
diff changeset
607 //----- (0045C911) --------------------------------------------------------
Ritor1
parents:
diff changeset
608 bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5)
Ritor1
parents:
diff changeset
609 {
Ritor1
parents:
diff changeset
610 double v13; // st7@8
Ritor1
parents:
diff changeset
611
Ritor1
parents:
diff changeset
612 if (!pLight->uRadius)
Ritor1
parents:
diff changeset
613 return false;
Ritor1
parents:
diff changeset
614
Ritor1
parents:
diff changeset
615 if (pLight->vPosition.x > a2->pBounding.x1 - pLight->uRadius &&
Ritor1
parents:
diff changeset
616 pLight->vPosition.x < a2->pBounding.x2 + pLight->uRadius &&
Ritor1
parents:
diff changeset
617 pLight->vPosition.y > a2->pBounding.y1 - pLight->uRadius &&
Ritor1
parents:
diff changeset
618 pLight->vPosition.y < a2->pBounding.y2 + pLight->uRadius &&
Ritor1
parents:
diff changeset
619 pLight->vPosition.z > a2->pBounding.z1 - pLight->uRadius &&
Ritor1
parents:
diff changeset
620 pLight->vPosition.z < a2->pBounding.z2 + pLight->uRadius)
Ritor1
parents:
diff changeset
621 {
Ritor1
parents:
diff changeset
622 v13 = (double)pLight->vPosition.z * a2->pFacePlane.vNormal.z +
Ritor1
parents:
diff changeset
623 (double)pLight->vPosition.y * a2->pFacePlane.vNormal.y +
Ritor1
parents:
diff changeset
624 (double)pLight->vPosition.x * a2->pFacePlane.vNormal.x +
Ritor1
parents:
diff changeset
625 a2->pFacePlane.dist;
Ritor1
parents:
diff changeset
626 if ((bLightBackfaces || v13 >= 0.0f) && fabsf(v13) <= pLight->uRadius)
Ritor1
parents:
diff changeset
627 {
Ritor1
parents:
diff changeset
628 auto slot = *pSlot;
Ritor1
parents:
diff changeset
629
Ritor1
parents:
diff changeset
630 stru_F8AD28._blv_lights_radii[slot] = pLight->uRadius;
Ritor1
parents:
diff changeset
631 stru_F8AD28._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius;
Ritor1
parents:
diff changeset
632 stru_F8AD28._blv_lights_xs[slot] = pLight->vPosition.x;
Ritor1
parents:
diff changeset
633 stru_F8AD28._blv_lights_ys[slot] = pLight->vPosition.y;
Ritor1
parents:
diff changeset
634 stru_F8AD28._blv_lights_zs[slot] = pLight->vPosition.z;
Ritor1
parents:
diff changeset
635 stru_F8AD28._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f;
Ritor1
parents:
diff changeset
636 stru_F8AD28._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f;
Ritor1
parents:
diff changeset
637 stru_F8AD28._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f;
Ritor1
parents:
diff changeset
638 stru_F8AD28._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f));
Ritor1
parents:
diff changeset
639 stru_F8AD28._blv_lights_types[slot] = pLight->uLightType;
Ritor1
parents:
diff changeset
640
Ritor1
parents:
diff changeset
641 *pSlot += 1;
Ritor1
parents:
diff changeset
642 return true;
Ritor1
parents:
diff changeset
643 }
Ritor1
parents:
diff changeset
644 }
Ritor1
parents:
diff changeset
645
Ritor1
parents:
diff changeset
646 return false;
Ritor1
parents:
diff changeset
647 }
Ritor1
parents:
diff changeset
648
Ritor1
parents:
diff changeset
649 //----- (0045CA88) --------------------------------------------------------
Ritor1
parents:
diff changeset
650 int LightmapBuilder::_45CA88(stru320 *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal)
Ritor1
parents:
diff changeset
651 {
Ritor1
parents:
diff changeset
652 int result; // eax@1
Ritor1
parents:
diff changeset
653 stru320 *v6; // ecx@2
Ritor1
parents:
diff changeset
654 RenderVertexSoft *v7; // ebx@2
Ritor1
parents:
diff changeset
655 double v8; // st7@2
Ritor1
parents:
diff changeset
656 double v9; // st6@2
Ritor1
parents:
diff changeset
657 char *v10; // eax@3
Ritor1
parents:
diff changeset
658 double v11; // st7@5
Ritor1
parents:
diff changeset
659 __int64 v12; // ST2C_8@5
Ritor1
parents:
diff changeset
660 float v13; // edx@5
Ritor1
parents:
diff changeset
661 int v14; // eax@5
Ritor1
parents:
diff changeset
662 float v15; // ST10_4@5
Ritor1
parents:
diff changeset
663 Vec3_float_ v16; // ST00_12@5
Ritor1
parents:
diff changeset
664 double v17; // st7@5
Ritor1
parents:
diff changeset
665 int a5; // [sp+2Ch] [bp-1Ch]@1
Ritor1
parents:
diff changeset
666 float v19; // [sp+30h] [bp-18h]@1
Ritor1
parents:
diff changeset
667 float v20; // [sp+34h] [bp-14h]@1
Ritor1
parents:
diff changeset
668 LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1
Ritor1
parents:
diff changeset
669 int v22; // [sp+3Ch] [bp-Ch]@1
Ritor1
parents:
diff changeset
670 int *j; // [sp+40h] [bp-8h]@3
Ritor1
parents:
diff changeset
671 int i; // [sp+44h] [bp-4h]@1
Ritor1
parents:
diff changeset
672 int a3a; // [sp+58h] [bp+10h]@2
Ritor1
parents:
diff changeset
673
Ritor1
parents:
diff changeset
674 *(float *)&a5 = 0.0;
Ritor1
parents:
diff changeset
675 v19 = 0.0;
Ritor1
parents:
diff changeset
676 thisa = this;
Ritor1
parents:
diff changeset
677 v20 = 0.0;
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1089
diff changeset
678 result = _45CBD4(a3, a4, dword_69B010.data(), &v22);
0
Ritor1
parents:
diff changeset
679 for ( i = 0; i < v22; result = i )
Ritor1
parents:
diff changeset
680 {
Ritor1
parents:
diff changeset
681 v6 = a2;
Ritor1
parents:
diff changeset
682 a3a = 0;
Ritor1
parents:
diff changeset
683 v7 = &a3[dword_69B010[i]];
Ritor1
parents:
diff changeset
684 v8 = v7->vWorldPosition.z;
Ritor1
parents:
diff changeset
685 v9 = v7->vWorldPosition.y;
Ritor1
parents:
diff changeset
686 *(float *)&a5 = v7->vWorldPosition.x;
Ritor1
parents:
diff changeset
687 v19 = v9;
Ritor1
parents:
diff changeset
688 v20 = v8;
Ritor1
parents:
diff changeset
689 v7->flt_2C = 0.0;
Ritor1
parents:
diff changeset
690 if ( a2->uNumLightsApplied > 0 )
Ritor1
parents:
diff changeset
691 {
Ritor1
parents:
diff changeset
692 v10 = (char *)a2->_blv_lights_ys;
Ritor1
parents:
diff changeset
693 for ( j = a2->_blv_lights_ys; ; v10 = (char *)j )
Ritor1
parents:
diff changeset
694 {
Ritor1
parents:
diff changeset
695 v11 = (double)*((signed int *)v10 - 60);
Ritor1
parents:
diff changeset
696 LODWORD(v12) = *((unsigned int *)v10 - 20);
Ritor1
parents:
diff changeset
697 HIDWORD(v12) = *(unsigned int *)v10;
Ritor1
parents:
diff changeset
698 LODWORD(v13) = *((unsigned int *)v10 + 60);
Ritor1
parents:
diff changeset
699 v14 = a3a;
Ritor1
parents:
diff changeset
700 LOBYTE(v14) = v6->_blv_lights_types[a3a];
Ritor1
parents:
diff changeset
701 v15 = v11;
Ritor1
parents:
diff changeset
702 *(_QWORD *)&v16.x = v12;
Ritor1
parents:
diff changeset
703 v16.z = v13;
Ritor1
parents:
diff changeset
704 v17 = _45CC0C_light(v16/*COERCE_VEC3_FLOAT_(v16.x)*/, 1.0, v15, pNormal, *(float *)&a5/*COERCE_FLOAT(&a5)*/, v14)
Ritor1
parents:
diff changeset
705 + v7->flt_2C;
Ritor1
parents:
diff changeset
706 ++a3a;
Ritor1
parents:
diff changeset
707 ++j;
Ritor1
parents:
diff changeset
708 v7->flt_2C = v17;
Ritor1
parents:
diff changeset
709 if ( a3a >= a2->uNumLightsApplied )
Ritor1
parents:
diff changeset
710 break;
Ritor1
parents:
diff changeset
711 v6 = a2;
Ritor1
parents:
diff changeset
712 }
Ritor1
parents:
diff changeset
713 }
Ritor1
parents:
diff changeset
714 ++i;
Ritor1
parents:
diff changeset
715 }
Ritor1
parents:
diff changeset
716 return result;
Ritor1
parents:
diff changeset
717 }
Ritor1
parents:
diff changeset
718
Ritor1
parents:
diff changeset
719 //----- (0045CB89) --------------------------------------------------------
Ritor1
parents:
diff changeset
720 int LightmapBuilder::_45CB89(RenderVertexSoft *a1, int a2)
Ritor1
parents:
diff changeset
721 {
Ritor1
parents:
diff changeset
722 int v3; // edx@1
Ritor1
parents:
diff changeset
723 int result; // eax@2
Ritor1
parents:
diff changeset
724 char *v5; // ecx@2
Ritor1
parents:
diff changeset
725 double v6; // st7@4
Ritor1
parents:
diff changeset
726 __int16 v7; // fps@4
Ritor1
parents:
diff changeset
727 char v8; // c0@4
Ritor1
parents:
diff changeset
728 char v9; // c2@4
Ritor1
parents:
diff changeset
729 char v10; // c3@4
Ritor1
parents:
diff changeset
730 double v11; // st7@5
Ritor1
parents:
diff changeset
731 double v12; // st7@6
Ritor1
parents:
diff changeset
732 __int16 v13; // fps@6
Ritor1
parents:
diff changeset
733 char v14; // c0@6
Ritor1
parents:
diff changeset
734 char v15; // c2@6
Ritor1
parents:
diff changeset
735 char v16; // c3@6
Ritor1
parents:
diff changeset
736
Ritor1
parents:
diff changeset
737 v3 = a2;
Ritor1
parents:
diff changeset
738 if ( a2 > 0 )
Ritor1
parents:
diff changeset
739 {
Ritor1
parents:
diff changeset
740 HIWORD(result) = HIWORD(a1);
Ritor1
parents:
diff changeset
741 v5 = (char *)&a1->flt_2C;
Ritor1
parents:
diff changeset
742 do
Ritor1
parents:
diff changeset
743 {
Ritor1
parents:
diff changeset
744 if ( *(float *)v5 < 0.0
Ritor1
parents:
diff changeset
745 || (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
746 {
Ritor1
parents:
diff changeset
747 v12 = *(float *)v5;
Ritor1
parents:
diff changeset
748 //UNDEF(v13);
Ritor1
parents:
diff changeset
749 v14 = 0.0 < v12;
Ritor1
parents:
diff changeset
750 v15 = 0;
Ritor1
parents:
diff changeset
751 v16 = 0.0 == v12;
Ritor1
parents:
diff changeset
752 LOWORD(result) = v13;
Ritor1
parents:
diff changeset
753 if ( v12 >= 0.0 )
Ritor1
parents:
diff changeset
754 v11 = *(float *)v5;
Ritor1
parents:
diff changeset
755 else
Ritor1
parents:
diff changeset
756 v11 = 0.0;
Ritor1
parents:
diff changeset
757 }
Ritor1
parents:
diff changeset
758 else
Ritor1
parents:
diff changeset
759 {
Ritor1
parents:
diff changeset
760 v11 = 1.0;
Ritor1
parents:
diff changeset
761 }
Ritor1
parents:
diff changeset
762 *(float *)v5 = v11;
Ritor1
parents:
diff changeset
763 v5 += 48;
Ritor1
parents:
diff changeset
764 --v3;
Ritor1
parents:
diff changeset
765 }
Ritor1
parents:
diff changeset
766 while ( v3 );
Ritor1
parents:
diff changeset
767 }
Ritor1
parents:
diff changeset
768 return result;
Ritor1
parents:
diff changeset
769 }
Ritor1
parents:
diff changeset
770
Ritor1
parents:
diff changeset
771 //----- (0045CBD4) --------------------------------------------------------
Ritor1
parents:
diff changeset
772 int LightmapBuilder::_45CBD4(RenderVertexSoft *a2, int a3, int *a4, int *a5)
Ritor1
parents:
diff changeset
773 {
Ritor1
parents:
diff changeset
774 int result; // eax@1
Ritor1
parents:
diff changeset
775 int v6; // edx@1
Ritor1
parents:
diff changeset
776 int v7; // ecx@2
Ritor1
parents:
diff changeset
777 int v8; // esi@2
Ritor1
parents:
diff changeset
778
Ritor1
parents:
diff changeset
779 result = (int)a5;
Ritor1
parents:
diff changeset
780 v6 = 0;
Ritor1
parents:
diff changeset
781 for ( *a5 = 0; v6 < a3; ++v6 )
Ritor1
parents:
diff changeset
782 {
Ritor1
parents:
diff changeset
783 v7 = *a5;
Ritor1
parents:
diff changeset
784 v8 = 0;
Ritor1
parents:
diff changeset
785 if ( *a5 <= 0 )
Ritor1
parents:
diff changeset
786 {
Ritor1
parents:
diff changeset
787 LABEL_5:
Ritor1
parents:
diff changeset
788 a4[v7] = v6;
Ritor1
parents:
diff changeset
789 ++*a5;
Ritor1
parents:
diff changeset
790 }
Ritor1
parents:
diff changeset
791 else
Ritor1
parents:
diff changeset
792 {
Ritor1
parents:
diff changeset
793 while ( a4[v8] != v6 )
Ritor1
parents:
diff changeset
794 {
Ritor1
parents:
diff changeset
795 ++v8;
Ritor1
parents:
diff changeset
796 if ( v8 >= v7 )
Ritor1
parents:
diff changeset
797 goto LABEL_5;
Ritor1
parents:
diff changeset
798 }
Ritor1
parents:
diff changeset
799 }
Ritor1
parents:
diff changeset
800 }
Ritor1
parents:
diff changeset
801 return result;
Ritor1
parents:
diff changeset
802 }
Ritor1
parents:
diff changeset
803
Ritor1
parents:
diff changeset
804 //----- (0045CC0C) --------------------------------------------------------
Ritor1
parents:
diff changeset
805 double LightmapBuilder::_45CC0C_light(Vec3_float_ a1, float a2, float a3, Vec3_float_ *pNormal, float a5, int uLightType)
Ritor1
parents:
diff changeset
806 {
Ritor1
parents:
diff changeset
807 float v7; // esi@1
Ritor1
parents:
diff changeset
808 int v8; // eax@1
Ritor1
parents:
diff changeset
809 int v9; // ebx@1
Ritor1
parents:
diff changeset
810 unsigned int v10; // ecx@1
Ritor1
parents:
diff changeset
811 int v11; // edx@2
Ritor1
parents:
diff changeset
812 int v12; // edx@4
Ritor1
parents:
diff changeset
813 unsigned int v13; // edx@6
Ritor1
parents:
diff changeset
814 double v14; // st7@7
Ritor1
parents:
diff changeset
815 double result; // st7@8
Ritor1
parents:
diff changeset
816 double v16; // st7@9
Ritor1
parents:
diff changeset
817 int v17; // esi@9
Ritor1
parents:
diff changeset
818 const char *v18; // ecx@9
Ritor1
parents:
diff changeset
819 double v19; // st7@10
Ritor1
parents:
diff changeset
820 double v20; // st7@10
Ritor1
parents:
diff changeset
821 std::string v21; // [sp-10h] [bp-40h]@13
Ritor1
parents:
diff changeset
822 const char *v22[6]; // [sp+0h] [bp-30h]@10
Ritor1
parents:
diff changeset
823 double v23; // [sp+18h] [bp-18h]@1
Ritor1
parents:
diff changeset
824 double v24; // [sp+20h] [bp-10h]@1
Ritor1
parents:
diff changeset
825 int v25; // [sp+28h] [bp-8h]@1
Ritor1
parents:
diff changeset
826 int v26; // [sp+2Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
827
Ritor1
parents:
diff changeset
828 v7 = a5;
Ritor1
parents:
diff changeset
829 LODWORD(a5) = *(unsigned int *)(LODWORD(a5) + 8);
Ritor1
parents:
diff changeset
830 //v24 = a5 + 6.7553994e15;
Ritor1
parents:
diff changeset
831 v26 = floorf(a5 + 0.5f);//LODWORD(v24);
Ritor1
parents:
diff changeset
832 LODWORD(a5) = *(unsigned int *)(LODWORD(v7) + 4);
Ritor1
parents:
diff changeset
833 //v24 = a5 + 6.7553994e15;
Ritor1
parents:
diff changeset
834 auto _v24 = floorf(a5 + 0.5f);
Ritor1
parents:
diff changeset
835 LODWORD(a5) = *(unsigned int *)LODWORD(v7);
Ritor1
parents:
diff changeset
836 //v23 = a5 + 6.7553994e15;
Ritor1
parents:
diff changeset
837 auto _v23 = floorf(a5 + 0.5f);
Ritor1
parents:
diff changeset
838 //*(_QWORD *)((char *)&v24 + 4) = __PAIR__(LODWORD(v24), LODWORD(v23));
Ritor1
parents:
diff changeset
839 v26 = abs((signed)LODWORD(a1.z) - v26);
Ritor1
parents:
diff changeset
840 //v25 = abs((signed)LODWORD(a1.y) - (signed)LODWORD(v24));
Ritor1
parents:
diff changeset
841 //v8 = abs((int)a1.x - (signed)LODWORD(v23));
Ritor1
parents:
diff changeset
842 v25 = abs((signed)LODWORD(a1.y) - (signed)_v24);
Ritor1
parents:
diff changeset
843 v8 = abs((int)a1.x - (signed)_v23);
Ritor1
parents:
diff changeset
844 LODWORD(a5) = v8;
Ritor1
parents:
diff changeset
845 v9 = v25;
Ritor1
parents:
diff changeset
846 v10 = v26;
Ritor1
parents:
diff changeset
847 if ( v8 < v25 )
Ritor1
parents:
diff changeset
848 {
Ritor1
parents:
diff changeset
849 v11 = v8;
Ritor1
parents:
diff changeset
850 v8 = v25;
Ritor1
parents:
diff changeset
851 v9 = v11;
Ritor1
parents:
diff changeset
852 }
Ritor1
parents:
diff changeset
853 if ( v8 < v26 )
Ritor1
parents:
diff changeset
854 {
Ritor1
parents:
diff changeset
855 v12 = v8;
Ritor1
parents:
diff changeset
856 v8 = v26;
Ritor1
parents:
diff changeset
857 v10 = v12;
Ritor1
parents:
diff changeset
858 }
Ritor1
parents:
diff changeset
859 if ( v9 < (signed int)v10 )
Ritor1
parents:
diff changeset
860 {
Ritor1
parents:
diff changeset
861 v13 = v10;
Ritor1
parents:
diff changeset
862 v10 = v9;
Ritor1
parents:
diff changeset
863 v9 = v13;
Ritor1
parents:
diff changeset
864 }
Ritor1
parents:
diff changeset
865 v14 = (double)(signed int)(((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8);
Ritor1
parents:
diff changeset
866 if ( v14 <= a3 )
Ritor1
parents:
diff changeset
867 {
Ritor1
parents:
diff changeset
868 a5 = v14 / a3;
Ritor1
parents:
diff changeset
869 v16 = (double)(signed int)a1.x;
Ritor1
parents:
diff changeset
870 *(float *)&v23 = (double)SLODWORD(a1.y);
Ritor1
parents:
diff changeset
871 LODWORD(a1.x) = *(unsigned int *)LODWORD(v7);
Ritor1
parents:
diff changeset
872 v17 = LODWORD(v7) + 4;
Ritor1
parents:
diff changeset
873 *((float *)&v23 + 1) = (double)SLODWORD(a1.z);
Ritor1
parents:
diff changeset
874 LODWORD(a1.y) = *(unsigned int *)v17;
Ritor1
parents:
diff changeset
875 LODWORD(a1.z) = *(unsigned int *)(v17 + 4);
Ritor1
parents:
diff changeset
876 a3 = *((float *)&v23 + 1) - a1.z;
Ritor1
parents:
diff changeset
877 a1.z = a3;
Ritor1
parents:
diff changeset
878 a1.x = v16 - a1.x;
Ritor1
parents:
diff changeset
879 a1.y = (float)v23 - a1.y;
Ritor1
parents:
diff changeset
880 a1.Normalize();
Ritor1
parents:
diff changeset
881 if ( uLightType & 4 )
Ritor1
parents:
diff changeset
882 {
Ritor1
parents:
diff changeset
883 v22[1] = v18;
Ritor1
parents:
diff changeset
884 uLightType = dword_4D86D8;
Ritor1
parents:
diff changeset
885 v22[0] = v18;
Ritor1
parents:
diff changeset
886 v19 = fabs(a1.z * pNormal->z + a1.y * pNormal->y + a1.x * pNormal->x);
Ritor1
parents:
diff changeset
887 v20 = v19 * *(float *)&uLightType * a2;
Ritor1
parents:
diff changeset
888 }
Ritor1
parents:
diff changeset
889 else
Ritor1
parents:
diff changeset
890 {
Ritor1
parents:
diff changeset
891 if ( uLightType & 8 )
Ritor1
parents:
diff changeset
892 {
Ritor1
parents:
diff changeset
893 v20 = 1.3 * a2;
Ritor1
parents:
diff changeset
894 }
Ritor1
parents:
diff changeset
895 else
Ritor1
parents:
diff changeset
896 {
Ritor1
parents:
diff changeset
897 MessageBoxW(nullptr, L"Invalid light type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:783", 0);
Ritor1
parents:
diff changeset
898 v20 = *(float *)&uLightType;
Ritor1
parents:
diff changeset
899 }
Ritor1
parents:
diff changeset
900 }
Ritor1
parents:
diff changeset
901 result = v20 - a5 * v20;
Ritor1
parents:
diff changeset
902 }
Ritor1
parents:
diff changeset
903 else
Ritor1
parents:
diff changeset
904 {
Ritor1
parents:
diff changeset
905 result = 0.0;
Ritor1
parents:
diff changeset
906 }
Ritor1
parents:
diff changeset
907 return result;
Ritor1
parents:
diff changeset
908 }
Ritor1
parents:
diff changeset
909 // 4D86D8: using guessed type int dword_4D86D8;
Ritor1
parents:
diff changeset
910
Ritor1
parents:
diff changeset
911 //----- (0045CDB7) --------------------------------------------------------
Ritor1
parents:
diff changeset
912 bool LightmapBuilder::ApplyLights_OutdoorFace(ODMFace *pFace)
Ritor1
parents:
diff changeset
913 {
Ritor1
parents:
diff changeset
914 int v2; // esi@1
Ritor1
parents:
diff changeset
915 int v3; // eax@1
Ritor1
parents:
diff changeset
916 MobileLight *pMobileLight; // ebx@2
Ritor1
parents:
diff changeset
917 int v5; // esi@5
Ritor1
parents:
diff changeset
918 StationaryLight *pStationaryLight; // ebx@6
Ritor1
parents:
diff changeset
919 bool result; // eax@9
Ritor1
parents:
diff changeset
920 LightmapBuilder *thisa; // [sp+Ch] [bp-8h]@1
Ritor1
parents:
diff changeset
921 int pSlot; // [sp+10h] [bp-4h]@1
Ritor1
parents:
diff changeset
922
Ritor1
parents:
diff changeset
923 v2 = 0;
Ritor1
parents:
diff changeset
924 thisa = this;
Ritor1
parents:
diff changeset
925 v3 = stru_F8AD28.uDefaultAmbientLightLevel + pFace->uShadeType;
Ritor1
parents:
diff changeset
926 pSlot = 0;
Ritor1
parents:
diff changeset
927 stru_F8AD28.uCurrentAmbientLightLevel = v3 << 16;
Ritor1
parents:
diff changeset
928 if ( pMobileLightsStack->uNumLightsActive > 0 )
Ritor1
parents:
diff changeset
929 {
Ritor1
parents:
diff changeset
930 pMobileLight = pMobileLightsStack->pLights;
Ritor1
parents:
diff changeset
931 do
Ritor1
parents:
diff changeset
932 {
Ritor1
parents:
diff changeset
933 if ( pSlot >= 20 )
Ritor1
parents:
diff changeset
934 break;
Ritor1
parents:
diff changeset
935 ApplyLight_ODM((StationaryLight *)pMobileLight, pFace, (unsigned int *)&pSlot, 1);
Ritor1
parents:
diff changeset
936 ++v2;
Ritor1
parents:
diff changeset
937 ++pMobileLight;
Ritor1
parents:
diff changeset
938 }
Ritor1
parents:
diff changeset
939 while ( v2 < pMobileLightsStack->uNumLightsActive );
Ritor1
parents:
diff changeset
940 }
Ritor1
parents:
diff changeset
941 v5 = 0;
Ritor1
parents:
diff changeset
942 if ( pStationaryLightsStack->uNumLightsActive > 0 )
Ritor1
parents:
diff changeset
943 {
Ritor1
parents:
diff changeset
944 pStationaryLight = pStationaryLightsStack->pLights;
Ritor1
parents:
diff changeset
945 do
Ritor1
parents:
diff changeset
946 {
Ritor1
parents:
diff changeset
947 if ( pSlot >= 20 )
Ritor1
parents:
diff changeset
948 break;
Ritor1
parents:
diff changeset
949 ApplyLight_ODM(pStationaryLight, pFace, (unsigned int *)&pSlot, 0);
Ritor1
parents:
diff changeset
950 ++v5;
Ritor1
parents:
diff changeset
951 ++pStationaryLight;
Ritor1
parents:
diff changeset
952 }
Ritor1
parents:
diff changeset
953 while ( v5 < pStationaryLightsStack->uNumLightsActive );
Ritor1
parents:
diff changeset
954 }
Ritor1
parents:
diff changeset
955 result = pSlot;
Ritor1
parents:
diff changeset
956 stru_F8AD28.uNumLightsApplied = pSlot;
Ritor1
parents:
diff changeset
957 return true;
Ritor1
parents:
diff changeset
958 }
Ritor1
parents:
diff changeset
959
Ritor1
parents:
diff changeset
960 //----- (0045CE50) --------------------------------------------------------
Ritor1
parents:
diff changeset
961 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4)
Ritor1
parents:
diff changeset
962 {
Ritor1
parents:
diff changeset
963 int result; // eax@0
Ritor1
parents:
diff changeset
964 signed int v6; // ebx@1
Ritor1
parents:
diff changeset
965 int v7; // ecx@2
Ritor1
parents:
diff changeset
966 int v8; // esi@4
Ritor1
parents:
diff changeset
967 int v9; // edx@6
Ritor1
parents:
diff changeset
968 int v10; // ecx@8
Ritor1
parents:
diff changeset
969 int v11; // eax@11
Ritor1
parents:
diff changeset
970 unsigned int v12; // ebx@11
Ritor1
parents:
diff changeset
971 RenderD3D *v13; // ecx@11
Ritor1
parents:
diff changeset
972 char v14; // dl@11
Ritor1
parents:
diff changeset
973
62
80484cf3a683 23.01.13 DrawParticles_ODM
Ritor1
parents: 61
diff changeset
974 //__debugbreak();
0
Ritor1
parents:
diff changeset
975
Ritor1
parents:
diff changeset
976 v6 = pLight->uRadius;
Ritor1
parents:
diff changeset
977 if ( v6 > 0
Ritor1
parents:
diff changeset
978 && (result = (int)pFace, v7 = pLight->vPosition.x, v7 > pFace->pBoundingBox.x1 - v6)
Ritor1
parents:
diff changeset
979 && v7 < v6 + pFace->pBoundingBox.x2
Ritor1
parents:
diff changeset
980 && (v8 = pLight->vPosition.y, v8 > pFace->pBoundingBox.y1 - v6)
Ritor1
parents:
diff changeset
981 && v8 < v6 + pFace->pBoundingBox.y2
Ritor1
parents:
diff changeset
982 && (v9 = pLight->vPosition.z, v9 > pFace->pBoundingBox.z1 - v6)
Ritor1
parents:
diff changeset
983 && v9 < v6 + pFace->pBoundingBox.z2
Ritor1
parents:
diff changeset
984 && ((v10 = (pFace->pFacePlane.dist
Ritor1
parents:
diff changeset
985 + pLight->vPosition.x * pFace->pFacePlane.vNormal.x
Ritor1
parents:
diff changeset
986 + v8 * pFace->pFacePlane.vNormal.y
Ritor1
parents:
diff changeset
987 + v9 * pFace->pFacePlane.vNormal.z) >> 16,
Ritor1
parents:
diff changeset
988 a4)
Ritor1
parents:
diff changeset
989 || v10 >= 0)
Ritor1
parents:
diff changeset
990 && v10 <= v6 )
Ritor1
parents:
diff changeset
991 {
Ritor1
parents:
diff changeset
992 stru_F8AD28._blv_lights_radii[*pSlot] = v6;
Ritor1
parents:
diff changeset
993 stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v6;
Ritor1
parents:
diff changeset
994 stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x;
Ritor1
parents:
diff changeset
995 stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y;
Ritor1
parents:
diff changeset
996 stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z;
Ritor1
parents:
diff changeset
997 stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689;
Ritor1
parents:
diff changeset
998 stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
Ritor1
parents:
diff changeset
999 stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
Ritor1
parents:
diff changeset
1000 v11 = abs(v10);
Ritor1
parents:
diff changeset
1001 v12 = pRenderer->bUsingSpecular;
Ritor1
parents:
diff changeset
1002 stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11;
Ritor1
parents:
diff changeset
1003 stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType;
Ritor1
parents:
diff changeset
1004 v13 = pRenderer->pRenderD3D;
Ritor1
parents:
diff changeset
1005 v14 = stru_F8AD28._blv_lights_types[*pSlot];
Ritor1
parents:
diff changeset
1006 if ( pRenderer->pRenderD3D && v12 && v14 & 4 )
Ritor1
parents:
diff changeset
1007 v14 = _4E94D2_light_type;
Ritor1
parents:
diff changeset
1008 stru_F8AD28._blv_lights_types[*pSlot] = v14;
Ritor1
parents:
diff changeset
1009 result = 4 * *pSlot;
Ritor1
parents:
diff changeset
1010 if ( v13 && v12 )
Ritor1
parents:
diff changeset
1011 {
Ritor1
parents:
diff changeset
1012 if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 )
Ritor1
parents:
diff changeset
1013 {
Ritor1
parents:
diff changeset
1014 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
Ritor1
parents:
diff changeset
1015 * 0.33000001;
Ritor1
parents:
diff changeset
1016 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result)
Ritor1
parents:
diff changeset
1017 * 0.33000001;
Ritor1
parents:
diff changeset
1018 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result)
Ritor1
parents:
diff changeset
1019 * 0.33000001;
Ritor1
parents:
diff changeset
1020 }
Ritor1
parents:
diff changeset
1021 }
Ritor1
parents:
diff changeset
1022 ++*pSlot;
Ritor1
parents:
diff changeset
1023 LOBYTE(result) = 1;
Ritor1
parents:
diff changeset
1024 }
Ritor1
parents:
diff changeset
1025 else
Ritor1
parents:
diff changeset
1026 {
Ritor1
parents:
diff changeset
1027 LOBYTE(result) = 0;
Ritor1
parents:
diff changeset
1028 }
Ritor1
parents:
diff changeset
1029 return result;
Ritor1
parents:
diff changeset
1030 }
Ritor1
parents:
diff changeset
1031 // 4E94D2: using guessed type char _4E94D2_light_type;
Ritor1
parents:
diff changeset
1032
Ritor1
parents:
diff changeset
1033 //----- (0045D036) --------------------------------------------------------
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1034 bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a2, RenderVertexSoft *a3, unsigned int uStripType, bool bLightBackfaces)
0
Ritor1
parents:
diff changeset
1035 {
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1036 /*int v6; // esi@1
0
Ritor1
parents:
diff changeset
1037 //LightmapBuilder *v7; // edi@1
Ritor1
parents:
diff changeset
1038 MobileLight *v8; // ebx@2
Ritor1
parents:
diff changeset
1039 int v9; // esi@5
Ritor1
parents:
diff changeset
1040 StationaryLight *v10; // ebx@6
Ritor1
parents:
diff changeset
1041 //bool result; // eax@9
Ritor1
parents:
diff changeset
1042 unsigned int a7; // [sp+Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
1043
Ritor1
parents:
diff changeset
1044 v6 = 0;
Ritor1
parents:
diff changeset
1045 //v7 = this;
Ritor1
parents:
diff changeset
1046 a7 = 0;
Ritor1
parents:
diff changeset
1047 stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type;
Ritor1
parents:
diff changeset
1048 if ( pMobileLightsStack->uNumLightsActive > 0 )
Ritor1
parents:
diff changeset
1049 {
Ritor1
parents:
diff changeset
1050 v8 = pMobileLightsStack->pLights;
Ritor1
parents:
diff changeset
1051 do
Ritor1
parents:
diff changeset
1052 {
Ritor1
parents:
diff changeset
1053 if ( (signed int)a7 >= 20 )
Ritor1
parents:
diff changeset
1054 break;
Ritor1
parents:
diff changeset
1055 StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, bLightBackfaces, &a7);
Ritor1
parents:
diff changeset
1056 ++v6;
Ritor1
parents:
diff changeset
1057 ++v8;
Ritor1
parents:
diff changeset
1058 }
Ritor1
parents:
diff changeset
1059 while ( v6 < pMobileLightsStack->uNumLightsActive );
Ritor1
parents:
diff changeset
1060 }
Ritor1
parents:
diff changeset
1061 v9 = 0;
Ritor1
parents:
diff changeset
1062 if ( pStationaryLightsStack->uNumLightsActive > 0 )
Ritor1
parents:
diff changeset
1063 {
Ritor1
parents:
diff changeset
1064 v10 = pStationaryLightsStack->pLights;
Ritor1
parents:
diff changeset
1065 do
Ritor1
parents:
diff changeset
1066 {
Ritor1
parents:
diff changeset
1067 if ( (signed int)a7 >= 20 )
Ritor1
parents:
diff changeset
1068 break;
Ritor1
parents:
diff changeset
1069 StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, bLightBackfaces, &a7);
Ritor1
parents:
diff changeset
1070 ++v9;
Ritor1
parents:
diff changeset
1071 ++v10;
Ritor1
parents:
diff changeset
1072 }
Ritor1
parents:
diff changeset
1073 while ( v9 < pStationaryLightsStack->uNumLightsActive );
Ritor1
parents:
diff changeset
1074 }
Ritor1
parents:
diff changeset
1075
Ritor1
parents:
diff changeset
1076 stru_F8AD28.uNumLightsApplied = a7;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1077 return true;*/
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1078 // 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
1079 //{
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1080 float v6; // ebx@2
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1081 unsigned int v10; // [sp+Ch] [bp-4h]@1
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1082 int i;
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1083
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1084 v10 = 0;
638
ccf8b4815a1f GetActorTintColor fixed
Nomad
parents: 595
diff changeset
1085 stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1086 for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1087 {
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1088 if ( v10 >= 20 )
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1089 break;
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1090 StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10);
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1091 }
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1092
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1093 for (i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1094 {
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1095 if ( v10 >= 20 )
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1096 break;
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1097 StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10);
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1098 }
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1099
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1100 stru_F8AD28.uNumLightsApplied = v10;
0
Ritor1
parents:
diff changeset
1101 return true;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1102
0
Ritor1
parents:
diff changeset
1103 }
Ritor1
parents:
diff changeset
1104 // 519AB4: using guessed type int uNumStationaryLightsApplied;
Ritor1
parents:
diff changeset
1105
Ritor1
parents:
diff changeset
1106 //----- (0045D0D5) --------------------------------------------------------
Ritor1
parents:
diff changeset
1107 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
1108 {
Ritor1
parents:
diff changeset
1109 StationaryLight *v8; // edi@1
Ritor1
parents:
diff changeset
1110 bool result; // eax@1
Ritor1
parents:
diff changeset
1111 unsigned int v10; // esi@2
Ritor1
parents:
diff changeset
1112 RenderVertexSoft *v11; // ebx@2
Ritor1
parents:
diff changeset
1113 float v12; // eax@3
Ritor1
parents:
diff changeset
1114 float v13; // eax@4
Ritor1
parents:
diff changeset
1115 double v14; // st7@11
Ritor1
parents:
diff changeset
1116 double maxz; // st7@11
Ritor1
parents:
diff changeset
1117 double v16; // st7@11
Ritor1
parents:
diff changeset
1118 double v17; // st6@11
Ritor1
parents:
diff changeset
1119 __int16 v18; // fps@11
Ritor1
parents:
diff changeset
1120 char v19; // c0@11
Ritor1
parents:
diff changeset
1121 char v20; // c2@11
Ritor1
parents:
diff changeset
1122 char v21; // c3@11
Ritor1
parents:
diff changeset
1123 double v22; // st6@12
Ritor1
parents:
diff changeset
1124 __int16 v23; // fps@12
Ritor1
parents:
diff changeset
1125 char v24; // c0@12
Ritor1
parents:
diff changeset
1126 char v25; // c2@12
Ritor1
parents:
diff changeset
1127 char v26; // c3@12
Ritor1
parents:
diff changeset
1128 double v27; // st7@13
Ritor1
parents:
diff changeset
1129 double v28; // st6@13
Ritor1
parents:
diff changeset
1130 __int16 v29; // fps@13
Ritor1
parents:
diff changeset
1131 char v30; // c0@13
Ritor1
parents:
diff changeset
1132 char v31; // c2@13
Ritor1
parents:
diff changeset
1133 char v32; // c3@13
Ritor1
parents:
diff changeset
1134 double v33; // st6@14
Ritor1
parents:
diff changeset
1135 __int16 v34; // fps@14
Ritor1
parents:
diff changeset
1136 char v35; // c0@14
Ritor1
parents:
diff changeset
1137 char v36; // c2@14
Ritor1
parents:
diff changeset
1138 char v37; // c3@14
Ritor1
parents:
diff changeset
1139 double v38; // st7@15
Ritor1
parents:
diff changeset
1140 double v39; // st6@15
Ritor1
parents:
diff changeset
1141 __int16 v40; // fps@15
Ritor1
parents:
diff changeset
1142 char v41; // c0@15
Ritor1
parents:
diff changeset
1143 char v42; // c2@15
Ritor1
parents:
diff changeset
1144 char v43; // c3@15
Ritor1
parents:
diff changeset
1145 double v44; // st6@16
Ritor1
parents:
diff changeset
1146 __int16 v45; // fps@16
Ritor1
parents:
diff changeset
1147 char v46; // c0@16
Ritor1
parents:
diff changeset
1148 char v47; // c2@16
Ritor1
parents:
diff changeset
1149 char v48; // c3@16
Ritor1
parents:
diff changeset
1150 Vec3_float_ *v49; // esi@17
Ritor1
parents:
diff changeset
1151 double v50; // st7@17
Ritor1
parents:
diff changeset
1152 double v51; // st6@17
Ritor1
parents:
diff changeset
1153 signed int v52; // ecx@17
Ritor1
parents:
diff changeset
1154 unsigned int *v53; // esi@18
Ritor1
parents:
diff changeset
1155 int v54; // eax@18
Ritor1
parents:
diff changeset
1156 unsigned int v55; // ebx@18
Ritor1
parents:
diff changeset
1157 RenderD3D *v56; // ecx@18
Ritor1
parents:
diff changeset
1158 char v57; // dl@18
Ritor1
parents:
diff changeset
1159 std::string v58; // [sp-18h] [bp-38h]@10
Ritor1
parents:
diff changeset
1160 const char *v59; // [sp-8h] [bp-28h]@10
Ritor1
parents:
diff changeset
1161 signed int v60; // [sp-4h] [bp-24h]@10
Ritor1
parents:
diff changeset
1162 double v61; // [sp+Ch] [bp-14h]@11
Ritor1
parents:
diff changeset
1163 float minz; // [sp+14h] [bp-Ch]@11
Ritor1
parents:
diff changeset
1164 int v63; // [sp+18h] [bp-8h]@1
Ritor1
parents:
diff changeset
1165 float v64; // [sp+1Ch] [bp-4h]@5
Ritor1
parents:
diff changeset
1166
Ritor1
parents:
diff changeset
1167 v8 = pLight;
Ritor1
parents:
diff changeset
1168 result = pLight->uRadius;
Ritor1
parents:
diff changeset
1169 v63 = pLight->uRadius;
Ritor1
parents:
diff changeset
1170 if ( result <= 0 )
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1171 return 0;
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1172 //v10 = uStripType;
0
Ritor1
parents:
diff changeset
1173 v11 = a1;
Ritor1
parents:
diff changeset
1174 if ( uStripType == 4 )
Ritor1
parents:
diff changeset
1175 {
Ritor1
parents:
diff changeset
1176 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x);
Ritor1
parents:
diff changeset
1177 v12 = a1[3].vWorldPosition.x;
Ritor1
parents:
diff changeset
1178 }
Ritor1
parents:
diff changeset
1179 else
Ritor1
parents:
diff changeset
1180 {
Ritor1
parents:
diff changeset
1181 if ( uStripType != 3 )
Ritor1
parents:
diff changeset
1182 {
Ritor1
parents:
diff changeset
1183 MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0);
Ritor1
parents:
diff changeset
1184 goto LABEL_11;
Ritor1
parents:
diff changeset
1185 }
Ritor1
parents:
diff changeset
1186 if ( (unsigned char)X )
Ritor1
parents:
diff changeset
1187 {
Ritor1
parents:
diff changeset
1188 pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x);
Ritor1
parents:
diff changeset
1189 uStripType = LODWORD(a1[2].vWorldPosition.x);
Ritor1
parents:
diff changeset
1190 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y);
Ritor1
parents:
diff changeset
1191 v13 = v11[2].vWorldPosition.y;
Ritor1
parents:
diff changeset
1192 goto LABEL_5;
Ritor1
parents:
diff changeset
1193 }
Ritor1
parents:
diff changeset
1194 pLight = (StationaryLight *)LODWORD(a1[1].vWorldPosition.x);
Ritor1
parents:
diff changeset
1195 v12 = a1[2].vWorldPosition.x;
Ritor1
parents:
diff changeset
1196 }
Ritor1
parents:
diff changeset
1197 uStripType = LODWORD(v12);
Ritor1
parents:
diff changeset
1198 a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y);
Ritor1
parents:
diff changeset
1199 v13 = v11->vWorldPosition.y;
Ritor1
parents:
diff changeset
1200 LABEL_5:
Ritor1
parents:
diff changeset
1201 v64 = v13;
Ritor1
parents:
diff changeset
1202 LABEL_11:
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1203 //v60 = v10;
0
Ritor1
parents:
diff changeset
1204 v59 = (const char *)v11;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1205 v60 = uStripType;
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1206 minz = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, uStripType);
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1207 maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, uStripType);
0
Ritor1
parents:
diff changeset
1208 result = v8->vPosition.x;
Ritor1
parents:
diff changeset
1209 *((float *)&v61 + 1) = maxz;
Ritor1
parents:
diff changeset
1210 v16 = (double)result;
Ritor1
parents:
diff changeset
1211 *(float *)&X = (double)v63;
Ritor1
parents:
diff changeset
1212 v17 = *(float *)&pLight - *(float *)&X;
Ritor1
parents:
diff changeset
1213 //UNDEF(v18);
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1214 //v19 = v16 < v17;
0
Ritor1
parents:
diff changeset
1215 v20 = 0;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1216 //v21 = v16 == v17;
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1217 /* BYTE1(result) = HIBYTE(v18);
0
Ritor1
parents:
diff changeset
1218 if ( v16 <= v17
Ritor1
parents:
diff changeset
1219 || (v22 = *(float *)&X + *(float *)&uStripType,
Ritor1
parents:
diff changeset
1220 //UNDEF(v23),
Ritor1
parents:
diff changeset
1221 v24 = v16 < v22,
Ritor1
parents:
diff changeset
1222 v25 = 0,
Ritor1
parents:
diff changeset
1223 v26 = v16 == v22,
Ritor1
parents:
diff changeset
1224 BYTE1(result) = HIBYTE(v23),
Ritor1
parents:
diff changeset
1225 v16 >= v22)
Ritor1
parents:
diff changeset
1226 || (result = v8->vPosition.y,
Ritor1
parents:
diff changeset
1227 pLight = (StationaryLight *)v8->vPosition.y,
Ritor1
parents:
diff changeset
1228 v27 = (double)(signed int)pLight,
Ritor1
parents:
diff changeset
1229 v28 = *(float *)&a1 - *(float *)&X,
Ritor1
parents:
diff changeset
1230 //UNDEF(v29),
Ritor1
parents:
diff changeset
1231 v30 = v27 < v28,
Ritor1
parents:
diff changeset
1232 v31 = 0,
Ritor1
parents:
diff changeset
1233 v32 = v27 == v28,
Ritor1
parents:
diff changeset
1234 BYTE1(result) = HIBYTE(v29),
Ritor1
parents:
diff changeset
1235 v27 <= v28)
Ritor1
parents:
diff changeset
1236 || (v33 = *(float *)&X + v64,
Ritor1
parents:
diff changeset
1237 //UNDEF(v34),
Ritor1
parents:
diff changeset
1238 v35 = v27 < v33,
Ritor1
parents:
diff changeset
1239 v36 = 0,
Ritor1
parents:
diff changeset
1240 v37 = v27 == v33,
Ritor1
parents:
diff changeset
1241 BYTE1(result) = HIBYTE(v34),
Ritor1
parents:
diff changeset
1242 v27 >= v33)
Ritor1
parents:
diff changeset
1243 || (result = v8->vPosition.z,
Ritor1
parents:
diff changeset
1244 pLight = (StationaryLight *)v8->vPosition.z,
Ritor1
parents:
diff changeset
1245 v38 = (double)(signed int)pLight,
Ritor1
parents:
diff changeset
1246 v39 = minz - *(float *)&X,
Ritor1
parents:
diff changeset
1247 //UNDEF(v40),
Ritor1
parents:
diff changeset
1248 v41 = v38 < v39,
Ritor1
parents:
diff changeset
1249 v42 = 0,
Ritor1
parents:
diff changeset
1250 v43 = v38 == v39,
Ritor1
parents:
diff changeset
1251 BYTE1(result) = HIBYTE(v40),
Ritor1
parents:
diff changeset
1252 v38 <= v39)
Ritor1
parents:
diff changeset
1253 || (v44 = *(float *)&X + *((float *)&v61 + 1),
Ritor1
parents:
diff changeset
1254 //UNDEF(v45),
Ritor1
parents:
diff changeset
1255 v46 = v38 < v44,
Ritor1
parents:
diff changeset
1256 v47 = 0,
Ritor1
parents:
diff changeset
1257 v48 = v38 == v44,
Ritor1
parents:
diff changeset
1258 BYTE1(result) = HIBYTE(v45),
Ritor1
parents:
diff changeset
1259 v38 >= v44)
Ritor1
parents:
diff changeset
1260 || (v49 = pNormal,
Ritor1
parents:
diff changeset
1261 Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3),
Ritor1
parents:
diff changeset
1262 X = v8->vPosition.y,
Ritor1
parents:
diff changeset
1263 v50 = (double)X * v49->y,
Ritor1
parents:
diff changeset
1264 X = v8->vPosition.z,
Ritor1
parents:
diff changeset
1265 v51 = (double)X * v49->z,
Ritor1
parents:
diff changeset
1266 X = v8->vPosition.x,
Ritor1
parents:
diff changeset
1267 *(float *)&a3 = v50 + v51 + (double)X * v49->x + *a3,
Ritor1
parents:
diff changeset
1268 v61 = *(float *)&a3 + 6.7553994e15,
Ritor1
parents:
diff changeset
1269 result = LODWORD(v61),
Ritor1
parents:
diff changeset
1270 X = LODWORD(v61),
Ritor1
parents:
diff changeset
1271 v52 = v63,
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1272 SLODWORD(v61) > v63) )*/
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1273 if (0)
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1274 return 0;
0
Ritor1
parents:
diff changeset
1275 v53 = pSlot;
Ritor1
parents:
diff changeset
1276 v60 = X;
Ritor1
parents:
diff changeset
1277 stru_F8AD28._blv_lights_radii[*pSlot] = v63;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1278 stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v63;
0
Ritor1
parents:
diff changeset
1279 stru_F8AD28._blv_lights_xs[*v53] = v8->vPosition.x;
Ritor1
parents:
diff changeset
1280 stru_F8AD28._blv_lights_ys[*v53] = v8->vPosition.y;
Ritor1
parents:
diff changeset
1281 stru_F8AD28._blv_lights_zs[*v53] = v8->vPosition.z;
Ritor1
parents:
diff changeset
1282 a3 = (float *)v8->uLightColorR;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1283 stru_F8AD28._blv_lights_rs[*v53] = (double)(signed int)a3 * 0.003921568859368563;
0
Ritor1
parents:
diff changeset
1284 a3 = (float *)v8->uLightColorG;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1285 stru_F8AD28._blv_lights_gs[*v53] = (double)(signed int)a3 * 0.003921568859368563;
0
Ritor1
parents:
diff changeset
1286 a3 = (float *)v8->uLightColorB;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1287 stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.003921568859368563;
0
Ritor1
parents:
diff changeset
1288 v54 = abs(v60);
Ritor1
parents:
diff changeset
1289 v55 = pRenderer->bUsingSpecular;
Ritor1
parents:
diff changeset
1290 stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54;
Ritor1
parents:
diff changeset
1291 stru_F8AD28._blv_lights_types[*v53] = v8->uLightType;
Ritor1
parents:
diff changeset
1292 v56 = pRenderer->pRenderD3D;
Ritor1
parents:
diff changeset
1293 v57 = stru_F8AD28._blv_lights_types[*v53];
Ritor1
parents:
diff changeset
1294 if ( pRenderer->pRenderD3D && v55 && v57 & 4 )
Ritor1
parents:
diff changeset
1295 v57 = _4E94D2_light_type;
Ritor1
parents:
diff changeset
1296 stru_F8AD28._blv_lights_types[*v53] = v57;
Ritor1
parents:
diff changeset
1297 result = 4 * *v53;
Ritor1
parents:
diff changeset
1298 if ( v56 && v55 )
Ritor1
parents:
diff changeset
1299 {
Ritor1
parents:
diff changeset
1300 if ( stru_F8AD28._blv_lights_types[*v53] & 4 )
Ritor1
parents:
diff changeset
1301 {
Ritor1
parents:
diff changeset
1302 *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1303 * 0.3300000131130219;
0
Ritor1
parents:
diff changeset
1304 *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result)
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1305 * 0.3300000131130219;
0
Ritor1
parents:
diff changeset
1306 *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result)
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1307 * 0.3300000131130219;
0
Ritor1
parents:
diff changeset
1308 }
Ritor1
parents:
diff changeset
1309 }
Ritor1
parents:
diff changeset
1310 ++*v53;
86
ec84db4c8f9d 4.01.13
Ritor1
parents: 64
diff changeset
1311 return 1;
0
Ritor1
parents:
diff changeset
1312 }
Ritor1
parents:
diff changeset
1313 // 4E94D2: using guessed type char _4E94D2_light_type;
Ritor1
parents:
diff changeset
1314
Ritor1
parents:
diff changeset
1315 //----- (0045D3C7) --------------------------------------------------------
Ritor1
parents:
diff changeset
1316 bool LightmapBuilder::_45D3C7(stru148 *a1)
Ritor1
parents:
diff changeset
1317 {
Ritor1
parents:
diff changeset
1318 LightmapBuilder *v2; // ebx@1
Ritor1
parents:
diff changeset
1319 stru148 *result; // eax@1
Ritor1
parents:
diff changeset
1320 float v4; // ecx@2
Ritor1
parents:
diff changeset
1321 Span *i; // edi@5
Ritor1
parents:
diff changeset
1322
Ritor1
parents:
diff changeset
1323 v2 = this;
Ritor1
parents:
diff changeset
1324 result = (stru148 *)a1->prolly_head;
Ritor1
parents:
diff changeset
1325 if ( result && (v4 = result->field_4, *(int *)&v4) != 0 && *(unsigned int *)(LODWORD(v4) + 60) )
Ritor1
parents:
diff changeset
1326 {
Ritor1
parents:
diff changeset
1327 for ( i = a1->prolly_head; ; i = i->pNext )
Ritor1
parents:
diff changeset
1328 {
Ritor1
parents:
diff changeset
1329 result = i->pParent;
Ritor1
parents:
diff changeset
1330 if ( result->field_108 )
Ritor1
parents:
diff changeset
1331 result = (stru148 *)_45D426(
Ritor1
parents:
diff changeset
1332 i,
Ritor1
parents:
diff changeset
1333 a1->pEdgeList1,
Ritor1
parents:
diff changeset
1334 a1->uEdgeList1Size,
Ritor1
parents:
diff changeset
1335 (Edge *)a1->pEdgeList2,
Ritor1
parents:
diff changeset
1336 a1->uEdgeList2Size);
Ritor1
parents:
diff changeset
1337 if ( a1->prolly_tail == i )
Ritor1
parents:
diff changeset
1338 break;
Ritor1
parents:
diff changeset
1339 }
Ritor1
parents:
diff changeset
1340 LOBYTE(result) = 1;
Ritor1
parents:
diff changeset
1341 }
Ritor1
parents:
diff changeset
1342 else
Ritor1
parents:
diff changeset
1343 {
Ritor1
parents:
diff changeset
1344 LOBYTE(result) = 0;
Ritor1
parents:
diff changeset
1345 }
Ritor1
parents:
diff changeset
1346 return (bool)result;
Ritor1
parents:
diff changeset
1347 }
Ritor1
parents:
diff changeset
1348
Ritor1
parents:
diff changeset
1349 //----- (0045D426) --------------------------------------------------------
Ritor1
parents:
diff changeset
1350 int LightmapBuilder::_45D426(Span *a1, Edge **a2, unsigned int a3, Edge *a4, int a5)
Ritor1
parents:
diff changeset
1351 {
Ritor1
parents:
diff changeset
1352 int v6; // edi@1
Ritor1
parents:
diff changeset
1353 signed int v7; // ebx@3
Ritor1
parents:
diff changeset
1354 signed int v8; // ecx@3
Ritor1
parents:
diff changeset
1355 Span *v9; // esi@3
Ritor1
parents:
diff changeset
1356 double v10; // st7@4
Ritor1
parents:
diff changeset
1357 Edge *v11; // edx@5
Ritor1
parents:
diff changeset
1358 double v12; // st7@11
Ritor1
parents:
diff changeset
1359 int v13; // edx@12
Ritor1
parents:
diff changeset
1360 int v14; // ebx@17
Ritor1
parents:
diff changeset
1361 Edge *v15; // edi@17
Ritor1
parents:
diff changeset
1362 float v16; // ST04_4@17
Ritor1
parents:
diff changeset
1363 float v17; // ST04_4@17
Ritor1
parents:
diff changeset
1364 double v18; // st7@17
Ritor1
parents:
diff changeset
1365 int result; // eax@19
Ritor1
parents:
diff changeset
1366 //double v20; // ST14_8@20
Ritor1
parents:
diff changeset
1367 //double v21; // ST14_8@20
Ritor1
parents:
diff changeset
1368 double v22; // st7@20
Ritor1
parents:
diff changeset
1369 int v23; // ecx@20
Ritor1
parents:
diff changeset
1370 double v24; // st6@20
Ritor1
parents:
diff changeset
1371 double v25; // st7@23
Ritor1
parents:
diff changeset
1372 double v26; // st7@28
Ritor1
parents:
diff changeset
1373 __int16 v27; // fps@28
Ritor1
parents:
diff changeset
1374 char v28; // c0@28
Ritor1
parents:
diff changeset
1375 char v29; // c2@28
Ritor1
parents:
diff changeset
1376 char v30; // c3@28
Ritor1
parents:
diff changeset
1377 double v31; // st7@29
Ritor1
parents:
diff changeset
1378 double v32; // st7@30
Ritor1
parents:
diff changeset
1379 __int16 v33; // fps@30
Ritor1
parents:
diff changeset
1380 char v34; // c0@30
Ritor1
parents:
diff changeset
1381 char v35; // c2@30
Ritor1
parents:
diff changeset
1382 char v36; // c3@30
Ritor1
parents:
diff changeset
1383 LightmapBuilder *this_4; // [sp+14h] [bp-8h]@1
Ritor1
parents:
diff changeset
1384 signed int v38; // [sp+18h] [bp-4h]@3
Ritor1
parents:
diff changeset
1385 float a1a; // [sp+24h] [bp+8h]@20
Ritor1
parents:
diff changeset
1386 float a2a; // [sp+28h] [bp+Ch]@17
Ritor1
parents:
diff changeset
1387 float a3a; // [sp+2Ch] [bp+10h]@17
Ritor1
parents:
diff changeset
1388 float a5a; // [sp+34h] [bp+18h]@20
Ritor1
parents:
diff changeset
1389 float a5b; // [sp+34h] [bp+18h]@20
Ritor1
parents:
diff changeset
1390
Ritor1
parents:
diff changeset
1391 v6 = 0;
Ritor1
parents:
diff changeset
1392 this_4 = this;
Ritor1
parents:
diff changeset
1393 if ( a5 && a3 )
Ritor1
parents:
diff changeset
1394 {
Ritor1
parents:
diff changeset
1395 v7 = -1;
Ritor1
parents:
diff changeset
1396 v8 = 0;
Ritor1
parents:
diff changeset
1397 v9 = a1;
Ritor1
parents:
diff changeset
1398 v38 = -1;
Ritor1
parents:
diff changeset
1399 if ( (signed int)a3 > 0 )
Ritor1
parents:
diff changeset
1400 {
Ritor1
parents:
diff changeset
1401 v10 = (double)a1->field_A;
Ritor1
parents:
diff changeset
1402 while ( 1 )
Ritor1
parents:
diff changeset
1403 {
Ritor1
parents:
diff changeset
1404 v11 = a2[v8];
Ritor1
parents:
diff changeset
1405 if ( v10 >= v11->field_2C )
Ritor1
parents:
diff changeset
1406 {
Ritor1
parents:
diff changeset
1407 if ( v10 <= v11->field_30 )
Ritor1
parents:
diff changeset
1408 break;
Ritor1
parents:
diff changeset
1409 }
Ritor1
parents:
diff changeset
1410 ++v8;
Ritor1
parents:
diff changeset
1411 if ( v8 >= (signed int)a3 )
Ritor1
parents:
diff changeset
1412 goto LABEL_10;
Ritor1
parents:
diff changeset
1413 }
Ritor1
parents:
diff changeset
1414 v38 = v8;
Ritor1
parents:
diff changeset
1415 }
Ritor1
parents:
diff changeset
1416 LABEL_10:
Ritor1
parents:
diff changeset
1417 if ( a5 > 0 )
Ritor1
parents:
diff changeset
1418 {
Ritor1
parents:
diff changeset
1419 v12 = (double)a1->field_A;
Ritor1
parents:
diff changeset
1420 while ( 1 )
Ritor1
parents:
diff changeset
1421 {
Ritor1
parents:
diff changeset
1422 v13 = *((unsigned int *)&a4->field_0 + v6);
Ritor1
parents:
diff changeset
1423 if ( v12 >= *(float *)(v13 + 44) )
Ritor1
parents:
diff changeset
1424 {
Ritor1
parents:
diff changeset
1425 if ( v12 <= *(float *)(v13 + 48) )
Ritor1
parents:
diff changeset
1426 break;
Ritor1
parents:
diff changeset
1427 }
Ritor1
parents:
diff changeset
1428 ++v6;
Ritor1
parents:
diff changeset
1429 if ( v6 >= a5 )
Ritor1
parents:
diff changeset
1430 goto LABEL_17;
Ritor1
parents:
diff changeset
1431 }
Ritor1
parents:
diff changeset
1432 v7 = v6;
Ritor1
parents:
diff changeset
1433 }
Ritor1
parents:
diff changeset
1434 LABEL_17:
Ritor1
parents:
diff changeset
1435 v14 = *((unsigned int *)&a4->field_0 + v7);
Ritor1
parents:
diff changeset
1436 v15 = a2[v38];
Ritor1
parents:
diff changeset
1437 v16 = (double)a1->field_A;
Ritor1
parents:
diff changeset
1438 a3a = _45D643(a2[v38], v16);
Ritor1
parents:
diff changeset
1439 v17 = (double)a1->field_A;
Ritor1
parents:
diff changeset
1440 v18 = _45D643((Edge *)v14, v17);
Ritor1
parents:
diff changeset
1441 a2a = v18;
Ritor1
parents:
diff changeset
1442 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x80 )
Ritor1
parents:
diff changeset
1443 {
Ritor1
parents:
diff changeset
1444 HIWORD(result) = HIWORD(a3a);
Ritor1
parents:
diff changeset
1445 a1->field_14 = v18;
Ritor1
parents:
diff changeset
1446 a1->field_10 = a3a;
Ritor1
parents:
diff changeset
1447 }
Ritor1
parents:
diff changeset
1448 else
Ritor1
parents:
diff changeset
1449 {
Ritor1
parents:
diff changeset
1450 a5a = ((double)a1->field_A - v15->field_2C) * v15->field_4 + v15->field_24 - 0.5;
Ritor1
parents:
diff changeset
1451 //v20 = a5a + 6.7553994e15;
Ritor1
parents:
diff changeset
1452 //a5b = (double)SLODWORD(v20);
Ritor1
parents:
diff changeset
1453 a5b = (double)floorf(a5a + 0.5f);
Ritor1
parents:
diff changeset
1454 a1a = ((double)a1->field_A - *(float *)(v14 + 44)) * *(float *)(v14 + 4) + *(float *)(v14 + 36) + 0.5;
Ritor1
parents:
diff changeset
1455 //v21 = a1a + 6.7553994e15;
Ritor1
parents:
diff changeset
1456 //v22 = (double)SLODWORD(v21);
Ritor1
parents:
diff changeset
1457 v22 = (double)floorf(a1a + 0.5f);
Ritor1
parents:
diff changeset
1458 result = v9->field_8;
Ritor1
parents:
diff changeset
1459 v23 = v9->field_C;
Ritor1
parents:
diff changeset
1460 v24 = -((a3a - a2a) / (v22 - a5b));
Ritor1
parents:
diff changeset
1461 v9->field_10 = ((double)result - a5b) * v24 + a3a;
Ritor1
parents:
diff changeset
1462 v9->field_14 = a2a - (v22 - (double)(result + v23)) * v24;
Ritor1
parents:
diff changeset
1463 }
Ritor1
parents:
diff changeset
1464 if ( v9->field_10 < 0.0 || v9->field_10 <= 1.0 )
Ritor1
parents:
diff changeset
1465 {
Ritor1
parents:
diff changeset
1466 if ( v9->field_10 >= 0.0 )
Ritor1
parents:
diff changeset
1467 v25 = v9->field_10;
Ritor1
parents:
diff changeset
1468 else
Ritor1
parents:
diff changeset
1469 v25 = 0.0;
Ritor1
parents:
diff changeset
1470 }
Ritor1
parents:
diff changeset
1471 else
Ritor1
parents:
diff changeset
1472 {
Ritor1
parents:
diff changeset
1473 v25 = 1.0;
Ritor1
parents:
diff changeset
1474 }
Ritor1
parents:
diff changeset
1475 v9->field_10 = v25;
Ritor1
parents:
diff changeset
1476 if ( v9->field_14 < 0.0
Ritor1
parents:
diff changeset
1477 || (v26 = v9->field_14,
Ritor1
parents:
diff changeset
1478 //UNDEF(v27),
Ritor1
parents:
diff changeset
1479 v28 = 1.0 < v26,
Ritor1
parents:
diff changeset
1480 v29 = 0,
Ritor1
parents:
diff changeset
1481 v30 = 1.0 == v26,
Ritor1
parents:
diff changeset
1482 BYTE1(result) = HIBYTE(v27),
Ritor1
parents:
diff changeset
1483 v26 <= 1.0) )
Ritor1
parents:
diff changeset
1484 {
Ritor1
parents:
diff changeset
1485 v32 = v9->field_14;
Ritor1
parents:
diff changeset
1486 //UNDEF(v33);
Ritor1
parents:
diff changeset
1487 v34 = 0.0 < v32;
Ritor1
parents:
diff changeset
1488 v35 = 0;
Ritor1
parents:
diff changeset
1489 v36 = 0.0 == v32;
Ritor1
parents:
diff changeset
1490 BYTE1(result) = HIBYTE(v33);
Ritor1
parents:
diff changeset
1491 if ( v32 >= 0.0 )
Ritor1
parents:
diff changeset
1492 v31 = v9->field_14;
Ritor1
parents:
diff changeset
1493 else
Ritor1
parents:
diff changeset
1494 v31 = 0.0;
Ritor1
parents:
diff changeset
1495 }
Ritor1
parents:
diff changeset
1496 else
Ritor1
parents:
diff changeset
1497 {
Ritor1
parents:
diff changeset
1498 v31 = 1.0;
Ritor1
parents:
diff changeset
1499 }
Ritor1
parents:
diff changeset
1500 v9->field_14 = v31;
Ritor1
parents:
diff changeset
1501 LOBYTE(result) = 1;
Ritor1
parents:
diff changeset
1502 }
Ritor1
parents:
diff changeset
1503 else
Ritor1
parents:
diff changeset
1504 {
Ritor1
parents:
diff changeset
1505 LOBYTE(result) = 0;
Ritor1
parents:
diff changeset
1506 }
Ritor1
parents:
diff changeset
1507 return result;
Ritor1
parents:
diff changeset
1508 }
Ritor1
parents:
diff changeset
1509 // 4D864C: using guessed type char byte_4D864C;
Ritor1
parents:
diff changeset
1510
Ritor1
parents:
diff changeset
1511 //----- (0045D643) --------------------------------------------------------
Ritor1
parents:
diff changeset
1512 double LightmapBuilder::_45D643(Edge *a1, float a2)
Ritor1
parents:
diff changeset
1513 {
Ritor1
parents:
diff changeset
1514 double result; // st7@1
Ritor1
parents:
diff changeset
1515
Ritor1
parents:
diff changeset
1516 result = (a1->field_1C - a1->field_20) * -1.0 / (a1->field_30 - a1->field_2C) * (a2 - a1->field_2C) + a1->field_1C;
Ritor1
parents:
diff changeset
1517 if ( result < 0.0 || result <= 1.0 )
Ritor1
parents:
diff changeset
1518 {
Ritor1
parents:
diff changeset
1519 if ( result < 0.0 )
Ritor1
parents:
diff changeset
1520 result = 0.0;
Ritor1
parents:
diff changeset
1521 }
Ritor1
parents:
diff changeset
1522 else
Ritor1
parents:
diff changeset
1523 {
Ritor1
parents:
diff changeset
1524 result = 1.0;
Ritor1
parents:
diff changeset
1525 }
Ritor1
parents:
diff changeset
1526 return result;
Ritor1
parents:
diff changeset
1527 }
Ritor1
parents:
diff changeset
1528
Ritor1
parents:
diff changeset
1529 //----- (0045D698) --------------------------------------------------------
Ritor1
parents:
diff changeset
1530 bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2)
Ritor1
parents:
diff changeset
1531 {
Ritor1
parents:
diff changeset
1532 bool result; // eax@1
Ritor1
parents:
diff changeset
1533 LightmapBuilder *v3; // esi@1
Ritor1
parents:
diff changeset
1534 RenderVertexSoft *v4; // edi@3
Ritor1
parents:
diff changeset
1535 RenderVertexSoft *v5; // edi@7
Ritor1
parents:
diff changeset
1536 IndoorCameraD3D *thisa; // [sp+10h] [bp-8h]@1
Ritor1
parents:
diff changeset
1537 bool v7; // [sp+14h] [bp-4h]@2
Ritor1
parents:
diff changeset
1538 bool a2a; // [sp+20h] [bp+8h]@6
Ritor1
parents:
diff changeset
1539
Ritor1
parents:
diff changeset
1540 result = (bool)pGame->pIndoorCameraD3D;
Ritor1
parents:
diff changeset
1541 v3 = this;
Ritor1
parents:
diff changeset
1542 thisa = pGame->pIndoorCameraD3D;
Ritor1
parents:
diff changeset
1543 if ( bit_one_for_list1__bit_two_for_list2 & 1 )
Ritor1
parents:
diff changeset
1544 {
Ritor1
parents:
diff changeset
1545 v7 = 0;
Ritor1
parents:
diff changeset
1546 if ( (signed int)this->std__vector_000004_size > 0 )
Ritor1
parents:
diff changeset
1547 {
Ritor1
parents:
diff changeset
1548 v4 = this->std__vector_000004[0].pVertices;
Ritor1
parents:
diff changeset
1549 do
Ritor1
parents:
diff changeset
1550 {
Ritor1
parents:
diff changeset
1551 pGame->pIndoorCameraD3D->debug_outline_sw(v4, *((unsigned int *)v4 - 1), 0xFF00u, 0.0);
Ritor1
parents:
diff changeset
1552 ++v7;
Ritor1
parents:
diff changeset
1553 v4 = (RenderVertexSoft *)((char *)v4 + 3100);
Ritor1
parents:
diff changeset
1554 result = v7;
Ritor1
parents:
diff changeset
1555 }
Ritor1
parents:
diff changeset
1556 while ( v7 < (signed int)v3->std__vector_000004_size );
Ritor1
parents:
diff changeset
1557 }
Ritor1
parents:
diff changeset
1558 }
Ritor1
parents:
diff changeset
1559 if ( bit_one_for_list1__bit_two_for_list2 & 2 )
Ritor1
parents:
diff changeset
1560 {
Ritor1
parents:
diff changeset
1561 a2a = 0;
Ritor1
parents:
diff changeset
1562 if ( (signed int)v3->std__vector_183808_size > 0 )
Ritor1
parents:
diff changeset
1563 {
Ritor1
parents:
diff changeset
1564 v5 = v3->std__vector_183808[0].pVertices;
Ritor1
parents:
diff changeset
1565 do
Ritor1
parents:
diff changeset
1566 {
Ritor1
parents:
diff changeset
1567 pGame->pIndoorCameraD3D->debug_outline_sw(v5, *((unsigned int *)v5 - 1), 0xC04000u, 0.00019999999);
Ritor1
parents:
diff changeset
1568 ++a2a;
Ritor1
parents:
diff changeset
1569 v5 = (RenderVertexSoft *)((char *)v5 + 3100);
Ritor1
parents:
diff changeset
1570 result = a2a;
Ritor1
parents:
diff changeset
1571 }
Ritor1
parents:
diff changeset
1572 while ( a2a < (signed int)v3->std__vector_183808_size );
Ritor1
parents:
diff changeset
1573 }
Ritor1
parents:
diff changeset
1574 }
Ritor1
parents:
diff changeset
1575 LOBYTE(result) = 1;
Ritor1
parents:
diff changeset
1576 return result;
Ritor1
parents:
diff changeset
1577 }
Ritor1
parents:
diff changeset
1578
Ritor1
parents:
diff changeset
1579 //----- (0045D73F) --------------------------------------------------------
Ritor1
parents:
diff changeset
1580 void LightmapBuilder::DrawLightmaps(int a2)
Ritor1
parents:
diff changeset
1581 {
Ritor1
parents:
diff changeset
1582 if ( a2 == 2 )
Ritor1
parents:
diff changeset
1583 DoDrawLightmaps();
Ritor1
parents:
diff changeset
1584 }
Ritor1
parents:
diff changeset
1585
Ritor1
parents:
diff changeset
1586 //----- (0045D74F) --------------------------------------------------------
Ritor1
parents:
diff changeset
1587 char LightmapBuilder::_45D74F_MessWithLight(int a2, int *a3)
Ritor1
parents:
diff changeset
1588 {
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1589 //char v3; // zf@1
0
Ritor1
parents:
diff changeset
1590 IDirect3DDevice3 *v4; // eax@2
Ritor1
parents:
diff changeset
1591 HRESULT v5; // eax@2
Ritor1
parents:
diff changeset
1592 //char *v6; // eax@2
Ritor1
parents:
diff changeset
1593 struct IDirect3DTexture2 *v7; // edi@4
Ritor1
parents:
diff changeset
1594 HRESULT v8; // eax@8
Ritor1
parents:
diff changeset
1595 HRESULT v9; // eax@8
Ritor1
parents:
diff changeset
1596 HRESULT v10; // eax@8
Ritor1
parents:
diff changeset
1597 HRESULT v11; // eax@8
Ritor1
parents:
diff changeset
1598 HRESULT v12; // eax@8
Ritor1
parents:
diff changeset
1599 int *v13; // eax@8
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1600 //float v14; // ecx@15
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1601 //IDirect3DDevice3 *v15; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1602 //HRESULT v16; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1603 //IDirect3DDevice3 *v17; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1604 //HRESULT v18; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1605 //IDirect3DDevice3 *v19; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1606 //HRESULT v20; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1607 //IDirect3DDevice3 *v21; // eax@21
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1608 //HRESULT v22; // eax@21
0
Ritor1
parents:
diff changeset
1609 //IDirect3DDevice3 *v23; // eax@23
Ritor1
parents:
diff changeset
1610 std::string v25; // [sp+44h] [bp-44h]@12
Ritor1
parents:
diff changeset
1611 signed int v26; // [sp+48h] [bp-40h]@21
Ritor1
parents:
diff changeset
1612 signed int v27; // [sp+4Ch] [bp-3Ch]@21
Ritor1
parents:
diff changeset
1613 Lightmap *v28; // [sp+50h] [bp-38h]@2
Ritor1
parents:
diff changeset
1614 int v29; // [sp+54h] [bp-34h]@2
Ritor1
parents:
diff changeset
1615 //float v30; // [sp+58h] [bp-30h]@2
Ritor1
parents:
diff changeset
1616 int arg4; // [sp+68h] [bp-20h]@8
Ritor1
parents:
diff changeset
1617 float v32; // [sp+6Ch] [bp-1Ch]@8
Ritor1
parents:
diff changeset
1618 float v33; // [sp+70h] [bp-18h]@8
Ritor1
parents:
diff changeset
1619 int v34; // [sp+74h] [bp-14h]@19
Ritor1
parents:
diff changeset
1620 int v35; // [sp+78h] [bp-10h]@2
Ritor1
parents:
diff changeset
1621 int *v36; // [sp+7Ch] [bp-Ch]@10
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1622 //int a1; // [sp+80h] [bp-8h]@12
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1623 //float v38; // [sp+84h] [bp-4h]@1
0
Ritor1
parents:
diff changeset
1624
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1625 if (std__vector_000004_size == 0)
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1626 return 1;
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1627
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1628 __debugbreak();
0
Ritor1
parents:
diff changeset
1629 //v30 = 0.0;
Ritor1
parents:
diff changeset
1630 //v4 = pRenderer->pRenderD3D->pDevice;
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1631 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
0
Ritor1
parents:
diff changeset
1632 //v6 = (char *)stru_69BD44.c_str();
Ritor1
parents:
diff changeset
1633 //if ( !stru_69BD44.c_str() )
Ritor1
parents:
diff changeset
1634 // v6 = (char *)&dword_4D86F0;
Ritor1
parents:
diff changeset
1635 v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
Ritor1
parents:
diff changeset
1636 if ( pRenderer->bUsingSpecular )
Ritor1
parents:
diff changeset
1637 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
Ritor1
parents:
diff changeset
1638 if ( !byte_4D864C || !(pGame->uFlags & 1) )
Ritor1
parents:
diff changeset
1639 {
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1640 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1641 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
0
Ritor1
parents:
diff changeset
1642 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7));
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1643 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1644 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
0
Ritor1
parents:
diff changeset
1645 v13 = a3;
Ritor1
parents:
diff changeset
1646 v33 = 1.0;
Ritor1
parents:
diff changeset
1647 v32 = 1.0;
Ritor1
parents:
diff changeset
1648 *(float *)&arg4 = 1.0;
Ritor1
parents:
diff changeset
1649 if ( a3 )
Ritor1
parents:
diff changeset
1650 {
Ritor1
parents:
diff changeset
1651 if ( *a3 != -1 )
Ritor1
parents:
diff changeset
1652 {
Ritor1
parents:
diff changeset
1653 v36 = a3;
Ritor1
parents:
diff changeset
1654 do
Ritor1
parents:
diff changeset
1655 {
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1656 v28 = &std__vector_000004[*v13];
0
Ritor1
parents:
diff changeset
1657 if ( !DrawLightmap(v28, (Vec3_float_ *)&arg4, 0.0) )
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1658 assert(false && "Invalid lightmap detected!");
0
Ritor1
parents:
diff changeset
1659 v13 = v36 + 1;
Ritor1
parents:
diff changeset
1660 v36 = v13;
Ritor1
parents:
diff changeset
1661 }
Ritor1
parents:
diff changeset
1662 while ( *v13 != -1 );
Ritor1
parents:
diff changeset
1663 }
Ritor1
parents:
diff changeset
1664 }
Ritor1
parents:
diff changeset
1665 else
Ritor1
parents:
diff changeset
1666 {
Ritor1
parents:
diff changeset
1667 v36 = 0;
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1668 if (std__vector_000004_size > 0 )
0
Ritor1
parents:
diff changeset
1669 {
Ritor1
parents:
diff changeset
1670 while ( 1 )
Ritor1
parents:
diff changeset
1671 {
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1672 auto _a1 = &std__vector_000004[(int)v36];
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1673 if ( !DrawLightmap(_a1, (Vec3_float_ *)&arg4, 0.0) )
0
Ritor1
parents:
diff changeset
1674 {
Ritor1
parents:
diff changeset
1675 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0);
Ritor1
parents:
diff changeset
1676 v35 = 5080812;
Ritor1
parents:
diff changeset
1677 }
Ritor1
parents:
diff changeset
1678 v36 = (int *)((char *)v36 + 1);
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1679 if ( (signed int)v36 >= std__vector_000004_size)
0
Ritor1
parents:
diff changeset
1680 break;
Ritor1
parents:
diff changeset
1681 }
Ritor1
parents:
diff changeset
1682 }
Ritor1
parents:
diff changeset
1683 }
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1684 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1685 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1686 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1687 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
0
Ritor1
parents:
diff changeset
1688 }
Ritor1
parents:
diff changeset
1689 if ( pRenderer->bUsingSpecular )
Ritor1
parents:
diff changeset
1690 {
Ritor1
parents:
diff changeset
1691 //LODWORD(v30) = 1;
Ritor1
parents:
diff changeset
1692 //v29 = 28;
Ritor1
parents:
diff changeset
1693 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1694 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
0
Ritor1
parents:
diff changeset
1695 //v30 = pRenderer->uFogColor;
Ritor1
parents:
diff changeset
1696 //v23 = pRenderer->pRenderD3D->pDevice;
Ritor1
parents:
diff changeset
1697 //v29 = 34;
Ritor1
parents:
diff changeset
1698 //v28 = (Lightmap *)v23;
Ritor1
parents:
diff changeset
1699 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, pRenderer->uFogColor));
Ritor1
parents:
diff changeset
1700 //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1701 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
0
Ritor1
parents:
diff changeset
1702 }
1390
613c77e51e38 Messed with spell effects drawing a bit.
Nomad
parents: 1277
diff changeset
1703
0
Ritor1
parents:
diff changeset
1704 return 1;
Ritor1
parents:
diff changeset
1705 }
Ritor1
parents:
diff changeset
1706
Ritor1
parents:
diff changeset
1707
Ritor1
parents:
diff changeset
1708 //----- (0045DA56) --------------------------------------------------------
Ritor1
parents:
diff changeset
1709 bool LightmapBuilder::DrawLightmaps2(float z_bias)
Ritor1
parents:
diff changeset
1710 {
Ritor1
parents:
diff changeset
1711 Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2
Ritor1
parents:
diff changeset
1712 v.z = 1.0;
Ritor1
parents:
diff changeset
1713 v.y = 1.0;
Ritor1
parents:
diff changeset
1714 v.x = 1.0;
Ritor1
parents:
diff changeset
1715
Ritor1
parents:
diff changeset
1716 for (uint i = 0; i < std__vector_183808_size; ++i)
Ritor1
parents:
diff changeset
1717 if (!DrawLightmap(std__vector_183808 + i, &v, z_bias))
Ritor1
parents:
diff changeset
1718 MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0);
Ritor1
parents:
diff changeset
1719
Ritor1
parents:
diff changeset
1720 return true;
Ritor1
parents:
diff changeset
1721 }
Ritor1
parents:
diff changeset
1722
Ritor1
parents:
diff changeset
1723 //----- (0045DAE8) --------------------------------------------------------
Ritor1
parents:
diff changeset
1724 bool LightmapBuilder::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias)
Ritor1
parents:
diff changeset
1725 {
Ritor1
parents:
diff changeset
1726 double v10; // st7@4
Ritor1
parents:
diff changeset
1727 double v14; // st7@7
Ritor1
parents:
diff changeset
1728 __int16 v15; // fps@8
Ritor1
parents:
diff changeset
1729 double v18; // st3@8
Ritor1
parents:
diff changeset
1730 signed int v24; // [sp-1Ch] [bp-670h]@13
Ritor1
parents:
diff changeset
1731 const char *v25; // [sp-18h] [bp-66Ch]@13
Ritor1
parents:
diff changeset
1732 int v26; // [sp-14h] [bp-668h]@13
Ritor1
parents:
diff changeset
1733 RenderVertexD3D3 a2[32]; // [sp+0h] [bp-654h]@7
Ritor1
parents:
diff changeset
1734
Ritor1
parents:
diff changeset
1735
Ritor1
parents:
diff changeset
1736 if (pLightmap->uNumVertices < 3)
Ritor1
parents:
diff changeset
1737 {
Ritor1
parents:
diff changeset
1738 Log::Warning(L"Lightmap uNumVertices < 3");
Ritor1
parents:
diff changeset
1739 return false;
Ritor1
parents:
diff changeset
1740 }
Ritor1
parents:
diff changeset
1741
Ritor1
parents:
diff changeset
1742 uint uLightmapColorMaskR = (pLightmap->uColorMask >> 16) & 0xFF;
Ritor1
parents:
diff changeset
1743 uint uLightmapColorR = floorf(uLightmapColorMaskR * pLightmap->fBrightness * pColorMult->x + 0.5f);
Ritor1
parents:
diff changeset
1744
Ritor1
parents:
diff changeset
1745 uint uLightmapColorMaskG = (pLightmap->uColorMask >> 8) & 0xFF;
Ritor1
parents:
diff changeset
1746 uint uLightmapColorG = floorf(uLightmapColorMaskG * pLightmap->fBrightness * pColorMult->y + 0.5f);
Ritor1
parents:
diff changeset
1747
Ritor1
parents:
diff changeset
1748 uint uLightmapColorMaskB = pLightmap->uColorMask & 0xFF;
Ritor1
parents:
diff changeset
1749 uint uLightmapColorB = floorf(uLightmapColorMaskB * pLightmap->fBrightness * pColorMult->z + 0.5f);
Ritor1
parents:
diff changeset
1750
Ritor1
parents:
diff changeset
1751 uint uLightmapColor = uLightmapColorB | (uLightmapColorMaskG << 8) | (uLightmapColorMaskR << 16);
Ritor1
parents:
diff changeset
1752
Ritor1
parents:
diff changeset
1753 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
Ritor1
parents:
diff changeset
1754 v10 = (double)pOutdoorCamera->shading_dist_mist;
Ritor1
parents:
diff changeset
1755 else
Ritor1
parents:
diff changeset
1756 v10 = 16192.0;
Ritor1
parents:
diff changeset
1757 v14 = 1.0 / v10;
Ritor1
parents:
diff changeset
1758
Ritor1
parents:
diff changeset
1759 for (uint i = 0; i < pLightmap->uNumVertices; ++i)
Ritor1
parents:
diff changeset
1760 {
Ritor1
parents:
diff changeset
1761 v18 = 1.0 - 1.0 / (v14 * pLightmap->pVertices[i].vWorldViewPosition.x * 1000.0);
Ritor1
parents:
diff changeset
1762 if (fabsf(z_bias) < 1e-5f)
Ritor1
parents:
diff changeset
1763 {
Ritor1
parents:
diff changeset
1764 v18 = v18 - z_bias;
Ritor1
parents:
diff changeset
1765 if (v18 < 0.000099999997)
Ritor1
parents:
diff changeset
1766 v18 = 0.000099999997;
Ritor1
parents:
diff changeset
1767 }
Ritor1
parents:
diff changeset
1768
Ritor1
parents:
diff changeset
1769 a2[i].pos.x = pLightmap->pVertices[i].vWorldViewProjX;
Ritor1
parents:
diff changeset
1770 a2[i].pos.z = v18;
Ritor1
parents:
diff changeset
1771 a2[i].pos.y = pLightmap->pVertices[i].vWorldViewProjY;
Ritor1
parents:
diff changeset
1772 a2[i].rhw = 1.0 / pLightmap->pVertices[i].vWorldViewPosition.x;
Ritor1
parents:
diff changeset
1773 a2[i].diffuse = uLightmapColor;
Ritor1
parents:
diff changeset
1774 a2[i].specular = 0;
Ritor1
parents:
diff changeset
1775 a2[i].texcoord.x = pLightmap->pVertices[i].u;
Ritor1
parents:
diff changeset
1776 a2[i].texcoord.y = pLightmap->pVertices[i].v;
Ritor1
parents:
diff changeset
1777 }
Ritor1
parents:
diff changeset
1778
Ritor1
parents:
diff changeset
1779 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
Ritor1
parents:
diff changeset
1780 v24 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
Ritor1
parents:
diff changeset
1781 else
Ritor1
parents:
diff changeset
1782 v24 = D3DDP_DONOTLIGHT;
Ritor1
parents:
diff changeset
1783
Ritor1
parents:
diff changeset
1784 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
Ritor1
parents:
diff changeset
1785 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
Ritor1
parents:
diff changeset
1786 a2,
Ritor1
parents:
diff changeset
1787 pLightmap->uNumVertices,
Ritor1
parents:
diff changeset
1788 v24));
Ritor1
parents:
diff changeset
1789
Ritor1
parents:
diff changeset
1790 return true;
Ritor1
parents:
diff changeset
1791 }
Ritor1
parents:
diff changeset
1792
Ritor1
parents:
diff changeset
1793 //----- (0045DCA9) --------------------------------------------------------
Ritor1
parents:
diff changeset
1794 void LightmapBuilder::DoDrawLightmaps()
Ritor1
parents:
diff changeset
1795 {
Ritor1
parents:
diff changeset
1796 if (!std__vector_183808_size)
Ritor1
parents:
diff changeset
1797 return;
Ritor1
parents:
diff changeset
1798
Ritor1
parents:
diff changeset
1799 if (pRenderer->bUsingSpecular)
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1800 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
0
Ritor1
parents:
diff changeset
1801
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1802 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1803 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1804 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1805 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
0
Ritor1
parents:
diff changeset
1806
Ritor1
parents:
diff changeset
1807 auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
Ritor1
parents:
diff changeset
1808 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
Ritor1
parents:
diff changeset
1809
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1810 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1811 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
0
Ritor1
parents:
diff changeset
1812
Ritor1
parents:
diff changeset
1813 DrawLightmaps2(0.00050000002);
Ritor1
parents:
diff changeset
1814
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1815 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1816 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1817 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1818 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1819 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1820 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
0
Ritor1
parents:
diff changeset
1821
Ritor1
parents:
diff changeset
1822 if (pRenderer->bUsingSpecular)
186
d65528fc3bda D3D constants, shore tiles, camera flags
Nomad
parents: 86
diff changeset
1823 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
0
Ritor1
parents:
diff changeset
1824 }