view IndoorCameraD3D.cpp @ 2:2ca04ccb612a

NoCD, main menu, various
author Nomad
date Wed, 10 Oct 2012 14:21:15 +0200
parents 8b8875f5b359
children 540178ef9b18
line wrap: on
line source

#include "IndoorCameraD3D.h"
#include "VectorTypes.h"
#include "Game.h"
#include "Indoor.h"
#include "Viewport.h"
#include "IndoorCamera.h"
#include "OutdoorCamera.h"
#include "Render.h"
#include "LOD.h"

#include "mm7_data.h"



//----- (004364C5) --------------------------------------------------------
void IndoorCameraD3D::_4364C5(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *a1, stru320 *a5)
{
  unsigned int v5; // ebx@1
  char *v6; // edx@2
  char *v7; // eax@2

  v5 = uNumVertices;
  if ( (signed int)uNumVertices > 0 )
  {
    v6 = (char *)&a1->vWorldPosition.z;
    v7 = (char *)&pVertices->vWorldPosition.z;
    do
    {
      *((int *)v6 - 2) = *((int *)v7 - 2);
      *((int *)v6 - 1) = *((int *)v7 - 1);
      *(int *)v6 = *(int *)v7;
      v7 += 48;
      v6 += 48;
      --v5;
      *((float *)v6 - 5) = (double)a5->pDeltaUV[0] + *((float *)v7 - 5);
      *((float *)v6 - 4) = (double)a5->pDeltaUV[1] + *((float *)v7 - 4);
    }
    while ( v5 );
  }
  ViewTransform(a1, uNumVertices);
}

