changeset 1981:d9ea00250e2e

DrawIndoorSky() continue
author Ritor1
date Fri, 01 Nov 2013 14:43:54 +0600
parents b0d96beedc80
children 2647e2f820a6
files Render.cpp
diffstat 1 files changed, 104 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/Render.cpp	Thu Oct 24 15:40:38 2013 +0600
+++ b/Render.cpp	Fri Nov 01 14:43:54 2013 +0600
@@ -4996,20 +4996,11 @@
 void Render::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID)
 {
   BLVFace *pFace; // esi@1
-  //unsigned int v3; // edi@1
-  //PolygonType v4; // al@1
   double v5; // st7@3
   signed __int64 v6; // qax@3
-  //PolygonType v7; // cl@3
-  //int v8; // esi@7
-  //int v9; // eax@7
-  //unsigned int v10; // eax@7
-  //double v11; // st6@7
   int v12; // edx@7
   int v13; // eax@7
-  //char *v14; // esi@8
   void *v15; // ecx@9
-  //int v16; // eax@9
   int v17; // edi@9
   double v18; // st7@9
   signed int v19; // ebx@9
@@ -5020,7 +5011,6 @@
   double v24; // st7@16
   unsigned __int8 v25; // sf@16
   unsigned __int8 v26; // of@16
-  //Render *v27; // ecx@17
   double v28; // st7@20
   char *v29; // ebx@20
   char *v30; // edx@20
@@ -5047,21 +5037,14 @@
   double v51; // st7@46
   RenderVertexSoft *v52; // edx@46
   void *v53; // edi@48
-  //char *v54; // ebx@52
-  //unsigned int v55; // eax@53
-  //unsigned int v56; // eax@55
-  //int v57; // ST10_4@55
-  //Texture *v58; // eax@55
   signed int v59; // [sp-4h] [bp-178h]@17
   struct Polygon *v60; // [sp+0h] [bp-174h]@17
   IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
-  struct Polygon pSkyPoligon; // [sp+14h] [bp-160h]@6
+  struct Polygon pSkyPolygon; // [sp+14h] [bp-160h]@6
   unsigned int v63; // [sp+120h] [bp-54h]@7
-  //double v64; // [sp+124h] [bp-50h]@7
   unsigned int v65; // [sp+128h] [bp-4Ch]@1
   unsigned int v66; // [sp+12Ch] [bp-48h]@7
-  float v67; // [sp+130h] [bp-44h]@7
-  //__int64 v68; // [sp+134h] [bp-40h]@3
+  //float v67; // [sp+130h] [bp-44h]@7
   __int64 v69; // [sp+13Ch] [bp-38h]@3
   int v70; // [sp+144h] [bp-30h]@3
   int X; // [sp+148h] [bp-2Ch]@9
@@ -5077,6 +5060,7 @@
   const void *v81; // [sp+170h] [bp-4h]@7
 
   pFace = &pIndoor->pFaces[uFaceID];
+  //for floor and wall-------------------
   if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor)
   {
     int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x;
@@ -5089,76 +5073,72 @@
     pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0);
     return;
   }
-
-  //*(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
-  v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)
+//---------------------------------------
+  v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)//179
                        / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0)
                         * 65536.0)
                        + (double)pBLVRenderParams->uViewportCenterY);
-  v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;
-  //*(float *)&v75 = v5;
-  v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY
+  v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;//0
+  v6 = (signed __int64)((double)pBLVRenderParams->uViewportCenterY//183
                       - (double)pBLVRenderParams->fov_rad_fixpoint
                       / ((cos(v5) * 16192.0 + 0.0000001)
                        * 65535.0)
                       * (sin(v5) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
 
-
-  stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
-  pSkyPoligon.Create_48607B(&stru_8019C8);
-  pSkyPoligon.uTileBitmapID = pFace->uBitmapID;
-
-  pSkyPoligon.pTexture = pBitmaps_LOD->GetTexture(pSkyPoligon.uTileBitmapID);
-  if ( !pSkyPoligon.pTexture )
+  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);
+  if ( !pSkyPolygon.pTexture )
     return;
 
-  pSkyPoligon.dimming_level = 0;
-  pSkyPoligon.uNumVertices = uNumVertices;
-  pSkyPoligon.v_18.y = 0;
-  pSkyPoligon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
-  pSkyPoligon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
+  pSkyPolygon.dimming_level = 0;
+  pSkyPolygon.uNumVertices = uNumVertices;
+
+  pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
+  pSkyPolygon.v_18.y = 0;
+  pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
+
   memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices]));
