changeset 1075:1e38e5c049f3

DecalBuilder cleaning and some type changes
author zipi
date Sat, 25 May 2013 14:07:26 +0100
parents d6bea22f8b53
children 9b6e252658e8
files DecalBuilder.cpp DecalBuilder.h Render.cpp
diffstat 3 files changed, 75 insertions(+), 96 deletions(-) [+]
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) --------------------------------------------------------
--- a/DecalBuilder.h	Sat May 25 13:30:58 2013 +0100
+++ b/DecalBuilder.h	Sat May 25 14:07:26 2013 +0100
@@ -95,7 +95,7 @@
   char _49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, struct RenderVertexSoft *a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
   bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
-  bool _49BE8A(struct stru148 *a2, float a3, int a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
+  bool _49BE8A(struct stru148 *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
   void DrawDecal(Decal *pDecal, float z_bias);
   void DrawDecals(float z_bias);
   void DrawBloodsplats();
@@ -138,7 +138,7 @@
   {
     this->field_1C = 0;
     this->field_20 = 0;
-    this->field_24 = 0;
+    //this->field_24 = 0;
     //this->vdestructor_ptr = &Bloodsplat_pvdtor;
   }
 
@@ -161,8 +161,8 @@
   char b;
   char field_1B;
   int field_1C;
-  int field_20;
-  int field_24;
+  unsigned long long field_20;
+  //int field_24;
 };
 #pragma pack(pop)
 
--- a/Render.cpp	Sat May 25 13:30:58 2013 +0100
+++ b/Render.cpp	Sat May 25 14:07:26 2013 +0100
@@ -1935,7 +1935,7 @@
   int v83; // [sp+60h] [bp-70h]@1
   int v84; // [sp+6Ch] [bp-64h]@1
   int v85; // [sp+70h] [bp-60h]@63
-  int a4; // [sp+74h] [bp-5Ch]@73
+  float a4; // [sp+74h] [bp-5Ch]@73
   float v87; // [sp+78h] [bp-58h]@122
   int v88; // [sp+7Ch] [bp-54h]@1
   int v89; // [sp+80h] [bp-50h]@6
@@ -2096,7 +2096,7 @@
           v32 = (struct8 *)array_50AC10;
           v97 = (int)pGame->pLightmapBuilder;
           pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1);
-          pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1);
+          pDecalBuilder->_49BE8A(v16, v23, &v95, array_50AC10, 4, 1);
           a5 = 4;
           if ( byte_4D864C && pGame->uFlags & 0x80 )
           {
@@ -2238,7 +2238,7 @@
       }*/
       v96 = pGame->pLightmapBuilder;
       pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0);
-      pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0);
+      pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0);
       uNumVertices = 3;
       if ( byte_4D864C && pGame->uFlags & 0x80 )
       {
@@ -2361,7 +2361,7 @@
       }*/
       v96 = pGame->pLightmapBuilder;
       pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1);
-      pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1);
+      pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1);
       v100 = 3;
       if ( byte_4D864C && pGame->uFlags & 0x80 )
       {