//----- (0043669D) --------------------------------------------------------
char IndoorCameraD3D::ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow)
{
  int to_z; // esi@2
  int v9; // ecx@3
  signed int *v10; // esi@5
  int pOutY_; // ecx@5
  signed int v12; // esi@7
  int v14; // [sp+8h] [bp-4h]@3
  int to_x; // [sp+14h] [bp+8h]@1
  int to_y; // [sp+18h] [bp+Ch]@1
  int a2b; // [sp+18h] [bp+Ch]@5
  int a3a; // [sp+1Ch] [bp+10h]@5

  to_x = (x - pBLVRenderParams->vPartyPos.x) << 16;
  to_y = (y - pBLVRenderParams->vPartyPos.y) << 16;
  if ( pBLVRenderParams->sPartyRotX )
  {
    to_z = (z - pBLVRenderParams->vPartyPos.z) << 16;
    if ( pRenderer->pRenderD3D )
    {
      v14 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
          + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
      v9 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
         - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
    }
    else
    {
      v14 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
          - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
      v9 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
         + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
    }
    a3a = (z - pBLVRenderParams->vPartyPos.z) << 16;
    a2b = (unsigned __int64)(to_z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16;
    v10 = pOutX;
    *pOutX = ((unsigned __int64)(v14 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - a2b;
    *pOutZ = v9;
    pOutY_ = ((unsigned __int64)(v14 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16)
           + ((unsigned __int64)(a3a * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16);
  }
  else
  {
    pOutY_ = (z - pBLVRenderParams->vPartyPos.z) << 16;
    if ( pRenderer->pRenderD3D )
    {
      v10 = pOutX;
      *pOutX = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
             + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
      *pOutZ = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
             - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
    }
    else
    {
      v10 = pOutX;
      *pOutX = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
             - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16);
      *pOutZ = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16)
             + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16);
    }
  }
  *pOutY = pOutY_;
  return !bDoNotShow || (v12 = *v10, v12 >= (signed int)0x40000u) && v12 <= (signed int)0x1F400000u;
}



//----- (00436455) --------------------------------------------------------
bool IndoorCameraD3D::IsFaceFacedTowardsCamera(BLVFace *pFace)
{
  IndoorCameraD3D *v2; // edi@1
  bool result; // eax@1
  RenderVertexSoft v; // [sp+8h] [bp-30h]@1

  v2 = this;
  Vec3_short__to_RenderVertexSoft(&v, &pIndoor->pVertices[*pFace->pVertexIDs]);
  LOBYTE(result) = is_vertex_with_normal_from_face_towards_camera(pFace, &v);
  return result;
}

//----- (00436523) --------------------------------------------------------
void IndoorCameraD3D::ViewTransform(RenderVertexSoft *a1a, unsigned int uNumVertices)
{
  __debugbreak();
  /*
  unsigned int v3; // esi@4
  unsigned int v4; // ecx@7
  float v7; // [sp+4h] [bp-4h]@7

  auto a1 = this;
  if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
  {
    __asm
    {
      fld     pIndoorCamera->fRotationYCosine
      fld     pIndoorCamera->fRotationYSine
      fld     pIndoorCamera->fRotationXCosine
    }
    v4 = uNumVertices;
    v7 = pIndoorCamera->fRotationXSine;
    if ( pIndoorCamera->sRotationX )
    {
      if ( (signed int)uNumVertices > 0 )
      {
        _EAX = a1a;
        do
        {
          __asm
          {
            fild    pIndoorCamera->pos.x
            fsubr   dword ptr [eax]
            fstp    [ebp+a1]
            fild    pIndoorCamera->pos.y
            fsubr   dword ptr [eax+4]
            fstp    [ebp+uNumVertices]
            fild    pIndoorCamera->pos.z
            fsubr   dword ptr [eax+8]
          }
          if ( pRenderer->pRenderD3D )
          {
            __asm
            {
              fld     [ebp+uNumVertices]
              fmul    st, st(3)
              fld     [ebp+a1]
              fmul    st, st(5)
              faddp   st(1), st
              fld     [ebp+a1]
              fmul    st, st(4)
              fld     [ebp+uNumVertices]
              fmul    st, st(6)
              fsubp   st(1), st
            }
          }
          else
          {
            __asm
            {
              fld     [ebp+a1]
              fmul    st, st(4)
              fld     [ebp+uNumVertices]
              fmul    st, st(4)
              fsubp   st(1), st
              fld     [ebp+a1]
              fmul    st, st(4)
              fld     [ebp+uNumVertices]
              fmul    st, st(6)
              faddp   st(1), st
            }
          }
          __asm
          {
            fld     st(1)
            fmul    st, st(4)
            fld     st(3)
            fmul    [ebp+var_4]
          }
          ++_EAX;
          --v4;
          __asm
          {
            fsubp   st(1), st
            fstp    dword ptr [eax-24h]
            fstp    dword ptr [eax-20h]
            fmul    [ebp+var_4]
            fld     st(1)
            fmul    st, st(3)
            faddp   st(1), st
            fstp    dword ptr [eax-1Ch]
            fstp    st
          }
        }
        while ( v4 );
      }
      __asm { fstp    st }
    }
    else
    {
      __asm { fstp    st }
      if ( (signed int)uNumVertices > 0 )
      {
        _EAX = a1a;
        do
        {
          __asm
          {
            fild    pIndoorCamera->pos.x
            fsubr   dword ptr [eax]
            fstp    [ebp+a1]
            fild    pIndoorCamera->pos.y
            fsubr   dword ptr [eax+4]
            fstp    [ebp+uNumVertices]
            fild    pIndoorCamera->pos.z
            fsubr   dword ptr [eax+8]
          }
          if ( pRenderer->pRenderD3D )
          {
            __asm
            {
              fld     [ebp+uNumVertices]
              fmul    st, st(2)
              fld     [ebp+a1]
              fmul    st, st(4)
              faddp   st(1), st
              fstp    dword ptr [eax+0Ch]
              fld     [ebp+a1]
              fmul    st, st(2)
              fld     [ebp+uNumVertices]
              fmul    st, st(4)
              fsubp   st(1), st
            }
          }
          else
          {
            __asm
            {
              fld     [ebp+a1]
              fmul    st, st(3)
              fld     [ebp+uNumVertices]
              fmul    st, st(3)
              fsubp   st(1), st
              fstp    dword ptr [eax+0Ch]
              fld     [ebp+a1]
              fmul    st, st(2)
              fld     [ebp+uNumVertices]
              fmul    st, st(4)
              faddp   st(1), st
            }
          }
          __asm
          {
            fstp    dword ptr [eax+10h]
            fstp    dword ptr [eax+14h]
          }
          ++_EAX;
          --v4;
        }
        while ( v4 );
      }
    }
    __asm
    {
      fstp    st
      fstp    st
    }
  }
  else
  {
    v3 = uNumVertices;
    if ( (signed int)uNumVertices > 0 )
    {
      do
      {
        :ViewTransform(a1a);
        ++a1a;
        --v3;
      }
      while ( v3 );
    }
  }*/
}


//----- (00436932) --------------------------------------------------------
char IndoorCameraD3D::GetFacetOrientation(char a1, Vec3_float_ *a2, Vec3_float_ *a3, Vec3_float_ *a4)
{
  Vec3_float_ *v5; // eax@9
  double v6; // st7@9

  if ( a1 == 1 )
  {
    a4->x = -a2->y;
    a4->y = a2->x;
    a4->z = 0.0;
LABEL_9:
    v5 = a3;
    a3->x = 0.0;
    a3->y = 0.0;
    v6 = 1.0;
LABEL_11:
    v5->z = v6;
    return 1;
  }
  if ( a1 == 3 || a1 == 5 )
  {
LABEL_10:
    a4->x = 1.0;
    a4->y = 0.0;
    a4->z = 0.0;
    v5 = a3;
    a3->x = 0.0;
    a3->y = 1.0;
    v6 = 0.0;
    goto LABEL_11;
  }
  if ( a1 == 4 || a1 == 6 )
  {
    if ( fabs(a2->z) < 0.70811361 )
    {
      a4->x = -a2->y;
      a4->y = a2->x;
      a4->z = 0.0;
      a4->Normalize();
      goto LABEL_9;
    }
    goto LABEL_10;
  }
  return 1;
}


//----- (00438258) --------------------------------------------------------
bool IndoorCameraD3D::is_vertex_with_normal_from_face_towards_camera(BLVFace *pFace, RenderVertexSoft *a2)
{
  char result; // al@2

  if ( (a2->vWorldPosition.z - (double)pIndoorCamera->pos.z) * (double)pFace->pFacePlane_old.vNormal.z
     + (a2->vWorldPosition.y - (double)pIndoorCamera->pos.y) * (double)pFace->pFacePlane_old.vNormal.y
     + (a2->vWorldPosition.x - (double)pIndoorCamera->pos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0
    || (result = 1, pFace->uAttributes & 1) )
    result = 0;
  return result;
}

//----- (00438250) --------------------------------------------------------
void IndoorCameraD3D::Reset_list_0037C()
{
  this->list_0037C_size = 0;
}


//----- (00438240) --------------------------------------------------------
void IndoorCameraD3D::_438240_draw_lits()
{
  IndoorCameraD3D *v1; // ebp@1
  int v2; // edi@2
  int v3; // ebx@3
  int v4; // esi@4
  double v5; // st7@6
  float v6; // ST00_4@8
  IndoorCameraD3D *v7; // esi@1
  float v8; // [sp+4h] [bp-28h]@6
  float v9; // [sp+8h] [bp-24h]@6
  unsigned int v10; // [sp+Ch] [bp-20h]@6
  char v11; // [sp+10h] [bp-1Ch]@6
  float v12; // [sp+14h] [bp-18h]@6
  int v13; // [sp+28h] [bp-4h]@1

  v7 = this;
  _438141_draw_list_0037C();
  v13 = 0;
  v1 = v7;
  if ( v7->list_E0380_size > 0 )
  {
    v2 = (int)&v7->list_E0380[0].field_C04;
    do
    {
      v3 = 0;
      if ( *(int *)v2 > 0 )
      {
        v4 = v2 - 3048;
        do
        {
          if ( *(char *)(v2 - 3076) & 1 )
          {
            LODWORD(v12) = 1;
            v11 = 1;
            v10 = *(int *)(v2 + 4);
            v9 = 0.0;
            v8 = *(float *)(v4 + 4);
            v5 = *(float *)v4;
          }
          else
          {
            LODWORD(v12) = 0;
            v11 = 1;
            v10 = *(int *)(v2 + 4);
            v9 = *(float *)(v4 - 16);
            v8 = *(float *)(v4 - 20);
            v5 = *(float *)(v4 - 24);
          }
          v6 = v5;
          _437D4A_draw_some_vertices(v6, v8, v9, v10, v11, v12);
          ++v3;
          v4 += 48;
        }
        while ( v3 < *(int *)v2 );
      }
      ++v13;
      v2 += 3088;
    }
    while ( v13 < v1->list_E0380_size );
  }
}


//----- (00438141) --------------------------------------------------------
void IndoorCameraD3D::_438141_draw_list_0037C()
{
  IndoorCameraD3D *v1; // edi@1
  signed int v2; // ebx@1
  char *v3; // esi@2
  double v4; // st7@4
  float v5; // ST00_4@6
  float v6; // [sp+4h] [bp-20h]@4
  float v7; // [sp+8h] [bp-1Ch]@4
  unsigned int v8; // [sp+Ch] [bp-18h]@4
  char v9; // [sp+10h] [bp-14h]@4
  float v10; // [sp+14h] [bp-10h]@4

  v1 = this;
  v2 = 0;
  if ( (signed int)this->list_0037C_size > 0 )
  {
    v3 = (char *)&this->list_0037C[0].field_20;
    do
    {
      if ( *(v3 - 32) & 1 )
      {
        LODWORD(v10) = 1;
        v9 = 1;
        v8 = *((int *)v3 + 5);
        v7 = 0.0;
        v6 = *(float *)v3;
        v4 = *((float *)v3 - 1);
      }
      else
      {
        LODWORD(v10) = 0;
        v9 = 1;
        v8 = *((int *)v3 + 5);
        v7 = *((float *)v3 - 5);
        v6 = *((float *)v3 - 6);
        v4 = *((float *)v3 - 7);
      }
      v5 = v4;
      _437D4A_draw_some_vertices(v5, v6, v7, v8, v9, v10);
      ++v2;
      v3 += 56;
    }
    while ( v2 < (signed int)v1->list_0037C_size );
  }
}


//----- (00437D4A) --------------------------------------------------------
void IndoorCameraD3D::_437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7)
{
  IndoorCameraD3D *v7; // edx@1
  char *v8; // eax@1
  signed int v9; // ecx@1
  signed int v10; // edx@10
  char *v11; // ecx@10
  signed int uNumD3DVertices; // edi@16
  char *v13; // ecx@24
  unsigned int v14; // edx@25
  unsigned int v15; // eax@25
  int v16; // ebx@25
  int v17; // eax@26
  int v18; // edx@26
  IDirect3DDevice3 *v19; // ST24_4@27
  HRESULT v20; // eax@27
  RenderVertexSoft vert[20]; // [sp+0h] [bp-680h]@1
  RenderVertexD3D3 pD3DVertices[5]; // [sp+3C0h] [bp-2C0h]@15
  RenderVertexSoft a1; // [sp+640h] [bp-40h]@1
  //double v24; // [sp+670h] [bp-10h]@25
  //double v25; // [sp+678h] [bp-8h]@1

  v7 = this;
  a1.flt_2C = 0.0;
  //HIDWORD(v25) = (int)this;
  v8 = (char *)&vert[0].flt_2C;
  v9 = 20;
  do
  {
    *(float *)v8 = 0.0;
    v8 += 48;
    --v9;
  }
  while ( v9 );
  if ( LOBYTE(a7) )
  {
    vert[0].vWorldViewProjX = x;
    vert[0].vWorldViewProjY = y;
    goto LABEL_15;
  }
  a1.vWorldPosition.x = x;
  a1.vWorldPosition.y = y;
  a1.vWorldPosition.z = z;
  if ( pRenderer->pRenderD3D )
  {
    LODWORD(a7) = 1;
    if ( v7->_437285_prolly_colide_vertices_against_frustrum(
           &a1,
           (unsigned int *)&a7,
           vert,
           v7->std__vector_000034_prolly_frustrum,
           4,
           1,
           0) == 1
      && SLODWORD(a7) < 1 )
      return;
  }
  else
  {
    vert[0].vWorldPosition.x = x;
    vert[0].vWorldPosition.y = y;
    vert[0].vWorldPosition.z = z;
  }
  ViewTransform(vert, 1u);
  v10 = 0;
  v11 = (char *)&vert[0].vWorldViewPosition;
  do
  {
    if ( *(float *)v11 >= 8.0 )
      break;
    ++v10;
    v11 += 48;
  }
  while ( v10 < 1 );
  if ( v10 < 1 )
  {
    _436BB7_project_and_stuff(vert, 1u, 0);
LABEL_15:
    pD3DVertices[0].pos.x = vert[0].vWorldViewProjX;
    pD3DVertices[0].pos.y = vert[0].vWorldViewProjY;
    pD3DVertices[0].specular = 0;
    pD3DVertices[0].diffuse = a5;
    if ( a6 )
    {
      pD3DVertices[0].pos.z = 0.000099999997;
      pD3DVertices[1].pos.x = vert[0].vWorldViewProjX;
      pD3DVertices[2].pos.x = vert[0].vWorldViewProjX;
      pD3DVertices[0].rhw = 0.001;
      uNumD3DVertices = 5;
      pD3DVertices[0].texcoord.x = 0.0;
      pD3DVertices[1].diffuse = a5;
      pD3DVertices[1].specular = 0;
      pD3DVertices[0].texcoord.y = 0.0;
      pD3DVertices[2].diffuse = a5;
      pD3DVertices[2].specular = 0;
      pD3DVertices[3].pos.y = vert[0].vWorldViewProjY;
      pD3DVertices[3].diffuse = a5;
      pD3DVertices[3].specular = 0;
      pD3DVertices[4].pos.y = vert[0].vWorldViewProjY;
      pD3DVertices[1].pos.y = vert[0].vWorldViewProjY - 1.0;
      pD3DVertices[4].diffuse = a5;
      pD3DVertices[4].specular = 0;
      pD3DVertices[1].pos.z = 0.000099999997;
      pD3DVertices[1].rhw = 0.001;
      pD3DVertices[1].texcoord.x = 0.0;
      pD3DVertices[1].texcoord.y = 0.0;
      pD3DVertices[2].pos.y = vert[0].vWorldViewProjY + 1.0;
      pD3DVertices[2].pos.z = 0.000099999997;
      pD3DVertices[2].rhw = 0.001;
      pD3DVertices[2].texcoord.x = 0.0;
      pD3DVertices[2].texcoord.y = 0.0;
      pD3DVertices[3].pos.x = vert[0].vWorldViewProjX - 1.0;
      pD3DVertices[3].pos.z = 0.000099999997;
      pD3DVertices[3].rhw = 0.001;
      pD3DVertices[3].texcoord.x = 0.0;
      pD3DVertices[3].texcoord.y = 0.0;
      pD3DVertices[4].pos.x = vert[0].vWorldViewProjX + 1.0;
      pD3DVertices[4].pos.z = 0.000099999997;
      pD3DVertices[4].rhw = 0.001;
      pD3DVertices[4].texcoord.x = 0.0;
      pD3DVertices[4].texcoord.y = 0.0;
    }
    else
    {
      uNumD3DVertices = 1;
      __debugbreak(); // make things right
      *(unsigned int *)(&pD3DVertices[0].pos.z) = 0x38D1B717u;
      pD3DVertices[0].texcoord.x = 0.0;
      *(unsigned int *)(&pD3DVertices[0].rhw) = 0x3A83126Fu;
      pD3DVertices[0].texcoord.y = 0.0;
    }
    if ( pRenderer->pRenderD3D )
    {
      __debugbreak(); // decompilation bug
      //v19 = pRenderer->pRenderD3D->pDevice;
      ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
      ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_POINTLIST,
              452,
              pD3DVertices,
              uNumD3DVertices,
              16));
    }
    else
    {
      if ( (double)(signed int)pViewport->uViewportX <= vert[0].vWorldViewProjX - 1.0
        && (double)(signed int)pViewport->uViewportZ > vert[0].vWorldViewProjX + 2.0
        && (double)(signed int)pViewport->uViewportY <= vert[0].vWorldViewProjY - 1.0
        && (double)(signed int)pViewport->uViewportW > vert[0].vWorldViewProjY + 2.0
        && uNumD3DVertices > 0 )
      {
        v13 = (char *)&pD3DVertices[0].diffuse;
        do
        {
          LODWORD(a7) = *((int *)v13 - 3);
          //v25 = a7 + 6.7553994e15;
          auto _v25 = floorf(a7);

          //v24 = *((float *)v13 - 4) + 6.7553994e15;
          auto _v24 = floorf(*((float *)v13 - 4));

          v14 = *(int *)v13;
          v15 = *(int *)v13;
          v16 = (*(int *)v13 >> 3) & 0x1F;
          if ( pRenderer->uTargetGBits == 5 )
          {
            v17 = (v15 >> 6) & 0x3E0;
            v18 = (v14 >> 9) & 0x7C00;
          }
          else
          {
            v17 = (v15 >> 5) & 0x7E0;
            v18 = (v14 >> 8) & 0xF800;
          }
          v13 += 32;
          --uNumD3DVertices;
          pRenderer->pTargetSurface[(uint)_v24 + pRenderer->uTargetSurfacePitch * (uint)_v25] = v18 | v16 | (unsigned __int16)v17;
        }
        while ( uNumD3DVertices );
      }
    }
  }
}


