diff Render.cpp @ 1999:079f2abf54e4

DrawIndoorSky() fix
author Ritor1
date Tue, 05 Nov 2013 12:58:19 +0600
parents 157fd2831567
children 2e6c63bdcfa9 bb1e7b0780d8
line wrap: on
line diff
--- 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 )