changeset 2316:25f771e528f0

Draw terrain
author Ritor1
date Wed, 19 Mar 2014 17:30:14 +0600
parents 58be29479e75
children 345b1ff000bb
files LightmapBuilder.cpp Render.cpp Render.h VideoPlayer.h _deleted.cpp
diffstat 5 files changed, 91 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/LightmapBuilder.cpp	Wed Mar 19 10:09:42 2014 +0600
+++ b/LightmapBuilder.cpp	Wed Mar 19 17:30:14 2014 +0600
@@ -240,7 +240,7 @@
   if (!v11->uNumVertices)
     return true;
 
-  v45 = _45C6D6(uNumVertices, a9, v11);
+  v45 = _45C6D6(uNumVertices, a9, v11);//освещён ли фейс(есть ошибка)
   if ( v45 != uNumVertices && v45 > 0 )
     _45C4B9(uNumVertices, a9, v11);
   //v59 = v11->uNumVertices;
@@ -332,7 +332,7 @@
   double v17; // st6@24
   signed int v18; // edx@33
   int v20; // [sp+4h] [bp-1Ch]@3
-  int v21; // [sp+8h] [bp-18h]@8
+  //int v21; // [sp+8h] [bp-18h]@8
   float v22; // [sp+Ch] [bp-14h]@23
   float v23; // [sp+10h] [bp-10h]@20
   int v24; // [sp+14h] [bp-Ch]@1
@@ -340,6 +340,8 @@
   char v26; // [sp+1Eh] [bp-2h]@17
   char v27; // [sp+1Fh] [bp-1h]@17
 
+  __debugbreak();//Ritor1: needed cleaning
+
   v4 = pLightmap;
   v5 = 0;
   v6 = pLightmap->uNumVertices;
@@ -357,23 +359,20 @@
         || v7->vWorldPosition.y != v4->pVertices[v8].vWorldPosition.y
         || v7->vWorldPosition.z != v4->pVertices[v8].vWorldPosition.z )
       {
-        v10 = 0;
+        //v10 = 0;
         if ( a2 > 0 )
         {
-          v11 = (char *)&a3->vWorldPosition.z;
-          do
+          //v11 = (char *)&a3->vWorldPosition.z;
+          for ( v10 = 1; v10 <= a2; ++v10 )
           {
-            v21 = v10 + 1;
-            v12 = &a3[(v10 + 1) % a2];
-            if ( (*((float *)v11 - 2) != v12->vWorldPosition.x
-               || *((float *)v11 - 1) != v12->vWorldPosition.y
-               || *(float *)v11 != v12->vWorldPosition.z)
-              && v7->vWorldPosition.x == *((float *)v11 - 2)
-              && v7->vWorldPosition.y == *((float *)v11 - 1)
-              && v7->vWorldPosition.z == *(float *)v11
+            //v21 = v10 + 1;
+            v12 = &a3[v10 % a2];
+            if ((a3[v10].vWorldPosition.x != v12->vWorldPosition.x
+              || a3[v10].vWorldPosition.y != v12->vWorldPosition.y || a3[v10].vWorldPosition.z != v12->vWorldPosition.z)
+              && v7->vWorldPosition.x == a3[v10].vWorldPosition.x
+              && v7->vWorldPosition.y == a3[v10].vWorldPosition.y && v7->vWorldPosition.z == a3[v10].vWorldPosition.z
               && (v9->vWorldPosition.x != v12->vWorldPosition.x
-               || v9->vWorldPosition.y != v12->vWorldPosition.y
-               || v9->vWorldPosition.z != v12->vWorldPosition.z) )
+               || v9->vWorldPosition.y != v12->vWorldPosition.y || v9->vWorldPosition.z != v12->vWorldPosition.z) )
             {
               v13 = 0;
               v14 = 0;
@@ -384,11 +383,13 @@
               else
                 v15 = v9->vWorldPosition.x - v12->vWorldPosition.x;
               v23 = v15;
+
               if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y )
                 v16 = v12->vWorldPosition.y - v9->vWorldPosition.y;
               else
                 v16 = v9->vWorldPosition.y - v12->vWorldPosition.y;
               v22 = v16;
+
               if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z )
                 v17 = v12->vWorldPosition.z - v9->vWorldPosition.z;
               else
@@ -431,10 +432,10 @@
               }
               v7 = v25;
             }
-            ++v10;
-            v11 += 48;
+            //++v10;
+            //v11 += 48;
           }
-          while ( v21 < a2 );
+          //while ( v21 < a2 );
           v4 = pLightmap;
         }
       }