//----- (00437C96) --------------------------------------------------------
void IndoorCameraD3D::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, unsigned int uDiffuseBegin, const RenderVertexD3D3 *pLineEnd, unsigned int uDiffuseEnd, float z_stuff)
{
  double v6; // st7@2
  IDirect3DDevice3 *v7; // eax@2
  HRESULT v8; // eax@2
  std::string v9; // [sp-18h] [bp-60h]@3
  const char *v10; // [sp-Ch] [bp-54h]@2
  const char *v11; // [sp-8h] [bp-50h]@2
  int v12; // [sp-4h] [bp-4Ch]@2
  RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2

  if ( pRenderer->pRenderD3D )
  {
    v6 = 0.001 - z_stuff;
    memcpy(v13, pLineBegin, 0x20u);
    memcpy(&v13[1], pLineEnd, sizeof(v13[1]));
    v13[0].pos.z = v6;
    v13[1].pos.z = v6;
    v12 = 0;
    v13[0].diffuse = uDiffuseBegin;
    v13[1].diffuse = uDiffuseEnd;
    v7 = pRenderer->pRenderD3D->pDevice;
    v11 = 0;
    //v10 = (const char *)v7;
    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
    ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
           D3DPT_LINELIST,
           452,
           v13,
           2,
           16));
  }
  else
  {
    MessageBoxW(nullptr, L"draw_debug_line() not implemented for SW rendering", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Core3D.cpp:1415", 0);
  }
}

