changeset 2559:6ab1273bc507

.
author Ritor1
date Thu, 14 May 2015 19:16:08 +0600
parents 5d6fb8eb023c
children 44d9df75dc13
files Build/Visual Studio 2012/World of Might and Magic.vcxproj Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Engine/Graphics/LightmapBuilder.cpp Engine/Graphics/Render.cpp
diffstat 4 files changed, 71 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
     <ClCompile Include="..\..\Engine\TurnEngine\TurnEngine.cpp" />
     <ClCompile Include="..\..\Engine\VectorTypes.cpp" />
     <ClCompile Include="..\..\Engine\ZlibWrapper.cpp" />
+    <ClCompile Include="..\..\Game\CreateParty.cpp" />
     <ClCompile Include="..\..\Game\Game.cpp" />
+    <ClCompile Include="..\..\Game\GameMenu.cpp" />
     <ClCompile Include="..\..\Game\GameOver.cpp" />
     <ClCompile Include="..\..\Game\MainMenu.cpp" />
+    <ClCompile Include="..\..\Game\MainMenuLoad.cpp" />
     <ClCompile Include="..\..\GUI\GUIButton.cpp" />
     <ClCompile Include="..\..\GUI\GUIFont.cpp" />
     <ClCompile Include="..\..\GUI\GUIProgressBar.cpp" />
@@ -332,9 +335,12 @@
     <ClInclude Include="..\..\Engine\TurnEngine\TurnEngine.h" />
     <ClInclude Include="..\..\Engine\VectorTypes.h" />
     <ClInclude Include="..\..\Engine\ZlibWrapper.h" />
+    <ClInclude Include="..\..\Game\CreateParty.h" />
     <ClInclude Include="..\..\Game\Game.h" />
+    <ClInclude Include="..\..\Game\GameMenu.h" />
     <ClInclude Include="..\..\Game\GameOver.h" />
     <ClInclude Include="..\..\Game\MainMenu.h" />
+    <ClInclude Include="..\..\Game\MainMenuLoad.h" />
     <ClInclude Include="..\..\GUI\GUIButton.h" />
     <ClInclude Include="..\..\GUI\GUIFont.h" />
     <ClInclude Include="..\..\GUI\GUIProgressBar.h" />
--- 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 @@
     <ClCompile Include="..\..\GUI\UI\Spellbook.cpp">
       <Filter>GUI\UI</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\Game\GameMenu.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\CreateParty.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\MainMenuLoad.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\lib\libavcodec\avcodec.h">
@@ -1375,6 +1384,15 @@
     <ClInclude Include="..\..\GUI\UI\Spellbook.h">
       <Filter>GUI\UI</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\Game\GameMenu.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\CreateParty.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\MainMenuLoad.h">
+      <Filter>Game</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\lib\OpenAL\lib\x86\avcodec-55.def">
--- 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) )
--- 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();