Mercurial > mm7
comparison Engine/Graphics/LightmapBuilder.cpp @ 2568:f2f2595fe308
rename Decals[], DecalCount
author | Ritor1 |
---|---|
date | Thu, 21 May 2015 18:32:45 +0600 |
parents | b8a56afc6ba1 |
children | 4d199006c716 |
comparison
equal
deleted
inserted
replaced
2565:117c219bf913 | 2568:f2f2595fe308 |
---|---|
63 Lights.uCurrentAmbientLightLevel = v3 << 16; | 63 Lights.uCurrentAmbientLightLevel = v3 << 16; |
64 for ( uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i ) | 64 for ( uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i ) |
65 { | 65 { |
66 if ( pSlot >= 20 ) | 66 if ( pSlot >= 20 ) |
67 break; | 67 break; |
68 ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, 1); | 68 ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, true); |
69 } | 69 } |
70 for ( uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i ) | 70 for ( uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i ) |
71 { | 71 { |
72 if ( pSlot >= 20 ) | 72 if ( pSlot >= 20 ) |
73 break; | 73 break; |
74 ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0); | 74 ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, false); |
75 } | 75 } |
76 result = pSlot; | 76 result = pSlot; |
77 Lights.uNumLightsApplied = pSlot; | 77 Lights.uNumLightsApplied = pSlot; |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 //----- (0045D0D5) -------------------------------------------------------- | 81 //----- (0045D0D5) -------------------------------------------------------- |
82 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot) | 82 bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *light_tile_dist, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot) |
83 { | 83 { |
84 //For outdoor terrain light (II) | 84 //For outdoor terrain light (II) |
85 bool result; // eax@1 | 85 bool result; // eax@1 |
86 double maxz; // st7@11 | 86 double maxz; // st7@11 |
87 char v20; // c2@11 | 87 char v20; // c2@11 |
106 | 106 |
107 if ( pLight->uRadius <= 0 ) | 107 if ( pLight->uRadius <= 0 ) |
108 return false; | 108 return false; |
109 if ( uStripType == 4 ) | 109 if ( uStripType == 4 ) |
110 { | 110 { |
111 tX_0 = TerrainVertices[0].vWorldPosition.x; | 111 tX_0 = TerrainVertices[0].vWorldPosition.x; |
112 tX_1 = TerrainVertices[3].vWorldPosition.x; | 112 tX_1 = TerrainVertices[3].vWorldPosition.x; |
113 | 113 |
114 tY_0 = TerrainVertices[1].vWorldPosition.y; | 114 tY_0 = TerrainVertices[1].vWorldPosition.y; |
115 tY_1 = TerrainVertices[0].vWorldPosition.y; | 115 tY_1 = TerrainVertices[0].vWorldPosition.y; |
116 } | 116 } |
117 else if(uStripType == 3) | 117 else if(uStripType == 3) |
118 { | 118 { |
119 if ((unsigned char)X) | 119 if ((unsigned char)X) |
120 { | 120 { |
151 if ( (float)pLight->vPosition.x <= bounding_x1 || (float)pLight->vPosition.x >= bounding_x2 | 151 if ( (float)pLight->vPosition.x <= bounding_x1 || (float)pLight->vPosition.x >= bounding_x2 |
152 || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2 | 152 || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2 |
153 || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 ) | 153 || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 ) |
154 return false; | 154 return false; |
155 | 155 |
156 Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3); | 156 Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, light_tile_dist); |
157 float p_dot = ((float)pLight->vPosition.x * pNormal->x | 157 float p_dot = ((float)pLight->vPosition.x * pNormal->x |
158 + (float)pLight->vPosition.y * pNormal->y | 158 + (float)pLight->vPosition.y * pNormal->y |
159 + (float)pLight->vPosition.z * pNormal->z + *a3)+0.5f; | 159 + (float)pLight->vPosition.z * pNormal->z + *light_tile_dist)+0.5f; |
160 if ( p_dot > pLight->uRadius ) | 160 if ( p_dot > pLight->uRadius ) |
161 return false; | 161 return false; |
162 | 162 |
163 Lights._blv_lights_radii[*pSlot] = pLight->uRadius; | 163 Lights._blv_lights_radii[*pSlot] = pLight->uRadius; |
164 Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; | 164 Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; |
191 ++*pSlot; | 191 ++*pSlot; |
192 return true; | 192 return true; |
193 } | 193 } |
194 | 194 |
195 //----- (0045CE50) -------------------------------------------------------- | 195 //----- (0045CE50) -------------------------------------------------------- |
196 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4) | 196 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, bool bLightBackfaces) |
197 { | 197 { |
198 //For outdoor light (IV) | 198 //For outdoor light (IV) |
199 int result; // eax@0 | 199 int result; // eax@0 |
200 int v10; // ecx@8 | 200 double v10; // ecx@8 |
201 char v14; // dl@11 | 201 char v14; // dl@11 |
202 | 202 |
203 v10 = (pFace->pFacePlane.dist | 203 if (!pLight->uRadius) |
204 + pLight->vPosition.x * pFace->pFacePlane.vNormal.x | 204 return false; |
205 + pLight->vPosition.y * pFace->pFacePlane.vNormal.y | 205 |
206 + pLight->vPosition.z * pFace->pFacePlane.vNormal.z) >> 16; | 206 if ( (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 |
207 if ( pLight->uRadius > 0 | |
208 && (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 | |
209 && (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2 | 207 && (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2 |
210 && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2 | 208 && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2) |
211 && ((a4) || v10 >= 0) && v10 <= pLight->uRadius ) | 209 { |
212 { | 210 v10 = (double)(pLight->vPosition.x * pFace->pFacePlane.vNormal.x |
213 Lights._blv_lights_radii[*pSlot] = pLight->uRadius; | 211 + pLight->vPosition.y * pFace->pFacePlane.vNormal.y |
214 Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; | 212 + pLight->vPosition.z * pFace->pFacePlane.vNormal.z + pFace->pFacePlane.dist); |
215 Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x; | 213 if(((bLightBackfaces) || v10 >= 0.0f) && fabsf(v10) <= pLight->uRadius) |
216 Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y; | 214 { |
217 Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z; | 215 Lights._blv_lights_radii[*pSlot] = pLight->uRadius; |
218 Lights._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; | 216 Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; |
219 Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; | 217 Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x; |
220 Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; | 218 Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y; |
221 //v11 = abs(v10); | 219 Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z; |
222 //v12 = pRenderer->bUsingSpecular; | 220 Lights._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR / 255.0f; |
223 Lights._blv_lights_light_dot_faces[*pSlot] = abs(v10); | 221 Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG / 255.0f; |
224 Lights._blv_lights_types[*pSlot] = pLight->uLightType; | 222 Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB / 255.0f; |
225 //v13 = pRenderer->pRenderD3D; | 223 Lights._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v10 + 0.5f)); |
226 v14 = Lights._blv_lights_types[*pSlot]; | 224 Lights._blv_lights_types[*pSlot] = pLight->uLightType; |
227 if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 ) | 225 v14 = Lights._blv_lights_types[*pSlot]; |
228 v14 = _4E94D2_light_type; | 226 if ( pRenderer->bUsingSpecular && Lights._blv_lights_types[*pSlot] & 4 ) |
229 Lights._blv_lights_types[*pSlot] = v14; | 227 v14 = _4E94D2_light_type; |
230 result = 4 * *pSlot; | 228 Lights._blv_lights_types[*pSlot] = v14; |
231 if ( /*v13*/true && pRenderer->bUsingSpecular ) | 229 result = 4 * *pSlot; |
232 { | 230 if ( pRenderer->bUsingSpecular ) |
233 if ( Lights._blv_lights_types[*pSlot] & 4 ) | 231 { |
234 { | 232 __debugbreak(); |
235 *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result) | 233 if ( Lights._blv_lights_types[*pSlot] & 4 ) |
236 * 0.33000001; | 234 { |
237 *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result) | 235 *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result) |
238 * 0.33000001; | 236 * 0.33000001; |
239 *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result) | 237 *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result) |
240 * 0.33000001; | 238 * 0.33000001; |
241 } | 239 *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result) |
240 * 0.33000001; | |
241 } | |
242 } | |
242 } | 243 } |
243 ++*pSlot; | 244 ++*pSlot; |
244 return true; | 245 return true; |
245 } | 246 } |
246 else | 247 else |
262 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) | 263 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) |
263 { | 264 { |
264 if (uNumLightsApplied >= 20) | 265 if (uNumLightsApplied >= 20) |
265 break; | 266 break; |
266 | 267 |
267 ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0); | 268 ApplyLight_BLV((StationaryLight *)&pMobileLightsStack->pLights[i], pFace, &uNumLightsApplied, true, 0); |
268 } | 269 } |
269 | 270 |
270 for (uint i = 0; i < pSector->uNumLights; ++i) | 271 for (uint i = 0; i < pSector->uNumLights; ++i) |
271 { | 272 { |
272 if (uNumLightsApplied >= 20 ) | 273 if (uNumLightsApplied >= 20 ) |
280 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | 281 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) |
281 { | 282 { |
282 if (uNumLightsApplied >= 20) | 283 if (uNumLightsApplied >= 20) |
283 break; | 284 break; |
284 | 285 |
285 ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type); | 286 ApplyLight_BLV(&pStationaryLightsStack->pLights[i], pFace, &uNumLightsApplied, false, &_4E94D0_light_type); |
286 } | 287 } |
287 | 288 |
288 Lights.uNumLightsApplied = uNumLightsApplied; | 289 Lights.uNumLightsApplied = uNumLightsApplied; |
289 return true; | 290 return true; |
290 } | 291 } |