//----- (00437AB5) --------------------------------------------------------
void IndoorCameraD3D::do_draw_debug_line_sw(RenderVertexSoft *pLineBegin, unsigned int uStartDiffuse, RenderVertexSoft *pLineEnd, unsigned int uEndDiffuse, unsigned int uOutNumVertices, float z_stuff)
{
  char *v7; // eax@2
  signed int v8; // edx@2
  float v9; // ecx@5
  float v10; // eax@5
  char *v11; // eax@6
  signed int v12; // edx@6
  float v13; // edx@8
  float v14; // eax@8
  float v15; // eax@8
  double v16; // st7@11
  HRESULT v17; // eax@11
  std::string v18; // [sp-18h] [bp-7E4h]@12
  IDirect3DDevice3 *v19; // [sp-Ch] [bp-7D8h]@8
  const char *v20; // [sp-8h] [bp-7D4h]@8
  int v21; // [sp-4h] [bp-7D0h]@8
  RenderVertexSoft a1[20]; // [sp+8h] [bp-7C4h]@6
  RenderVertexSoft pVertices[20]; // [sp+3C8h] [bp-404h]@2
  RenderVertexD3D3 v24[2]; // [sp+788h] [bp-44h]@11
  IndoorCameraD3D *v25; // [sp+7C8h] [bp-4h]@1

  v25 = this;
  if ( pRenderer->pRenderD3D )
  {
    v7 = (char *)&pVertices[0].flt_2C;
    v8 = 20;
    do
    {
      *(float *)v7 = 0.0;
      v7 += 48;
      --v8;
    }
    while ( v8 );
    if ( (char)uOutNumVertices )
    {
      v9 = pLineBegin->vWorldViewProjX;
      pVertices[0].vWorldViewProjY = pLineBegin->vWorldViewProjY;
      pVertices[0].vWorldViewProjX = v9;
      v10 = pLineEnd->vWorldViewProjY;
      pVertices[1].vWorldViewProjX = pLineEnd->vWorldViewProjX;
      pVertices[1].vWorldViewProjY = v10;
LABEL_11:
      v16 = 0.001 - z_stuff;
      v24[0].specular = 0;
      v24[0].pos.x = pVertices[0].vWorldViewProjX;
      v24[0].pos.y = pVertices[0].vWorldViewProjY;
      v24[0].pos.z = v16;
      v24[0].diffuse = uStartDiffuse;
      v24[0].rhw = 0.001;
      v24[1].pos.x = pVertices[1].vWorldViewProjX;
      v24[0].texcoord.x = 0.0;
      v24[1].pos.y = pVertices[1].vWorldViewProjY;
      v24[0].texcoord.y = 0.0;
      v24[1].diffuse = uEndDiffuse;
      v24[1].pos.z = v16;
      v24[1].specular = 0;
      v21 = 0;
      v24[1].rhw = 0.001;
      v20 = 0;
      v24[1].texcoord.x = 0.0;
      v24[1].texcoord.y = 0.0;
      //v19 = pRenderer->pRenderD3D->pDevice;
      ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
      ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
              D3DPT_LINELIST,
              452,
              v24,
              2,
              16));
      return;
    }
    v11 = (char *)&a1[0].flt_2C;
    v12 = 20;
    do
    {
      *(float *)v11 = 0.0;
      v11 += 48;
      --v12;
    }
    while ( v12 );
    v21 = 0;
    v20 = (const char *)1;
    v19 = (IDirect3DDevice3 *)4;
    v13 = pLineBegin->vWorldPosition.x;
    uOutNumVertices = 2;
    a1[0].vWorldPosition.x = v13;
    v14 = pLineBegin->vWorldPosition.z;
    a1[0].vWorldPosition.y = pLineBegin->vWorldPosition.y;
    a1[0].vWorldPosition.z = v14;
    a1[1].vWorldPosition.x = pLineEnd->vWorldPosition.x;
    v15 = pLineEnd->vWorldPosition.z;
    a1[1].vWorldPosition.y = pLineEnd->vWorldPosition.y;
    a1[1].vWorldPosition.z = v15;
    if ( _437285_prolly_colide_vertices_against_frustrum(
           a1,
           &uOutNumVertices,
           pVertices,
           this->std__vector_000034_prolly_frustrum,
           4,
           1,
           0) != 1
      || (signed int)uOutNumVertices >= 2 )
    {
      ViewTransform(pVertices, 2u);
      _436BB7_project_and_stuff(pVertices, 2u, 0);
      goto LABEL_11;
    }
  }
  else
    MessageBoxW(nullptr, L"draw_debug_line() not implemented for SW rendering", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Core3D.cpp:1383", 0);
}


//----- (00437A55) --------------------------------------------------------
void IndoorCameraD3D::debug_outline_d3d(const RenderVertexD3D3 *pLineVertices, unsigned int uNumLines, int uDiffuse, float z_stuff)
{
  unsigned int v5; // esi@1
  const RenderVertexD3D3 *v6; // ecx@2
  unsigned int v7; // ebx@2
  const RenderVertexD3D3 *v8; // edi@3
  IndoorCameraD3D *thisa; // [sp+10h] [bp-4h]@1

  v5 = 0;
  thisa = this;
  if ( (signed int)(uNumLines - 1) > 0 )
  {
    v6 = pLineVertices;
    v7 = uNumLines - 1;
    v5 = uNumLines - 1;
    do
    {
      v8 = v6 + 1;
      do_draw_debug_line_d3d(v6, uDiffuse, v6 + 1, uDiffuse, z_stuff);
      --v7;
      v6 = v8;
    }
    while ( v7 );
  }
  do_draw_debug_line_d3d(&pLineVertices[v5], uDiffuse, pLineVertices, uDiffuse, z_stuff);
}


//----- (004379EE) --------------------------------------------------------
void IndoorCameraD3D::debug_outline_sw(RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5)
{
  unsigned int v5; // esi@1
  RenderVertexSoft *v6; // eax@2
  RenderVertexSoft *v7; // edi@3
  char v8; // zf@3
  IndoorCameraD3D *v9; // [sp+10h] [bp-4h]@1
  unsigned int uNumVerticesa; // [sp+20h] [bp+Ch]@2

  v9 = this;
  v5 = 0;
  if ( (signed int)(uNumVertices - 1) > 0 )
  {
    v6 = a2;
    v5 = uNumVertices - 1;
    uNumVerticesa = uNumVertices - 1;
    do
    {
      v7 = v6 + 1;
      do_draw_debug_line_sw(v6, uDiffuse, v6 + 1, uDiffuse, 0, a5);
      v8 = uNumVerticesa-- == 1;
      v6 = v7;
    }
    while ( !v8 );
  }
  do_draw_debug_line_sw(&a2[v5], uDiffuse, a2, uDiffuse, 0, a5);
}


//----- (00437906) --------------------------------------------------------
void IndoorCameraD3D::PrepareAndDrawDebugOutline(BLVFace *pFace, unsigned int uDiffuse)
{
  char *v3; // eax@2
  signed int v4; // ecx@2
  signed int v5; // ebx@5
  Vec3_short_ *v6; // edx@6
  char *v7; // esi@6
  signed int v8; // ecx@7
  IndoorCameraD3D *thisa; // [sp+8h] [bp-4h]@1

  thisa = this;

  
  static RenderVertexSoft static_sub_437906_array_50CDD0[64];
  static bool __init_flag1 = false;
  if (!__init_flag1)
  {
    __init_flag1 = true;

    for (uint i = 0; i < 64; ++i)
      static_sub_437906_array_50CDD0[i].flt_2C = 0.0f;
  }

  v5 = 0;
  if ( pFace->uNumVertices )
  {
    v6 = pIndoor->pVertices;
    v7 = (char *)&static_sub_437906_array_50CDD0[0].vWorldPosition.y;
    do
    {
      v8 = v5++;
      *((float *)v7 - 1) = (double)v6[pFace->pVertexIDs[v8]].x;
      *(float *)v7 = (double)v6[pFace->pVertexIDs[v8]].y;
      v7 += 48;
      *((float *)v7 - 11) = (double)v6[pFace->pVertexIDs[v8]].z;
      *((float *)v7 - 4) = (double)pFace->pVertexUIDs[v8];
      *((float *)v7 - 3) = (double)pFace->pVertexVIDs[v8];
    }
    while ( v5 < pFace->uNumVertices );
  }
  debug_outline_sw(static_sub_437906_array_50CDD0, pFace->uNumVertices, uDiffuse, 0.0);
}
// 50D9D0: using guessed type char static_sub_437906_byte_50D9D0_init_flag;