@@ -486,7 +487,7 @@
                   : pLightmap->pVertices[i].vWorldPosition.z - a3[j].vWorldPosition.z;
               if ( v11 < 2.0 )
               {
-                v12 = v9 + v11 + v10;
+                v12 = v9 + v11 + v10;//Ritor1: Ошибка: В ИДА сюда заходит в данже рядом с факелом, а у нас нет, причину не нашёл
                 if ( v12 < v16 )
                 {
                   v16 = v12;
@@ -611,15 +612,17 @@
   int a5; // [sp+2Ch] [bp-1Ch]@1
   float v19; // [sp+30h] [bp-18h]@1
   float v20; // [sp+34h] [bp-14h]@1
-  LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1
+  //LightmapBuilder *thisa; // [sp+38h] [bp-10h]@1
   int v22; // [sp+3Ch] [bp-Ch]@1
   int *j; // [sp+40h] [bp-8h]@3
   int i; // [sp+44h] [bp-4h]@1
   int a3a; // [sp+58h] [bp+10h]@2
 
+  __debugbreak();//Ritor1: needed cleaning
+
   *(float *)&a5 = 0.0;
   v19 = 0.0;
-  thisa = this;
+  //thisa = this;
   v20 = 0.0;
   result = _45CBD4(a3, a4, dword_69B010.data(), &v22);
   for ( i = 0; i < v22; result = i )
--- a/Render.cpp	Wed Mar 19 10:09:42 2014 +0600
+++ b/Render.cpp	Wed Mar 19 17:30:14 2014 +0600
@@ -264,11 +264,56 @@
     }
   }
 //--------------------------------------------------------------------------------------------------------------------
-
-  //
-  for (unsigned int z = 0; z < 127; ++z)
-  {
-    for (unsigned int x = 0; x < 127; ++x)
+  int direction = pGame->pIndoorCameraD3D->sRotationY / 256;//direction of the camera(напрвление камеры), не могу округлить :(
+  //0-East(B)
+  //1-NorthEast(CB)
+  //2-North(C)
+  //3-WestNorth(CЗ)
+  //4-West(З)
+  //5-SouthWest(ЮЗ)
+  //6-South(Ю)
+  //7-SouthEast(ЮВ)
+  int Start_X, End_X, Start_Z, End_Z;
+  switch ( direction )
+  {
+    case 0://East(B)
+      Start_X = pODMRenderParams->uMapGridCellX, End_X = 127;
+      Start_Z = 0, End_Z = 127;
+      break;
+    case 1://NorthEast(CB)
+      Start_X = 0,/*pODMRenderParams->uMapGridCellX - 1,*/ End_X = 127;
+      Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ;
+      break;
+    case 2://North(C)
+      Start_X = 0, End_X = 127;
+      Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ;
+      break;
+    case 3://WestNorth(CЗ)
+      Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1;
+      Start_Z = 0, End_Z = 127;//pODMRenderParams->uMapGridCellZ + 2;
+      break;
+    case 4://West(З)
+      Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1;
+      Start_Z = 0, End_Z = 127;
+      break;
+    case 5://SouthWest(ЮЗ)
+      Start_X = 0, End_X = 127;//pODMRenderParams->uMapGridCellX + 2;
+      Start_Z = pODMRenderParams->uMapGridCellZ - 1, End_Z = 127;
+      break;
+    case 6://South(Ю)
+      Start_X = 0, End_X = 127;
+      Start_Z = pODMRenderParams->uMapGridCellZ - 1, End_Z = 127;
+      break;
+    case 7://SouthEast(ЮВ)
+      Start_X = pODMRenderParams->uMapGridCellX, End_X = 127;
+      Start_Z = 0,/*pODMRenderParams->uMapGridCellZ,*/ End_Z = 127;
+      break;
+    default:
+      __debugbreak();//Ritor1: error
+  }
+  for (unsigned int z = Start_Z; z < End_Z; ++z)
+  {
+    for (unsigned int x = Start_X; x < End_X; ++x)
     {
       pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons];
       pTilePolygon->flags = 0;
--- a/Render.h	Wed Mar 19 10:09:42 2014 +0600
+++ b/Render.h	Wed Mar 19 17:30:14 2014 +0600
@@ -363,7 +363,7 @@
   void TransformBillboardsAndSetPalettesODM();
   //float DrawBezierTerrain();
   void RenderTerrainD3D();
-  void DrawTerrainD3D(int a1, int edx0, int a3, int unk4);
+  //void DrawTerrainD3D(int a1, int edx0, int a3, int unk4);
   //void DrawTerrainSW(int a1, int a2, int a3, int a4);
   //void ExecOutdoorDrawSW();
   void ChangeBetweenWinFullscreenModes();
--- a/VideoPlayer.h	Wed Mar 19 10:09:42 2014 +0600
+++ b/VideoPlayer.h	Wed Mar 19 17:30:14 2014 +0600
@@ -220,13 +220,6 @@
 		}
 	}
 
