Mercurial > mm7
diff Engine/Graphics/LightmapBuilder.cpp @ 2568:f2f2595fe308
rename Decals[], DecalCount
author | Ritor1 |
---|---|
date | Thu, 21 May 2015 18:32:45 +0600 |
parents | b8a56afc6ba1 |
children | 4d199006c716 |
line wrap: on
line diff
--- a/Engine/Graphics/LightmapBuilder.cpp Wed May 20 15:12:33 2015 +0200 +++ b/Engine/Graphics/LightmapBuilder.cpp Thu May 21 18:32:45 2015 +0600 @@ -65,13 +65,13 @@ { if ( pSlot >= 20 ) break; - ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, 1); + ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, true); } for ( uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i ) { if ( pSlot >= 20 ) break; - ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0); + ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, false); } result = pSlot; Lights.uNumLightsApplied = pSlot; @@ -79,7 +79,7 @@ } //----- (0045D0D5) -------------------------------------------------------- -bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot) +bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *light_tile_dist, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot) { //For outdoor terrain light (II) bool result; // eax@1 @@ -108,11 +108,11 @@ return false; if ( uStripType == 4 ) { - tX_0 = TerrainVertices[0].vWorldPosition.x; - tX_1 = TerrainVertices[3].vWorldPosition.x; + tX_0 = TerrainVertices[0].vWorldPosition.x; + tX_1 = TerrainVertices[3].vWorldPosition.x; - tY_0 = TerrainVertices[1].vWorldPosition.y; - tY_1 = TerrainVertices[0].vWorldPosition.y; + tY_0 = TerrainVertices[1].vWorldPosition.y; + tY_1 = TerrainVertices[0].vWorldPosition.y; } else if(uStripType == 3) { @@ -153,10 +153,10 @@ || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 ) return false; - Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3); + Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, light_tile_dist); float p_dot = ((float)pLight->vPosition.x * pNormal->x + (float)pLight->vPosition.y * pNormal->y - + (float)pLight->vPosition.z * pNormal->z + *a3)+0.5f; + + (float)pLight->vPosition.z * pNormal->z + *light_tile_dist)+0.5f; if ( p_dot > pLight->uRadius ) return false; @@ -193,52 +193,53 @@ } //----- (0045CE50) -------------------------------------------------------- -bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4) +bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, bool bLightBackfaces) { //For outdoor light (IV) int result; // eax@0 - int v10; // ecx@8 + double v10; // ecx@8 char v14; // dl@11 - v10 = (pFace->pFacePlane.dist - + pLight->vPosition.x * pFace->pFacePlane.vNormal.x - + pLight->vPosition.y * pFace->pFacePlane.vNormal.y - + pLight->vPosition.z * pFace->pFacePlane.vNormal.z) >> 16; - if ( pLight->uRadius > 0 - && (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 + if (!pLight->uRadius) + return false; + + if ( (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2 && (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2 - && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2 - && ((a4) || v10 >= 0) && v10 <= pLight->uRadius ) + && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2) { - Lights._blv_lights_radii[*pSlot] = pLight->uRadius; - Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; - Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x; - Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y; - Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z; - Lights._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; - Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; - Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; - //v11 = abs(v10); - //v12 = pRenderer->bUsingSpecular; - Lights._blv_lights_light_dot_faces[*pSlot] = abs(v10); - Lights._blv_lights_types[*pSlot] = pLight->uLightType; - //v13 = pRenderer->pRenderD3D; - v14 = Lights._blv_lights_types[*pSlot]; - if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 ) - v14 = _4E94D2_light_type; - Lights._blv_lights_types[*pSlot] = v14; - result = 4 * *pSlot; - if ( /*v13*/true && pRenderer->bUsingSpecular ) - { - if ( Lights._blv_lights_types[*pSlot] & 4 ) - { - *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result) - * 0.33000001; - *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result) - * 0.33000001; - *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result) - * 0.33000001; - } + v10 = (double)(pLight->vPosition.x * pFace->pFacePlane.vNormal.x + + pLight->vPosition.y * pFace->pFacePlane.vNormal.y + + pLight->vPosition.z * pFace->pFacePlane.vNormal.z + pFace->pFacePlane.dist); + if(((bLightBackfaces) || v10 >= 0.0f) && fabsf(v10) <= pLight->uRadius) + { + Lights._blv_lights_radii[*pSlot] = pLight->uRadius; + Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; + Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x; + Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y; + Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z; + Lights._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR / 255.0f; + Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG / 255.0f; + Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB / 255.0f; + Lights._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v10 + 0.5f)); + Lights._blv_lights_types[*pSlot] = pLight->uLightType; + v14 = Lights._blv_lights_types[*pSlot]; + if ( pRenderer->bUsingSpecular && Lights._blv_lights_types[*pSlot] & 4 ) + v14 = _4E94D2_light_type; + Lights._blv_lights_types[*pSlot] = v14; + result = 4 * *pSlot; + if ( pRenderer->bUsingSpecular ) + { + __debugbreak(); + if ( Lights._blv_lights_types[*pSlot] & 4 ) + { + *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result) + * 0.33000001; + *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result) + * 0.33000001; + *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result) + * 0.33000001; + } + } } ++*pSlot; return true; @@ -264,7 +265,7 @@ if (uNumLightsApplied >= 20) break; - ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0); + ApplyLight_BLV((StationaryLight *)&pMobileLightsStack->pLights[i], pFace, &uNumLightsApplied, true, 0); } for (uint i = 0; i < pSector->uNumLights; ++i) @@ -282,7 +283,7 @@ if (uNumLightsApplied >= 20) break; - ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type); + ApplyLight_BLV(&pStationaryLightsStack->pLights[i], pFace, &uNumLightsApplied, false, &_4E94D0_light_type); } Lights.uNumLightsApplied = uNumLightsApplied;