diff Render.cpp @ 64:f6e7d7110512

Слияние
author Ritor1
date Wed, 23 Jan 2013 13:14:41 +0600
parents a96ebf3123d2 80484cf3a683
children 31feb3432bbd
line wrap: on
line diff
--- a/Render.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/Render.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -1001,7 +1001,7 @@
   char v102; // [sp+Ch] [bp-68h]@191
   __int16 v103; // [sp+10h] [bp-64h]@190
   __int16 v104; // [sp+12h] [bp-62h]@190
-  int v105; // [sp+1Ch] [bp-58h]@1
+  int pHeight; // [sp+1Ch] [bp-58h]@1
   int v106; // [sp+20h] [bp-54h]@3
   int v107; // [sp+24h] [bp-50h]@3
   int v108; // [sp+28h] [bp-4Ch]@9
@@ -1025,7 +1025,7 @@
   float v126; // [sp+70h] [bp-4h]@9
 
   memset(&v102, 0, sizeof(v102));
-  v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);
+  pHeight = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);
   v0 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);
   v1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + v0);
   LODWORD(v124) = (signed int)((pIndoorCamera->uMapGridCellX << 16)
@@ -1149,7 +1149,7 @@
   LODWORD(v126) = 0;
   v17 = v117 - 1;
   v18 = v116 - 1;
-  switch ( v105 )
+  switch ( pHeight )
   {
     case 0:
     case 7:
@@ -1561,7 +1561,7 @@
   ptr_801A08 = pVerticesSR_806210;
   ptr_801A04 = pVerticesSR_801A10;
   LODWORD(v126) = v69;
-  if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )
+  if ( pHeight && pHeight != 7 && pHeight != 3 && pHeight != 4 )
   {
     for ( i = v69; i >= 1; --i )
     {
@@ -1590,21 +1590,21 @@
         v127 = 0;
         v79 = (v73 - 66) << 9;
         v116 = v77;
-        v105 = v79;
+        pHeight = v79;
         v111 = v75 - v77;
         do
         {//    
-		  *(float *)&v106 = (double)v105;
+		  *(float *)&v106 = (double)pHeight;
           *(float *)((char *)&ptr_801A08->vWorldPosition.x + v127) = *(float *)&v106;//x
-          v105 = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
-          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)v105;//y
-          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
-          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)v105;//z
+          pHeight = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)pHeight;//y
+          pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
+          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)pHeight;//z
           *(float *)((char *)&ptr_801A04->vWorldPosition.x + v127) = *(float *)&v106;//x
-          v105 = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
-          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)v105;//y
-          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
-          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)v105;//z
+          pHeight = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)pHeight;//y
+          pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)pHeight;//z
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
             a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v127, 1);
@@ -1615,16 +1615,16 @@
           v79 += 512;
           v127 += 48;
           ++v116;
-          v105 = v79;
+          pHeight = v79;
 		}
         while ( v116 < v107 );
       }
 	  v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v70]);
       v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v70]);
-	  //if ( pRenderer->pRenderD3D )
-        //Render::DrawTerrainD3D(v111, 0, (int)&v102);
-      //else
-        //Render::DrawTerrainSW(v111, 0, (int)&v102);
+	  if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
+        Render::DrawTerrainD3D(v111, 0, (int)&v102);
+      else
+        Render::DrawTerrainSW(v111, 0, (int)&v102);
     }
   }
   else
@@ -1653,23 +1653,23 @@
         v86 = 0;
         v116 = v89 - 2;
         v92 = (66 - v89) << 9;
-        v105 = (66 - v89) << 9;
+        pHeight = (66 - v89) << 9;
         v111 = v90 + 2 - (v89 - 2);
         do
         {
           v93 = v116;
           v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
           *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106;
-          *(float *)&v105 = (double)v105;
-          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&v105;
+          *(float *)&pHeight = (double)pHeight;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&pHeight;
           v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93);
           v97 = v116;
           *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106;
           v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
           *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106;
-          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&v105;
-          v105 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
-          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)v105;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&pHeight;
+          pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight;
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
            a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1);
@@ -1680,16 +1680,16 @@
           v92 -= 512;
           v86 += 48;
           ++v116;
-          v105 = v92;
+          pHeight = v92;
 		}
         while ( v116 < v107 );
       }
       v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
 	  v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
-	  //if ( pRenderer->pRenderD3D )
-        //Render::DrawTerrainD3D(v111, 1, (int)&v102);
-      //else
-        //Render::DrawTerrainSW(v111, 1, (int)&v102);
+	  if ( pRenderer->pRenderD3D )
+        Render::DrawTerrainD3D(v111, 1, (int)&v102);
+      else
+        Render::DrawTerrainSW(v111, 1, (int)&v102);
     }
   }
   result = v126;
@@ -1851,11 +1851,11 @@
                v13 = v8->vWorldPosition.y + 6.755399441055744e15,
                sY = LODWORD(v13),
                thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5,
-               v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),
+               v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X
                v15 = v9->vWorldPosition.y + v8->vWorldPosition.y,
                v89 = v14,
                thise = v15 * 0.5,
-               _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),
+               _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z
                WorldPosToGridCellX(sX),
                WorldPosToGridCellZ(sY),
                !byte_4D864C)