-  pSkyPoligon.field_24 = 0x2000000;
+  pSkyPolygon.field_24 = 0x2000000;
 
   extern float _calc_fov(int viewport_width, int angle_degree);
   //v64 = (double)(signed int)(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX) * 0.5;
   //v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
   v72 = 65536.0f / _calc_fov(pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX, 74);
-  v12 = pSkyPoligon.pTexture->uWidthMinus1;
-  v13 = pSkyPoligon.pTexture->uHeightMinus1;
-  v67 = 1.0 / (double)pSkyPoligon.pTexture->uTextureWidth;
+  v12 = pSkyPolygon.pTexture->uWidthMinus1;
+  v13 = pSkyPolygon.pTexture->uHeightMinus1;
+  //v67 = 1.0 / (double)pSkyPolygon.pTexture->uTextureWidth;
   v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
   v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
   v78 = 0;
   v81 = 0;
-  float v68 = 1.0 / (double)pSkyPoligon.pTexture->uTextureHeight;
-  if ( (signed int)pSkyPoligon.uNumVertices <= 0 )
-  {
-LABEL_17:
-    v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPoligon.uTileBitmapID];
-    //v27 = pRenderer;
-    v60 = &pSkyPoligon;
-    v59 = pSkyPoligon.uNumVertices;
-    goto LABEL_18;
+  float v68 = 1.0 / (double)pSkyPolygon.pTexture->uTextureHeight;
+  if ( (signed int)pSkyPolygon.uNumVertices <= 0 )
+  {
+    pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
+       pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
+    return;
   }
 
   //v14 = (char *)&array_507D30[0].vWorldViewProjY;
   int _507D30_idx = 0;
   while ( 2 )
   {
-    v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
-    v77 = (unsigned __int64)(pSkyPoligon.ptr_38->viewing_angle_from_west_east * (signed __int64)(signed int)v15) >> 16;
-    v74 = v77 + pSkyPoligon.ptr_38->angle_from_north;
-    v77 = (int)v15;
-    v77 = (unsigned __int64)(pSkyPoligon.ptr_38->viewing_angle_from_north_south * (signed __int64)(signed int)v15) >> 16;
-    v79 = v15;
-    v75 = (RenderVertexSoft *)(v77 + pSkyPoligon.ptr_38->angle_from_east);
-    v79 = (void *)((unsigned __int64)(pSkyPoligon.v_18.z * (signed __int64)(signed int)v15) >> 16);
+    //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);
+
+    v79 = (void *)(((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16);
     v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
     v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
-    v19 = -pSkyPoligon.field_24;
-    v77 = -pSkyPoligon.field_24;
-    X = (int)((char *)v79 + pSkyPoligon.v_18.x);
+    v19 = -pSkyPolygon.field_24;
+    v77 = -pSkyPolygon.field_24;
+    X = (int)((char *)v79 + pSkyPolygon.v_18.x);
     LODWORD(v76) = (signed __int64)v18;
     v20 = (void *)(v72 * (v70 - LODWORD(v76)));
     while ( 1 )
@@ -5174,44 +5154,68 @@
       v19 = v77;
       v20 = v79;
 LABEL_14:
-      v79 = (void *)((unsigned __int64)(pSkyPoligon.v_18.z * (signed __int64)(signed int)v20) >> 16);
-      v22 = (unsigned __int64)(pSkyPoligon.v_18.z * (signed __int64)(signed int)v20) >> 16;
+      v79 = (void *)((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v20) >> 16);
+      v22 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v20) >> 16;
       --LODWORD(v76);
       v20 = (char *)v20 + v72;
-      X = v22 + pSkyPoligon.v_18.x;
+      X = v22 + pSkyPolygon.v_18.x;
       v78 = 1;
     }
     if ( !v78 )
     {
       LODWORD(v23) = v77 << 16;
-      HIDWORD(v23) = v77 >> 16;
-      v79 = (void *)(v23 / X);
+      HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000
+	  int i = HIDWORD(v23) / X;
+      v79 = (void *)(v23 / X);//X = FFFF96A3(FFFF9014)
       v77 = v17;
       v77 = v17;
-      LODWORD(v76) = v74 + ((unsigned __int64)(pSkyPoligon.ptr_38->angle_from_west * (signed __int64)v17) >> 16);
-      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(pSkyPoligon.ptr_38->angle_from_south * (signed __int64)v17) >> 16));
+
+      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;
+      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);
+      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;
-      LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
       v81 = (char *)v81 + 1;
