diff mm7_3.cpp @ 676:ecfb1b3c9a39

BLV: when standing right on the portal (orange wall) everything looks fine
author Nomad
date Fri, 15 Mar 2013 04:13:24 +0200
parents 92c1e1250e7c
children c0bfb386b15f
line wrap: on
line diff
--- a/mm7_3.cpp	Thu Mar 14 23:44:03 2013 +0200
+++ b/mm7_3.cpp	Fri Mar 15 04:13:24 2013 +0200
@@ -138,7 +138,7 @@
     {
       v11 = v9->pFloors[v10];
       v12 = &pIndoor->pFaces[v11];
-      if ( v12->TwoSided()
+      if ( v12->Portal()
         || stru_721530.sMaxX > v12->pBounding.x2
         || stru_721530.sMinX < v12->pBounding.x1
         || stru_721530.sMaxY > v12->pBounding.y2
@@ -3795,7 +3795,7 @@
         v6 = (unsigned __int64)(a2->z * (signed __int64)v4->pFacePlane_old.vNormal.z) >> 16,
         v7 = v5 + v6 + a4b,
         (v16 = v5 + v6 + a4b) == 0)
-    || v7 > 0 && !v4->TwoSided())
+    || v7 > 0 && !v4->Portal())
     return 0;
   v8 = v4->pFacePlane_old.vNormal.z * a1->z;
   v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x);
@@ -3855,7 +3855,7 @@
         v14 = v10 + v12 + v11,
         v22 = v10 + v12 + v11,
         v13)
-    || v14 > 0 && !a2->TwoSided())
+    || v14 > 0 && !a2->Portal())
     return 0;
   v15 = a4 * a2->pFacePlane_old.vNormal.y;
   v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
