comparison Indoor.cpp @ 1370:14695590d7a6

GetPortalScreenCoord fix
author Ritor1
date Mon, 15 Jul 2013 15:03:40 +0600
parents b99aeb077d4f
children 5572e7b02f45
comparison
equal deleted inserted replaced
1345:b99aeb077d4f 1370:14695590d7a6
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 sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
6835 { 6835 {
6836 //int v4; // edi@1
6837 //BspRenderer_stru2 *v5; // ebx@1
6838 int v6; // eax@3 6836 int v6; // eax@3
6839 int min_y; // esi@5 6837 int min_y; // esi@5
6840 int max_y; // edx@5 6838 int max_y; // edx@5
6841 //int v9; // ecx@6
6842 int v10; // eax@12 6839 int v10; // eax@12
6843 //int v11; // edi@13
6844 //int v12; // edx@18
6845 int v13; // eax@22 6840 int v13; // eax@22
6846 //int v14; // edi@28
6847 int v15; // ecx@29 6841 int v15; // ecx@29
6848 //int v16; // edi@30
6849 //int v17; // edx@35
6850 int v18; // eax@39 6842 int v18; // eax@39
6851 int v19; // eax@44 6843 int v19; // eax@44
6852 int v20; // ecx@44 6844 int v20; // ecx@44
6853 //int v21; // edi@45
6854 int v22; // edi@46 6845 int v22; // edi@46
6855 //__int16 *v23; // ecx@47
6856 int v24; // edx@48 6846 int v24; // edx@48
6857 //int v25; // eax@50
6858 int v26; // eax@55 6847 int v26; // eax@55
6859 signed int v27; // edi@55 6848 signed int v27; // edi@55
6860 //int v28; // edx@56
6861 int v29; // edx@57 6849 int v29; // edx@57
6862 //int v30; // eax@59
6863 int v31; // eax@64 6850 int v31; // eax@64
6864 signed int v32; // edi@64 6851 signed int v32; // edi@64
6865 //int v33; // edx@65
6866 int v34; // eax@66 6852 int v34; // eax@66
6867 int v35; // dx@66 6853 int v35; // dx@66
6868 __int16 v36; // dx@67 6854 __int16 v36; // dx@67
6869 __int16 v37; // di@67 6855 __int16 v37; // di@67
6870 __int16 v38; // dx@67 6856 __int16 v38; // dx@67
6871 //BspRenderer_stru2 *v39; // ecx@69
6872 //int v40; // edx@69
6873 //int v41; // edi@70
6874 //__int16 *v42; // eax@76
6875 //__int16 *v43; // eax@81
6876 //__int16 *v45; // eax@87
6877 int v46; // edx@87 6857 int v46; // edx@87
6878 //__int16 v47; // cx@88
6879 //int v48; // eax@93
6880 int v49; // esi@93 6858 int v49; // esi@93
6881 //__int16 *v50; // ecx@94
6882 //int v51; // eax@95
6883 //int v52; // eax@97
6884 int v53; // [sp+Ch] [bp-34h]@44 6859 int v53; // [sp+Ch] [bp-34h]@44
6885 int v54; // [sp+10h] [bp-30h]@0 6860 int v54; // [sp+10h] [bp-30h]@0
6886 int v55; // [sp+14h] [bp-2Ch]@12 6861 int v55; // [sp+14h] [bp-2Ch]@12
6887 //__int16 *v56; // [sp+14h] [bp-2Ch]@47
6888 //__int16 v57; // [sp+14h] [bp-2Ch]@76
6889 //__int16 v58; // [sp+14h] [bp-2Ch]@81
6890 int v59; // [sp+14h] [bp-2Ch]@87 6862 int v59; // [sp+14h] [bp-2Ch]@87
6891 //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
6892 int v61; // [sp+1Ch] [bp-24h]@29 6863 int v61; // [sp+1Ch] [bp-24h]@29
6893 int v62; // [sp+20h] [bp-20h]@0 6864 int v62; // [sp+20h] [bp-20h]@0
6894 signed int v63; // [sp+24h] [bp-1Ch]@3 6865 signed int v63; // [sp+24h] [bp-1Ch]@3
6895 signed int v64; // [sp+28h] [bp-18h]@3 6866 signed int v64; // [sp+28h] [bp-18h]@3
6896 int v65; // [sp+2Ch] [bp-14h]@5 6867 int v65; // [sp+2Ch] [bp-14h]@5
6897 //int v66; // [sp+2Ch] [bp-14h]@39
6898 //int v67; // [sp+30h] [bp-10h]@22
6899 int v68; // [sp+34h] [bp-Ch]@12 6868 int v68; // [sp+34h] [bp-Ch]@12
6900 int v69; // [sp+34h] [bp-Ch]@29 6869 int v69; // [sp+34h] [bp-Ch]@29
6901 int v70; // [sp+34h] [bp-Ch]@46 6870 int v70; // [sp+34h] [bp-Ch]@46
6902 int v71; // [sp+34h] [bp-Ch]@75 6871 int v71; // [sp+34h] [bp-Ch]@75
6903 int v72; // [sp+34h] [bp-Ch]@80 6872 int v72; // [sp+34h] [bp-Ch]@80
6904 //int v73; // [sp+38h] [bp-8h]@11 6873
6905 //int v74; // [sp+3Ch] [bp-4h]@1
6906 //int a3a; // [sp+48h] [bp+8h]@76
6907 //int a3b; // [sp+48h] [bp+8h]@87
6908
6909 //try graphic engine with function returning 1 always, and without
6910 //return true;
6911 if ( pNumVertices <= 1 ) 6874 if ( pNumVertices <= 1 )
6912 return false; 6875 return false;
6913 min_y = PortalFace._screen_space_y[0]; 6876 min_y = PortalFace._screen_space_y[0];
6914 v65 = 0; 6877 v65 = 0;
6915 max_y = PortalFace._screen_space_y[0]; 6878 max_y = PortalFace._screen_space_y[0];
7167 int __fastcall GetPortalScreenCoord(unsigned int uFaceID) 7130 int __fastcall GetPortalScreenCoord(unsigned int uFaceID)
7168 { 7131 {
7169 BLVFace *pFace; // ebx@1 7132 BLVFace *pFace; // ebx@1
7170 int pNextVertices; // edx@11 7133 int pNextVertices; // edx@11
7171 int t; // ST28_4@12 7134 int t; // ST28_4@12
7172 signed int v13; // edx@12
7173 signed __int64 v14; // qtt@12
7174 signed int v17; // eax@14
7175 signed __int64 v18; // qtt@14
7176 signed int v20; // edx@17
7177 int v25; // eax@22
7178 int pScreenX; // eax@22 7135 int pScreenX; // eax@22
7179 int v31; // eax@27
7180 int pScreenY; // eax@27 7136 int pScreenY; // eax@27
7181 int v35; // ST30_4@30
7182 signed int left_num_vertices; // edi@31 7137 signed int left_num_vertices; // edi@31
7183 signed int right_num_vertices; // ebx@41 7138 signed int right_num_vertices; // ebx@41
7184 signed int top_num_vertices; // edi@51 7139 signed int top_num_vertices; // edi@51
7185 int bottom_num_vertices; // ebx@61 7140 int bottom_num_vertices; // ebx@61
7186 signed int v62; // edx@75 7141 signed int v62; // edx@75
7187 int v63; // ecx@76 7142 int v63; // ecx@76
7188 int v64; // esi@76 7143 int v64; // esi@76
7189 int v65; // ecx@83 7144 int v65; // ecx@83
7190 signed int v71; // [sp+14h] [bp-14h]@75 7145 signed int v71; // [sp+14h] [bp-14h]@75
7191 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 7146 bool current_vertices_flag; // [sp+18h] [bp-10h]@9
7192 int thisb; // [sp+18h] [bp-10h]@12
7193 int thisf; // [sp+18h] [bp-10h]@74 7147 int thisf; // [sp+18h] [bp-10h]@74
7194 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 7148 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9
7195 int v80; // [sp+1Ch] [bp-Ch]@76 7149 int v80; // [sp+1Ch] [bp-Ch]@76
7196 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 7150 bool next_vertices_flag; // [sp+20h] [bp-8h]@10
7197 signed int v90; // [sp+24h] [bp-4h]@51
7198 7151
7199 pFace = &pIndoor->pFaces[uFaceID]; 7152 pFace = &pIndoor->pFaces[uFaceID];
7200 memset(&PortalFace, 0, sizeof(stru367)); 7153 memset(&PortalFace, 0, sizeof(stru367));
7201 7154
7202 //get direction the face(определение направленности фейса)********************************************************************************* 7155 //get direction the face(определение направленности фейса)*********************************************************************************
7239 pIndoor->pVertices[pFace->pVertexIDs[i]].y, 7192 pIndoor->pVertices[pFace->pVertexIDs[i]].y,
7240 pIndoor->pVertices[pFace->pVertexIDs[i]].z, 7193 pIndoor->pVertices[pFace->pVertexIDs[i]].z,
7241 &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); 7194 &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0);
7242 } 7195 }
7243 } 7196 }
7244 //х: 55681665, 55681665, 53050369, 47787777, 45156481, 45156481
7245 //x: 0x0351 a281,0x0351 a281,0x0329 7c01,0x02d9 2f01,0x02b1 0881,0x02b1 0881
7246 //***************************************************************************************************************************************** 7197 //*****************************************************************************************************************************************
7247 //check vertices for the nearest plane(проверка вершин есть ли в области за ближайшей плоскостью) 7198 //check vertices for the nearest plane(проверка вершин есть ли в области за ближайшей плоскостью)
7248 if ( pFace->uNumVertices <= 0 ) 7199 if ( pFace->uNumVertices <= 0 )
7249 return 0; 7200 return 0;
7250 bool bFound = false; 7201 bool bFound = false;
7285 next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000) 7236 next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000)
7286 if ( current_vertices_flag ^ next_vertices_flag )//или текущая или следующая вершина за ближней границей 7237 if ( current_vertices_flag ^ next_vertices_flag )//или текущая или следующая вершина за ближней границей
7287 { 7238 {
7288 if ( next_vertices_flag )//следующая вершина за ближней границей 7239 if ( next_vertices_flag )//следующая вершина за ближней границей
7289 { 7240 {
7290 v13 = 524288 - PortalFace._view_transformed_z[i + 2];
7291 LODWORD(v14) = v13 << 16;
7292 HIDWORD(v14) = v13 >> 16;
7293 //t = near_clip - v0.z / v1.z - v0.z 7241 //t = near_clip - v0.z / v1.z - v0.z
7294 t = v14 / PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]; 7242 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 2], PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]);
7295 //New_x = (v1.x - v0.x)*t + v0.x 7243 //New_x = (v1.x - v0.x)*t + v0.x
7296 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3] 7244 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3]
7297 - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2]; 7245 - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2];
7298 //New_y = (v1.y - v0.y)*t + v0.y 7246 //New_y = (v1.y - v0.y)*t + v0.y
7299 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2]) 7247 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2])
7301 //New_z = 8.0(0x80000) 7249 //New_z = 8.0(0x80000)
7302 PortalFace._view_transformed_z[depth_num_vertices] = 524288; 7250 PortalFace._view_transformed_z[depth_num_vertices] = 524288;
7303 } 7251 }
7304 else// текущая вершина за ближней границей 7252 else// текущая вершина за ближней границей
7305 { 7253 {
7306 v17 = 524288 - PortalFace._view_transformed_z[i + 3];
7307 LODWORD(v18) = v17 << 16;
7308 HIDWORD(v18) = v17 >> 16;
7309 //t = near_clip - v1.z / v0.z - v1.z 7254 //t = near_clip - v1.z / v0.z - v1.z
7310 t = v18 / PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]; 7255 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 3], PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]);
7311 //New_x = (v0.x - v1.x)*t + v1.x 7256 //New_x = (v0.x - v1.x)*t + v1.x
7312 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2] 7257 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2]
7313 - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3]; 7258 - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3];
7314 //New_y = (v0.x - v1.y)*t + v1.y 7259 //New_y = (v0.x - v1.y)*t + v1.y
7315 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3]) 7260 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3])
7377 } 7322 }
7378 } 7323 }
7379 PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16); 7324 PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16);
7380 PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16); 7325 PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16);
7381 } 7326 }
7382 //х -34, 4, 61, 83, 83, -34
7383 //y 211, 152, 172, 216, 273, 293
7384 // результат: при повороте камеры, когда граница портала сдвигается к краю экрана, портал остается прозрачным(видимым) 7327 // результат: при повороте камеры, когда граница портала сдвигается к краю экрана, портал остается прозрачным(видимым)
7385 //****************************************************************************************************************************************** 7328 //******************************************************************************************************************************************
7386 //check for left_clip plane(порверка по левой границе) 7329 //check for left_clip plane(порверка по левой границе)
7387 left_num_vertices = 0; 7330 left_num_vertices = 0;
7388 PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12]; 7331 PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12];
7389 PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12]; 7332 PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12];
7390 current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX; 7333 current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;//8.0
7391 if ( depth_num_vertices < 1 ) 7334 if ( depth_num_vertices < 1 )
7392 return 0; 7335 return 0;
7393 for ( uint i = 1; i <= depth_num_vertices; ++i ) 7336 for ( uint i = 1; i <= depth_num_vertices; ++i )
7394 { 7337 {
7395 next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX; 7338 next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX;
7396 if ( current_vertices_flag ^ next_vertices_flag ) 7339 if ( current_vertices_flag ^ next_vertices_flag )
7397 { 7340 {
7398 if ( next_vertices_flag ) 7341 if ( next_vertices_flag )
7399 { 7342 {
7400 //t = left_clip - v0.x / v1.x - v0.x 7343 //t = left_clip - v0.x / v1.x - v0.x
7401 t = (signed __int64)(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11]) 7344 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11], PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]);
7402 / (PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]);
7403 //New_y = (v1.y - v0.y)*t + v0.y 7345 //New_y = (v1.y - v0.y)*t + v0.y
7404 PortalFace._screen_space_y[left_num_vertices + 9] = (signed int)(PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) 7346 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)((PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11])
7405 * t + PortalFace._screen_space_y[i + 11]; 7347 * t) >> 16) + PortalFace._screen_space_y[i + 11];
7406 //New_x = left_clip 7348 //New_x = left_clip
7407 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; 7349 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX;
7408 } 7350 }
7409 else 7351 else
7410 { 7352 {
7411 //t = left_clip - v1.x / v0.x - v1.x 7353 //t = left_clip - v1.x / v0.x - v1.x
7412 t = (signed __int64)(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12]) 7354 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12], PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]);
7413 / (PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]);
7414 //New_y = (v0.y - v1.y)*t + v1.y 7355 //New_y = (v0.y - v1.y)*t + v1.y
7415 PortalFace._screen_space_y[left_num_vertices + 9] = (signed int)( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) 7356 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)(( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12])
7416 * t + PortalFace._screen_space_y[i + 12]; 7357 * t) >> 16) + PortalFace._screen_space_y[i + 12];
7417 //New_x = left_clip 7358 //New_x = left_clip
7418 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; 7359 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX;
7419 } 7360 }
7420 left_num_vertices++; 7361 left_num_vertices++;
7421 } 7362 }
7430 //********************************************************************************************************************************* 7371 //*********************************************************************************************************************************
7431 //for right_clip plane(проверка по правой плоскости) 7372 //for right_clip plane(проверка по правой плоскости)
7432 right_num_vertices = 0; 7373 right_num_vertices = 0;
7433 PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9]; 7374 PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9];
7434 PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9]; 7375 PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9];
7435 current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ; 7376 current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ;//468.0
7436 if (left_num_vertices < 1) 7377 if (left_num_vertices < 1)
7437 return 0; 7378 return 0;
7438 for ( uint i = 1; i <= left_num_vertices; ++i ) 7379 for ( uint i = 1; i <= left_num_vertices; ++i )
7439 { 7380 {
7440 next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ; 7381 next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ;
7441 if ( current_vertices_flag ^ next_vertices_flag ) 7382 if ( current_vertices_flag ^ next_vertices_flag )
7442 { 7383 {
7443 if ( next_vertices_flag ) 7384 if ( next_vertices_flag )
7444 { 7385 {
7445 //t = right_clip - v1.x / v0.x - v1.x 7386 //t = right_clip - v1.x / v0.x - v1.x
7446 t = (signed __int64)(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9]) 7387 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8], PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]);
7447 / (PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]);
7448 //New_y = (v0.y - v1.y)*t + v1.y 7388 //New_y = (v0.y - v1.y)*t + v1.y
7449 PortalFace._screen_space_y[right_num_vertices + 6] = (signed int)(PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) 7389 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8])
7450 * t + PortalFace._screen_space_y[i + 9]; 7390 * t) >> 16) + PortalFace._screen_space_y[i + 8];
7451 //New_x = right_clip 7391 //New_x = right_clip
7452 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; 7392 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ;
7453 } 7393 }
7454 else 7394 else
7455 { 7395 {
7456 //t = right_clip - v0.x / v1.x - v0.x 7396 //t = right_clip - v0.x / v1.x - v0.x
7457 t = (signed __int64)(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8]) 7397 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9], PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]);
7458 / (PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]);
7459 //New_y = (v1.y - v0.y)*t + v0.y 7398 //New_y = (v1.y - v0.y)*t + v0.y
7460 PortalFace._screen_space_y[right_num_vertices + 6] = (signed int)(PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) 7399 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9])
7461 * t + PortalFace._screen_space_y[i + 8]; 7400 * t) >> 16) + PortalFace._screen_space_y[i + 9];
7462 //New_x = right_clip 7401 //New_x = right_clip
7463 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; 7402 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ;
7464 } 7403 }
7465 right_num_vertices++; 7404 right_num_vertices++;
7466 } 7405 }
7476 // for top clip plane 7415 // for top clip plane
7477 top_num_vertices = 0; 7416 top_num_vertices = 0;
7478 PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6]; 7417 PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6];
7479 PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6]; 7418 PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6];
7480 7419
7481 current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY; 7420 current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY;//8.0
7482 if ( right_num_vertices < 1 ) 7421 if ( right_num_vertices < 1 )
7483 return 0; 7422 return 0;
7484 for ( uint i = 1; i <= right_num_vertices; ++i ) 7423 for ( uint i = 1; i <= right_num_vertices; ++i )
7485 { 7424 {
7486 next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY; 7425 next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY;
7487 if ( current_vertices_flag ^ next_vertices_flag ) 7426 if ( current_vertices_flag ^ next_vertices_flag )
7488 { 7427 {
7489 if ( next_vertices_flag ) 7428 if ( next_vertices_flag )
7490 { 7429 {
7491 t = (signed __int64)(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5]) 7430 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5], PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]);
7492 / (PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); 7431 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5])
7493 PortalFace._screen_space_x[top_num_vertices + 3] = (signed int)(PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) 7432 * t) >> 16) + PortalFace._screen_space_x[i + 5];
7494 * t + PortalFace._screen_space_x[i + 5];
7495 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; 7433 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY;
7496 } 7434 }
7497 else 7435 else
7498 { 7436 {
7499 t = (signed __int64)(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6]) 7437 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6], PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]);
7500 / (PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); 7438 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6])
7501 PortalFace._screen_space_x[top_num_vertices + 3] = (signed int)(PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) 7439 * t) >> 16) + PortalFace._screen_space_x[i + 6];
7502 * t + PortalFace._screen_space_x[i + 6];
7503 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; 7440 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY;
7504 } 7441 }
7505 top_num_vertices++; 7442 top_num_vertices++;
7506 } 7443 }
7507 current_vertices_flag = next_vertices_flag; 7444 current_vertices_flag = next_vertices_flag;
7515 //********************************************************************************************************************************** 7452 //**********************************************************************************************************************************
7516 //for bottom_clip plane(проверка по нижней плоскости) 7453 //for bottom_clip plane(проверка по нижней плоскости)
7517 bottom_num_vertices = 0; 7454 bottom_num_vertices = 0;
7518 PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3]; 7455 PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3];
7519 PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3]; 7456 PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3];
7520 current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW; 7457 current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW;//351.0
7521 if ( top_num_vertices < 1 ) 7458 if ( top_num_vertices < 1 )
7522 return 0; 7459 return 0;
7523 for ( uint i =1; i <= top_num_vertices; ++i ) 7460 for ( uint i =1; i <= top_num_vertices; ++i )
7524 { 7461 {
7525 next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW; 7462 next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW;
7526 if ( current_vertices_flag ^ next_vertices_flag ) 7463 if ( current_vertices_flag ^ next_vertices_flag )
7527 { 7464 {
7528 if ( next_vertices_flag ) 7465 if ( next_vertices_flag )
7529 { 7466 {
7530 t = (signed __int64)(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3]) 7467 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2], PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]);
7531 / (PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); 7468 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2])
7532 PortalFace._screen_space_x[bottom_num_vertices] = (signed int)(PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) 7469 * t) >> 16) + PortalFace._screen_space_x[i + 2];
7533 * t + PortalFace._screen_space_x[i + 3];
7534 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; 7470 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW;
7535 } 7471 }
7536 else 7472 else
7537 { 7473 {
7538 t = (signed __int64)(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2]) 7474 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3], PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]);
7539 / (PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); 7475 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3])
7540 PortalFace._screen_space_x[bottom_num_vertices] = (signed int)(PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) 7476 * t) >> 16) + PortalFace._screen_space_x[i + 3];
7541 * t + PortalFace._screen_space_x[i + 2];
7542 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; 7477 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW;
7543 } 7478 }
7544 bottom_num_vertices++; 7479 bottom_num_vertices++;
7545 } 7480 }
7546 if ( next_vertices_flag ) 7481 if ( next_vertices_flag )
7549 PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3]; 7484 PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3];
7550 PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3]; 7485 PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3];
7551 } 7486 }
7552 current_vertices_flag = next_vertices_flag; 7487 current_vertices_flag = next_vertices_flag;
7553 } 7488 }
7554 //out_x: 83,8,8,61,83
7555 //out_y: 273,293,152,172,216
7556 //*************************************************************************************************************************************** 7489 //***************************************************************************************************************************************
7557 7490
7558 if ( !bottom_num_vertices ) 7491 if ( !bottom_num_vertices )
7559 return 0; 7492 return 0;
7560 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; 7493 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0];