-      v24 = (double)SLODWORD(v80) * 0.000015259022;
-      LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
-      v26 = __OFSUB__((int)v81, pSkyPoligon.uNumVertices);
-      v25 = (signed int)((char *)v81 - pSkyPoligon.uNumVertices) < 0;
-      array_507D30[_507D30_idx].u = v24 * v67;
-      array_507D30[_507D30_idx].v = (double)SLODWORD(v80) * 0.000015259022 * v68;
+      //v26 = __OFSUB__((int)v81, pSkyPolygon.uNumVertices);
+      //v25 = (signed int)((char *)v81 - pSkyPolygon.uNumVertices) < 0;
       array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
+	  /*
+      v18 = v17 / v38;
+      if ( v18 < 0 )
+        v18 = pODMRenderParams->shading_dist_mist;
+
+      v37 = v35 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v13) >> 16);
+      v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3);
+      array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0);
+
+      v36 = v36 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v13) >> 16);
+      v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)((unsigned __int64)(v36 * (signed __int64)v18) >> 16) >> 3);
+      array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0);
+
+      array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist
+      array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16);
+	  */
       _507D30_idx++;
-      if ( !(v25 ^ v26) )
-        goto LABEL_17;
+      if ( (int)v81 >= pSkyPolygon.uNumVertices )
+      {
+        pRenderer->DrawIndoorSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon,
+           pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
+        return;
+      }
       continue;
     }
     break;
   }
   LODWORD(v73) = 0;
   v80 = v76;
-  if ( (signed int)pSkyPoligon.uNumVertices > 0 )
+  if ( (signed int)pSkyPolygon.uNumVertices > 0 )
   {
     v28 = (double)SLODWORD(v76);
     LODWORD(v76) = (int)(char *)array_50AC10 + 28;
@@ -5219,7 +5223,7 @@
     v30 = (char *)&array_507D30[1].vWorldViewProjY;
     v79 = array_50AC10;
     v81 = array_507D30;
-    v78 = pSkyPoligon.uNumVertices;
+    v78 = pSkyPolygon.uNumVertices;
     do
     {
       v31 = v28 < *((float *)v30 - 12);
@@ -5262,17 +5266,17 @@
   do
   {
     v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34));
-    v78 = pSkyPoligon.ptr_38->viewing_angle_from_west_east;
+    v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east;
     v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
-    v36 = (int)((char *)v81 + pSkyPoligon.ptr_38->angle_from_north);
+    v36 = (int)((char *)v81 + pSkyPolygon.ptr_38->angle_from_north);
     v81 = v35;
     v74 = v36;
-    v78 = pSkyPoligon.ptr_38->viewing_angle_from_north_south;
+    v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south;
     v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
     v78 = (int)v35;
-    v75 = (RenderVertexSoft *)((char *)v81 + pSkyPoligon.ptr_38->angle_from_east);
-    v81 = (const void *)pSkyPoligon.v_18.z;
-    v78 = (unsigned __int64)(pSkyPoligon.v_18.z * (signed __int64)(signed int)v35) >> 16;
+    v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east);
+    v81 = (const void *)pSkyPolygon.v_18.z;
+    v78 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v35) >> 16;
     v37 = (const void *)(v72
                        * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1)));
     v38 = (signed __int64)(*(float *)v34 - 1.0);
