# HG changeset patch # User Ritor1 # Date 1431609368 -21600 # Node ID 6ab1273bc507d893ea29ac7945959b4411b0dd85 # Parent 5d6fb8eb023c065ef2c6c5551b71b6f275270588 . diff -r 5d6fb8eb023c -r 6ab1273bc507 Build/Visual Studio 2012/World of Might and Magic.vcxproj --- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj Wed May 13 20:09:12 2015 +0600 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj Thu May 14 19:16:08 2015 +0600 @@ -152,9 +152,12 @@ + + + @@ -332,9 +335,12 @@ + + + diff -r 5d6fb8eb023c -r 6ab1273bc507 Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters --- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Wed May 13 20:09:12 2015 +0600 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Thu May 14 19:16:08 2015 +0600 @@ -604,6 +604,15 @@ GUI\UI + + Game + + + Game + + + Game + @@ -1375,6 +1384,15 @@ GUI\UI + + Game + + + Game + + + Game + diff -r 5d6fb8eb023c -r 6ab1273bc507 Engine/Graphics/LightmapBuilder.cpp --- a/Engine/Graphics/LightmapBuilder.cpp Wed May 13 20:09:12 2015 +0600 +++ b/Engine/Graphics/LightmapBuilder.cpp Thu May 14 19:16:08 2015 +0600 @@ -79,7 +79,7 @@ } //----- (0045D0D5) -------------------------------------------------------- -bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot) +bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot) { //For outdoor terrain light (II) bool result; // eax@1 @@ -95,37 +95,49 @@ float tY_0; float tY_1; // [sp+1Ch] [bp-4h]@5 + // x0,y0 x1,y1 + // .____________. + // | | + // | | + // | | + // .____________. + // x3,y3 x2,y2 + + if ( pLight->uRadius <= 0 ) - return 0; + return false; if ( uStripType == 4 ) { - tX_0 = a1->vWorldPosition.x; - tX_1 = a1[3].vWorldPosition.x; - tY_0 = a1[1].vWorldPosition.y; - tY_1 = a1->vWorldPosition.y; + tX_0 = TerrainVertices[0].vWorldPosition.x; + tX_1 = TerrainVertices[3].vWorldPosition.x; + + tY_0 = TerrainVertices[1].vWorldPosition.y; + tY_1 = TerrainVertices[0].vWorldPosition.y; } - else // uStripType == 3 + else if(uStripType == 3) { - if ( uStripType != 3 ) - MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0); - else if ((unsigned char)X) + if ((unsigned char)X) { - tX_0 = a1->vWorldPosition.x; - tX_1 = a1[2].vWorldPosition.x; - tY_0 = a1[1].vWorldPosition.y; - tY_1 = a1[2].vWorldPosition.y; + tX_0 = TerrainVertices[0].vWorldPosition.x; + tX_1 = TerrainVertices[2].vWorldPosition.x; + + tY_0 = TerrainVertices[1].vWorldPosition.y; + tY_1 = TerrainVertices[2].vWorldPosition.y; } else { - tX_0 = a1[1].vWorldPosition.x; - tX_1 = a1[2].vWorldPosition.x; - tY_0 = a1[1].vWorldPosition.y; - tY_1 = a1->vWorldPosition.y; + tX_0 = TerrainVertices[1].vWorldPosition.x; + tX_1 = TerrainVertices[2].vWorldPosition.x; + + tY_0 = TerrainVertices[1].vWorldPosition.y; + tY_1 = TerrainVertices[0].vWorldPosition.y; } } + else + MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0); - minz = pIndoorCameraD3D->GetPolygonMinZ(a1, uStripType); - maxz = pIndoorCameraD3D->GetPolygonMaxZ(a1, uStripType); + minz = pIndoorCameraD3D->GetPolygonMinZ(TerrainVertices, uStripType); + maxz = pIndoorCameraD3D->GetPolygonMaxZ(TerrainVertices, uStripType); float bounding_x1 = tX_0 - (float)pLight->uRadius; //13 976 - 128 = 13848.0 float bounding_y1 = tY_0 - (float)pLight->uRadius; // 3 800 - 128 = 3672.0 @@ -135,16 +147,17 @@ float bounding_y2 = (float)pLight->uRadius + tY_1; //3 792 + 128 = 3920.0 float bounding_z2 = (float)pLight->uRadius + maxz;// 260.0 + //проверяем вершины if ( (float)pLight->vPosition.x <= bounding_x1 || (float)pLight->vPosition.x >= bounding_x2 || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2 || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 ) - return 0; + return false; - Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3); - float p_dot = (float)pLight->vPosition.x * pNormal->x - + (float)pLight->vPosition.y * pNormal->y - + (float)pLight->vPosition.z * pNormal->z + *a3; - p_dot = p_dot + 0.5f; + Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3); + float p_dot = (float)pLight->vPosition.x * pNormal->x + + (float)pLight->vPosition.y * pNormal->y + + (float)pLight->vPosition.z * pNormal->z + *a3; + p_dot = p_dot + 0.5f; if ( (//v49 = pNormal, //Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3), //X = v8->vPosition.y, @@ -160,7 +173,7 @@ //X = LODWORD(v61), //v52 = v63, p_dot > pLight->uRadius) ) - return 0; + return false; /* v49 = pNormal; Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3); @@ -192,18 +205,18 @@ v57 = _4E94D2_light_type; stru_F8AD28._blv_lights_types[*pSlot] = v57; - result = 4 * *pSlot; + int id = 4 * *pSlot; if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular ) { if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) { - stru_F8AD28._blv_lights_rs[result] = stru_F8AD28._blv_lights_rs[result] * 0.3300000131130219; - stru_F8AD28._blv_lights_gs[result] = stru_F8AD28._blv_lights_gs[result] * 0.3300000131130219; - stru_F8AD28._blv_lights_bs[result] = stru_F8AD28._blv_lights_bs[result] * 0.3300000131130219; + stru_F8AD28._blv_lights_rs[id] = stru_F8AD28._blv_lights_rs[id] * 0.3300000131130219; + stru_F8AD28._blv_lights_gs[id] = stru_F8AD28._blv_lights_gs[id] * 0.3300000131130219; + stru_F8AD28._blv_lights_bs[id] = stru_F8AD28._blv_lights_bs[id] * 0.3300000131130219; } } ++*pSlot; - return 1; + return true; } //----- (0045CE50) -------------------------------------------------------- @@ -869,7 +882,7 @@ } } else - if (for_refactoring) + //if (for_refactoring) { for (unsigned int i = 0; i < std__vector_000004_size; ++i) if ( !pRenderer->DrawLightmap(std__vector_000004 + i, &arg4, 0.0) ) diff -r 5d6fb8eb023c -r 6ab1273bc507 Engine/Graphics/Render.cpp --- a/Engine/Graphics/Render.cpp Wed May 13 20:09:12 2015 +0600 +++ b/Engine/Graphics/Render.cpp Thu May 14 19:16:08 2015 +0600 @@ -383,7 +383,7 @@ norm = 0; else norm = &pTerrainNormals[norm_idx]; - if (for_refactoring) + //if (for_refactoring) { //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); //__debugbreak();