diff DecalBuilder.cpp @ 59:5159d2e6f559

BLV render
author Nomad
date Fri, 26 Oct 2012 02:38:26 +0200
parents fde5c5acb66e
children fdacbc653945
line wrap: on
line diff
--- a/DecalBuilder.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/DecalBuilder.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -202,20 +202,20 @@
   {
     v16 = a4;
   }
-  v18 = v16->vNormal.z;
-  v19 = v16->vNormal.y;
-  v20 = v16->vNormal.x;
-  v37 = (int)&stru_AE4F7C;
-  stru_AE4F64.y = v19;
-  stru_AE4F64.x = v20;
-  LODWORD(v36) = (DWORD)&stru_AE4F70;
-  stru_AE4F64.z = v18;
-  dword_AE4F88 = LODWORD(v16->field_10);
+  v18 = v16->face_plane.vNormal.z;
+  v19 = v16->face_plane.vNormal.y;
+  v20 = v16->face_plane.vNormal.x;
+  v37 = (int)&static_AE4F60.field_1C;
+  static_AE4F60.field_4.y = v19;
+  static_AE4F60.field_4.x = v20;
+  LODWORD(v36) = (DWORD)&static_AE4F60.field_10;
+  static_AE4F60.field_4.z = v18;
+  static_AE4F60.dist = v16->face_plane.dist;
   if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
-          v16->field_14,
-          &stru_AE4F64,
-          &stru_AE4F70,
-          &stru_AE4F7C) )
+          v16->polygonType,
+          &static_AE4F60.field_4,
+          &static_AE4F60.field_10,
+          &static_AE4F60.field_1C) )
   {
       MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
   }
@@ -242,7 +242,7 @@
       v27 = (signed __int64)v21->y;
       v37 = a8;
       v40 = (signed __int64)v26;
-      v28 = *(float *)&v21->field_14;
+      v28 = v21->dot_dist;
       LODWORD(v36) = (uint32)a11;
       a5a = v25;
       v39 = v27;
@@ -374,7 +374,7 @@
     v28 = v18->field_4.y * *(float *)v25
         + *((float *)v25 - 1) * v18->field_4.x
         + *((float *)v25 + 1) * v18->field_4.z
-        + *(float *)&v18->field_28;
+        + v18->dist;
     *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
     *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
     v25 += 48;
@@ -401,7 +401,7 @@
     v39 = a8;
     pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
     v40 = 0;
-    pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v32, *v31, 0);
+    pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
     if ( !(uClipFlags & 1) )
     {
 LABEL_19:
@@ -420,7 +420,7 @@
       {
         v40 = (unsigned int *)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436CDC(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
 LABEL_14:
         v40 = v31;
         v39 = v12->pVertices;
@@ -431,7 +431,7 @@
       {
         v40 = (unsigned int *)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
         goto LABEL_14;
       }
       v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
@@ -453,64 +453,43 @@
 }
 
 //----- (0049BBBD) --------------------------------------------------------
-char DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
+bool DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
 {
-  int v2; // edi@1
-  unsigned int v3; // ebx@1
-  BLVFace *v4; // esi@2
-  unsigned int v5; // eax@2
-  char *v6; // edx@5
   double v7; // st7@12
 
-  v2 = 0;
-  this->uNumDecals = 0;
-  v3 = pBloodsplatContainer->std__vector_pBloodsplats_size;
-  if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
+  if (!pBloodsplatContainer->std__vector_pBloodsplats_size)
+    return true;
+  
+  auto pFace = &pIndoor->pFaces[uFaceID];
+
+  if (pFace->uAttributes & 0x400000)
+    return true;
+  if (pFace->Animated())
+    return true;
+
+  for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
   {
-    v4 = &pIndoor->pFaces[uFaceID];
-    v5 = v4->uAttributes;
-    if ( !(v5 & 0x400000) )
+    auto pBloodsplat = pBloodsplatContainer->std__vector_pBloodsplats + i;
+    if (pFace->pBounding.x1 - pBloodsplat->radius < pBloodsplat->x &&
+        pFace->pBounding.x2 + pBloodsplat->radius > pBloodsplat->x &&
+        pFace->pBounding.y1 - pBloodsplat->radius < pBloodsplat->y &&
+        pFace->pBounding.y2 + pBloodsplat->radius > pBloodsplat->y &&
+        pFace->pBounding.z1 - pBloodsplat->radius < pBloodsplat->z &&
+        pFace->pBounding.z2 + pBloodsplat->radius > pBloodsplat->z)
     {
-      if ( !(v5 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
+      v7 = pFace->pFacePlane.vNormal.z * pBloodsplat->z +
+           pFace->pFacePlane.vNormal.y * pBloodsplat->y +
+           pFace->pFacePlane.vNormal.x * pBloodsplat->x +
+           pFace->pFacePlane.dist;
+      if (v7 <= pBloodsplat->radius)
       {
-        v6 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
-        do
-        {
-          if ( (double)v4->pBounding.x1 - *((float *)v6 + 2) < *((float *)v6 - 1) )
-          {
-            if ( (double)v4->pBounding.x2 + *((float *)v6 + 2) > *((float *)v6 - 1) )
-            {
-              if ( (double)v4->pBounding.y1 - *((float *)v6 + 2) < *(float *)v6 )
-              {
-                if ( (double)v4->pBounding.y2 + *((float *)v6 + 2) > *(float *)v6 )
-                {
-                  if ( (double)v4->pBounding.z1 - *((float *)v6 + 2) < *((float *)v6 + 1) )
-                  {
-                    if ( (double)v4->pBounding.z2 + *((float *)v6 + 2) > *((float *)v6 + 1) )
-                    {
-                      v7 = v4->pFacePlane.vNormal.z * *((float *)v6 + 1)
-                         + v4->pFacePlane.vNormal.y * *(float *)v6
-                         + v4->pFacePlane.vNormal.x * *((float *)v6 - 1)
-                         + v4->pFacePlane.dist;
-                      if ( v7 <= *((float *)v6 + 2) )
-                      {
-                        *((float *)v6 + 3) = v7;
-                        this->std__vector_30B00C[this->uNumDecals++] = v2;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-          ++v2;
-          v6 += 40;
-        }
-        while ( v2 < (signed int)v3 );
+        pBloodsplat->dot_dist = v7;
+        std__vector_30B00C[uNumDecals++] = i;
       }
     }
   }
-  return 1;
+
+  return true;
 }
 
 //----- (0049BCEB) --------------------------------------------------------
@@ -530,7 +509,7 @@
   v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
   if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
   {
-    v3 = pFace->uFaceAttributes;
+    v3 = pFace->uAttributes;
     if ( !(v3 & 0x400000) )
     {
       if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )