view OutdoorCamera.cpp @ 1379:db3769ae574c

m
author Ritor1
date Tue, 16 Jul 2013 14:11:35 +0600
parents 86a83e12d795
children cc9a3a24d61d
line wrap: on
line source

#include "OutdoorCamera.h"
#include "IndoorCamera.h"
#include "Outdoor_stuff.h"
#include "Game.h"
#include "LightmapBuilder.h"
#include "Viewport.h"
#include "Math.h"
#include "mm7_data.h"
#include "Allocator.h"

//----- (00487355) --------------------------------------------------------
bool OutdoorCamera::_487355()
{
  int v0; // esi@1
  stru148 *v1; // edi@2
  bool result; // eax@3

  v0 = 0;
  if ( pOutdoorCamera->numStru148s > 0 )
  {
    v1 = array_77EC08.data();
    do
    {
      result = pGame->pLightmapBuilder->_45D3C7(v1);
      ++v0;
      ++v1;
    }
    while ( v0 < pOutdoorCamera->numStru148s );
  }
  return result;
}
//----- (00481E55) --------------------------------------------------------
void OutdoorCamera::Project(unsigned int uNumVertices)
{
  double v1; // st7@2
  double v2; // st6@2
  double v3; // st5@2
  int v4; // eax@2
  unsigned int v5; // edx@2
  double v6; // st4@3
  double v7; // st3@3

  if ( (signed int)uNumVertices > 0 )
  {
    v1 = (double)pOutdoorCamera->int_fov_rad;
    v2 = (double)pViewport->uScreenCenterX;
    v3 = (double)pViewport->uScreenCenterY;
    v4 = 0;
    v5 = uNumVertices;
    do
    {
      v6 = v1 * array_507D30[v4]._rhw;
      v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
      memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
      array_50AC10[v4].vWorldViewProjX = v2 - v7;
      array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
      ++v4;
      --v5;
    }
    while ( v5 );
  }
}
//----- (00485F64) --------------------------------------------------------
void OutdoorCamera::_485F64()
{
  int v1; // eax@1
  int v2; // eax@2
  signed __int64 v3; // qtt@4
  int v4; // eax@4

  this->uCameraFovInDegrees = 75;
  v1 = stru_5C6E00->uPiMask & 0xD5;
  if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
    v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
  else
    v2 = stru_5C6E00->pTanTable[v1];
  LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
  HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
  v4 = (signed int)(v3 / v2) >> 16;
  this->int_fov_rad = v4;
  this->field_4C = 360000;
  this->int_fov_rad_inv = 65536 / v4;
  this->field_50 = 115;
  unnamed_6BE060[1] = 1;
  RotationToInts();
}

//----- (0048600E) --------------------------------------------------------
void OutdoorCamera::RotationToInts()
{
  camera_rotation_y_int_sine   = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
  camera_rotation_y_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
  camera_rotation_x_int_sine   = stru_5C6E00->Sin(pIndoorCamera->sRotationX);
  camera_rotation_x_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationX);
}
//----- (00486A28) --------------------------------------------------------
void OutdoorCamera::AllocSoftwareDrawBuffers()
{
  if ( !this || !pSpans )
  {
    ReleaseSoftwareDrawBuffers();
    pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS");
    pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES");
    pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS");
    pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES");
    memset(pSpans, 0, 0x493E0u);
    memset(pEdges, 0, 0x4C2C0u);
    memset(pSurfs, 0, 0x11940u);
    memset(pNewEdges, 0, 0x6180u);
  }
}

//----- (00486AFC) --------------------------------------------------------
void OutdoorCamera::ReleaseSoftwareDrawBuffers()
{
  pAllocator->FreeChunk(pSpans);
  pAllocator->FreeChunk(pEdges);
  pAllocator->FreeChunk(pSurfs);
  pAllocator->FreeChunk(pNewEdges);
  pSpans = 0;
  pEdges = 0;
  pSurfs = 0;
  pNewEdges = 0;
}