Mercurial > mm7
diff Vis.cpp @ 1038:39f42990698f
Cleanings
author | Nomad |
---|---|
date | Thu, 23 May 2013 03:29:29 +0200 |
parents | 306ec23b37df |
children | d36681a9e4f8 |
line wrap: on
line diff
--- a/Vis.cpp Wed May 22 14:12:51 2013 +0200 +++ b/Vis.cpp Thu May 23 03:29:29 2013 +0200 @@ -6,7 +6,9 @@ #include "Game.h" #include "Actor.h" #include "IndoorCamera.h" +#include "OutdoorCamera.h" #include "Viewport.h" +#include "Math.h" #include "Log.h" #include "mm7_data.h" @@ -820,8 +822,8 @@ //unsigned int v10; // ecx@1 //unsigned int v11; // edx@3 //signed int v12; // ecx@4 - __int16 v13; // si@4 - __int16 *v14; // ecx@4 + //__int16 v13; // si@4 + //__int16 *v14; // ecx@4 unsigned int v15; // edx@8 //signed int v16; // ecx@9 __int16 v17; // si@9 @@ -831,7 +833,7 @@ __int16 v21; // si@13 __int16 *v22; // ecx@13 //signed int a1a; // [sp+14h] [bp+8h]@1 - __int16 *a5a; // [sp+24h] [bp+18h]@3 + //__int16 *a5a; // [sp+24h] [bp+18h]@3 __int16 *a5b; // [sp+24h] [bp+18h]@8 __int16 *a5c; // [sp+24h] [bp+18h]@12 @@ -839,73 +841,93 @@ //v9 = pFace; //v10 = pFace->uAttributes; //a1a = 0; - if ( BYTE1(pFace->uAttributes) & 1 ) + if (pFace->uAttributes & FACE_XY_PLANE) { pFace->pFacePlane.vNormal.x = a5->x; pFace->pFacePlane.vNormal.y = a5->y; - if ( pFace->uNumVertices ) + + for (int i = 0; i < pFace->uNumVertices; ++i) + { + displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; + displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + } + } + else if (pFace->uAttributes & FACE_XZ_PLANE) + { + pFace->pFacePlane.vNormal.x = a5->x; + pFace->pFacePlane.vNormal.z = a5->z; + + for (int i = 0; i < pFace->uNumVertices; ++i) { - //v11 = 188 * ModelID + 72; - a5a = displaced_face_intersect_plane_coords_b + 1; - for ( uint i = 0; i < pFace->uNumVertices; ++i ) - { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; - displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - *(__int16 *)((char *)a5a + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = - pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - v13 = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; - v14 = a5a; - a5a += 2; - *v14 = v13; - } + displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; + displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; + } + } + else if (pFace->uAttributes & FACE_YZ_PLANE) + { + pFace->pFacePlane.vNormal.y = a5->y; + pFace->pFacePlane.vNormal.z = a5->z; + + for (int i = 0; i < pFace->uNumVertices; ++i) + { + displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; + displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + + displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; + displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; } } + else assert(false); + + return true; +} + + + + + +//----- (0046A0A1) -------------------------------------------------------- +int UnprojectX(int x) +{ + int v3; // [sp-4h] [bp-8h]@5 + + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + if ( pRenderer->pRenderD3D ) + v3 = pGame->pIndoorCameraD3D->fov; + else + v3 = pIndoorCamera->flt_1C_fov; + } else { - if ( BYTE1(pFace->uAttributes) & 2 ) - { - pFace->pFacePlane.vNormal.x = a5->x; - pFace->pFacePlane.vNormal.z = a5->z; - if ( pFace->uNumVertices ) - { - v15 = 188 * uModelID + 72; - a5b = displaced_face_intersect_plane_coords_b + 1; - for ( uint i = 0; i < pFace->uNumVertices; ++i ) - { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; - *(a5b - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - *(__int16 *)((char *)a5b + (int)displaced_face_intersect_plane_coords_a - (int)displaced_face_intersect_plane_coords_b) = pFace->pXInterceptDisplacements[i + 1] - + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - v17 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; - v18 = a5b; - a5b += 2; - *v18 = v17; - } - } - } + v3 = pOutdoorCamera->int_fov_rad; + } + return stru_5C6E00->Atan2(x - pViewport->uScreenCenterX, v3) - stru_5C6E00->uIntegerHalfPi; +} + +//----- (0046A0F6) -------------------------------------------------------- +int UnprojectY(int y) +{ + int v3; // [sp-4h] [bp-8h]@5 + + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + if ( pRenderer->pRenderD3D ) + v3 = pGame->pIndoorCameraD3D->fov; else - { - pFace->pFacePlane.vNormal.y = a5->y; - pFace->pFacePlane.vNormal.z = a5->z; - if ( pFace->uNumVertices ) - { - v19 = 188 * uModelID + 72; - a5c = displaced_face_intersect_plane_coords_b + 1; - for ( uint i = 0; i < pFace->uNumVertices; ++i ) - { - displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; - *(a5c - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; - *(__int16 *)((char *)a5c + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = pFace->pYInterceptDisplacements[i + 1] - + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; - v21 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; - v22 = a5c; - a5c += 2; - *v22 = v21; - } - } - } + v3 = pIndoorCamera->flt_1C_fov; } - return true; + else + { + v3 = pOutdoorCamera->int_fov_rad; + } + return stru_5C6E00->Atan2(y - pViewport->uScreenCenterY, v3) - stru_5C6E00->uIntegerHalfPi; } //----- (004C248E) --------------------------------------------------------