@@ -11144,24 +11144,23 @@
 //----- (0043F953) --------------------------------------------------------
 void PrepareBspRenderList_BLV()
 {
-  pBspRenderer->uNumFaceIDs = 0;
+  pBspRenderer->num_faces = 0;
 
   if (pBLVRenderParams->uPartySectorID)
   {
-    pBspRenderer->pSectors[0].uSectorID = pBLVRenderParams->uPartySectorID;
-    pBspRenderer->pSectors[0].uViewportW = pBLVRenderParams->uViewportW;
-    pBspRenderer->pSectors[0].uViewportZ = pBLVRenderParams->uViewportZ;
-    pBspRenderer->pSectors[0].uViewportY = pBLVRenderParams->uViewportY;
-    pBspRenderer->pSectors[0].uViewportX = pBLVRenderParams->uViewportX;
-    pBspRenderer->pSectors[0].field_C._43F9E1(
-      pBLVRenderParams->uViewportX,
-      pBLVRenderParams->uViewportY,
-      pBLVRenderParams->uViewportZ,
-      pBLVRenderParams->uViewportW);
-    pBspRenderer->pSectors[0].uFaceID = -1;
-    pBspRenderer->pSectors[0].std__vector_0007A8 = -1;
-    pBspRenderer->pNumSectors = 1;
-    sub_440639(0);
+    pBspRenderer->nodes[0].uSectorID = pBLVRenderParams->uPartySectorID;
+    pBspRenderer->nodes[0].uViewportW = pBLVRenderParams->uViewportW;
+    pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ;
+    pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY;
+    pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX;
+    pBspRenderer->nodes[0].field_C._43F9E1(pBLVRenderParams->uViewportX,
+                                           pBLVRenderParams->uViewportY,
+                                           pBLVRenderParams->uViewportZ,
+                                           pBLVRenderParams->uViewportW);
+    pBspRenderer->nodes[0].uFaceID = -1;
+    pBspRenderer->nodes[0].std__vector_0007A8 = -1;
+    pBspRenderer->num_nodes = 1;
+    AddBspNodeToRenderList(0);
   }
 
   pBspRenderer->MakeVisibleSectorList();
@@ -11177,8 +11176,8 @@
   {
     if ( i < y || i > w )
     {
+      array_18[i] = 640;
       array_3D8[i] = -1;
-      array_18[i] = 640;
     }
     else
     {
@@ -11516,36 +11515,36 @@
 
 
 //----- (00440639) --------------------------------------------------------
-void __fastcall sub_440639(int a1)
-{
-  int v1; // ebx@1
+void AddBspNodeToRenderList(unsigned int node_id)
+{
+  //int v1; // ebx@1
   signed int v2; // edi@1
   BLVSector *v3; // esi@1
 
-  v1 = a1;
+  //v1 = sector_id;
   v2 = 0;
-  v3 = &pIndoor->pSectors[pBspRenderer->pSectors[a1].uSectorID];
+  v3 = &pIndoor->pSectors[pBspRenderer->nodes[node_id].uSectorID];
   if ( pRenderer->pRenderD3D )
   {
     for (uint i = 0; i < v3->uNumNonBSPFaces; ++i)
       //Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]);
-      pBspRenderer->AddFaceToRenderList_d3d(v1, v3->pFaceIDs[i]);
+      pBspRenderer->AddFaceToRenderList_d3d(node_id, v3->pFaceIDs[i]);
   }
   else
   {
     if ( v3->uNumNonBSPFaces > 0 )
     {
       do
-        pBspRenderer->AddFaceToRenderList_sw(v1, v3->pFaceIDs[v2++]);
+        pBspRenderer->AddFaceToRenderList_sw(node_id, v3->pFaceIDs[v2++]);
       while ( v2 < v3->uNumNonBSPFaces );
     }
   }
   if ( v3->field_0 & 0x10 )
-    sub_4406BC(v1, v3->uFirstBSPNode);
+    sub_4406BC(node_id, v3->uFirstBSPNode);
 }
 
 //----- (004406BC) --------------------------------------------------------
-void __fastcall sub_4406BC(int a1, unsigned int uFirstNode)
+void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode)
 {
   BLVSector *v2; // esi@2
   BSPNode *v3; // edi@2
@@ -11555,14 +11554,14 @@
   int v7; // ebp@10
   int v8; // ebx@10
   __int16 v9; // di@18
-  int v10; // [sp+10h] [bp-Ch]@1
+  //int v10; // [sp+10h] [bp-Ch]@1
   bool v11; // [sp+14h] [bp-8h]@5
   BspRenderer_stru0 *v12; // [sp+18h] [bp-4h]@1
 
   //Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode);
 
-  v10 = a1;
-  v12 = &pBspRenderer->pSectors[a1];
+  //v10 = a1;
+  v12 = &pBspRenderer->nodes[node_id];
   while ( 1 )
   {
     v2 = &pIndoor->pSectors[v12->uSectorID];
@@ -11572,7 +11571,7 @@
        + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x
        + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y
        + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z;
-    if (v4->TwoSided() && v4->uSectorID != v12->uSectorID )
+    if (v4->Portal() && v4->uSectorID != v12->uSectorID )
       v5 = -v5;
     v11 = v5 > 0;
     if ( v5 <= 0 )
@@ -11580,7 +11579,7 @@
     else
       v6 = v3->uBack;
     if ( v6 != -1 )
-      sub_4406BC(v10, v6);
+      sub_4406BC(node_id, v6);
     v7 = v3->uCoplanarOffset;
     v8 = v7 + v3->uCoplanarSize;
 
@@ -11589,12 +11588,12 @@
     if ( pRenderer->pRenderD3D )
     {
       while ( v7 < v8 )
-        pBspRenderer->AddFaceToRenderList_d3d(v10, v2->pFaceIDs[v7++]);
+        pBspRenderer->AddFaceToRenderList_d3d(node_id, v2->pFaceIDs[v7++]);
     }
     else
     {
       while ( v7 < v8 )
-        pBspRenderer->AddFaceToRenderList_sw(v10, v2->pFaceIDs[v7++]);
+        pBspRenderer->AddFaceToRenderList_sw(node_id, v2->pFaceIDs[v7++]);
     }
     v9 = v11 ? v3->uFront : v3->uBack;
     if ( v9 == -1 )