comparison Vis.cpp @ 1038:39f42990698f

Cleanings
author Nomad
date Thu, 23 May 2013 03:29:29 +0200
parents 306ec23b37df
children d36681a9e4f8
comparison
equal deleted inserted replaced
1035:306ec23b37df 1038:39f42990698f
4 #include "Vis.h" 4 #include "Vis.h"
5 #include "Outdoor.h" 5 #include "Outdoor.h"
6 #include "Game.h" 6 #include "Game.h"
7 #include "Actor.h" 7 #include "Actor.h"
8 #include "IndoorCamera.h" 8 #include "IndoorCamera.h"
9 #include "OutdoorCamera.h"
9 #include "Viewport.h" 10 #include "Viewport.h"
11 #include "Math.h"
10 #include "Log.h" 12 #include "Log.h"
11 13
12 #include "mm7_data.h" 14 #include "mm7_data.h"
13 #include "MM7.h" 15 #include "MM7.h"
14 16
818 bool result; // eax@1 820 bool result; // eax@1
819 //int *v9; // esi@1 821 //int *v9; // esi@1
820 //unsigned int v10; // ecx@1 822 //unsigned int v10; // ecx@1
821 //unsigned int v11; // edx@3 823 //unsigned int v11; // edx@3
822 //signed int v12; // ecx@4 824 //signed int v12; // ecx@4
823 __int16 v13; // si@4 825 //__int16 v13; // si@4
824 __int16 *v14; // ecx@4 826 //__int16 *v14; // ecx@4
825 unsigned int v15; // edx@8 827 unsigned int v15; // edx@8
826 //signed int v16; // ecx@9 828 //signed int v16; // ecx@9
827 __int16 v17; // si@9 829 __int16 v17; // si@9
828 __int16 *v18; // ecx@9 830 __int16 *v18; // ecx@9
829 unsigned int v19; // edx@12 831 unsigned int v19; // edx@12
830 //signed int v20; // ecx@13 832 //signed int v20; // ecx@13
831 __int16 v21; // si@13 833 __int16 v21; // si@13
832 __int16 *v22; // ecx@13 834 __int16 *v22; // ecx@13
833 //signed int a1a; // [sp+14h] [bp+8h]@1 835 //signed int a1a; // [sp+14h] [bp+8h]@1
834 __int16 *a5a; // [sp+24h] [bp+18h]@3 836 //__int16 *a5a; // [sp+24h] [bp+18h]@3
835 __int16 *a5b; // [sp+24h] [bp+18h]@8 837 __int16 *a5b; // [sp+24h] [bp+18h]@8
836 __int16 *a5c; // [sp+24h] [bp+18h]@12 838 __int16 *a5c; // [sp+24h] [bp+18h]@12
837 839
838 //result = (bool)a6; 840 //result = (bool)a6;
839 //v9 = pFace; 841 //v9 = pFace;
840 //v10 = pFace->uAttributes; 842 //v10 = pFace->uAttributes;
841 //a1a = 0; 843 //a1a = 0;
842 if ( BYTE1(pFace->uAttributes) & 1 ) 844 if (pFace->uAttributes & FACE_XY_PLANE)
843 { 845 {
844 pFace->pFacePlane.vNormal.x = a5->x; 846 pFace->pFacePlane.vNormal.x = a5->x;
845 pFace->pFacePlane.vNormal.y = a5->y; 847 pFace->pFacePlane.vNormal.y = a5->y;
846 if ( pFace->uNumVertices ) 848
847 { 849 for (int i = 0; i < pFace->uNumVertices; ++i)
848 //v11 = 188 * ModelID + 72; 850 {
849 a5a = displaced_face_intersect_plane_coords_b + 1; 851 displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x;
850 for ( uint i = 0; i < pFace->uNumVertices; ++i ) 852 displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x;
851 { 853
852 displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x; 854 displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y;
853 displaced_face_intersect_plane_coords_b[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; 855 displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y;
854 *(__int16 *)((char *)a5a + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = 856 }
855 pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; 857 }
856 v13 = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; 858 else if (pFace->uAttributes & FACE_XZ_PLANE)
857 v14 = a5a; 859 {
858 a5a += 2; 860 pFace->pFacePlane.vNormal.x = a5->x;
859 *v14 = v13; 861 pFace->pFacePlane.vNormal.z = a5->z;
860 } 862
861 } 863 for (int i = 0; i < pFace->uNumVertices; ++i)
862 } 864 {
863 else 865 displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x;
864 { 866 displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pXInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x;
865 if ( BYTE1(pFace->uAttributes) & 2 ) 867
866 { 868 displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z;
867 pFace->pFacePlane.vNormal.x = a5->x; 869 displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z;
868 pFace->pFacePlane.vNormal.z = a5->z; 870 }
869 if ( pFace->uNumVertices ) 871 }
870 { 872 else if (pFace->uAttributes & FACE_YZ_PLANE)
871 v15 = 188 * uModelID + 72; 873 {
872 a5b = displaced_face_intersect_plane_coords_b + 1;
873 for ( uint i = 0; i < pFace->uNumVertices; ++i )
874 {
875 displaced_face_intersect_plane_coords_a[2 * i] = pFace->pXInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].x;
876 *(a5b - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y;
877 *(__int16 *)((char *)a5b + (int)displaced_face_intersect_plane_coords_a - (int)displaced_face_intersect_plane_coords_b) = pFace->pXInterceptDisplacements[i + 1]
878 + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].x;
879 v17 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z;
880 v18 = a5b;
881 a5b += 2;
882 *v18 = v17;
883 }
884 }
885 }
886 else
887 {
888 pFace->pFacePlane.vNormal.y = a5->y; 874 pFace->pFacePlane.vNormal.y = a5->y;
889 pFace->pFacePlane.vNormal.z = a5->z; 875 pFace->pFacePlane.vNormal.z = a5->z;
890 if ( pFace->uNumVertices ) 876
891 { 877 for (int i = 0; i < pFace->uNumVertices; ++i)
892 v19 = 188 * uModelID + 72; 878 {
893 a5c = displaced_face_intersect_plane_coords_b + 1; 879 displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y;
894 for ( uint i = 0; i < pFace->uNumVertices; ++i ) 880 displaced_face_intersect_plane_coords_a[i * 2 + 1] = pFace->pYInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y;
895 { 881
896 displaced_face_intersect_plane_coords_a[2 * i] = pFace->pYInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].y; 882 displaced_face_intersect_plane_coords_b[2 * i] = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z;
897 *(a5c - 1) = pFace->pZInterceptDisplacements[i] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i]].z; 883 displaced_face_intersect_plane_coords_b[i * 2 + 1] = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[ModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z;
898 *(__int16 *)((char *)a5c + (int)(char *)displaced_face_intersect_plane_coords_a - (char *)displaced_face_intersect_plane_coords_b) = pFace->pYInterceptDisplacements[i + 1] 884 }
899 + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; 885 }
900 v21 = pFace->pZInterceptDisplacements[i + 1] + pOutdoor->pBModels[uModelID].pVertices.pVertices[pFace->pVertexIDs[i + 1]].z; 886 else assert(false);
901 v22 = a5c; 887
902 a5c += 2;
903 *v22 = v21;
904 }
905 }
906 }
907 }
908 return true; 888 return true;
889 }
890
891
892
893
894
895 //----- (0046A0A1) --------------------------------------------------------
896 int UnprojectX(int x)
897 {
898 int v3; // [sp-4h] [bp-8h]@5
899
900 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
901 {
902 if ( pRenderer->pRenderD3D )
903 v3 = pGame->pIndoorCameraD3D->fov;
904 else
905 v3 = pIndoorCamera->flt_1C_fov;
906 }
907 else
908 {
909 v3 = pOutdoorCamera->int_fov_rad;
910 }
911 return stru_5C6E00->Atan2(x - pViewport->uScreenCenterX, v3) - stru_5C6E00->uIntegerHalfPi;
912 }
913
914 //----- (0046A0F6) --------------------------------------------------------
915 int UnprojectY(int y)
916 {
917 int v3; // [sp-4h] [bp-8h]@5
918
919 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
920 {
921 if ( pRenderer->pRenderD3D )
922 v3 = pGame->pIndoorCameraD3D->fov;
923 else
924 v3 = pIndoorCamera->flt_1C_fov;
925 }
926 else
927 {
928 v3 = pOutdoorCamera->int_fov_rad;
929 }
930 return stru_5C6E00->Atan2(y - pViewport->uScreenCenterY, v3) - stru_5C6E00->uIntegerHalfPi;
909 } 931 }
910 932
911 //----- (004C248E) -------------------------------------------------------- 933 //----- (004C248E) --------------------------------------------------------
912 void Vis::CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth) 934 void Vis::CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth)
913 { 935 {