changeset 1999:079f2abf54e4

DrawIndoorSky() fix
author Ritor1
date Tue, 05 Nov 2013 12:58:19 +0600
parents 1175adbf8c58
children 985fff9fb62d bb1e7b0780d8
files Indoor.cpp Render.cpp
diffstat 2 files changed, 45 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Sun Nov 03 22:42:37 2013 +0600
+++ b/Indoor.cpp	Tue Nov 05 12:58:19 2013 +0600
@@ -487,7 +487,7 @@
   //int v25; // eax@38
   //char *v26; // edi@38
   IDirect3DTexture2 *v27; // eax@42
-  Texture *v28; // [sp+Ch] [bp-1Ch]@15
+  //Texture *v28; // [sp+Ch] [bp-1Ch]@15
   //int i; // [sp+10h] [bp-18h]@38
   //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16
   //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16
@@ -497,9 +497,6 @@
   int a4a; // [sp+34h] [bp+Ch]@25
   //unsigned int a4b; // [sp+34h] [bp+Ch]@38
 
-  //v4 = uFaceID;
-  //a7 = pVertices;
-  //uFaceID_ = uFaceID;
   if (uFaceID >= pIndoor->uNumFaces)
     return;
 
@@ -507,7 +504,6 @@
   static RenderVertexSoft static_vertices_F7B628[64];
   static stru154 stru_F7B60C; // idb
 
-    //v9 = &pIndoor->pFaces[uFaceID];
   BLVFace* pFace = &pIndoor->pFaces[uFaceID];
   if (pFace->uNumVertices < 3)
     return;
@@ -522,8 +518,6 @@
   if (!pFace->GetTexture())
     return;
 
-  v28 = pFace->GetTexture();
-
   if (!pGame->pIndoorCameraD3D->IsCulled(pFace))
   {
     uNumVerticesa = pFace->uNumVertices;
@@ -551,8 +545,7 @@
         pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
         pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0);
         pGame->pLightmapBuilder->std__vector_000004_size = 0;
-        if (stru_F8AD28.uNumLightsApplied > 0 ||
-            pDecalBuilder->uNumDecals > 0)
+        if (stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0)
         {
           stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x;
           stru_F7B60C.polygonType = pFace->uPolygonType;
@@ -570,10 +563,7 @@
         if (pFace->Fluid())
         {
           if (pFace->uBitmapID == pRenderer->hd_water_tile_id)
-          {
-            v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
-            v27 = pBitmaps_LOD->pHardwareTextures[v23];
-          }
+            v27 = pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]];
           else
           {
             //auto v24 = GetTickCount() / 4;
@@ -585,72 +575,52 @@
             for (uint i = 0; i < uNumVerticesa; ++i)
               //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8));
               array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle);
-            v23 = pFace->uBitmapID;
-            v27 = pBitmaps_LOD->pHardwareTextures[v23];
+            v27 = pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID];
           }
         }
         else if (pFace->uAttributes & 0x4000)
-        {
-          v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_);
-          v27 = pBitmaps_LOD->pHardwareTextures[v23];
-        }
+          v27 = pBitmaps_LOD->pHardwareTextures[pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_)];
         else
         {
           v17 = 0xFF808080;
-          v23 = pFace->uBitmapID;
-          v27 = pBitmaps_LOD->pHardwareTextures[v23];
+          v27 = pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID];
         }
 
         if (pFace->uAttributes & FACE_INDOOR_SKY)
           pRenderer->DrawIndoorSky(uNumVerticesa, uFaceID);
         else
-          pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, PID(OBJECT_BModel, uFaceID), v17, 0);
+          pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), v17, 0);
         return;
       }
     }
   }
 }
 
-
-
-
 //----- (004B0E07) --------------------------------------------------------
 unsigned int __fastcall sub_4B0E07(unsigned int uFaceID)
 {
-  BLVFace *v1; // edi@1
-  BLVFaceExtra *v2; // ecx@1
-  Texture *v3; // esi@1
-  unsigned int v4; // eax@1
-  unsigned int v5; // ecx@1
   unsigned int result; // eax@1
-  unsigned int v7; // ecx@5
-
-  v1 = &pIndoor->pFaces[uFaceID];
-  v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID];
-  v3 = pBitmaps_LOD->GetTexture(v1->uBitmapID);
-  stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU;
-  stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV;
-  v4 = GetTickCount();
-  v5 = v1->uAttributes;
-  result = v4 >> 3;
-  if ( v5 & 4 )
+
+  stru_F8AD28.pDeltaUV[0] = pIndoor->pFaceExtras[pIndoor->pFaces[uFaceID].uFaceExtraID].sTextureDeltaU;
+  stru_F8AD28.pDeltaUV[1] = pIndoor->pFaceExtras[pIndoor->pFaces[uFaceID].uFaceExtraID].sTextureDeltaV;
+  result = GetTickCount() >> 3;
+  if ( pIndoor->pFaces[uFaceID].uAttributes & 4 )
   {
-    stru_F8AD28.pDeltaUV[1] -= result & v3->uHeightMinus1;
+    stru_F8AD28.pDeltaUV[1] -= result & pBitmaps_LOD->GetTexture(pIndoor->pFaces[uFaceID].uBitmapID)->uHeightMinus1;
   }
   else
   {
-    if ( v5 & 0x20 )
-      stru_F8AD28.pDeltaUV[1] += result & v3->uHeightMinus1;
+    if ( pIndoor->pFaces[uFaceID].uAttributes & 0x20 )
+      stru_F8AD28.pDeltaUV[1] += result & pBitmaps_LOD->GetTexture(pIndoor->pFaces[uFaceID].uBitmapID)->uHeightMinus1;
   }