//----- (004378BA) --------------------------------------------------------
void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *a3)
{
  float *v4; // ecx@1
  float *v5; // eax@1
  signed int v6; // ebx@1
  float *v7; // edx@2
  float *v8; // ecx@2
  signed int v9; // edi@2
  double v10; // st7@3
  double v11; // st6@3

  v4 = (float *)a3;
  v5 = &a1->_12;
  v6 = 3;
  do
  {
    v7 = v4;
    v8 = &a2->_21;
    v9 = 3;
    do
    {
      v10 = v8[3] * v5[1] + *(v8 - 3) * *(v5 - 1);
      v11 = *v8 * *v5;
      ++v8;
      *v7 = v10 + v11;
      ++v7;
      --v9;
    }
    while ( v9 );
    v5 += 3;
    --v6;
    v4 = v7;
  }
  while ( v6 );
}


//----- (004376E7) --------------------------------------------------------
void IndoorCameraD3D::CreateWorldMatrixAndSomeStuff()
{
  IndoorCameraD3D *v1; // esi@1
  double v2; // st7@1
  signed int v3; // edi@1
  int v4; // eax@1
  double v5; // st7@2
  double v6; // st7@3
  Matrix3x3_float_ a3; // [sp+10h] [bp-B8h]@1
  Matrix3x3_float_ v8; // [sp+34h] [bp-94h]@1
  Matrix3x3_float_ a2; // [sp+58h] [bp-70h]@1
  Matrix3x3_float_ v10; // [sp+7Ch] [bp-4Ch]@1
  Matrix3x3_float_ a1; // [sp+A0h] [bp-28h]@1
  float v12; // [sp+C4h] [bp-4h]@1

  v1 = this;
  a1._13 = 0.0;
  a1._23 = 0.0;
  a1._31 = 0.0;
  a1._32 = 0.0;
  a1._33 = 1.0;
  v10._11 = 1.0;
  v10._12 = 0.0;
  v10._13 = 0.0;
  v10._21 = 0.0;
  v10._31 = 0.0;
  a2._12 = 0.0;
  a2._21 = 0.0;
  a2._22 = 1.0;
  a2._23 = 0.0;
  a2._32 = 0.0;
  v12 = cos(0.0);
  v2 = sin(0.0);
  a1._11 = v12;
  a1._12 = v2;
  a1._21 = -v2;
  a1._22 = v12;
  v10._22 = pIndoorCamera->fRotationXCosine;
  v10._32 = -pIndoorCamera->fRotationXSine;
  v10._23 = pIndoorCamera->fRotationXSine;
  v10._33 = pIndoorCamera->fRotationXCosine;
  a2._11 = pIndoorCamera->fRotationYCosine;
  a2._13 = -pIndoorCamera->fRotationYSine;
  a2._31 = pIndoorCamera->fRotationYSine;
  a2._33 = pIndoorCamera->fRotationYCosine;
  MatrixMultiply(&a1, &a2, &a3);
  MatrixMultiply(&v10, &a3, &v8);
  v3 = 0;
  v4 = (int)&v1->field_4.x;
  do
  {
    v5 = *(&v8._11 + v3++);
    *(float *)(v4 + 16) = v5;
    *(float *)v4 = *(float *)((char *)&v8._12 - (char *)v1 + v4);
    *(float *)(v4 + 32) = *(float *)((char *)&v8._22 - (char *)v1 + v4);
    v4 += 4;
  }
  while ( v3 < 3 );
  LODWORD(v1->field_D8) = 0x3F91361Du;
  v1->flt_D0 = (double)pViewport->uScreenWidth * 0.8814736;
  v6 = 0.8814736 * (double)pViewport->uScreenHeight;
  v1->flt_D4 = v6;
  if ( v1->flt_D0 > v6 )
    v6 = v1->flt_D0;
  v1->flt_fov = v6;
  v1->field_C8 = (double)pViewport->uScreenCenterX;
  v1->field_CC = (double)(pViewport->uScreenCenterY - pViewport->uScreenY);
}


//----- (00437691) --------------------------------------------------------
IndoorCameraD3D_Vec3 *IndoorCameraD3D::Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut)
{
  IndoorCameraD3D_Vec3 *result; // eax@1

  result = (IndoorCameraD3D_Vec3 *)pVector;
  pOut->y = this->field_14.x * pVector->x + this->field_4.x * pVector->y + this->field_24.x * pVector->z;
  pOut->z = this->field_14.y * result->x + this->field_4.y * result->y + this->field_24.y * result->z;
  pOut->x = this->field_14.z * result->x + this->field_4.z * result->y + this->field_24.z * pVector->z;
  return result;
}

//----- (00437607) --------------------------------------------------------
void IndoorCameraD3D::_437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2)
{
  IndoorCameraD3D *v3; // edi@1
  double v4; // st7@1
  signed int v5; // ecx@1
  char *v6; // eax@1
  double v7; // st6@2
  IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1
  Vec3_float_ v9; // [sp+Ch] [bp-18h]@1
  int v10; // [sp+20h] [bp-4h]@1

  v3 = this;
  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v8);
  v10 = 0;
  v9.x = (double)pIndoorCamera->pos.x;
  v9.y = (double)pIndoorCamera->pos.y;
  v9.z = (double)pIndoorCamera->pos.z;
  Vec3Transform(a1, a2);
  v4 = 0.0;
  v5 = 0;
  v6 = (char *)&a2->x;
  do
  {
    v7 = *(&v9.x + v5++) * *(float *)v6;
    v6 += 4;
    v4 = v4 + v7;
  }
  while ( v5 < 3 );
  v10 = -1;
  a2->dot = v4 + 0.000099999997;
  //IndoorCameraD3D_Vec3::dtor(&v8);
}

//----- (004374E8) --------------------------------------------------------
void IndoorCameraD3D::_4374E8_ProllyBuildFrustrum()
{
  IndoorCameraD3D *v1; // esi@1
  double v2; // st7@1
  double v3; // st7@1
  double v4; // st7@1
  double v5; // st7@1
  double v6; // st7@1
  IndoorCameraD3D_Vec3 v7; // [sp+Ch] [bp-24h]@1
  float v8; // [sp+10h] [bp-20h]@1
  float v9; // [sp+14h] [bp-1Ch]@1
  float v10; // [sp+18h] [bp-18h]@1
  float v11; // [sp+1Ch] [bp-14h]@1
  float v12; // [sp+20h] [bp-10h]@1
  int v13; // [sp+2Ch] [bp-4h]@1

  v1 = this;
  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v7);
  v2 = 2.0 / v1->field_D8;
  v13 = 0;
  v3 = atan(v2 * v1->flt_fov / v1->flt_D0);
  v12 = v3;
  v11 = sin(v3);
  v4 = cos(v12);
  v8 = -v11;
  v9 = 0.0;
  v10 = v4;
  _437607(&v7, v1->std__vector_000034_prolly_frustrum);
  v8 = v11;
  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[1]);
  v5 = atan(2.0 / v1->field_D8 * v1->flt_fov / (v1->flt_D4 + 0.5));
  v12 = v5;
  v11 = sin(v5);
  v6 = cos(v12);
  v9 = v11;
  v8 = 0.0;
  v10 = v6;
  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[2]);
  v9 = -v11;
  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[3]);
  v13 = -1;
  //IndoorCameraD3D_Vec3::dtor(&v7);
}

