diff DecalBuilder.cpp @ 2245:8817c398b792

for RasterLine2D
author Ritor1
date Tue, 25 Feb 2014 20:02:06 +0600
parents e18200fcfb50
children aff7a7b072b7
line wrap: on
line diff
--- a/DecalBuilder.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/DecalBuilder.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -236,7 +236,7 @@
       v29 = v21->radius;
       //v30 = (int)v21;
       //v31 = thisa;
-      if ( !this->_49B790_build_decal_geometry(v42, a3, (DecalBuilder_stru0 *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) )
+      if ( !this->_49B790_build_decal_geometry(v42, a3, (Bloodsplat *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) )
       {
       MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
       }
@@ -249,26 +249,26 @@
 }
 
 //----- (0049B790) --------------------------------------------------------
-char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
+char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, Bloodsplat *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
 {
-  DecalBuilder *v12; // esi@1
+  //DecalBuilder *v12; // esi@1
   Decal *v13; // edi@2
   int *v14; // eax@2
-  double v15; // st7@4
-  double v16; // st7@4
-  int v17; // eax@4
-  stru314 *v18; // ebx@4
-  double v19; // st7@4
-  double v20; // st7@4
-  double v21; // st7@4
-  double v22; // st6@4
-  double v23; // st6@4
-  double v24; // st5@4
-  char *v25; // eax@4
-  signed int v26; // ecx@4
-  double v27; // st5@4
+  //double v15; // st7@4
+  //double v16; // st7@4
+  //int v17; // eax@4
+  //stru314 *v18; // ebx@4
+  //double v19; // st7@4
+  //double v20; // st7@4
+  //double v21; // st7@4
+  //double v22; // st6@4
+  //double v23; // st6@4
+  //double v24; // st5@4
+  //char *v25; // eax@4
+  //signed int v26; // ecx@4
+  //double v27; // st5@4
   double v28; // st7@5
-  double v29; // st7@6
+  //double v29; // st7@6
   char result; // al@6
   unsigned int *v31; // edi@7
   RenderVertexSoft *v32; // ebx@8
@@ -277,163 +277,150 @@
   const char *v35; // [sp-Ch] [bp-2Ch]@15
   int v36; // [sp-8h] [bp-28h]@15
   std::string v37; // [sp-4h] [bp-24h]@15
-  float v38; // [sp+8h] [bp-18h]@6
-  RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
-  unsigned int v40; // [sp+10h] [bp-10h]@6
+  //float v38; // [sp+8h] [bp-18h]@6
+  //RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
+  //unsigned int v40; // [sp+10h] [bp-10h]@6
 
-  int a6a;
-  RenderVertexSoft *a8a;
+  //int a6a;
+  //RenderVertexSoft *a8a;
   unsigned int a8b = 0;
 
-  v12 = this;
+  //v12 = this;
   if ( a6 == 0.0 )
     return 1;
   v13 = &this->std__vector_pDecals[this->field_308008];
   v14 = &this->std__vector_pDecals[this->field_308008].field_C1C;
-  this->std__vector_pDecals[this->field_308008].field_C18 = a4;
+  this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
   *v14 = 0;
   if ( a3 & 2 )
     *v14 = 1;
-  v15 = a6 - a8;
-  this->field_30C028 = v15;
-  v16 = sqrt((a6 + a6 - v15) * v15);
-  v12->field_30C02C = v16;
-  v17 = a5;
-  v18 = a9;
-  v12->flt_30C030 = 1.0 - (a6 - v16) / a6;
-  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - a8 * v18->field_4.x);
-  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * v18->field_4.y);
-  v19 = a6;
-  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * v18->field_4.z);
-  v20 = v19 * v12->flt_30C030;
-  a8a = v13->pVertices;
-  v12->field_30C034 = v20;
-  v12->field_30C010 = v20 * v18->field_10.x;
-  v12->field_30C014 = v20 * v18->field_10.y;
-  v12->field_30C018 = v20 * v18->field_10.z;
-  v12->field_30C01C = v20 * v18->field_1C.x;
-  v12->field_30C020 = v20 * v18->field_1C.y;
-  v12->field_30C024 = v20 * v18->field_1C.z;
-  a6a = v13->field_C08;
-  v21 = (double)a6a;
-  v22 = v21 - v12->field_30C01C;
-  a6a = v13->field_C0A;
-  v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
-  v23 = (double)a6a;
-  v24 = v23 - v12->field_30C020 + v12->field_30C014;
-  v25 = (char *)&v13->pVertices[0].vWorldPosition.y;
-  a6 = v13->field_C0C;
-  v26 = 4;
-  v13->pVertices[0].vWorldPosition.y = v24;
-  v27 = (double)a6a;
-  a6 = v27;
-  v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018;
+  //v15 = a6 - a8;
+  this->field_30C028 = a6 - a8;
+  //v16 = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028);
+  this->field_30C02C = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028);
+  //v17 = a5;
+  //v18 = a9;
+  this->flt_30C030 = 1.0 - (a6 - this->field_30C02C) / a6;
+  v13->field_C08 = (signed __int64)((double)*(signed int *)a5 - a8 * a9->field_4.x);
+  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * a9->field_4.y);
+  //v19 = a6;
+  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * a9->field_4.z);
+  //v20 = a6 * this->flt_30C030;
+  //a8a = v13->pVertices;
+  this->field_30C034 = a6 * this->flt_30C030;
+  this->field_30C010 = this->field_30C034 * a9->field_10.x;
+  this->field_30C014 = this->field_30C034 * a9->field_10.y;
+  this->field_30C018 = this->field_30C034 * a9->field_10.z;
+  this->field_30C01C = this->field_30C034 * a9->field_1C.x;
+  this->field_30C020 = this->field_30C034 * a9->field_1C.y;
+  this->field_30C024 = this->field_30C034 * a9->field_1C.z;
+  //a6a = v13->field_C08;
+  //v21 = (double)v13->field_C08;
+  //v22 = (double)v13->field_C08 - this->field_30C01C;
+  //a6a = v13->field_C0A;
+  v13->pVertices[0].vWorldPosition.x = (double)v13->field_C08 - this->field_30C01C + this->field_30C010;
+  v13->pVertices[0].vWorldPosition.y = (double)v13->field_C0A - this->field_30C020 + this->field_30C014;
+  v13->pVertices[0].vWorldPosition.z = (double)v13->field_C0A - this->field_30C024 + this->field_30C018;
   v13->pVertices[0].u = 0.0;
   v13->pVertices[0].v = 0.0;
