diff DecalBuilder.cpp @ 1075:1e38e5c049f3

DecalBuilder cleaning and some type changes
author zipi
date Sat, 25 May 2013 14:07:26 +0100
parents c45d51b3f4f4
children 9b6e252658e8
line wrap: on
line diff
--- a/DecalBuilder.cpp	Sat May 25 13:30:58 2013 +0100
+++ b/DecalBuilder.cpp	Sat May 25 14:07:26 2013 +0100
@@ -546,17 +546,17 @@
 }
 
 //----- (0049BE8A) --------------------------------------------------------
-bool DecalBuilder::_49BE8A(struct stru148 *a2, float a3, int a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
+bool DecalBuilder::_49BE8A(struct stru148 *a2, Vec3_float_ *_a3, float *a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
 {
   bool result; // eax@1
   RenderVertexSoft *v8; // edi@3
-  float v9; // ebx@3
-  char *v10; // esi@3
+  Vec3_float_ *v9; // ebx@3
+  Bloodsplat *v10; // esi@3
   float v11; // eax@5
   float v12; // eax@6
   double v13; // st7@13
   double v14; // st7@19
-  int v15; // eax@20
+  short v15; // eax@20
   int v16; // eax@22
   int v17; // edx@24
   DecalBuilder *v18; // eax@24
@@ -574,6 +574,7 @@
   float v30; // [sp+30h] [bp-Ch]@6
   float v31; // [sp+34h] [bp-8h]@6
   bool v32; // [sp+38h] [bp-4h]@2
+  float a3;
 
   this->uNumDecals = 0;
   result = pBloodsplatContainer->std__vector_pBloodsplats_size;
@@ -585,11 +586,20 @@
     if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
     {
       v8 = a5;
-      v9 = a3;
-      v10 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
-      while ( uStripType != 4 )
+      v9 = _a3;
+	  v10 = pBloodsplatContainer->std__vector_pBloodsplats;
+      while ( v32 < (signed int)v23)
       {
-        if ( uStripType == 3 )
+		if ( uStripType == 4 )
+		{
+		  a3 = v8->vWorldPosition.x;
+		  v11 = v8[3].vWorldPosition.x;
+		  v31 = v11;
+		  v30 = v8[1].vWorldPosition.y;
+		  v12 = v8->vWorldPosition.y;
+		  v29 = v12;
+		}
+		else if ( uStripType == 3 )
         {
           if ( a7 )
           {
@@ -597,83 +607,67 @@
             v31 = v8[2].vWorldPosition.x;
             v30 = v8[1].vWorldPosition.y;
             v12 = v8[2].vWorldPosition.y;
-            goto LABEL_7;
+            v29 = v12;
           }
-          a3 = v8[1].vWorldPosition.x;
-          v11 = v8[2].vWorldPosition.x;
-LABEL_6:
-          v31 = v11;
-          v30 = v8[1].vWorldPosition.y;
-          v12 = v8->vWorldPosition.y;
-LABEL_7:
-          v29 = v12;
-          goto LABEL_13;
+		  else
+		  {
+			  a3 = v8[1].vWorldPosition.x;
+			  v11 = v8[2].vWorldPosition.x;
+			  v31 = v11;
+			  v30 = v8[1].vWorldPosition.y;
+			  v12 = v8->vWorldPosition.y;
+			  v29 = v12;
+		  }
         }
-      MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
-LABEL_13:
+		else
+			MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
         v21 = uStripType;
         v13 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v8, uStripType);
         v21 = uStripType;
         v28 = v13;
         v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v8, uStripType);
-        if ( a3 - *((float *)v10 + 2) < *((float *)v10 - 1) )
+		if ( a3 - v10->radius < v10->x &&
+			v31 + v10->radius > v10->x &&
+			v30 - v10->radius < v10->y &&
+            v29 + v10->radius > v10->y &&
+            v28 - v10->radius < v10->z &&
+            v26 + v10->radius > v10->z )
         {
-          if ( v31 + *((float *)v10 + 2) > *((float *)v10 - 1) )
-          {
-            if ( v30 - *((float *)v10 + 2) < *(float *)v10 )
-            {
-              if ( v29 + *((float *)v10 + 2) > *(float *)v10 )
-              {
-                if ( v28 - *((float *)v10 + 2) < *((float *)v10 + 1) )
-                {
-                  if ( v26 + *((float *)v10 + 2) > *((float *)v10 + 1) )
-                  {
-                    Vec3_float_::NegDot(&v8->vWorldPosition, (Vec3_float_ *)LODWORD(v9), (float *)a4);
-                    v26 = *(float *)(LODWORD(v9) + 4) * *(float *)v10
-                        + *(float *)(LODWORD(v9) + 8) * *((float *)v10 + 1)
-                        + *(unsigned int *)LODWORD(v9) * *((float *)v10 - 1)
-                        + *(float *)a4;
-                    v22 = v26 + 6.7553994e15;
-                    v25 = LODWORD(v22);
-                    v14 = (double)SLODWORD(v22);
-                    v28 = v14;
-                    if ( v14 <= *((float *)v10 + 2) )
-                    {
-                      v15 = *(int *)&a2->flags;
-                      if ( v15 & 2 || BYTE1(v15) & 1 )
-                      {
-                        v16 = *((int *)v10 + 5);
-                        if ( !(v16 & 1) )
-                        {
-                          LOBYTE(v16) = v16 | 1;
-                          *((int *)v10 + 5) = v16;
-                          *((_QWORD *)v10 + 3) = pEventTimer->Time();
-                        }
-                      }
-                      v17 = v32;
-                      *((int *)v10 + 3) = LODWORD(v28);
-                      v18 = v24;
-                      v24->std__vector_30B00C[v24->uNumDecals] = v17;
-                      ++v18->uNumDecals;
-                    }
-                  }
-                }
-              }
-            }
-          }
+			Vec3_float_::NegDot(&v8->vWorldPosition, v9, a4);
+			v26 = v9->y * v10->y
+				+ v9->z * v10->z
+				+ v9->x * v10->x
+				+ *a4;
+			v22 = v26 + 6.7553994e15;
+			v25 = LODWORD(v22);
+			v14 = (double)SLODWORD(v22);
+			v28 = v14;
+			if ( v14 <= v10->radius )
+			{
+				v15 = a2->flags;
+				if ( v15 & 2 || BYTE1(v15) & 1 )
+				{
+					v16 = v10->field_1C;
+					if ( !(v16 & 1) )
+					{
+						LOBYTE(v16) = v16 | 1;
+						v10->field_1C = v16;
+						v10->field_20 = pEventTimer->Time();
+					}
+				}
+				v17 = v32;
+				v10->dot_dist = LODWORD(v28);
+				v18 = v24;
+				v24->std__vector_30B00C[v24->uNumDecals] = v17;
+				++v18->uNumDecals;
+			}
         }
         ++v32;
-        v10 += 40;
+        ++v10;
         result = v32;
-        if ( v32 >= (signed int)v23 )
-          goto LABEL_26;
       }
-      a3 = v8->vWorldPosition.x;
-      v11 = v8[3].vWorldPosition.x;
-      goto LABEL_6;
     }
   }
-LABEL_26:
   LOBYTE(result) = 1;
   return result;
 }
@@ -787,23 +781,8 @@
 //----- (0049C550) --------------------------------------------------------
 void DecalBuilder::DrawDecalDebugOutlines()
 {
-  DecalBuilder *v1; // esi@1
-  signed int v2; // ebx@1
-  RenderVertexSoft *v3; // edi@2
-
-  v1 = this;
-  v2 = 0;
-  if ( (signed int)this->std__vector_pDecals_size > 0 )
-  {
-    v3 = this->std__vector_pDecals[0].pVertices;
-    do
-    {
-      pGame->pIndoorCameraD3D->debug_outline_sw(v3, *((int *)v3 - 1), 0xC86400u, 0.0);
-      ++v2;
-      v3 = (RenderVertexSoft *)((char *)v3 + 3104);
-    }
-    while ( v2 < (signed int)v1->std__vector_pDecals_size );
-  }
+  for(int i = 0; i < std__vector_pDecals_size; i++)
+	pGame->pIndoorCameraD3D->debug_outline_sw(std__vector_pDecals[i].pVertices, std__vector_pDecals[i].uNumVertices, 0xC86400u, 0.0);
 }
 
 //----- (0040E4C2) --------------------------------------------------------