-  v7 = v1->uAttributes;
-  if ( BYTE1(v7) & 8 )
+  if ( BYTE1(pIndoor->pFaces[uFaceID].uAttributes) & 8 )
   {
-    stru_F8AD28.pDeltaUV[0] -= result & v3->uWidthMinus1;
+    stru_F8AD28.pDeltaUV[0] -= result & pBitmaps_LOD->GetTexture(pIndoor->pFaces[uFaceID].uBitmapID)->uWidthMinus1;
   }
   else
   {
-    if ( v7 & 0x40 )
-      stru_F8AD28.pDeltaUV[0] += result & v3->uWidthMinus1;
+    if ( pIndoor->pFaces[uFaceID].uAttributes & 0x40 )
+      stru_F8AD28.pDeltaUV[0] += result & pBitmaps_LOD->GetTexture(pIndoor->pFaces[uFaceID].uBitmapID)->uWidthMinus1;
   }
   return result;
 }
--- a/Render.cpp	Sun Nov 03 22:42:37 2013 +0600
+++ b/Render.cpp	Tue Nov 05 12:58:19 2013 +0600
@@ -4978,7 +4978,7 @@
       {
         d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
         d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
-        d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y;
+        d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
         d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw;
         d3d_vertex_buffer[i].diffuse = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
         d3d_vertex_buffer[i].specular = 0;
@@ -5051,6 +5051,7 @@
   int v72; // [sp+14Ch] [bp-28h]@7
   float v73; // [sp+150h] [bp-24h]@16
   unsigned int v74; // [sp+154h] [bp-20h]@3
+  unsigned int v74_; // [sp+154h] [bp-20h]@3
   RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
   float v76; // [sp+15Ch] [bp-18h]@9
   int v77; // [sp+160h] [bp-14h]@9
@@ -5085,8 +5086,8 @@
                        * 65535.0)
                       * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
 
+  stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
   pSkyPolygon.Create_48607B(&stru_8019C8);
-  pSkyPolygon.ptr_38->_48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
   pSkyPolygon.uTileBitmapID = pFace->uBitmapID;
 
   pSkyPolygon.pTexture = pBitmaps_LOD->GetTexture(pSkyPolygon.uTileBitmapID);
@@ -5113,21 +5114,20 @@
   v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
   v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
   v78 = 0;
-  v81 = 0;
+  //v81 = 0;
   float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight;
   if ( (signed int)pSkyPolygon.uNumVertices <= 0 )
     return;
 
-  //v14 = (char *)&array_507D30[0].vWorldViewProjY;
   int _507D30_idx = 0;
-  while ( 2 )
+  for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ )
   {
     //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
     v77 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16;
     v74 = v77 + pSkyPolygon.ptr_38->angle_from_north;
 
     v77 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16;
-    v75 = (RenderVertexSoft *)(v77 + pSkyPolygon.ptr_38->angle_from_east);
+    v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east;
 
     v79 = (void *)(((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))) >> 16);
     v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
@@ -5143,7 +5143,7 @@
       if ( !X )
         goto LABEL_14;
       v21 = abs(v19 >> 14);
-      if ( v21 <= abs(X) )
+      if ( v21 <= abs(X) )//0x800 <= 0x28652
         break;
       if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
         break;
@@ -5163,34 +5163,34 @@
       HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000
       v79 = (void *)(v23 / X);//X = FFFF9014(-28652)
       v77 = v17;
-      LODWORD(v76) = v74 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v17) >> 16);
-      LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
-      //v24 = (double)SLODWORD(v80) * 0.000015259022;
+      signed __int64 s = v74 + ((pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v17) >> 16);// s = 0xFFFFFFFF FFFF3EE6
+      LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(s) * (v23 / X)) >> 16) >> 4);
       array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth);
 
-      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v17) >> 16));
-      LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
+      signed __int64 s2 = (signed __int64)(v74_ + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v17) >> 16));
+      LODWORD(v80) = v63 + ((signed int)((unsigned __int64)(SLODWORD(s2) * (v23 / X)) >> 16) >> 4);
       array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68;
 
-      v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
-      LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
-      //v14 += 48;
-      v81 = (char *)v81 + 1;
-      //v26 = __OFSUB__((int)v81, pSkyPolygon.uNumVertices);
-      //v25 = (signed int)((char *)v81 - pSkyPolygon.uNumVertices) < 0;
+      v77 = (unsigned __int64)(SLODWORD(s) * (v23 / X)) >> 16;
+      LODWORD(v73) = (unsigned __int64)(SLODWORD(s2) * (v23 / X)) >> 16;
       array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
-      _507D30_idx++;
-      if ( (int)v81 >= pSkyPolygon.uNumVertices )
-      {
-        pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
-           pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
-        return;
-      }
+
+      //if ( (int)v81 >= pSkyPolygon.uNumVertices )
+      //{
+      //  pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
+      //     pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
+      //  return;
+      //}
       continue;
     }
     break;
   }
-
+  if ( _507D30_idx >= pSkyPolygon.uNumVertices )
+  {
+    pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
+       pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
+    return;
+  }
   LODWORD(v73) = 0;
   v80 = v76;
   if ( (signed int)pSkyPolygon.uNumVertices > 0 )