-  v13->pVertices[1].vWorldPosition.x = v21 - v12->field_30C01C - v12->field_30C010;
-  v13->pVertices[1].vWorldPosition.y = v23 - v12->field_30C020 - v12->field_30C014;
-  v13->pVertices[1].vWorldPosition.z = v27 - v12->field_30C024 - v12->field_30C018;
+
+  v13->pVertices[1].vWorldPosition.x = (double)v13->field_C08 - this->field_30C01C - this->field_30C010;
+  v13->pVertices[1].vWorldPosition.y = (double)v13->field_C0A - this->field_30C020 - this->field_30C014;
+  v13->pVertices[1].vWorldPosition.z = (double)v13->field_C0A - this->field_30C024 - this->field_30C018;
   v13->pVertices[1].u = 0.0;
   v13->pVertices[1].v = 1.0;
-  v13->pVertices[2].vWorldPosition.x = v21 + v12->field_30C01C - v12->field_30C010;
-  v13->pVertices[2].vWorldPosition.y = v23 + v12->field_30C020 - v12->field_30C014;
-  v13->pVertices[2].vWorldPosition.z = v27 + v12->field_30C024 - v12->field_30C018;
+
+  v13->pVertices[2].vWorldPosition.x = (double)v13->field_C08 + this->field_30C01C - this->field_30C010;
+  v13->pVertices[2].vWorldPosition.y = (double)v13->field_C0A + this->field_30C020 - this->field_30C014;
+  v13->pVertices[2].vWorldPosition.z = (double)v13->field_C0A + this->field_30C024 - this->field_30C018;
   v13->pVertices[2].u = 1.0;
   v13->pVertices[2].v = 1.0;
-  v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010;
-  v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014;
-  v13->pVertices[3].vWorldPosition.z = a6 + v12->field_30C024 + v12->field_30C018;
+
+  v13->pVertices[3].vWorldPosition.x = (double)v13->field_C08 + this->field_30C01C + this->field_30C010;
+  v13->pVertices[3].vWorldPosition.y = (double)v13->field_C0A + this->field_30C020 + this->field_30C014;
+  v13->pVertices[3].vWorldPosition.z = (double)v13->field_C0A + this->field_30C024 + this->field_30C018;
   v13->pVertices[3].u = 1.0;
   v13->pVertices[3].v = 0.0;
-  do
+
+  for ( uint i = 0; i < 4; ++i )
   {
-    v28 = v18->field_4.y * *(float *)v25
-        + *((float *)v25 - 1) * v18->field_4.x
-        + *((float *)v25 + 1) * v18->field_4.z
-        + v18->dist;
-    *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
-    *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
-    v25 += 48;
-    --v26;
-    *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z;
+    v28 = a9->field_4.x * v13->pVertices[i].vWorldPosition.x
+        + a9->field_4.y * v13->pVertices[i].vWorldPosition.y
+        + a9->field_4.z * v13->pVertices[i].vWorldPosition.z
+        + a9->dist;
+    v13->pVertices[i].vWorldPosition.x = v13->pVertices[i].vWorldPosition.x - v28 * a9->field_4.x;
+    v13->pVertices[i].vWorldPosition.y = v13->pVertices[i].vWorldPosition.y - v28 * a9->field_4.y;
+    v13->pVertices[i].vWorldPosition.z = v13->pVertices[i].vWorldPosition.z - v28 * a9->field_4.z;
+    //v25 += 48;
   }