@@ -2110,24 +2110,10 @@
       a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0);
       static_sub_0048034E_stru_76D590._49B0C9(v99, *(float *)&a4);
       if ( pDecalBuilder->uNumDecals > 0 )
-        pDecalBuilder->ApplyDecals(
-          31 - v40->field_58,
-          4,
-          &static_sub_0048034E_stru_76D590,
-          uNumVertices,
-          array_50AC10,
-          0,
-          (char)a8,
-          -1);
+        pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)a8, -1);
     }
     if ( stru_F8AD28.uNumLightsApplied > 0 )
-      v96->ApplyLights(
-        &stru_F8AD28,
-        &static_sub_0048034E_stru_76D590,
-        uNumVertices,
-        array_50AC10,
-        0,
-        (char)a8);
+      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)a8);
     v55 = uNumVertices;
     v35 = byte_4D864C == 0;
     v40->uNumVertices = uNumVertices;
@@ -2836,7 +2822,7 @@
   int v13; // eax@14
   RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1
   int v15; // [sp+54h] [bp-10h]@13
-  int i; // [sp+58h] [bp-Ch]@1
+  int v16; // [sp+58h] [bp-Ch]@1
   int v17; // [sp+5Ch] [bp-8h]@2
   int v18; // [sp+60h] [bp-4h]@13
 
@@ -2850,41 +2836,39 @@
   billboard.uViewportW = pViewport->uViewportW;
   v0 = 0;
   pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
-  //v16 = 0;
-  for (i = 0; i < uNumBillboardsToDraw; ++i)//if ( (signed int)uNumBillboardsToDraw > 0 )
+  v16 = 0;
+  if ( (signed int)uNumBillboardsToDraw > 0 )
   {
     v17 = 0;
-    struct RenderBillboard *pBillboard;
-    pBillboard = &pBillboardRenderList[i];
     v1 = (char *)&pBillboardRenderList[0].uScreenSpaceY;
-    //do
-    //{
-      billboard.uScreenSpaceX = pBillboard->uScreenSpaceX;;
-      v2 = pBillboard->field_1E;
-      billboard.uScreenSpaceY = pBillboard->uScreenSpaceY;
-      //v3 = *((int *)v1 - 10);
-      billboard.uParentBillboardID = i;
-      //v4 = *((int *)v1 + 1);
-      billboard.field_10 = pBillboard->field_0;
-      //v5 = *((int *)v1 - 9);
-      billboard.uTintColor = pBillboard->uTintColor;
-      //v6 = *((short *)v1 - 8);
-      billboard.field_14 = pBillboard->field_4;
-      //v7 = *((int *)v1 - 6);
-      billboard.sZValue = pBillboard->sZValue;
-      billboard.uFlags = pBillboard->field_1E;
-      if ( pBillboard->uHwSpriteID != -1 )
-      {
-        v8 = pBillboard->uPaletteSubindex;;
-        //if ( pRenderer->pRenderD3D )
-        //{
-          billboard.sZValue = pBillboard->sZValue;
-          billboard.uFlags = pBillboard->field_1E;
-          pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], pBillboard->uPaletteSubindex, pBillboard);
-        //}
-        //else
-        //{
-          /*if ( *(v1 - 10) & 2 )
+    do
+    {
+      billboard.uScreenSpaceX = *((short *)v1 - 1);
+      v2 = *((short *)v1 - 5);
+      billboard.uScreenSpaceY = *(short *)v1;
+      v3 = *((int *)v1 - 10);
+      billboard.uParentBillboardID = v0;
+      v4 = *((int *)v1 + 1);
+      billboard.field_10 = v3;
+      v5 = *((int *)v1 - 9);
+      billboard.uTintColor = v4;
+      v6 = *((short *)v1 - 8);
+      billboard.field_14 = v5;
+      v7 = *((int *)v1 - 6);
+      billboard.sZValue = *((int *)v1 - 6);
+      billboard.uFlags = v2;
+      if ( v6 != -1 )
+      {
+        v8 = *((short *)v1 + 1);
+        if ( pRenderer->pRenderD3D )
+        {
+          billboard.sZValue = v7;
+          billboard.uFlags = v2;
+          pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[v6], v8, (RenderBillboard *)(v1 - 40));
+        }
+        else
+        {
+          if ( *(v1 - 10) & 2 )
             v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1);
           else
             v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), v7, *((short *)v1 + 1));
@@ -2902,15 +2886,15 @@
           }
           v13 = *((short *)v1 - 8);
           if ( v13 >= 0 )
-            pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1);*/
-        //}
+            pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1);
+        }
       }
       v17 += 5;
-      //v0 = i + 1;
+      v0 = v16 + 1;
       v1 += 52;
-      //++v16;
-    //}
-    //while ( v16 < (signed int)uNumBillboardsToDraw );
+      ++v16;
+    }
+    while ( v16 < (signed int)uNumBillboardsToDraw );
   }
 }
 
@@ -4291,7 +4275,7 @@
     {
       if ( !v54 || byte_4D864C && pGame->uFlags & 2 )
       {
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));//   
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
         if (bUsingSpecular)
         {