//----- (00437376) --------------------------------------------------------
char IndoorCameraD3D::_437376(stru154 *thisa, RenderVertexSoft *a2, unsigned int *pOutNumVertices)
{
  unsigned int v4; // ebx@1
  RenderVertexSoft *v5; // edx@2
  double v6; // st7@3
  unsigned int v7; // edi@5
  signed int v8; // esi@6
  int v9; // ebx@8
  int v10; // eax@8
  int v11; // ecx@14
  int v12; // eax@14
  int v13; // eax@15
  signed int v14; // ebx@17
  RenderVertexSoft *v15; // eax@18
  unsigned int *v16; // eax@20
  char result; // al@24
  RenderVertexSoft v18; // [sp+Ch] [bp-34h]@2
  int v19; // [sp+3Ch] [bp-4h]@8
  signed int thisb; // [sp+48h] [bp+8h]@6
  char a2_3; // [sp+4Fh] [bp+Fh]@5

  v4 = *pOutNumVertices;
  if ( (signed int)*pOutNumVertices <= 3
    || ((v5 = a2,
         memcpy(&v18, a2, sizeof(v18)),
         (v18.vWorldPosition.z - (double)pBLVRenderParams->vPartyPos.z) * thisa->vNormal.z
       + (v18.vWorldPosition.y - (double)pBLVRenderParams->vPartyPos.y) * thisa->vNormal.y
       + (v18.vWorldPosition.x - (double)pBLVRenderParams->vPartyPos.x) * thisa->vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0),
        a2_3 = 0,
        memcpy(&v5[v4], v5, sizeof(v5[v4])),
        memcpy(&v5[*pOutNumVertices + 1], &v5[1], sizeof(v5[*pOutNumVertices + 1])),
        v7 = *pOutNumVertices,
        (signed int)*pOutNumVertices <= 0) )
    goto LABEL_28;
  v8 = 1;
  for ( thisb = 1; ; v8 = thisb )
  {
    v9 = v8 - 1;
    v10 = v8 + 1;
    v19 = v8 + 1;
    if ( v8 - 1 >= (signed int)v7 )
      v9 -= v7;
    if ( v8 >= (signed int)v7 )
      v8 -= v7;
    if ( v19 >= (signed int)v7 )
      v10 = v19 - v7;
    v11 = (int)&v5[v10];
    v12 = (int)&v5[v9];
    if ( -0.009999999776482582 > ((v5[v8].vWorldViewProjX - *(float *)(v12 + 24))
                                * (*(float *)(v11 + 28) - *(float *)(v12 + 28))
                                - (v5[v8].vWorldViewProjY - *(float *)(v12 + 28))
                                * (*(float *)(v11 + 24) - *(float *)(v12 + 24)))
                               * v6 )
    {
      thisb = v19;
      v16 = pOutNumVertices;
    }
    else
    {
      v13 = thisb;
      if ( thisb >= (signed int)v7 )
        v13 = thisb - v7;
      v14 = v13;
      if ( v13 < (signed int)v7 )
      {
        v15 = &v5[v13];
        do
        {
          memcpy(v15, &v15[1], 0x30u);
          ++v14;
          ++v15;
        }
        while ( v14 < (signed int)*pOutNumVertices );
      }
      v16 = pOutNumVertices;
      a2_3 = 1;
      --*v16;
    }
    v7 = *v16;
    if ( thisb - 1 >= (signed int)*v16 )
      break;
  }
  if ( a2_3 )
    result = 1;
  else
LABEL_28:
    result = 0;
  return result;
}

//----- (00437285) --------------------------------------------------------
bool IndoorCameraD3D::_437285_prolly_colide_vertices_against_frustrum(RenderVertexSoft *a1, unsigned int *pOutNumVertices, RenderVertexSoft *pVertices, IndoorCameraD3D_Vec4 *a4, signed int uNumVertices, char a6, int _unused)
{
  char *v8; // eax@2
  signed int v9; // ecx@2
  bool result; // eax@5
  int v11; // ecx@5
  signed int v12; // ecx@6
  char *v13; // esi@6
  RenderVertexSoft *v14; // eax@8
  RenderVertexSoft *v15; // edx@8
  Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12
  float v17; // [sp+44h] [bp-10h]@1
  int v18; // [sp+48h] [bp-Ch]@5
  stru9 *thisa; // [sp+4Ch] [bp-8h]@1
  int a7a; // [sp+53h] [bp-1h]@5
  bool a6a; // [sp+70h] [bp+1Ch]@5

  v17 = 0.0;
  thisa = pGame->pStru9Instance;

  
  static RenderVertexSoft sr_vertices_50D9D8[64];
  static bool __init_flag1 = false;
  if (!__init_flag1)
  {
    __init_flag1 = true;

    for (uint i = 0; i < 64; ++i)
      sr_vertices_50D9D8[i].flt_2C = 0.0f;
  }

  result = 0;
  LOBYTE(a7a) = 0;
  v11 = 2 * (a6 == 0) + 1;
  a6a = 0;
  v18 = v11;
  if ( uNumVertices <= 0 )
  {
LABEL_14:
    LOBYTE(result) = a7a;
  }
  else
  {
    v12 = *pOutNumVertices;
    v13 = (char *)&a4->y;
    while ( 1 )
    {
      if ( result % 2 )
      {
        v14 = a1;
        v15 = sr_vertices_50D9D8;
      }
      else
      {
        v15 = a1;
        v14 = sr_vertices_50D9D8;
      }
      ++a6a;
      if ( a6a == uNumVertices )
        v14 = pVertices;
      a5.x = *((float *)v13 - 1);
      a5.y = *(float *)v13;
      a5.z = *((float *)v13 + 1);
      result = thisa->_4985FB(v15, v12, v14, pOutNumVertices, &a5, *((float *)v13 + 2), (char *)&a7a, _unused);
      v12 = *pOutNumVertices;
      if ( (signed int)*pOutNumVertices < v18 )
        break;
      result = a6a;
      v13 += 24;
      if ( a6a >= uNumVertices )
        goto LABEL_14;
    }
    *pOutNumVertices = 0;
    LOBYTE(result) = 1;
  }
  return result;
}
// 50E5D8: using guessed type char static_50D9D8_init_flag_bit1;

//----- (004371C3) --------------------------------------------------------
bool IndoorCameraD3D::_4371C3(RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused)
{
  char *v4; // eax@2
  signed int v5; // ecx@2
  RenderVertexSoft *v6; // esi@5
  unsigned int *v7; // edi@5
  char *v8; // ecx@6
  int v9; // eax@6
  IndoorCameraD3D *thisa; // [sp+0h] [bp-Ch]@1
  signed int v12; // [sp+4h] [bp-8h]@5
  unsigned int pVerticesa; // [sp+14h] [bp+8h]@6
  unsigned int pOutNumVerticesa; // [sp+18h] [bp+Ch]@6

  thisa = this;

  
  static RenderVertexSoft static_4371C3_array_50E5E0[64];
  static bool __init_flag1 = false;
  if (!__init_flag1)
  {
    __init_flag1 = true;

    for (uint i = 0; i < 64; ++i)
      static_4371C3_array_50E5E0[i].flt_2C = 0.0f;
  }

  v12 = 0;
  v6 = pVertices;
  v7 = pOutNumVertices;
  if ( (signed int)*pOutNumVertices > 0 )
  {
    pOutNumVerticesa = (char *)static_4371C3_array_50E5E0 - (char *)pVertices;
    pVerticesa = (char *)&static_4371C3_array_50E5E0[0].vWorldViewProjY - (char *)pVertices;
    v8 = (char *)&static_4371C3_array_50E5E0[0].vWorldPosition.y;
    v9 = (int)&v6->vWorldPosition.z;
    do
    {
      ++v12;
      *((int *)v8 - 1) = *(int *)(v9 - 8);
      *(int *)v8 = *(int *)(v9 - 4);
      v8 += 48;
      *(float *)(pOutNumVerticesa + v9) = *(float *)v9;
      *(float *)(pVerticesa + v9) = *(float *)(v9 + 28);
      *(float *)((char *)&static_4371C3_array_50E5E0[0].flt_20 - (char *)v6 + v9) = *(float *)(v9 + 32);
      v9 += 48;
    }
    while ( v12 < (signed int)*v7 );
  }
  return _437285_prolly_colide_vertices_against_frustrum(
           static_4371C3_array_50E5E0,
           v7,
           v6,
           thisa->std__vector_000034_prolly_frustrum,
           4,
           0,
           _unused);
}
// 50F1E0: using guessed type char static_sub_4371C3_byte_50F1E0_init_flags;