@@ -5291,34 +5295,34 @@
         break;
       v39 = v78;
 LABEL_36:
-      v78 = pSkyPoligon.v_18.z;
-      v41 = (unsigned __int64)(pSkyPoligon.v_18.z * (signed __int64)v39) >> 16;
+      v78 = pSkyPolygon.v_18.z;
+      v41 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v39) >> 16;
       --LODWORD(v76);
       v39 += v72;
-      X = v41 + pSkyPoligon.v_18.x;
+      X = v41 + pSkyPolygon.v_18.x;
       v81 = (const void *)1;
     }
     if ( v81 )
     {
-      v79 = (void *)pSkyPoligon.v_18.z;
+      v79 = (void *)pSkyPolygon.v_18.z;
       v78 = 2 * LODWORD(v76);
-      v81 = (const void *)((unsigned __int64)(pSkyPoligon.v_18.z
+      v81 = (const void *)((unsigned __int64)(pSkyPolygon.v_18.z
                                             * (signed __int64)(signed int)(signed __int64)(((double)v70
                                                                                           - ((double)(2 * LODWORD(v76))
                                                                                            - *(float *)v34))
                                                                                          * (double)v72)) >> 16);
-      X = (int)((char *)v81 + pSkyPoligon.v_18.x);
+      X = (int)((char *)v81 + pSkyPolygon.v_18.x);
     }
     LODWORD(v42) = v77 << 16;
     HIDWORD(v42) = v77 >> 16;
     v79 = (void *)(v42 / X);
     v81 = v37;
-    v78 = pSkyPoligon.ptr_38->angle_from_west;
+    v78 = pSkyPolygon.ptr_38->angle_from_west;
     v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
     v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
     v74 = (unsigned int)v37;
     LODWORD(v76) = v43;
-    v78 = pSkyPoligon.ptr_38->angle_from_south;
+    v78 = pSkyPolygon.ptr_38->angle_from_south;
     v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16));
     v74 = (unsigned __int64)(v43 * v42 / X) >> 16;
     v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16);
@@ -5327,7 +5331,7 @@
     v44 = HIDWORD(v69)-- == 1;
     v45 = (double)v78 * 0.000015259022;
     v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
-    *((float *)v34 - 10) = v45 * v67;
+    *((float *)v34 - 10) = v45 * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth);
     *((float *)v34 - 9) = (double)v78 * 0.000015259022 * v68;
     v46 = (double)(signed int)v79;
     *((float *)v34 - 16) = 0.000015258789 * v46;
@@ -5356,8 +5360,8 @@
     }
     while ( HIDWORD(v69) );
   }
-  pSkyPoligon.uNumVertices = v47;
-  pRenderer->DrawIndoorSkyPolygon(v47, &pSkyPoligon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPoligon.uTileBitmapID]);
+  pSkyPolygon.uNumVertices = v47;
+  pRenderer->DrawIndoorSkyPolygon(v47, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
   *(float *)&v74 = 0.0;
   if ( SLODWORD(v73) > 0 )
   {
@@ -5379,12 +5383,12 @@
     }
     while ( v80 != 0.0 );
   }
-  pSkyPoligon.uNumVertices = v74;
-  v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPoligon.uTileBitmapID];
-  v60 = &pSkyPoligon;
+  pSkyPolygon.uNumVertices = v74;
+  v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID];
+  v60 = &pSkyPolygon;
   v59 = v74;
   //v27 = pRenderer;
-LABEL_18:
+//LABEL_18:
   pRenderer->DrawIndoorSkyPolygon(v59, v60, v61);
 }