diff Render.cpp @ 1644:dbd6f940f26c

Fixed Celestia sky a bit.
author Nomad
date Tue, 17 Sep 2013 21:41:39 +0200
parents 8971dc85b8fb
children a7eebb6ee7a2
line wrap: on
line diff
--- a/Render.cpp	Tue Sep 17 20:15:56 2013 +0200
+++ b/Render.cpp	Tue Sep 17 21:41:39 2013 +0200
@@ -5008,20 +5008,20 @@
 void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID)
 {
   BLVFace *pFace; // esi@1
-  unsigned int v3; // edi@1
-  PolygonType v4; // al@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
+  //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
+  //char *v14; // esi@8
   void *v15; // ecx@9
-  int v16; // eax@9
+  //int v16; // eax@9
   int v17; // edi@9
   double v18; // st7@9
   signed int v19; // ebx@9
@@ -5059,21 +5059,21 @@
   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
+  //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 v62; // [sp+14h] [bp-160h]@6
   unsigned int v63; // [sp+120h] [bp-54h]@7
-  double v64; // [sp+124h] [bp-50h]@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
+  //__int64 v68; // [sp+134h] [bp-40h]@3
   __int64 v69; // [sp+13Ch] [bp-38h]@3
   int v70; // [sp+144h] [bp-30h]@3
   int X; // [sp+148h] [bp-2Ch]@9
@@ -5088,41 +5088,20 @@
   float v80; // [sp+16Ch] [bp-8h]@3
   const void *v81; // [sp+170h] [bp-4h]@7
 
-  __debugbreak();
-
   pFace = &pIndoor->pFaces[uFaceID];
-  v65 = uFaceID;
-  v3 = uNumVertices;
-  v4 = pFace->uPolygonType;
-  if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor )
-  {
-    if ( (signed int)uNumVertices > 0 )
-    {
-      v54 = (char *)&array_507D30[0].u;
-      LODWORD(v80) = uNumVertices;
-      do
-      {
-        v69 = (GetTickCount() >> 5) - pGame->pIndoorCameraD3D->vPartyPos.x;
-        *(float *)v54 = (double)v69 + *(float *)v54;
-        *(float *)v54 = *(float *)v54 * 0.25;
-        v55 = GetTickCount();
-        v54 += 48;
-        v44 = LODWORD(v80)-- == 1;
-        v68 = pGame->pIndoorCameraD3D->vPartyPos.y + (v55 >> 5);
-        *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
-      }
-      while ( !v44 );
-      uFaceID = v65;
-    }
-    v56 = 8 * uFaceID;
-    LOBYTE(v56) = PID(OBJECT_BModel,uFaceID);
-    v57 = v56;
-    v58 = pFace->GetTexture();
-    pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
+  if (pFace->uPolygonType == POLYGON_InBetweenFloorAndWall || pFace->uPolygonType == POLYGON_Floor)
+  {
+    int v69 = (GetTickCount() / 32) - pGame->pIndoorCameraD3D->vPartyPos.x;
+    int v55 = (GetTickCount() / 32) + pGame->pIndoorCameraD3D->vPartyPos.y;
+    for (uint i = 0; i < uNumVertices; ++i)
+    {
+      array_507D30[i].u = (v69 + array_507D30[i].u) * 0.25f;
+      array_507D30[i].v = (v55 + array_507D30[i].v) * 0.25f;
+    }
+    pRenderer->DrawIndoorPolygon(uNumVertices, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), -1, 0);
     return;
   }