//----- (00437143) --------------------------------------------------------
int IndoorCameraD3D::_437143(unsigned int uNumInVertices, RenderVertexSoft *pOutVertices, RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices)
{
  unsigned int v5; // edi@1
  char *pOutVertices_; // edx@2
  char *v7; // eax@2
  unsigned int v8; // ebx@2
  double v9; // st7@3
  double v10; // st6@3
  int result; // eax@5
  unsigned int a2a; // [sp+10h] [bp+Ch]@2

  v5 = uNumInVertices;
  if ( (signed int)uNumInVertices > 0 )
  {
    pOutVertices_ = (char *)&pOutVertices->vWorldViewProjY;
    v7 = (char *)&pInVertices->flt_20;
    v8 = (char *)pOutVertices - (char *)pInVertices;
    a2a = uNumInVertices;
    do
    {
      *(float *)v7 = 1.0 / (*((float *)v7 - 5) + 0.0000001);
      memcpy(pOutVertices_ - 28, v7 - 32, 0x30u);
      v9 = (double)pOutdoorCamera->int_fov_rad * *(float *)&v7[v8];
      v10 = (double)pViewport->uScreenCenterX - v9 * *((float *)v7 - 4);
      v7 += 48;
      *((float *)pOutVertices_ - 1) = v10;
      *(float *)pOutVertices_ = (double)pViewport->uScreenCenterY - v9 * *((float *)v7 - 15);
      pOutVertices_ += 48;
      --a2a;
    }
    while ( a2a );
    v5 = uNumInVertices;
  }
  result = (int)pOutNumVertices;
  *pOutNumVertices = v5;
  return result;
}
//----- (00436F09) --------------------------------------------------------
void IndoorCameraD3D::_436F09(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
{
  unsigned int *pOutNumVertices_; // ebx@1
  double v6; // st7@2
  signed int v7; // esi@2
  char *v8; // edx@5
  unsigned int v9; // eax@10
  RenderVertexSoft *v10; // ecx@11
  double v11; // st6@11
  double v12; // st6@12
  unsigned int v13; // edi@14
  unsigned __int8 v14; // c2@16
  unsigned __int8 v15; // c3@16
  unsigned int v16; // edi@17
  bool a1a; // [sp+Ch] [bp+8h]@7
  int a4a; // [sp+18h] [bp+14h]@5

  pOutNumVertices_ = pOutNumVertices;
  *pOutNumVertices = 0;
  if ( uNumInVertices )
  {
    memcpy(&pInVertices[uNumInVertices], pInVertices, sizeof(pInVertices[uNumInVertices]));
    v6 = (double)pOutdoorCamera->shading_dist_mist;
    v7 = 0;
    if ( v6 >= pInVertices->vWorldViewPosition.x )
      v7 = 1;
    if ( uNumInVertices + 1 > 1 )
    {
      a4a = uNumInVertices;
      v8 = (char *)&pInVertices[1].u;
      do
      {
        a1a = v6 >= *((float *)v8 - 6);
        if ( v7 == a1a )
        {
          v10 = pOutVertices;
          goto LABEL_23;
        }
        v9 = *pOutNumVertices_;
        if ( a1a )
        {
          v10 = pOutVertices;
          v11 = (v6 - *((float *)v8 - 18)) / (*((float *)v8 - 6) - *((float *)v8 - 18));
          pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 5) - *((float *)v8 - 17)) * v11 + *((float *)v8 - 17);
          pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 4) - *((float *)v8 - 16)) * v11
                                                               + *((float *)v8 - 16);
          pOutVertices[*pOutNumVertices_].u = (*(float *)v8 - *((float *)v8 - 12)) * v11 + *((float *)v8 - 12);
          pOutVertices[*pOutNumVertices_].v = (*((float *)v8 + 1) - *((float *)v8 - 11)) * v11 + *((float *)v8 - 11);
        }
        else
        {
          v12 = (v6 - *((float *)v8 - 6)) / (*((float *)v8 - 18) - *((float *)v8 - 6));
          pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 17) - *((float *)v8 - 5)) * v12 + *((float *)v8 - 5);
          pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 16) - *((float *)v8 - 4)) * v12
                                                               + *((float *)v8 - 4);
          pOutVertices[*pOutNumVertices_].u = (*((float *)v8 - 12) - *(float *)v8) * v12 + *(float *)v8;
          pOutVertices[*pOutNumVertices_].v = (*((float *)v8 - 11) - *((float *)v8 + 1)) * v12 + *((float *)v8 + 1);
          v10 = pOutVertices;
        }
        v10[*pOutNumVertices_].vWorldViewPosition.x = v6;
        v10[*pOutNumVertices_].flt_20 = 1.0 / v6;
        if ( v7 )
        {
          v13 = (unsigned int)&v10[*pOutNumVertices_];
          if ( *(float *)(v13 + 12) != *((float *)v8 - 18) || *(float *)(v13 + 16) != *((float *)v8 - 17) )
            goto LABEL_21;
          v14 = 0;
          v15 = *(float *)(v13 + 20) == *((float *)v8 - 16);
        }
        else
        {
          v16 = (unsigned int)&v10[*pOutNumVertices_];
          if ( *(float *)(v16 + 12) != *((float *)v8 - 6) || *(float *)(v16 + 16) != *((float *)v8 - 5) )
          {
LABEL_21:
            ++*pOutNumVertices_;
            goto LABEL_23;
          }
          v14 = 0;
          v15 = *(float *)(v16 + 20) == *((float *)v8 - 4);
        }
        if ( !(v15 | v14) )
          goto LABEL_21;
LABEL_23:
        if ( a1a )
        {
          memcpy(&v10[*pOutNumVertices_], v8 - 36, sizeof(v10[*pOutNumVertices_]));
          pOutVertices[*pOutNumVertices_].flt_20 = 1.0 / (*((float *)v8 - 6) + 0.0000001);
          pOutVertices[(*pOutNumVertices_)++].flt_2C = *((float *)v8 + 2);
        }
        v7 = a1a;
        v8 += 48;
        --a4a;
      }
      while ( a4a );
    }
    if ( (signed int)*pOutNumVertices_ < 3 )
      *pOutNumVertices_ = 0;
  }
}


