comparison Indoor.cpp @ 1372:5572e7b02f45

m
author Ritor1
date Mon, 15 Jul 2013 17:09:22 +0600
parents 14695590d7a6
children 78671379d8da
comparison
equal deleted inserted replaced
1371:d1c8121cf0ad 1372:5572e7b02f45
769 v128 = stru_F8AD28.pDeltaUV[1]; 769 v128 = stru_F8AD28.pDeltaUV[1];
770 v107 = bUseLoResSprites; 770 v107 = bUseLoResSprites;
771 v7 = GetPortalScreenCoord(v1); 771 v7 = GetPortalScreenCoord(v1);
772 if ( v7 ) 772 if ( v7 )
773 { 773 {
774 if ( sub_424829(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) 774 if ( PortalFrustrum(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
775 { 775 {
776 if ( v2->uPolygonType == 1 ) 776 if ( v2->uPolygonType == 1 )
777 { 777 {
778 for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 ) 778 for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 )
779 { 779 {
1377 //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ 1377 //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ
1378 if (face_max_screenspace_x >= nodes[node_id].uViewportX && 1378 if (face_max_screenspace_x >= nodes[node_id].uViewportX &&
1379 face_min_screenspace_x <= nodes[node_id].uViewportZ && 1379 face_min_screenspace_x <= nodes[node_id].uViewportZ &&
1380 face_max_screenspace_y >= nodes[node_id].uViewportY && 1380 face_max_screenspace_y >= nodes[node_id].uViewportY &&
1381 face_min_screenspace_y <= nodes[node_id].uViewportW && 1381 face_min_screenspace_y <= nodes[node_id].uViewportW &&
1382 sub_424829(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID)) 1382 PortalFrustrum(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID))
1383 { 1383 {
1384 pTransitionSector = pFace->uSectorID; 1384 pTransitionSector = pFace->uSectorID;
1385 if (nodes[node_id].uSectorID == pTransitionSector ) 1385 if (nodes[node_id].uSectorID == pTransitionSector )
1386 pTransitionSector = pFace->uBackSectorID; 1386 pTransitionSector = pFace->uBackSectorID;
1387 nodes[num_nodes].uSectorID = pTransitionSector; 1387 nodes[num_nodes].uSectorID = pTransitionSector;
1530 } 1530 }
1531 if ( v11 >= *((short *)v20 + 2005) 1531 if ( v11 >= *((short *)v20 + 2005)
1532 && v23 <= *((short *)v20 + 2007) 1532 && v23 <= *((short *)v20 + 2007)
1533 && v12 >= *((short *)v20 + 2006) 1533 && v12 >= *((short *)v20 + 2006)
1534 && v22 <= *((short *)v20 + 2008) 1534 && v22 <= *((short *)v20 + 2008)
1535 && sub_424829(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) ) 1535 && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) )
1536 { 1536 {
1537 v16 = v21->uSectorID; 1537 v16 = v21->uSectorID;
1538 if ( *((short *)v20 + 2004) == v16 ) 1538 if ( *((short *)v20 + 2004) == v16 )
1539 v16 = v21->uBackSectorID; 1539 v16 = v21->uBackSectorID;
1540 v3->nodes[v3->num_nodes].uSectorID = v16; 1540 v3->nodes[v3->num_nodes].uSectorID = v16;
1589 v2 = pBspRenderer->faces[i].uFaceID; 1589 v2 = pBspRenderer->faces[i].uFaceID;
1590 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; 1590 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C;
1591 v3 = GetPortalScreenCoord(v2); 1591 v3 = GetPortalScreenCoord(v2);
1592 if ( v3 ) 1592 if ( v3 )
1593 { 1593 {
1594 if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) 1594 if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
1595 { 1595 {
1596 v4 = stru_F8A590._viewport_space_y; 1596 v4 = stru_F8A590._viewport_space_y;
1597 v5 = pBLVRenderParams->pRenderTarget; 1597 v5 = pBLVRenderParams->pRenderTarget;
1598 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) 1598 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
1599 { 1599 {
6829 UpdateActors_BLV(); 6829 UpdateActors_BLV();
6830 BLV_UpdateDoors(); 6830 BLV_UpdateDoors();
6831 check_event_triggers(); 6831 check_event_triggers();
6832 } 6832 }
6833 //----- (00424829) -------------------------------------------------------- 6833 //----- (00424829) --------------------------------------------------------
6834 bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID) 6834 bool PortalFrustrum(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
6835 { 6835 {
6836 int v6; // eax@3 6836 //int v6; // eax@3
6837 int min_y; // esi@5 6837 int min_y; // esi@5
6838 int max_y; // edx@5 6838 int max_y; // edx@5
6839 int v10; // eax@12 6839 int current_ID; // eax@12
6840 int v13; // eax@22 6840 int v13; // eax@22
6841 int v15; // ecx@29 6841 int v15; // ecx@29
6842 int v18; // eax@39 6842 int v18; // eax@39
6843 int v19; // eax@44 6843 int v19; // eax@44
6844 int v20; // ecx@44 6844 int v20; // ecx@44
6856 __int16 v38; // dx@67 6856 __int16 v38; // dx@67
6857 int v46; // edx@87 6857 int v46; // edx@87
6858 int v49; // esi@93 6858 int v49; // esi@93
6859 int v53; // [sp+Ch] [bp-34h]@44 6859 int v53; // [sp+Ch] [bp-34h]@44
6860 int v54; // [sp+10h] [bp-30h]@0 6860 int v54; // [sp+10h] [bp-30h]@0
6861 int v55; // [sp+14h] [bp-2Ch]@12 6861 int min_y_ID2; // [sp+14h] [bp-2Ch]@12
6862 int v59; // [sp+14h] [bp-2Ch]@87 6862 int v59; // [sp+14h] [bp-2Ch]@87
6863 int v61; // [sp+1Ch] [bp-24h]@29 6863 int v61; // [sp+1Ch] [bp-24h]@29
6864 int v62; // [sp+20h] [bp-20h]@0 6864 int v62; // [sp+20h] [bp-20h]@0
6865 signed int v63; // [sp+24h] [bp-1Ch]@3 6865 signed int direction1; // [sp+24h] [bp-1Ch]@3
6866 signed int v64; // [sp+28h] [bp-18h]@3 6866 signed int direction2; // [sp+28h] [bp-18h]@3
6867 int v65; // [sp+2Ch] [bp-14h]@5 6867 int min_y_ID; // [sp+2Ch] [bp-14h]@5
6868 int v68; // [sp+34h] [bp-Ch]@12 6868 //int v68; // [sp+34h] [bp-Ch]@12
6869 int v69; // [sp+34h] [bp-Ch]@29 6869 int v69; // [sp+34h] [bp-Ch]@29
6870 int v70; // [sp+34h] [bp-Ch]@46 6870 int v70; // [sp+34h] [bp-Ch]@46
6871 int v71; // [sp+34h] [bp-Ch]@75 6871 int v71; // [sp+34h] [bp-Ch]@75
6872 int v72; // [sp+34h] [bp-Ch]@80 6872 int v72; // [sp+34h] [bp-Ch]@80
6873 6873
6874 if ( pNumVertices <= 1 ) 6874 if ( pNumVertices <= 1 )
6875 return false; 6875 return false;
6876 min_y = PortalFace._screen_space_y[0]; 6876 min_y = PortalFace._screen_space_y[0];
6877 v65 = 0; 6877 min_y_ID = 0;
6878 max_y = PortalFace._screen_space_y[0]; 6878 max_y = PortalFace._screen_space_y[0];
6879 //face direction(направление фейса)
6879 if ( !PortalFace.direction ) 6880 if ( !PortalFace.direction )
6880 { 6881 {
6881 v63 = 1; 6882 direction1 = 1;
6882 v64 = -1; 6883 direction2 = -1;
6883 } 6884 }
6884 else 6885 else
6885 { 6886 {
6886 v63 = -1; 6887 direction1 = -1;
6887 v64 = 1; 6888 direction2 = 1;
6888 } 6889 }
6889 6890
6890 for ( v6 = 1; v6 < pNumVertices; ++v6 ) 6891 //get min and max y for portal(дать минимальное и максимальное значение y для портала)
6891 { 6892 for ( uint i = 1; i < pNumVertices; ++i )
6892 if ( PortalFace._screen_space_y[v6] >= min_y ) 6893 {
6893 { 6894 if ( PortalFace._screen_space_y[i] >= min_y )
6894 if ( PortalFace._screen_space_y[v6] > max_y ) 6895 {
6895 max_y = PortalFace._screen_space_y[v6]; 6896 if ( PortalFace._screen_space_y[i] > max_y )
6896 } 6897 max_y = PortalFace._screen_space_y[i];
6897 if ( PortalFace._screen_space_y[v6] < min_y ) 6898 }
6898 { 6899 else
6899 v65 = v6; 6900 {
6900 min_y = PortalFace._screen_space_y[v6]; 6901 min_y_ID = i;
6902 min_y = PortalFace._screen_space_y[i];
6901 } 6903 }
6902 } 6904 }
6903 if ( max_y == min_y ) 6905 if ( max_y == min_y )
6904 return false; 6906 return false;
6905 6907
6906 v10 = v65; 6908 //*****************************************************************************************************************************
6907 a2->_viewport_space_y = min_y; 6909 a2->_viewport_space_y = min_y;
6908 a2->_viewport_space_w = max_y; 6910 a2->_viewport_space_w = max_y;
6909 v55 = v65; 6911 current_ID = min_y_ID;
6910 6912 min_y_ID2 = min_y_ID;
6911 for ( v68 = 0; v68 < pNumVertices; ++v68 ) 6913
6912 { 6914 for ( uint i = 0; i < pNumVertices; ++i )
6913 v10 += v64; 6915 {
6914 if ( v10 < pNumVertices ) 6916 current_ID += direction2;
6915 { 6917 if ( current_ID < pNumVertices )
6916 if ( v10 < 0 ) 6918 {
6917 v10 += pNumVertices; 6919 if ( current_ID < 0 )
6920 current_ID += pNumVertices;
6918 } 6921 }
6919 else 6922 else
6920 v10 -= pNumVertices; 6923 current_ID -= pNumVertices;
6921 if ( PortalFace._screen_space_y[v10] <= PortalFace._screen_space_y[v65] ) 6924 if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )//определение минимальной у
6922 { 6925 {
6923 v55 = v10; 6926 min_y_ID2 = current_ID;
6924 v65 = v10; 6927 min_y_ID = current_ID;
6925 } 6928 }
6926 if ( PortalFace._screen_space_y[v10] == max_y ) 6929 if ( PortalFace._screen_space_y[current_ID] == max_y )
6927 break; 6930 break;
6928 } 6931 }
6929 v13 = v55 + v64; 6932
6933 v13 = min_y_ID2 + direction2;
6930 if ( v13 < pNumVertices ) 6934 if ( v13 < pNumVertices )
6931 { 6935 {
6932 if ( v13 < 0 ) 6936 if ( v13 < 0 )
6933 v13 += pNumVertices; 6937 v13 += pNumVertices;
6934 } 6938 }
6935 else 6939 else
6936 v13 -= pNumVertices; 6940 v13 -= pNumVertices;
6937 if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[v55] ) 6941 if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] )
6938 { 6942 {
6939 v62 = PortalFace._screen_space_x[v55] << 16; 6943 v62 = PortalFace._screen_space_x[min_y_ID2] << 16;
6940 v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[v55]) << 16) / (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[v55]); 6944 v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[min_y_ID2]) << 16) / (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[min_y_ID2]);
6941 a2->viewport_left_side[min_y] = LOWORD(PortalFace._screen_space_x[v55]); 6945 a2->viewport_left_side[min_y] = PortalFace._screen_space_x[min_y_ID2];
6942 } 6946 }
6943 v15 = v65; 6947 //****************************************************************************************************************************************
6944 v61 = v65; 6948 //
6945 6949 v15 = min_y_ID;
6950 v61 = min_y_ID;
6946 for ( v69 = 0; v69 < pNumVertices; ++v69 ) 6951 for ( v69 = 0; v69 < pNumVertices; ++v69 )
6947 { 6952 {
6948 v15 += v63; 6953 v15 += direction1;
6949 if ( v15 < pNumVertices ) 6954 if ( v15 < pNumVertices )
6950 { 6955 {
6951 if ( v15 < 0 ) 6956 if ( v15 < 0 )
6952 v15 += pNumVertices; 6957 v15 += pNumVertices;
6953 } 6958 }
6954 else 6959 else
6955 v15 -= pNumVertices; 6960 v15 -= pNumVertices;
6956 if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[v65] ) 6961 if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] )
6957 { 6962 {
6958 v61 = v15; 6963 v61 = v15;
6959 v65 = v15; 6964 min_y_ID = v15;
6960 } 6965 }
6961 if ( PortalFace._screen_space_y[v15] == max_y ) 6966 if ( PortalFace._screen_space_y[v15] == max_y )
6962 break; 6967 break;
6963 } 6968 }
6964 v18 = v63 + v61; 6969 v18 = direction1 + v61;
6965 if ( v18 < pNumVertices ) 6970 if ( v18 < pNumVertices )
6966 { 6971 {
6967 if ( v18 < 0 ) 6972 if ( v18 < 0 )
6968 v18 += pNumVertices; 6973 v18 += pNumVertices;
6969 } 6974 }
6973 v20 = v61; 6978 v20 = v61;
6974 if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) 6979 if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] )
6975 { 6980 {
6976 v61 = PortalFace._screen_space_x[v20] << 16; 6981 v61 = PortalFace._screen_space_x[v20] << 16;
6977 v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]; 6982 v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20];
6978 a2->viewport_right_side[max_y] = LOWORD(PortalFace._screen_space_x[v20]); 6983 a2->viewport_right_side[max_y] = PortalFace._screen_space_x[v20];
6979 } 6984 }
6985 //****************************************************************************************************************************************
6980 v22 = min_y; 6986 v22 = min_y;
6981 if ( min_y <= max_y ) 6987 if ( min_y <= max_y )
6982 { 6988 {
6983 //v56 = &a2->array_3D8[v7]; 6989 //v56 = &a2->array_3D8[v7];
6984 //v23 = &a2->array_18[v7]; 6990 //v23 = &a2->array_18[v7];
6985 for ( v70 = min_y; v70 <= max_y; ++v70 ) 6991 for ( v70 = min_y; v70 <= max_y; ++v70 )
6986 { 6992 {
6987 v24 = v13; 6993 v24 = v13;
6988 if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) 6994 if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y )
6989 { 6995 {
6990 v13 = v64 + v13; 6996 v13 = direction2 + v13;
6991 if ( v13 < pNumVertices ) 6997 if ( v13 < pNumVertices )
6992 { 6998 {
6993 if ( v13 < 0 ) 6999 if ( v13 < 0 )
6994 v13 += pNumVertices; 7000 v13 += pNumVertices;
6995 } 7001 }
7004 } 7010 }
7005 } 7011 }
7006 v29 = v18; 7012 v29 = v18;
7007 if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) 7013 if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y )
7008 { 7014 {
7009 v18 += v63; 7015 v18 += direction1;
7010 if ( v18 < pNumVertices ) 7016 if ( v18 < pNumVertices )
7011 { 7017 {
7012 if ( v18 < 0 ) 7018 if ( v18 < 0 )
7013 v18 += pNumVertices; 7019 v18 += pNumVertices;
7014 } 7020 }