-  HIDWORD(v69) = pGame->pIndoorCameraD3D->sRotationX;
-  HIDWORD(v68) = pGame->pIndoorCameraD3D->vPartyPos.z;
+
   *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
   v70 = (signed __int64)((double)(pBLVRenderParams->fov_rad_fixpoint * pGame->pIndoorCameraD3D->vPartyPos.z)
                        / (((double)pBLVRenderParams->fov_rad_fixpoint + 16192.0)
@@ -5130,45 +5109,41 @@
                        + *(float *)&v74);
   v5 = (double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064;
   *(float *)&v75 = v5;
-  v80 = cos(v5) * 16192.0;
   v6 = (signed __int64)(*(float *)&v74
                       - (double)pBLVRenderParams->fov_rad_fixpoint
-                      / ((v80 + 0.0000001)
+                      / ((cos(v5) * 16192.0 + 0.0000001)
                        * 65535.0)
-                      * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68)));
-  v7 = pFace->uPolygonType;
-  if ( v7 == 4 || v7 == 3 )
-    v70 = v6;
+                      * (sin(*(float *)&v75) * -16192.0 - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
+
+
   stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
   v62.Create_48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
-  v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
+
+  v62.pTexture = pBitmaps_LOD->GetTexture(v62.uTileBitmapID);
   if ( !v62.pTexture )
     return;
-  v8 = pGame->pIndoorCameraD3D->sRotationX;
+
   v62.dimming_level = 0;
-  v62.uNumVertices = v3;
-  v9 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
+  v62.uNumVertices = uNumVertices;
   v62.v_18.y = 0;
-  v62.v_18.x = -v9;
-  v62.v_18.z = -stru_5C6E00->Cos(v8 + 16);
-  v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX;
-  memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3]));
-  LODWORD(v80) = v10;
-  v62.field_24 = 33554432;
-  v64 = (double)(signed int)v10 * 0.5;
-  v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
-  LODWORD(v80) = v62.pTexture->uTextureWidth;
-  v11 = 1.0 / (double)SLODWORD(v80);
-  LODWORD(v80) = v62.pTexture->uTextureHeight;
+  v62.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
+  v62.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
+  memcpy(&array_507D30[uNumVertices], array_507D30, sizeof(array_507D30[uNumVertices]));
+  v62.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 = v62.pTexture->uWidthMinus1;
   v13 = v62.pTexture->uHeightMinus1;
-  v67 = v11;
+  v67 = 1.0 / (double)v62.pTexture->uTextureWidth;
   v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
   v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
   v78 = 0;
   v81 = 0;
-  *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80);
+  float v68 = 1.0 / (double)v62.pTexture->uTextureHeight;
   if ( (signed int)v62.uNumVertices <= 0 )
   {
 LABEL_17:
@@ -5178,23 +5153,21 @@
     v59 = v62.uNumVertices;
     goto LABEL_18;
   }
-  v14 = (char *)&array_507D30[0].vWorldViewProjY;
+
+  //v14 = (char *)&array_507D30[0].vWorldViewProjY;
+  int _507D30_idx = 0;
   while ( 2 )
   {
-    v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14));
-    LODWORD(v80) = v62.ptr_38->field_14;
-    v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
-    v16 = v77 + v62.ptr_38->field_C;
+    v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
+    v77 = (unsigned __int64)(v62.ptr_38->field_14 * (signed __int64)(signed int)v15) >> 16;
+    v74 = v77 + v62.ptr_38->field_C;
     v77 = (int)v15;
-    v74 = v16;
-    LODWORD(v80) = v62.ptr_38->field_20;
-    v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
+    v77 = (unsigned __int64)(v62.ptr_38->field_20 * (signed __int64)(signed int)v15) >> 16;
     v79 = v15;
     v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
-    LODWORD(v80) = v62.v_18.z;
     v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
-    v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1));
-    v18 = *(float *)v14 - 1.0;
+    v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
+    v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
     v19 = -v62.field_24;
     v77 = -v62.field_24;
     X = (int)((char *)v79 + v62.v_18.x);
@@ -5213,7 +5186,6 @@
       v19 = v77;
       v20 = v79;
 LABEL_14:
-      LODWORD(v80) = v62.v_18.z;
       v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
       v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
       --LODWORD(v76);
@@ -5227,23 +5199,22 @@
       HIDWORD(v23) = v77 >> 16;
       v79 = (void *)(v23 / X);
       v77 = v17;
-      LODWORD(v80) = v62.ptr_38->field_10;
       v77 = v17;
-      LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16);
-      LODWORD(v80) = v62.ptr_38->field_1C;
-      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
+      LODWORD(v76) = v74 + ((unsigned __int64)(v62.ptr_38->field_10 * (signed __int64)v17) >> 16);
+      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v62.ptr_38->field_1C * (signed __int64)v17) >> 16));
       v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
       LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
-      v14 += 48;
+      //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, v62.uNumVertices);
       v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
-      *((float *)v14 - 10) = v24 * v67;
-      *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1);
-      *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79;
+      array_507D30[_507D30_idx].u = v24 * v67;
+      array_507D30[_507D30_idx].v = (double)SLODWORD(v80) * 0.000015259022 * v68;
+      array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79;
+      _507D30_idx++;
       if ( !(v25 ^ v26) )
         goto LABEL_17;
       continue;
@@ -5369,7 +5340,7 @@
     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 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1);
+    *((float *)v34 - 9) = (double)v78 * 0.000015259022 * v68;
     v46 = (double)(signed int)v79;
     *((float *)v34 - 16) = 0.000015258789 * v46;
     *((float *)v34 - 11) = 65536.0 / v46;