//----- (00436CDC) --------------------------------------------------------
void IndoorCameraD3D::_436CDC(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
{
  signed int v5; // esi@2
  char *v6; // edx@5
  unsigned int v7; // eax@10
  RenderVertexSoft *v8; // ecx@11
  double v9; // st6@11
  double v10; // st6@12
  unsigned int v11; // edi@14
  unsigned __int8 v12; // c2@16
  unsigned __int8 v13; // c3@16
  unsigned int v14; // edi@17
  bool a1a; // [sp+Ch] [bp+8h]@7

  if ( uNumInVertices )
  {
    *pOutNumVertices = 0;
    memcpy(&pInVertices[uNumInVertices], pInVertices, sizeof(pInVertices[uNumInVertices]));
    v5 = 0;
    if ( pInVertices->vWorldViewPosition.x >= 8.0 )
      v5 = 1;
    if ( uNumInVertices + 1 > 1 )
    {
      v6 = (char *)&pInVertices[1].u;
      do
      {
        a1a = *((float *)v6 - 6) >= 8.0;
        if ( v5 == a1a )
        {
          v8 = pOutVertices;
          goto LABEL_23;
        }
        v7 = *pOutNumVertices;
        if ( a1a )
        {
          v8 = pOutVertices;
          v9 = (8.0 - *((float *)v6 - 18)) / (*((float *)v6 - 6) - *((float *)v6 - 18));
          pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 5) - *((float *)v6 - 17)) * v9 + *((float *)v6 - 17);
          pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 4) - *((float *)v6 - 16)) * v9
                                                              + *((float *)v6 - 16);
          pOutVertices[*pOutNumVertices].u = (*(float *)v6 - *((float *)v6 - 12)) * v9 + *((float *)v6 - 12);
          pOutVertices[*pOutNumVertices].v = (*((float *)v6 + 1) - *((float *)v6 - 11)) * v9 + *((float *)v6 - 11);
        }
        else
        {
          v10 = (8.0 - *((float *)v6 - 6)) / (*((float *)v6 - 18) - *((float *)v6 - 6));
          pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 17) - *((float *)v6 - 5)) * v10 + *((float *)v6 - 5);
          pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 16) - *((float *)v6 - 4)) * v10
                                                              + *((float *)v6 - 4);
          pOutVertices[*pOutNumVertices].u = (*((float *)v6 - 12) - *(float *)v6) * v10 + *(float *)v6;
          pOutVertices[*pOutNumVertices].v = (*((float *)v6 - 11) - *((float *)v6 + 1)) * v10 + *((float *)v6 + 1);
          v8 = pOutVertices;
        }
        v8[*pOutNumVertices].vWorldViewPosition.x = 8.0;
        v8[*pOutNumVertices].flt_20 = 0.125;
        if ( v5 )
        {
          v11 = (unsigned int)&v8[*pOutNumVertices];
          if ( *(float *)(v11 + 12) != *((float *)v6 - 18) || *(float *)(v11 + 16) != *((float *)v6 - 17) )
            goto LABEL_21;
          v12 = 0;
          v13 = *(float *)(v11 + 20) == *((float *)v6 - 16);
        }
        else
        {
          v14 = (unsigned int)&v8[*pOutNumVertices];
          if ( *(float *)(v14 + 12) != *((float *)v6 - 6) || *(float *)(v14 + 16) != *((float *)v6 - 5) )
          {
LABEL_21:
            ++*pOutNumVertices;
            goto LABEL_23;
          }
          v12 = 0;
          v13 = *(float *)(v14 + 20) == *((float *)v6 - 4);
        }
        if ( !(v13 | v12) )
          goto LABEL_21;
LABEL_23:
        if ( a1a )
        {
          memcpy(&v8[*pOutNumVertices], v6 - 36, sizeof(v8[*pOutNumVertices]));
          pOutVertices[(*pOutNumVertices)++].flt_20 = 1.0 / (*((float *)v6 - 6) + 0.0000001);
        }
        v5 = a1a;
        v6 += 48;
        --uNumInVertices;
      }
      while ( uNumInVertices );
    }
    if ( (signed int)*pOutNumVertices < 3 )
      *pOutNumVertices = 0;
  }
}


//----- (00436BB7) --------------------------------------------------------
void IndoorCameraD3D::_436BB7_project_and_stuff(RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4)
{
  unsigned int v4; // ebx@1
  IndoorCameraD3D *v5; // edi@1
  float *v6; // esi@2
  double v7; // st7@7
  double v8; // st7@9
  double v9; // st6@10
  double v10; // st5@12
  double v11; // st7@16
  double v12; // st6@17
  double v13; // st5@19
  float uNumVerticesa; // [sp+14h] [bp+Ch]@13
  float uNumVerticesb; // [sp+14h] [bp+Ch]@20

  v4 = uNumVertices;
  v5 = this;
  if ( (signed int)uNumVertices > 0 )
  {
    v6 = &pVertices->vWorldViewProjX;
    do
    {
      if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
      {
        v7 = 1.0 / *(v6 - 3);
        *v6 = *(v6 - 2) * v5->flt_fov * v7 + v5->field_C8;
        v6[1] = (double)(signed int)pViewport->uViewportW - (*(v6 - 1) * v5->flt_fov * v7 + v5->field_CC);
      }
      else
      {
        extern void _outdoor_project(RenderVertexSoft *v);
        _outdoor_project((RenderVertexSoft *)(v6 - 6));
      }
      if ( a4 )
      {
        v8 = (double)(signed int)pViewport->uViewportZ;
        if ( v8 >= *v6 )
          v9 = *v6;
        else
          v9 = v8;
        v10 = (double)(signed int)pViewport->uViewportX;
        if ( v10 <= v9 )
        {
          if ( v8 >= *v6 )
            v8 = *v6;
        }
        else
        {
          uNumVerticesa = v10;
          v8 = uNumVerticesa;
        }
        *v6 = v8;
        v11 = (double)(signed int)pViewport->uViewportW;
        if ( v11 >= v6[1] )
          v12 = v6[1];
        else
          v12 = v11;
        v13 = (double)(signed int)pViewport->uViewportY;
        if ( v13 <= v12 )
        {
          if ( v11 >= v6[1] )
            v11 = v6[1];
        }
        else
        {
          uNumVerticesb = v13;
          v11 = uNumVerticesb;
        }
        v6[1] = v11;
      }
      v6 += 12;
      --v4;
    }
    while ( v4 );
  }
}


//----- (00436A9A) --------------------------------------------------------
void IndoorCameraD3D::Project(signed int x, signed int y, signed int z, int *a5, int *a6)
{
  double v6; // ST00_8@2
  double v7; // ST08_8@2
  double v8; // ST00_8@2
  signed __int64 v9; // qtt@3
  int v10; // ST04_4@3
  float a2a; // [sp+18h] [bp+8h]@2
  float a2b; // [sp+18h] [bp+8h]@2

  if ( pRenderer->pRenderD3D )
  {
    v6 = 1.0 / (double)x;
    a2a = (double)y * this->flt_fov * v6 + this->field_C8;
    v7 = a2a + 6.7553994e15;
    *a5 = LODWORD(v7);
    a2b = (double)z * this->flt_fov * v6 + this->field_CC;
    v8 = a2b + 6.7553994e15;
    *a6 = pViewport->uViewportW - LODWORD(v8);
  }
  else
  {
    LODWORD(v9) = pBLVRenderParams->field_40 << 16;
    HIDWORD(v9) = pBLVRenderParams->field_40 >> 16;
    v10 = v9 / x;
    LODWORD(v9) = pBLVRenderParams->field_40 << 16;
    HIDWORD(v9) = pBLVRenderParams->field_40 >> 16;
    *a5 = pBLVRenderParams->uViewportCenterX
        - ((signed int)(((unsigned __int64)(v10 * (signed __int64)y) >> 16) + 32768) >> 16);
    *a6 = pBLVRenderParams->uViewportCenterY - ((signed int)(((unsigned __int64)(v9 / x * z) >> 16) + 32768) >> 16);
  }
}

//----- (00436A6D) --------------------------------------------------------
double IndoorCameraD3D::GetPolygonMinZ(RenderVertexSoft *pVertices, unsigned int uStripType)
{
  unsigned int v3; // edx@1
  double result; // st7@1
  float *v5; // ecx@2

  v3 = uStripType;
  result = 3.4028235e38;
  if ( (signed int)uStripType > 0 )
  {
    v5 = &pVertices->vWorldPosition.z;
    do
    {
      if ( *v5 < result )
        result = *v5;
      v5 += 12;
      --v3;
    }
    while ( v3 );
  }
  return result;
}


//----- (00436A24) --------------------------------------------------------
struct IDirect3DTexture2 *IndoorCameraD3D::LoadTextureAndGetHardwarePtr(char *Str1)
{
  return pBitmaps_LOD->pHardwareTextures[pBitmaps_LOD->LoadTexture(Str1)];
}

//----- (00436A40) --------------------------------------------------------
double IndoorCameraD3D::GetPolygonMaxZ(RenderVertexSoft *pVertex, unsigned int uStripType)
{
  unsigned int v3; // edx@1
  double result; // st7@1
  float *v5; // ecx@2

  v3 = uStripType;
  result = 1.1754944e-38;
  if ( (signed int)uStripType > 0 )
  {
    v5 = &pVertex->vWorldPosition.z;
    do
    {
      if ( *v5 > result )
        result = *v5;
      v5 += 12;
      --v3;
    }
    while ( v3 );
  }
  return result;
}