-  while ( v26 );
   v13->uColorMultiplier = uColorMultiplier;
   //v40 = (unsigned int *)&v13->uNumVertices;
-  v39 = v13->pVertices;
+  //v39 = v13->pVertices;
   v13->uNumVertices = 4;
   v13->field_C14 = a2;
-  v29 = v18->field_4.z;
+  //v29 = a9->field_4.z;
   //a6a = (unsigned int *)&v13->uNumVertices;
-  v38 = v29;
-  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, (unsigned int*)&v13->uNumVertices);
+  //v38 = a9->field_4.z;
+  result = pGame->pStru9Instance->_4980B9(a11, a10, a9->field_4.x, a9->field_4.y, a9->field_4.z, v13->pVertices, (unsigned int*)&v13->uNumVertices);
   if ( result )
   {
     //v31 = a6a;
     if ( !v13->uNumVertices )
       return 1;
-    v32 = a8a;
+    //v32 = a8a;
     //v40 = *a6a;
-    v39 = a8a;
-    pGame->pIndoorCameraD3D->ViewTransform(a8a, (unsigned int)v13->uNumVertices);
-    v40 = 0;
-    pGame->pIndoorCameraD3D->Project(v32, v13->uNumVertices, 0);
+    //v39 = a8a;
+    pGame->pIndoorCameraD3D->ViewTransform(v13->pVertices, (unsigned int)v13->uNumVertices);
+    //v40 = 0;
+    pGame->pIndoorCameraD3D->Project(v13->pVertices, v13->uNumVertices, 0);
     if ( !(uClipFlags & 1) )
     {
-      ++v12->field_308008;
+      ++this->field_308008;
       v34 = 1024;
-      if ( v12->field_308008 == 1024 )
-        v12->field_308008 = 0;
-      if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
-        v34 = v12->std__vector_pDecals_size + 1;
-      v12->std__vector_pDecals_size = v34;
+      if ( this->field_308008 == 1024 )
+        this->field_308008 = 0;
+      if ( (signed int)(this->std__vector_pDecals_size + 1) <= 1024 )
+        v34 = this->std__vector_pDecals_size + 1;
+      this->std__vector_pDecals_size = v34;
       return 1;
     }
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
     {
       if ( uClipFlags & 2 )
       {
-        v40 = (int)&a8;
-        v39 = v12->pVertices;
-      __debugbreak(); // warning C4700: uninitialized local variable 'v31' used
-        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b);
-        v40 = (int)v31;
-        v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
+        //v40 = (int)&a8;
+        //v39 = this->pVertices;
+      //__debugbreak(); // warning C4700: uninitialized local variable 'v31' used
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v13->pVertices, v13->uNumVertices, this->pVertices, &a8b);
+        //v40 = (int)v31;
+        //v39 = this->pVertices;
+        pGame->pIndoorCameraD3D->_437143(a8b, v13->pVertices, this->pVertices, (unsigned int *)v13->uNumVertices);
       }
       else if ( uClipFlags & 4 )
       {
-        v40 = (int)&a8;
-        v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, &a8b);
-        v40 = (int)v31;
-        v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
+        //v40 = (int)&a8;
+        //v39 = this->pVertices;
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v13->pVertices, v13->uNumVertices, this->pVertices, &a8b);
+        //v40 = (int)v31;
+        //v39 = this->pVertices;
+        pGame->pIndoorCameraD3D->_437143(a8b, v13->pVertices, this->pVertices, (unsigned int *)v13->uNumVertices);
       }
-	  else
-	  {
-        v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
-        v35 = "Undefined clip flag specified";
-	    MessageBoxA(nullptr, v35, (const char *)v39, 0);
-	  }
+      else
+        MessageBoxA(nullptr, "Undefined clip flag specified", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258", 0);
     }
     else
-    {
-      v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263";
-      v35 = "Lightpoly builder native indoor clipping not implemented";
-	  MessageBoxA(nullptr, v35, (const char *)v39, 0);
-    }
+      MessageBoxA(nullptr, "Lightpoly builder native indoor clipping not implemented", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263", 0);
     if ( a8b != 0 )
-	{
-      ++v12->field_308008;
+    {
+      ++this->field_308008;
       v34 = 1024;
-      if ( v12->field_308008 == 1024 )
-        v12->field_308008 = 0;
-      if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
-        v34 = v12->std__vector_pDecals_size + 1;
-      v12->std__vector_pDecals_size = v34;
+      if ( this->field_308008 == 1024 )
+        this->field_308008 = 0;
+      if ( (signed int)(this->std__vector_pDecals_size + 1) <= 1024 )
+        v34 = this->std__vector_pDecals_size + 1;
+      this->std__vector_pDecals_size = v34;
       return 1;
-	}
+    }
     result = 1;
   }
   return result;