diff DecalBuilder.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children 2ca04ccb612a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DecalBuilder.cpp	Fri Oct 05 16:07:14 2012 +0200
@@ -0,0 +1,951 @@
+#include "DecalBuilder.h"
+#include "Game.h"
+#include "Time.h"
+#include "stru314.h"
+#include "Outdoor.h"
+
+#include "mm7_data.h"
+//#include "MM7.h"
+
+
+
+
+
+struct DecalBuilder *pDecalBuilder;
+struct BloodsplatContainer *pBloodsplatContainer; // idb
+
+
+//----- (0043B570) --------------------------------------------------------
+double DecalBuilder_stru0::_43B570()
+{
+  DecalBuilder_stru0 *v1; // esi@1
+  double result; // st7@3
+
+  v1 = this;
+  if ( this->field_1C_flags & 1 )
+  {
+    if ( (double)(signed __int64)(this->field_20_time - pEventTimer->Time() + 384) * 0.0026041667 >= 0.0 )
+      result = (double)(signed __int64)(v1->field_20_time - pEventTimer->Time() + 384) * 0.0026041667;
+    else
+      result = 0.0;
+  }
+  else
+  {
+    result = 1.0;
+  }
+  return result;
+}
+
+
+
+
+
+//----- (0043B6EF) --------------------------------------------------------
+bool BloodsplatContainer::AddBloodsplat(float x, float y, float z, float radius, char r, char g, char b)
+{
+  int *v8; // esi@1
+  int v9; // eax@3
+  Bloodsplat *v10; // eax@3
+  int *result; // eax@3
+  int v12; // ecx@3
+
+  v8 = &this->uNumBloodsplats;
+  if ( this->uNumBloodsplats == 64 )
+    *v8 = 0;
+  v9 = 5 * (*v8)++;
+  v10 = &this->std__vector_pBloodsplats[8 * v9 / 0x28u];
+  v10->x = x;
+  v10->y = y;
+  v10->z = z;
+  v10->radius = radius;
+  v10->r = r;
+  v10->g = g;
+  v10->b = b;
+  result = (int *)&this->std__vector_pBloodsplats_size;
+  v12 = this->std__vector_pBloodsplats_size + 1;
+  if ( v12 > 64 )
+    v12 = 64;
+  *result = v12;
+  LOBYTE(result) = 1;
+  return (bool)result;
+}
+
+//----- (0049B490) --------------------------------------------------------
+bool DecalBuilder::AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9)
+{
+  double v10; // ST1C_8@1
+  char v11; // ST24_1@1
+  double v12; // ST1C_8@1
+  double v13; // ST1C_8@1
+  int a7a; // [sp+40h] [bp+18h]@1
+  float arg14a; // [sp+44h] [bp+1Ch]@1
+  float arg14b; // [sp+44h] [bp+1Ch]@1
+  float arg14c; // [sp+44h] [bp+1Ch]@1
+
+  arg14a = b * 255.0;
+  v10 = arg14a + 6.7553994e15;
+  v11 = LOBYTE(v10);
+  arg14b = g * 255.0;
+  v12 = arg14b + 6.7553994e15;
+  a7a = LODWORD(v12);
+  arg14c = r * 255.0;
+  v13 = arg14c + 6.7553994e15;
+  return pBloodsplatContainer->AddBloodsplat(x, y, z, radius, SLOBYTE(v13), a7a, v11);
+}
+
+//----- (0049B525) --------------------------------------------------------
+void DecalBuilder::Reset(unsigned int bPreserveBloodsplats)
+{
+  if ( !bPreserveBloodsplats )
+  {
+    pBloodsplatContainer->std__vector_pBloodsplats_size = 0;
+    pBloodsplatContainer->uNumBloodsplats = 0;
+  }
+  this->std__vector_pDecals_size = 0;
+}
+
+//----- (0049B540) --------------------------------------------------------
+char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, int a7, char a8, int a9)
+{
+  char *v9; // eax@3
+  signed int v10; // ecx@3
+  RenderVertexSoft *v11; // eax@10
+  unsigned int v12; // edx@10
+  RenderVertexSoft *v13; // esi@11
+  RenderVertexSoft *v14; // edi@11
+  char v15; // zf@11
+  stru154 *v16; // esi@12
+  double v18; // st7@17
+  double v19; // st6@17
+  float v20; // eax@17
+  Bloodsplat *v21; // esi@21
+  int v22; // eax@21
+  int v23; // ecx@21
+  double v24; // st7@21
+  int v25; // ebx@21
+  double v26; // st7@21
+  int v27; // edi@21
+  double v28; // st7@21
+  int v29; // ST10_4@21
+  int v30; // ST08_4@21
+  DecalBuilder *v31; // esi@21
+  int v32; // [sp+4h] [bp-44h]@18
+  RenderVertexSoft *v33; // [sp+8h] [bp-40h]@21
+  stru314 *v34; // [sp+Ch] [bp-3Ch]@21
+  float v35; // [sp+10h] [bp-38h]@21
+  float v36; // [sp+14h] [bp-34h]@17
+  int v37; // [sp+18h] [bp-30h]@17
+  int a5a; // [sp+28h] [bp-20h]@21
+  int v39; // [sp+2Ch] [bp-1Ch]@21
+  int v40; // [sp+30h] [bp-18h]@21
+  int v41; // [sp+34h] [bp-14h]@22
+  int v42; // [sp+38h] [bp-10h]@21
+  int v43; // [sp+3Ch] [bp-Ch]@21
+  DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
+  RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
+
+  thisa = this;
+  if ( !a5 )
+    return 0;
+
+  static RenderVertexSoft static_AE4F90[64];
+  static bool __init_flag1 = false;
+  if (!__init_flag1)
+  {
+    __init_flag1 = true;
+
+    for (uint i = 0; i < 64; ++i)
+      static_AE4F90[i].flt_2C = 0.0f;
+  }
+  
+  static stru314 static_AE4F60; // idb
+  /*static bool __init_flag2 = false;
+  if (!__init_flag2)
+  {
+    __init_flag2 = true;
+
+    stru314::stru314(&static_AE4F60);
+  }*/
+
+  a11 = a6;
+  if ( a7 )
+  {
+    if ( a5 > 0 )
+    {
+      v11 = static_AE4F90;
+      v12 = (char *)a6 - (char *)static_AE4F90;
+      a6 = (RenderVertexSoft *)a5;
+      do
+      {
+        v13 = (RenderVertexSoft *)((char *)v11 + v12);
+        v14 = v11;
+        ++v11;
+        v15 = a6 == (RenderVertexSoft *)1;
+        a6 = (RenderVertexSoft *)((char *)a6 - 1);
+        memcpy(v14, v13, 0x30u);
+      }
+      while ( !v15 );
+    }
+    v16 = a4;
+    if ( pGame->pIndoorCameraD3D->_437376(a4, static_AE4F90, (unsigned int *)&a5) == 1 )
+    {
+      if ( !a5 )
+        return 0;
+      a11 = static_AE4F90;
+    }
+  }
+  else
+  {
+    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);
+  if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
+          v16->field_14,
+          &stru_AE4F64,
+          &stru_AE4F70,
+          &stru_AE4F7C) )
+  {
+      MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
+  }
+  a7 = 0;
+  if ( thisa->uNumDecals > 0 )
+  {
+    a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
+    do
+    {
+      v21 = &pBloodsplatContainer->std__vector_pBloodsplats[LODWORD(a6->vWorldPosition.x)];
+      *(float *)&v37 = v21->z;
+      v36 = v21->y;
+      v35 = v21->x;
+      v22 = sub_43F5C8(a2, a9, v35, v36, *(float *)&v37);
+      v23 = v21->b;
+      v24 = v21->x;
+      v42 = v22;
+      BYTE3(v22) = 0;
+      *(short *)((char *)&v22 + 1) = v21->r;
+      LOBYTE(v22) = v21->g;
+      v43 = v23 | (v22 << 8);
+      v25 = (signed __int64)v24;
+      v26 = v21->z;
+      v27 = (signed __int64)v21->y;
+      v37 = a8;
+      v40 = (signed __int64)v26;
+      v28 = *(float *)&v21->field_14;
+      LODWORD(v36) = (uint32)a11;
+      a5a = v25;
+      v39 = v27;
+      LODWORD(v35) = a5;
+      v34 = &static_AE4F60;
+      *(float *)&v33 = v28;
+      v32 = v23 | (v22 << 8);
+      *(float *)&v29 = v21->radius;
+      v30 = (int)v21;
+      v31 = thisa;
+      if ( !thisa->_49B790_build_decal_geometry(
+              v42,
+              a3,
+              v30,
+              (int)&a5a,
+              v29,
+              v43,
+              v33,
+              &static_AE4F60,
+              a5,
+              a11,
+              a8) )
+      {
+      MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
+      }
+      ++a7;
+      a6 = (RenderVertexSoft *)((char *)a6 + 4);
+    }
+    while ( a7 < v31->uNumDecals );
+  }
+  return 1;
+}
+// AE4F88: using guessed type int dword_AE4F88;
+// AE5B90: using guessed type char static_init_flag__AE4F90_bit1__AE4F60_bit2;
+
+//----- (0049B790) --------------------------------------------------------
+char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, int a7, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
+{
+  DecalBuilder *v12; // esi@1
+  Decal *v13; // edi@2
+  char *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 v28; // st7@5
+  double v29; // st7@6
+  char result; // al@6
+  unsigned int *v31; // edi@7
+  RenderVertexSoft *v32; // ebx@8
+  std::string *v33; // ecx@15
+  int v34; // eax@19
+  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
+
+  v12 = this;
+  if ( *(float *)&a6 == 0.0 )
+    goto LABEL_24;
+  v13 = &this->std__vector_pDecals[this->field_308008];
+  v14 = (char *)&this->std__vector_pDecals[this->field_308008].field_C1C;
+  this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
+  *(int *)v14 = 0;
+  if ( a3 & 2 )
+    *(int *)v14 = 1;
+  v15 = *(float *)&a6 - *(float *)&a8;
+  *(float *)&this->field_30C028 = v15;
+  v16 = sqrt((*(float *)&a6 + *(float *)&a6 - v15) * v15);
+  *(float *)&v12->field_30C02C = v16;
+  v17 = a5;
+  v18 = a9;
+  v12->flt_30C030 = 1.0 - (*(float *)&a6 - v16) / *(float *)&a6;
+  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - *(float *)&a8 * v18->field_4.x);
+  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - *(float *)&a8 * v18->field_4.y);
+  v19 = *(float *)&a6;
+  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - *(float *)&a8 * v18->field_4.z);
+  v20 = v19 * v12->flt_30C030;
+  a8 = 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;
+  a6 = v13->field_C08;
+  v21 = (double)a6;
+  v22 = v21 - v12->field_30C01C;
+  a6 = v13->field_C0A;
+  v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
+  v23 = (double)a6;
+  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)a6;
+  *(float *)&a6 = v27;
+  v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->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].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].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 = *(float *)&a6 + v12->field_30C024 + v12->field_30C018;
+  v13->pVertices[3].u = 1.0;
+  v13->pVertices[3].v = 0.0;
+  do
+  {
+    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;
+    *((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;
+  }
+  while ( v26 );
+  v13->field_C10 = a7;
+  v40 = (unsigned int *)&v13->uNumVertices;
+  v39 = v13->pVertices;
+  v13->uNumVertices = 4;
+  v13->field_C14 = a2;
+  v29 = v18->field_4.z;
+  a6 = (int)&v13->uNumVertices;
+  v38 = v29;
+  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, v40);
+  if ( result )
+  {
+    v31 = (unsigned int *)a6;
+    if ( !*(int *)a6 )
+      goto LABEL_24;
+    v32 = a8;
+    v40 = *(unsigned int **)a6;
+    v39 = a8;
+    pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
+    v40 = 0;
+    pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v32, *v31, 0);
+    if ( !(uClipFlags & 1) )
+    {
+LABEL_19:
+      ++v12->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;
+      goto LABEL_24;
+    }
+    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+    {
+      if ( uClipFlags & 2 )
+      {
+        v40 = (unsigned int *)&a8;
+        v39 = v12->pVertices;
+        pGame->pIndoorCameraD3D->_436CDC(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+LABEL_14:
+        v40 = v31;
+        v39 = v12->pVertices;
+        pGame->pIndoorCameraD3D->_437143((unsigned int)a8, v32, v12->pVertices, v31);
+        goto LABEL_18;
+      }
+      if ( uClipFlags & 4 )
+      {
+        v40 = (unsigned int *)&a8;
+        v39 = v12->pVertices;
+        pGame->pIndoorCameraD3D->_436F09(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        goto LABEL_14;
+      }
+      v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
+      v35 = "Undefined clip flag specified";
+    }
+    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);
+LABEL_18:
+    if ( *(float *)&a8 != 0.0 )
+      goto LABEL_19;
+LABEL_24:
+    result = 1;
+  }
+  return result;
+}
+
+//----- (0049BBBD) --------------------------------------------------------
+char 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 )
+  {
+    v4 = &pIndoor->pFaces[uFaceID];
+    v5 = v4->uAttributes;
+    if ( !(v5 & 0x400000) )
+    {
+      if ( !(v5 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
+      {
+        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 );
+      }
+    }
+  }
+  return 1;
+}
+
+//----- (0049BCEB) --------------------------------------------------------
+char DecalBuilder::ApplyDecals_OutdoorFace(ODMFace *pFace)
+{
+  int v2; // edi@1
+  unsigned int v3; // eax@2
+  char *v4; // edx@5
+  double v5; // ST1C_8@12
+  double v6; // ST14_8@12
+  double v7; // ST0C_8@12
+  double v8; // st7@12
+  unsigned int v10; // [sp+20h] [bp-1Ch]@1
+
+  v2 = 0;
+  this->uNumDecals = 0;
+  v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
+  if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
+  {
+    v3 = pFace->uFaceAttributes;
+    if ( !(v3 & 0x400000) )
+    {
+      if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
+      {
+        v4 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
+        do
+        {
+          if ( (double)pFace->pBoundingBox.x1 - *((float *)v4 + 2) < *((float *)v4 - 1) )
+          {
+            if ( (double)pFace->pBoundingBox.x2 + *((float *)v4 + 2) > *((float *)v4 - 1) )
+            {
+              if ( (double)pFace->pBoundingBox.y1 - *((float *)v4 + 2) < *(float *)v4 )
+              {
+                if ( (double)pFace->pBoundingBox.y2 + *((float *)v4 + 2) > *(float *)v4 )
+                {
+                  if ( (double)pFace->pBoundingBox.z1 - *((float *)v4 + 2) < *((float *)v4 + 1) )
+                  {
+                    if ( (double)pFace->pBoundingBox.z2 + *((float *)v4 + 2) > *((float *)v4 + 1) )
+                    {
+                      v5 = *((float *)v4 - 1) + 6.7553994e15;
+                      v6 = *(float *)v4 + 6.7553994e15;
+                      v7 = *((float *)v4 + 1) + 6.7553994e15;
+                      v8 = (double)((pFace->pFacePlane.dist
+                                   + LODWORD(v5) * pFace->pFacePlane.vNormal.x
+                                   + LODWORD(v6) * pFace->pFacePlane.vNormal.y
+                                   + LODWORD(v7) * pFace->pFacePlane.vNormal.z) >> 16);
+                      if ( v8 <= *((float *)v4 + 2) )
+                      {
+                        *((float *)v4 + 3) = v8;
+                        this->std__vector_30B00C[this->uNumDecals++] = v2;
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+          ++v2;
+          v4 += 40;
+        }
+        while ( v2 < (signed int)v10 );
+      }
+    }
+  }
+  return 1;
+}
+
+//----- (0049BE8A) --------------------------------------------------------
+bool DecalBuilder::_49BE8A(struct stru148 *a2, float a3, int a4, RenderVertexSoft *a5, unsigned int uStripType, char a7)
+{
+  bool result; // eax@1
+  RenderVertexSoft *v8; // edi@3
+  float v9; // ebx@3
+  char *v10; // esi@3
+  float v11; // eax@5
+  float v12; // eax@6
+  double v13; // st7@13
+  double v14; // st7@19
+  int v15; // eax@20
+  int v16; // eax@22
+  int v17; // edx@24
+  DecalBuilder *v18; // eax@24
+  std::string v19; // [sp-18h] [bp-54h]@12
+  const char *v20; // [sp-8h] [bp-44h]@12
+  int v21; // [sp-4h] [bp-40h]@12
+  double v22; // [sp+Ch] [bp-30h]@19
+  unsigned int v23; // [sp+14h] [bp-28h]@1
+  DecalBuilder *v24; // [sp+18h] [bp-24h]@1
+  int v25; // [sp+1Ch] [bp-20h]@19
+  float v26; // [sp+20h] [bp-1Ch]@12
+  int v27; // [sp+24h] [bp-18h]@12
+  float v28; // [sp+28h] [bp-14h]@13
+  float v29; // [sp+2Ch] [bp-10h]@7
+  float v30; // [sp+30h] [bp-Ch]@6
+  float v31; // [sp+34h] [bp-8h]@6
+  bool v32; // [sp+38h] [bp-4h]@2
+
+  this->uNumDecals = 0;
+  result = pBloodsplatContainer->std__vector_pBloodsplats_size;
+  v24 = this;
+  v23 = pBloodsplatContainer->std__vector_pBloodsplats_size;
+  if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
+  {
+    v32 = 0;
+    if ( (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
+    {
+      v8 = a5;
+      v9 = a3;
+      v10 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
+      while ( uStripType != 4 )
+      {
+        if ( uStripType == 3 )
+        {
+          if ( a7 )
+          {
+            a3 = v8->vWorldPosition.x;
+            v31 = v8[2].vWorldPosition.x;
+            v30 = v8[1].vWorldPosition.y;
+            v12 = v8[2].vWorldPosition.y;
+            goto LABEL_7;
+          }
+          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;
+        }
+      MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:434", 0);
+LABEL_13:
+        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 ( 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;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+        ++v32;
+        v10 += 40;
+        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;
+}
+
+//----- (0049C095) --------------------------------------------------------
+void DecalBuilder::DrawDecal(Decal *pDecal, float a2)
+{
+  Decal *v3; // edi@1
+  double v4; // st7@3
+  double v5; // st7@5
+  int v6; // eax@5
+  unsigned __int8 v7; // zf@5
+  unsigned __int8 v8; // sf@5
+  char *v9; // esi@6
+  int v10; // ebx@6
+  int v11; // eax@8
+  int v12; // edx@8
+  int v13; // eax@8
+  int v14; // ecx@8
+  double v15; // st7@9
+  int v16; // eax@12
+  double v17; // st7@12
+  int v18; // eax@12
+  unsigned __int8 v19; // of@12
+  HRESULT v20; // eax@17
+  signed int v21; // [sp+Ch] [bp-864h]@15
+  const char *v22; // [sp+10h] [bp-860h]@15
+  int v23; // [sp+14h] [bp-85Ch]@15
+  unsigned int v24; // [sp+18h] [bp-858h]@14
+  RenderVertexD3D3 hr[64]; // [sp+20h] [bp-850h]@6
+  double v26; // [sp+820h] [bp-50h]@8
+  double v27; // [sp+828h] [bp-48h]@8
+  double v28; // [sp+830h] [bp-40h]@8
+  int v29; // [sp+838h] [bp-38h]@8
+  int v30; // [sp+83Ch] [bp-34h]@8
+  __int64 v31; // [sp+840h] [bp-30h]@8
+  __int64 v32; // [sp+848h] [bp-28h]@8
+  __int64 v33; // [sp+850h] [bp-20h]@8
+  int v34; // [sp+858h] [bp-18h]@8
+  unsigned __int64 v35; // [sp+85Ch] [bp-14h]@8
+  float v36; // [sp+864h] [bp-Ch]@6
+  int v37; // [sp+868h] [bp-8h]@5
+  float v38; // [sp+86Ch] [bp-4h]@8
+  float thisa; // [sp+878h] [bp+8h]@5
+
+  v3 = pDecal;
+  if ( pDecal->uNumVertices >= 3 )
+  {
+    if ( pDecal->field_C1C & 1 )
+      v4 = 1.0;
+    else
+      v4 = pDecal->field_C18->_43B570();
+    thisa = v4;
+    v5 = get_shading_dist_mist();
+    v6 = 0;
+    v7 = v3->uNumVertices == 0;
+    v8 = v3->uNumVertices < 0;
+    v37 = 0;
+    if ( !(v8 | v7) )
+    {
+      v9 = (char *)&hr[0].pos.y;
+      v10 = (int)&v3->pVertices[0].vWorldViewPosition;
+      v36 = 1.0 / v5;
+      while ( 1 )
+      {
+        v11 = pRenderer->GetActorTintColor(*(float *)v10, v3->field_C14, v6, v6, (RenderBillboard *)v6);
+        LOBYTE(v12) = v11;
+        v33 = ((unsigned int)v11 >> 16) & 0xFFi64;
+        LOBYTE(v38) = BYTE2(v3->field_C10);
+        v38 = (double)v33 * 0.0039215689 * thisa * (double)LOBYTE(v38);
+        v28 = v38 + 6.7553994e15;
+        v31 = (unsigned __int16)v11 >> 8;
+        LODWORD(v38) = BYTE1(v3->field_C10);
+        v38 = (double)v31 * 0.0039215689 * thisa * (double)SLODWORD(v38);
+        v26 = v38 + 6.7553994e15;
+        v35 = __PAIR__(LODWORD(v28), LODWORD(v26));
+        v13 = v3->field_C10;
+        v32 = v12 & 0xFFi64;
+        v29 = (unsigned __int8)v13;
+        v30 = 0;
+        v38 = (double)v32 * 0.0039215689 * thisa * (double)(unsigned __int8)v13;
+        v27 = v38 + 6.7553994e15;
+        v34 = LODWORD(v27);
+        v14 = LODWORD(v27) | ((LODWORD(v26) | (LODWORD(v28) << 8)) << 8);
+        if ( a2 == 0.0 )
+        {
+          v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0);
+        }
+        else
+        {
+          v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0) - a2;
+          if ( v15 < 0.000099999997 )
+            v15 = 0.000099999997;
+        }
+        *((float *)v9 + 1) = v15;
+        v16 = *(int *)(v10 + 12);
+        ++v37;
+        v17 = 1.0 / *(float *)v10;
+        *((int *)v9 - 1) = v16;
+        *(int *)v9 = *(int *)(v10 + 16);
+        *((int *)v9 + 5) = *(int *)(v10 + 24);
+        *((int *)v9 + 6) = *(int *)(v10 + 28);
+        v18 = v37;
+        *((int *)v9 + 3) = v14;
+        *((int *)v9 + 4) = 0;
+        v10 += 48;
+        v9 += 32;
+        v19 = __OFSUB__(v18, v3->uNumVertices);
+        v8 = v18 - v3->uNumVertices < 0;
+        *((float *)v9 - 6) = v17;
+        if ( !(v8 ^ v19) )
+          break;
+        v6 = 0;
+      }
+      v6 = 0;
+    }
+    v24 = v6;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    {
+      v21 = 28;
+    }
+    else
+    {
+      v21 = 16;
+    }
+    ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
+            D3DPT_TRIANGLEFAN,
+            452,
+            hr,
+            v3->uNumVertices,
+            v21));
+  }
+}
+
+//----- (0049C2CD) --------------------------------------------------------
+void DecalBuilder::DrawDecals(float a2)
+{
+  DecalBuilder *v2; // esi@1
+  signed int v3; // edi@1
+  Decal *v4; // ebx@2
+
+  v2 = this;
+  v3 = 0;
+  if ( (signed int)this->std__vector_pDecals_size > 0 )
+  {
+    v4 = this->std__vector_pDecals;
+    do
+    {
+      DrawDecal(v4, a2);
+      ++v3;
+      ++v4;
+    }
+    while ( v3 < (signed int)v2->std__vector_pDecals_size );
+  }
+}
+
+//----- (0049C304) --------------------------------------------------------
+void DecalBuilder::DrawBloodsplats()
+{
+  unsigned int v1; // ebx@0
+  int v2; // esi@0
+  char v3; // zf@1
+  HRESULT v4; // eax@4
+  HRESULT v5; // eax@4
+  HRESULT v6; // eax@4
+  HRESULT v7; // eax@4
+  HRESULT v8; // eax@4
+  HRESULT v9; // eax@4
+  HRESULT v10; // eax@4
+  char *v11; // eax@4
+  //IDirect3DDevice3Vtbl *v12; // ebx@6
+  int v13; // ST6C_4@6
+  HRESULT v14; // eax@6
+  HRESULT v15; // eax@6
+  HRESULT v16; // eax@6
+  HRESULT v17; // eax@6
+  HRESULT v18; // eax@6
+  HRESULT v19; // eax@6
+  char thisa; // [sp+80h] [bp-8h]@4
+  DecalBuilder *v21; // [sp+84h] [bp-4h]@1
+
+  v3 = this->std__vector_pDecals_size == 0;
+  v21 = this;
+  if ( !v3 )
+  {
+    if ( pRenderer->bUsingSpecular )
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
+
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+
+    v11 = (char *)std__string_AE5B94.c_str();
+    if ( !std__string_AE5B94.size() )
+      v11 = (char *)&dword_4D86F0;
+    //v12 = pRenderer->pRenderD3D->pDevice->lpVtbl;
+    v13 = (int)pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v11);
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, (IDirect3DTexture2 *)v13));
+
+    v21->DrawDecals(0.00039999999);
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
+
+    if ( pRenderer->bUsingSpecular )
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
+  }
+}
+
+//----- (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 );
+  }
+}
+
+//----- (0040E4C2) --------------------------------------------------------
+void Decal::Decal_base_ctor()
+{
+  uNumVertices = -1;
+  for (uint i = 0; i < 64; ++i)
+    pVertices[i].flt_2C = 0.0f;
+}