-
-
-
-
-
-
-
 	void PlaySample(int num_channels, int sample_rate, int num_samples, void *samples)
 	{
 		//char msg[256];sprintf(msg, "chan %u rate %5u num %5u ptr %p\n", num_channels, sample_rate, num_samples, samples);
--- a/_deleted.cpp	Wed Mar 19 10:09:42 2014 +0600
+++ b/_deleted.cpp	Wed Mar 19 17:30:14 2014 +0600
@@ -2560,9 +2560,9 @@
 
   if ( v2 > 90 )
     v2 = 90;
-  v3 = (v2 << 11) / 720;
-  v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3);
-  v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1);
+  //v3 = (v2 << 11) / 720;
+  v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - ((v2 << 11) / 720));
+  v5 = stru_5C6E00->uDoublePiMask & (((v2 << 11) / 720) + pDirectionIndicator1);
 
   v106 = stru_5C6E00->Cos(v4);
   uEndZ = stru_5C6E00->Sin(v4);
@@ -2679,7 +2679,7 @@
   v17 = j - 1;
   v18 = _i - 1;
 
-  switch ( v105 )
+  switch ( v105 )//напрвление камеры
   {
     case 0:
     case 7:
@@ -2704,12 +2704,11 @@
       }
       if ( v17 < 0 )
         v17 = 0;
-      v21 = terrain_76DFC8[v17];
-      while ( 1 )
-      {
-        v125 = terrain_76DFC8[v17];
-        if ( v21 < v124 )
-          break;
+      
+      //while ( 1 )
+	  for ( v21 = terrain_76DFC8[v17]; v21 < v124; v21 = terrain_76DFC8[v17] - 1; )
+      {
+        //v125 = terrain_76DFC8[v17];
         terrain_76DBC8[v16] = v21;
         //v22 = terrain_76DDC8[v17] == 65535;
         terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1;
@@ -2727,7 +2726,6 @@
           while ( v23 == terrain_76DDC8[v17 -1] );
         }
         --v17;
-        v21 = v125 - 1;
         ++v16;
       }
       v16 = 0;
@@ -2906,7 +2904,7 @@
       {
         //v22 = terrain_76DFC8[v17] == 65535;
         terrain_76DBC8[v16] = terrain_76DFC8[v17];
-        terrain_76D9C8[v16] = v125;
+        terrain_76D9C8[v16] = terrain_76DDC8[v17];
         if ( terrain_76DFC8[v17] == 65535 )
         {
           terrain_76DBC8[v16] = v124;
@@ -3005,10 +3003,10 @@
       v59 = terrain_76DFC8[v17];
       while ( 1 )
       {
-        v125 = v59;
-        if ( v59 > v124 )
+        v125 = terrain_76DFC8[v17];
+        if ( terrain_76DFC8[v17] > v124 )
           break;
-        terrain_76DBC8[v16] = v59;
+        terrain_76DBC8[v16] = terrain_76DFC8[v17];
         //v60 = terrain_76DDC8[v17];
         terrain_76D9C8[v16] = terrain_76DDC8[v17];
         if ( terrain_76DDC8[v17] == 65535 )
@@ -3060,7 +3058,7 @@
       {
         v67 = terrain_76E1C8[v18];
         terrain_76D7C8[v16] = v66;
-        terrain_76D5C8[v16] = v67 + 1;
+        terrain_76D5C8[v16] = terrain_76E1C8[v18] + 1;
         if ( terrain_76E1C8[v18] == 65535 )
         {
           v31 = v123 + 1;
@@ -3089,7 +3087,7 @@
   ptr_801A04 = pVerticesSR_801A10;
   //v126 = v69;
 
-  if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//блок
+  if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//блок, ориентация камеры 1(СВ), 2(С), 5(ЮЗ), 6(Ю)
   {
     for ( i = v16 - 1; i >= 1; --i )
     {
@@ -3154,7 +3152,7 @@
         Render::DrawTerrainSW(v111, 0, v103, v104);
     }
   }
-  else
+  else//ориентация камеры 0(В), 3(СЗ), 4(З), 7(ЮВ)
   {
     for ( i = v16 - 1; i >= 1; --i )
     {