Mercurial > mm7
diff Indoor.cpp @ 1439:468f434a8d8a
Слияние
author | Ritor1 |
---|---|
date | Mon, 22 Jul 2013 18:00:58 +0600 |
parents | bc99e1a48bea 8ea496564034 |
children | b67a3e0d6fc3 |
line wrap: on
line diff
--- a/Indoor.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Indoor.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -63,7 +63,7 @@ stru320 stru_F8AD28; // idb stru337 stru_F81018; stru167_wrap array_5118E8; -BspRenderer_stru2 stru_F8A590; +BspRenderer_PortalViewportData stru_F8A590; BspRenderer *pBspRenderer = new BspRenderer; // idb stru141 stru_721530; std::array<stru352, 480> stru_F83B80; @@ -314,8 +314,9 @@ } else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) { - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].field_C; - IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); + __debugbreak(); // no SW + //pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].PortalScreenData; + //IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); } } @@ -347,22 +348,22 @@ for(int i=0; i < pBspRenderer->num_nodes; i++) { BspRenderer_stru0 *pNode = &pBspRenderer->nodes[i]; - v4 = pRenderer->uTargetSurfacePitch * pNode->field_C._viewport_space_y; - if ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w ) + v4 = pRenderer->uTargetSurfacePitch * pNode->PortalScreenData._viewport_space_y; + if ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ) { //v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7]; - v5 = &pNode->field_C.viewport_right_side[pNode->field_C._viewport_space_y]; - v8 = &pNode->field_C.viewport_left_side[pNode->field_C._viewport_space_y]; + v5 = &pNode->PortalScreenData.viewport_right_side[pNode->PortalScreenData._viewport_space_y]; + v8 = &pNode->PortalScreenData.viewport_left_side[pNode->PortalScreenData._viewport_space_y]; do { v1[v4 + *v8] = 255; - ++pNode->field_C._viewport_space_y; + ++pNode->PortalScreenData._viewport_space_y; v1[v4 + *v5] = 255; v4 += pRenderer->uTargetSurfacePitch; ++v5; ++v8; } - while ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w ); + while ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ); } } } @@ -583,13 +584,13 @@ } else { - v17 = 0xFFD0D0D0; + v17 = 0xFF808080; v23 = pFace->uBitmapID; v27 = pBitmaps_LOD->pHardwareTextures[v23]; } if (pFace->uAttributes & FACE_DO_NOT_LIGHT) - _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); + pRenderer->DrawIndoorPolygonNoLight(uNumVerticesa, uFaceID); else pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, PID(OBJECT_BModel, uFaceID), v17, 0); return; @@ -598,619 +599,6 @@ } } -//----- (004AFF79) -------------------------------------------------------- -void IndoorLocation::ExecDraw_sw(unsigned int uFaceID) -{ - unsigned int v1; // ebx@1 - BLVFace *v2; // esi@3 - unsigned int v3; // eax@3 - Texture *v4; // eax@8 - Texture *v5; // edi@8 - int v6; // eax@9 - int v7; // eax@9 - int v8; // ecx@17 - int v9; // ebx@17 - int v10; // eax@17 - int v11; // esi@17 - unsigned int v12; // eax@17 - int j; // ecx@19 - int v14; // edx@20 - int v15; // eax@20 - int v16; // edx@20 - int i; // ebx@22 - int v18; // ecx@23 - int v19; // eax@23 - int v20; // eax@23 - int v21; // eax@24 - unsigned __int8 *v22; // ecx@24 - int v23; // ebx@24 - int v24; // esi@25 - int v25; // eax@28 - unsigned __int16 *v26; // eax@28 - unsigned int v27; // eax@29 - int v28; // eax@30 - char *v29; // esi@31 - int v30; // eax@33 - int v31; // eax@33 - int v32; // eax@35 - int v33; // edx@35 - signed int v34; // ebx@35 - int v35; // eax@35 - int v36; // ebx@35 - signed int v37; // ebx@35 - signed int v38; // edi@35 - unsigned int v39; // edi@36 - int v40; // edx@40 - int v41; // ecx@40 - signed int v42; // edx@40 - int v43; // edx@42 - int v44; // eax@42 - unsigned __int16 *v45; // eax@43 - int *v46; // esi@44 - unsigned __int16 *v47; // edi@44 - unsigned int v48; // edx@44 - int v49; // ebx@44 - char v50; // cl@44 - char v51; // ch@44 - unsigned int v52; // ebx@46 - int v53; // edx@46 - unsigned int v54; // ebx@46 - int v55; // edx@46 - unsigned int v56; // ebx@47 - int v57; // edx@47 - int v58; // ebx@47 - int v59; // edx@47 - unsigned __int16 *v60; // eax@50 - int *v61; // esi@51 - unsigned __int16 *v62; // edi@51 - unsigned int v63; // edx@51 - int v64; // ebx@51 - char v65; // cl@51 - char v66; // ch@51 - unsigned int v67; // ebx@53 - int v68; // edx@53 - unsigned int v69; // ebx@53 - int v70; // edx@53 - unsigned int v71; // ebx@54 - int v72; // edx@54 - int v73; // ebx@54 - int v74; // edx@54 - unsigned __int16 *v75; // eax@58 - int *v76; // esi@59 - int v77; // edi@59 - unsigned int v78; // edx@59 - int v79; // ebx@59 - char v80; // cl@59 - char v81; // ch@59 - int v82; // ebx@61 - int v83; // edx@61 - unsigned int v84; // ebx@62 - int v85; // edx@62 - unsigned __int16 *v86; // eax@65 - int *v87; // esi@66 - int v88; // edi@66 - unsigned int v89; // edx@66 - int v90; // ebx@66 - char v91; // cl@66 - char v92; // ch@66 - int v93; // ebx@68 - int v94; // edx@68 - unsigned __int16 v95; // bx@69 - int v96; // edx@69 - unsigned __int8 *v97; // [sp+Ch] [bp-9Ch]@24 - unsigned __int8 *v98; // [sp+10h] [bp-98h]@24 - unsigned __int8 *v99; // [sp+14h] [bp-94h]@24 - unsigned __int8 *v100; // [sp+18h] [bp-90h]@24 - int v101; // [sp+1Ch] [bp-8Ch]@40 - int v102; // [sp+20h] [bp-88h]@31 - BLVFace *v103; // [sp+24h] [bp-84h]@3 - unsigned __int16 *v104; // [sp+28h] [bp-80h]@24 - int v105; // [sp+2Ch] [bp-7Ch]@30 - int v106; // [sp+30h] [bp-78h]@24 - int v107; // [sp+34h] [bp-74h]@9 - Texture *v108; // [sp+38h] [bp-70h]@8 - int v109; // [sp+3Ch] [bp-6Ch]@9 - unsigned int v110; // [sp+40h] [bp-68h]@24 - unsigned int v111; // [sp+44h] [bp-64h]@1 - int *k; // [sp+48h] [bp-60h]@31 - int v113; // [sp+4Ch] [bp-5Ch]@35 - int v114; // [sp+50h] [bp-58h]@35 - int v115; // [sp+54h] [bp-54h]@42 - unsigned __int8 *v116; // [sp+58h] [bp-50h]@35 - int v117; // [sp+5Ch] [bp-4Ch]@33 - int a1; // [sp+60h] [bp-48h]@27 - int v119; // [sp+64h] [bp-44h]@17 - int v120; // [sp+68h] [bp-40h]@23 - unsigned int v121; // [sp+6Ch] [bp-3Ch]@40 - unsigned int v122; // [sp+70h] [bp-38h]@35 - int v123; // [sp+74h] [bp-34h]@30 - int v124; // [sp+78h] [bp-30h]@17 - int v125; // [sp+7Ch] [bp-2Ch]@35 - unsigned int v126; // [sp+80h] [bp-28h]@9 - int v127; // [sp+84h] [bp-24h]@17 - int v128; // [sp+88h] [bp-20h]@9 - int *pZPixel; // [sp+8Ch] [bp-1Ch]@28 - int a2; // [sp+90h] [bp-18h]@16 - unsigned int v131; // [sp+94h] [bp-14h]@17 - unsigned __int16 *pColorPixel; // [sp+98h] [bp-10h]@28 - int v133; // [sp+9Ch] [bp-Ch]@17 - int v134; // [sp+A0h] [bp-8h]@17 - int v135; // [sp+A4h] [bp-4h]@24 - - v1 = uFaceID; - v111 = pRenderer->uTargetSurfacePitch; - if ( (uFaceID & 0x80000000u) == 0 ) - { - if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces ) - { - v2 = &pIndoor->pFaces[uFaceID]; - v103 = v2; - v3 = v2->uAttributes; - if ( !(BYTE1(v3) & 0x20) ) - { - if ( v3 & 0x400000 ) - { - sub_4ADD1D(uFaceID); - return; - } - if ( !(v3 & 0x10) || (sub_4AD504(uFaceID), pRenderer->pRenderD3D) ) - { - v4 = v2->GetTexture(); - ++pBLVRenderParams->uNumFacesRenderedThisFrame; - v5 = v4; - v108 = v4; - if ( v4 ) - { - v6 = v4->palette_id2; - LOBYTE(v2->uAttributes) |= 0x80u; - v109 = v6; - sub_4AE5F1(v1); - v126 = stru_F8AD28.pDeltaUV[0]; - v128 = stru_F8AD28.pDeltaUV[1]; - v107 = bUseLoResSprites; - v7 = sub_423B5D(v1); - if ( v7 ) - { - if ( sub_424829(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) - { - if ( v2->uPolygonType == 1 ) - { - for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 ) - { - v18 = i; - v120 = stru_F8AD28._blv_lights_xs[i]; - v134 = (unsigned __int64)(v120 * (signed __int64)-stru_F8AD28.plane_4.vNormal.y) >> 16; - v133 = stru_F8AD28.plane_4.vNormal.x; - v120 = stru_F8AD28._blv_lights_ys[i]; - v133 = (unsigned __int64)(v120 * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16; - v19 = v128; - stru_F8AD28._blv_lights_xs[i] = v126 - + v134 - + ((unsigned __int64)(v120 - * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16); - v20 = v19 - stru_F8AD28._blv_lights_zs[i++]; - } - } - else - { - if ( v2->uPolygonType != 3 ) - { - if ( v2->uPolygonType == 4 ) - { -LABEL_16: - a2 = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 ) - { - do - { - v8 = a2; - v9 = stru_F8AD28._blv_lights_xs[a2]; - v131 = stru_F8AD28._blv_lights_ys[a2]; - v10 = stru_F8AD28._blv_lights_zs[a2]; - v11 = (signed int)(v10 * stru_F8AD28.plane_4.vNormal.z - + stru_F8AD28.plane_4.dist - + v9 * stru_F8AD28.plane_4.vNormal.x - + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16; - v119 = v9 - - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)((signed int)(v10 * stru_F8AD28.plane_4.vNormal.z - + stru_F8AD28.plane_4.dist - + v9 * stru_F8AD28.plane_4.vNormal.x - + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16)) >> 16); - v131 -= (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)v11) >> 16; - v127 = v10 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)v11) >> 16); - stru_F8AD28._blv_lights_xs[a2] = ((unsigned __int64)(v119 - * (signed __int64)stru_F8AD28.vec_14.x) >> 16) - + ((unsigned __int64)((signed int)v131 - * (signed __int64)stru_F8AD28.vec_14.y) >> 16); - v124 = (unsigned __int64)(v119 * (signed __int64)stru_F8AD28.vec_20.x) >> 16; - v134 = (unsigned __int64)((signed int)v131 * (signed __int64)stru_F8AD28.vec_20.y) >> 16; - v133 = (unsigned __int64)(v127 * (signed __int64)stru_F8AD28.vec_20.z) >> 16; - v12 = v126; - stru_F8AD28._blv_lights_ys[v8] = v124 - + ((unsigned __int64)((signed int)v131 - * (signed __int64)stru_F8AD28.vec_20.y) >> 16) - + ((unsigned __int64)(v127 - * (signed __int64)stru_F8AD28.vec_20.z) >> 16); - stru_F8AD28._blv_lights_xs[v8] += v12; - stru_F8AD28._blv_lights_ys[v8] += v128; - ++a2; - } - while ( a2 < stru_F8AD28.uNumLightsApplied ); - v2 = v103; - } - goto LABEL_24; - } - if ( v2->uPolygonType != 5 ) - { - if ( v2->uPolygonType != 6 ) - goto LABEL_24; - goto LABEL_16; - } - } - for ( j = 0; j < stru_F8AD28.uNumLightsApplied; *(int *)v15 = v16 ) - { - v14 = v128; - stru_F8AD28._blv_lights_xs[j] += v126; - v15 = 4 * j + 16297672; - v16 = v14 - stru_F8AD28._blv_lights_ys[j++]; - } - } -LABEL_24: - v135 = 1; - pGame->_44ED0A(v2, &v135, 31); - v104 = sr_sub_47C24C_get_palette(v2, v109, 0, 1); - v134 = stru_F8AD28.field_44; - v106 = stru_F8AD28.field_48; - v21 = stru_F8A590._viewport_space_y; - a2 = stru_F8A590._viewport_space_y; - v110 = v111 * stru_F8A590._viewport_space_y; - v97 = v5->pLevelOfDetail0_prolly_alpha_mask; - v98 = v5->pLevelOfDetail1; - v99 = v5->pLevelOfDetail2; - v22 = v5->pLevelOfDetail3; - v23 = 640 * stru_F8A590._viewport_space_y; - v119 = 640 * stru_F8A590._viewport_space_y; - v100 = v22; - if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) - { - v24 = 2 * stru_F8A590._viewport_space_y; - v120 = 2 * stru_F8A590._viewport_space_y; - while ( 1 ) - { - a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24); - sub_4AE313(a1, v21, &stru_F81018.field_0); - if ( LOBYTE(viewparams->field_20) ) - { - v27 = v111 * (v24 - pBLVRenderParams->uViewportY); - pZPixel = &pBLVRenderParams->pTargetZBuffer[2 - * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v24) - + 320 * (v24 - pBLVRenderParams->uViewportY)) - - pBLVRenderParams->uViewportX]; - pColorPixel = &pBLVRenderParams->pRenderTarget[v27 - + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24) - - pBLVRenderParams->uViewportX]; - v26 = &pBLVRenderParams->pRenderTarget[v27 - + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24) - - pBLVRenderParams->uViewportX]; - v23 = v119; - } - else - { - v25 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24); - pZPixel = &pBLVRenderParams->pTargetZBuffer[v25 + v23]; - pColorPixel = &pBLVRenderParams->pRenderTarget[v25 + v110]; - v26 = &pBLVRenderParams->pRenderTarget[v110 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24)]; - } - v131 = (unsigned int)v26; - HIWORD(v28) = HIWORD(stru_F81018.field_0.field_0); - LOWORD(v28) = 0; - v105 = stru_F8AD28.field_0 | v28; - v123 = sub_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8)); - if ( (unsigned int)pColorPixel < v131 ) - { - v102 = v107 + v106; - v29 = (char *)&stru_F81018.field_34.field_8; - a1 += v134; - for ( k = &stru_F81018.field_34.field_8; ; v29 = (char *)k ) - { - sub_4AE313(a1, a2, (stru337_stru0 *)(v29 - 8)); - v30 = *((int *)v29 - 2); - LOWORD(v30) = 0; - v117 = v105; - v31 = stru_F8AD28.field_0 | v30; - if ( v105 <= (unsigned int)v31 ) - v117 = v31; - v105 = v31; - v32 = *((int *)v29 - 14); - v122 = *((int *)v29 - 14) >> v107; - v33 = *((int *)v29 - 13); - v125 = *((int *)v29 - 13) >> v107; - v34 = *((int *)v29 - 1) - v32; - v113 = (*(int *)v29 - v33) >> v102; - v35 = *((int *)v29 - 11); - v114 = v34 >> v102; - v116 = (&v97)[4 * v35]; - v36 = v35 + 16 - v5->uWidthLn2; - v133 = v35 + 16; - v127 = v35 + v36; - v37 = v5->uWidthMinus1 >> v35; - v38 = v5->uHeightMinus1 >> v35 << (v35 + 16); - v128 = v37; - v126 = v38; - v39 = (unsigned int)(LOBYTE(viewparams->field_20) ? &pColorPixel[2 * v134] : &pColorPixel[v134]); - if ( v39 > v131 ) - v39 = v131; - v40 = *((short *)v29 + 1); - v41 = *((short *)v29 - 1); - v121 = v39; - v42 = sub_4AE491(v41, v40); - v101 = v42; - v124 = (signed int)(v39 - (int)pColorPixel) >> 1; - if ( v123 >> 16 == v42 >> 16 || v135 & 2 ) - { - v123 = (int)sr_sub_47C24C_get_palette(v103, v109, v123 >> 16, 1); - if ( LOBYTE(viewparams->field_20) ) - { - v86 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v87 = pZPixel; - v88 = v123; - v89 = v122; - v90 = v125; - v91 = v133; - v92 = v127; - if ( v124 & 2 ) - { - *pZPixel = v117; - v87 -= 2; - v86 = pColorPixel + 2; - goto LABEL_69; - } - do - { - v86 += 4; - v93 = *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92)); - v94 = v117; - LOWORD(v93) = *(short *)(v88 + 2 * v93); - *v87 = v117; - v87[1] = v94; - v87[640] = v94; - v87[641] = v94; - *(v86 - 4) = v93; - *(v86 - 3) = v93; - v86[636] = v93; - v86[637] = v93; - v87[2] = v94; - v87[3] = v94; - v87[642] = v94; - v87[643] = v94; - v122 += v114; - v125 += v113; - v89 = v122; - v90 = v125; -LABEL_69: - v87 += 4; - v95 = *(short *)(v88 + 2 * *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92))); - v96 = v114; - *(v86 - 2) = v95; - *(v86 - 1) = v95; - v86[638] = v95; - v86[639] = v95; - v122 += v96; - v125 += v113; - v89 = v122; - v90 = v125; - } - while ( (unsigned int)v86 < v121 ); - pColorPixel = v86; - pZPixel = v87; - } - } - else - { - v75 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v76 = pZPixel; - v77 = v123; - v78 = v122; - v79 = v125; - v80 = v133; - v81 = v127; - if ( v124 & 1 ) - { - *pZPixel = v117; - --v76; - v75 = pColorPixel + 1; - goto LABEL_62; - } - do - { - v75 += 2; - v82 = *(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); - v83 = v117; - LOWORD(v82) = *(short *)(v77 + 2 * v82); - *v76 = v117; - *(v75 - 2) = v82; - v76[1] = v83; - v122 += v114; - v125 += v113; - v78 = v122; - v79 = v125; -LABEL_62: - v84 = (unsigned int)(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); - v76 += 2; - v85 = v114; - *(v75 - 1) = *(short *)(v77 + 2 * *(char *)v84); - v122 += v85; - v125 += v113; - v78 = v122; - v79 = v125; - } - while ( (unsigned int)v75 < v121 ); - pColorPixel = v75; - pZPixel = v76; - } - } - } - else - { - v43 = (v42 - v123) >> v106; - v44 = v123 - v43; - v123 = v43; - v115 = v44; - if ( LOBYTE(viewparams->field_20) ) - { - v60 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v61 = pZPixel; - v62 = v104; - v63 = v122; - v64 = v125; - v65 = v133; - v66 = v127; - if ( v124 & 2 ) - { - *pZPixel = v117; - v61 += 2; - v60 = pColorPixel + 2; - goto LABEL_54; - } - do - { - v67 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); - v68 = v123 + v115; - v60 += 4; - v115 = v68; - v69 = ((v68 & 0xFFFF0000u) >> 8) + v116[v67]; - v70 = v117; - LOWORD(v69) = v62[v69]; - *v61 = v117; - v61[1] = v70; - v61[640] = v70; - v61[641] = v70; - *(v60 - 4) = v69; - *(v60 - 3) = v69; - v60[636] = v69; - v60[637] = v69; - v61[2] = v70; - v61[3] = v70; - v61[642] = v70; - v61[643] = v70; - v122 += v114; - v125 += v113; - v63 = v122; - v64 = v125; - v61 += 4; -LABEL_54: - v71 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); - v72 = v123 + v115; - v73 = v116[v71]; - v115 = v72; - LOWORD(v73) = v62[((v72 & 0xFFFF0000u) >> 8) + v73]; - v74 = v114; - *(v60 - 2) = v73; - *(v60 - 1) = v73; - v60[638] = v73; - v60[639] = v73; - v122 += v74; - v125 += v113; - v63 = v122; - v64 = v125; - } - while ( (unsigned int)v60 < v121 ); - pColorPixel = v60; - pZPixel = v61; - } - } - else - { - v45 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v46 = pZPixel; - v47 = v104; - v48 = v122; - v49 = v125; - v50 = v133; - v51 = v127; - if ( v124 & 1 ) - { - *pZPixel = v117; - ++v46; - v45 = pColorPixel + 1; - goto LABEL_47; - } - do - { - v52 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); - v53 = v123 + v115; - v45 += 2; - v115 = v53; - v54 = ((v53 & 0xFFFF0000u) >> 8) + v116[v52]; - v55 = v117; - LOWORD(v54) = v47[v54]; - *v46 = v117; - *(v45 - 2) = v54; - v46[1] = v55; - v122 += v114; - v125 += v113; - v48 = v122; - v49 = v125; - v46 += 2; -LABEL_47: - v56 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); - v57 = v123 + v115; - v58 = v116[v56]; - v115 = v57; - LOWORD(v58) = v47[((v57 & 0xFFFF0000u) >> 8) + v58]; - v59 = v114; - *(v45 - 1) = v58; - v122 += v59; - v125 += v113; - v48 = v122; - v49 = v125; - } - while ( (unsigned int)v45 < v121 ); - pColorPixel = v45; - pZPixel = v46; - } - } - } - k += 13; - v5 = v108; - v123 = v101; - a1 += v134; - if ( (unsigned int)pColorPixel >= v131 ) - break; - } - v23 = v119; - v24 = v120; - } - ++a2; - v110 += v111; - v23 += 640; - v24 += 2; - v120 = v24; - v119 = v23; - if ( a2 > stru_F8A590._viewport_space_w ) - break; - v21 = a2; - } - } - return; - } - } - } - } - } - } - } -} -// 4AE491: using guessed type int __fastcall sub_4AE491(int, int); @@ -1337,7 +725,7 @@ nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; - nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, + nodes[num_nodes].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); AddBspNodeToRenderList(++num_nodes - 1); return; @@ -1352,25 +740,25 @@ if (v9 >= 0) return; - auto num_vertices = sub_423B5D(uFaceID); + auto num_vertices = GetPortalScreenCoord(uFaceID); if (num_vertices < 2) return; - auto face_min_screenspace_x = stru_50B700._screen_space_x[0], - face_max_screenspace_x = stru_50B700._screen_space_x[0]; - auto face_min_screenspace_y = stru_50B700._screen_space_y[0], - face_max_screenspace_y = stru_50B700._screen_space_y[0]; + auto face_min_screenspace_x = PortalFace._screen_space_x[0], + face_max_screenspace_x = PortalFace._screen_space_x[0]; + auto face_min_screenspace_y = PortalFace._screen_space_y[0], + face_max_screenspace_y = PortalFace._screen_space_y[0]; for (uint i = 1; i < num_vertices; ++i) { - if (face_min_screenspace_x > stru_50B700._screen_space_x[i]) - face_min_screenspace_x = stru_50B700._screen_space_x[i]; - if (face_max_screenspace_x < stru_50B700._screen_space_x[i]) - face_max_screenspace_x = stru_50B700._screen_space_x[i]; - - if (face_min_screenspace_y > stru_50B700._screen_space_y[i]) - face_min_screenspace_y = stru_50B700._screen_space_y[i]; - if (face_max_screenspace_y < stru_50B700._screen_space_y[i]) - face_max_screenspace_y = stru_50B700._screen_space_y[i]; + if (face_min_screenspace_x > PortalFace._screen_space_x[i]) + face_min_screenspace_x = PortalFace._screen_space_x[i]; + if (face_max_screenspace_x < PortalFace._screen_space_x[i]) + face_max_screenspace_x = PortalFace._screen_space_x[i]; + + if (face_min_screenspace_y > PortalFace._screen_space_y[i]) + face_min_screenspace_y = PortalFace._screen_space_y[i]; + if (face_max_screenspace_y < PortalFace._screen_space_y[i]) + face_max_screenspace_y = PortalFace._screen_space_y[i]; } //_screen_space_x = 719, 568, 493 //savegame: qw , 0Bh and 0x1D4h @@ -1379,7 +767,7 @@ face_min_screenspace_x <= nodes[node_id].uViewportZ && face_max_screenspace_y >= nodes[node_id].uViewportY && face_min_screenspace_y <= nodes[node_id].uViewportW && - sub_424829(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID)) + PortalFrustrum(num_vertices, &nodes[num_nodes].PortalScreenData, &nodes[node_id].PortalScreenData, uFaceID)) { pTransitionSector = pFace->uSectorID; if (nodes[node_id].uSectorID == pTransitionSector ) @@ -1481,7 +869,7 @@ v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); - v3->nodes[v3->num_nodes++].field_C.GetViewportData( + v3->nodes[v3->num_nodes++].PortalScreenData.GetViewportData( SLOWORD(pBLVRenderParams->uViewportX), pBLVRenderParams->uViewportY, SLOWORD(pBLVRenderParams->uViewportZ), @@ -1500,29 +888,29 @@ v9 = -v9; if ( v9 < 0 ) { - v10 = sub_423B5D(uFaceID); + v10 = GetPortalScreenCoord(uFaceID); v19 = v10; if ( v10 ) { - v11 = stru_50B700._screen_space_x[0]; - v12 = stru_50B700._screen_space_y[0]; - v23 = stru_50B700._screen_space_x[0]; + v11 = PortalFace._screen_space_x[0]; + v12 = PortalFace._screen_space_y[0]; + v23 = PortalFace._screen_space_x[0]; v13 = 1; - v22 = stru_50B700._screen_space_y[0]; + v22 = PortalFace._screen_space_y[0]; if ( v10 > 1 ) { do { - v14 = stru_50B700._screen_space_x[v13]; + v14 = PortalFace._screen_space_x[v13]; if ( v14 < v23 ) - v23 = stru_50B700._screen_space_x[v13]; + v23 = PortalFace._screen_space_x[v13]; if ( v14 > v11 ) - v11 = stru_50B700._screen_space_x[v13]; - v15 = stru_50B700._screen_space_y[v13]; + v11 = PortalFace._screen_space_x[v13]; + v15 = PortalFace._screen_space_y[v13]; if ( v15 < v22 ) - v22 = stru_50B700._screen_space_y[v13]; + v22 = PortalFace._screen_space_y[v13]; if ( v15 > v12 ) - v12 = stru_50B700._screen_space_y[v13]; + v12 = PortalFace._screen_space_y[v13]; v10 = v19; ++v13; } @@ -1532,7 +920,7 @@ && v23 <= *((short *)v20 + 2007) && v12 >= *((short *)v20 + 2006) && v22 <= *((short *)v20 + 2008) - && sub_424829(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) ) + && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].PortalScreenData, (BspRenderer_PortalViewportData *)(v20 + 4020), uFaceID) ) { v16 = v21->uSectorID; if ( *((short *)v20 + 2004) == v16 ) @@ -1587,11 +975,11 @@ if ( v1 < (signed int)pIndoor->uNumFaces ) { v2 = pBspRenderer->faces[i].uFaceID; - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; - v3 = sub_423B5D(v2); + pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData; + v3 = GetPortalScreenCoord(v2); if ( v3 ) { - if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) + if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) { v4 = stru_F8A590._viewport_space_y; v5 = pBLVRenderParams->pRenderTarget; @@ -5612,9 +5000,9 @@ local_0.x = v5; local_0.y = (double)v2->vPosition.y; local_0.z = (double)v2->vPosition.z; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.flt_28 = 1.0; local_0.timeToLive = (rand() & 0x80) + 128; local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); @@ -5734,7 +5122,7 @@ pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ; pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY; pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX; - pBspRenderer->nodes[0].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, + pBspRenderer->nodes[0].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); pBspRenderer->nodes[0].uFaceID = -1; pBspRenderer->nodes[0].viewing_portal_id = -1; @@ -5746,7 +5134,7 @@ } //----- (0043F9E1) -------------------------------------------------------- -void BspRenderer_stru2::GetViewportData(__int16 x, int y, __int16 z, int w) +void BspRenderer_PortalViewportData::GetViewportData(__int16 x, int y, __int16 z, int w) { _viewport_space_y = y; _viewport_space_w = w; @@ -6831,139 +6219,102 @@ check_event_triggers(); } //----- (00424829) -------------------------------------------------------- -bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID) +// Finds out if current portal can be seen through the previous portal +bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID) { - //int v4; // edi@1 - //BspRenderer_stru2 *v5; // ebx@1 - int v6; // eax@3 int min_y; // esi@5 int max_y; // edx@5 - //int v9; // ecx@6 - int v10; // eax@12 - //int v11; // edi@13 - //int v12; // edx@18 + int current_ID; // eax@12 int v13; // eax@22 - //int v14; // edi@28 int v15; // ecx@29 - //int v16; // edi@30 - //int v17; // edx@35 int v18; // eax@39 int v19; // eax@44 int v20; // ecx@44 - //int v21; // edi@45 int v22; // edi@46 - //__int16 *v23; // ecx@47 int v24; // edx@48 - //int v25; // eax@50 int v26; // eax@55 signed int v27; // edi@55 - //int v28; // edx@56 int v29; // edx@57 - //int v30; // eax@59 int v31; // eax@64 signed int v32; // edi@64 - //int v33; // edx@65 int v34; // eax@66 int v35; // dx@66 __int16 v36; // dx@67 - __int16 v37; // di@67 + //__int16 v37; // di@67 __int16 v38; // dx@67 - //BspRenderer_stru2 *v39; // ecx@69 - //int v40; // edx@69 - //int v41; // edi@70 - //__int16 *v42; // eax@76 - //__int16 *v43; // eax@81 - //__int16 *v45; // eax@87 int v46; // edx@87 - //__int16 v47; // cx@88 - //int v48; // eax@93 int v49; // esi@93 - //__int16 *v50; // ecx@94 - //int v51; // eax@95 - //int v52; // eax@97 int v53; // [sp+Ch] [bp-34h]@44 int v54; // [sp+10h] [bp-30h]@0 - int v55; // [sp+14h] [bp-2Ch]@12 - //__int16 *v56; // [sp+14h] [bp-2Ch]@47 - //__int16 v57; // [sp+14h] [bp-2Ch]@76 - //__int16 v58; // [sp+14h] [bp-2Ch]@81 + int min_y_ID2; // [sp+14h] [bp-2Ch]@12 int v59; // [sp+14h] [bp-2Ch]@87 - //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1 int v61; // [sp+1Ch] [bp-24h]@29 int v62; // [sp+20h] [bp-20h]@0 - signed int v63; // [sp+24h] [bp-1Ch]@3 - signed int v64; // [sp+28h] [bp-18h]@3 - int v65; // [sp+2Ch] [bp-14h]@5 - //int v66; // [sp+2Ch] [bp-14h]@39 - //int v67; // [sp+30h] [bp-10h]@22 - int v68; // [sp+34h] [bp-Ch]@12 + signed int direction1; // [sp+24h] [bp-1Ch]@3 + signed int direction2; // [sp+28h] [bp-18h]@3 + int min_y_ID; // [sp+2Ch] [bp-14h]@5 int v69; // [sp+34h] [bp-Ch]@29 int v70; // [sp+34h] [bp-Ch]@46 - int v71; // [sp+34h] [bp-Ch]@75 - int v72; // [sp+34h] [bp-Ch]@80 - //int v73; // [sp+38h] [bp-8h]@11 - //int v74; // [sp+3Ch] [bp-4h]@1 - //int a3a; // [sp+48h] [bp+8h]@76 - //int a3b; // [sp+48h] [bp+8h]@87 - - //try graphic engine with function returning 1 always, and without - //return true; + if ( pNumVertices <= 1 ) return false; - min_y = stru_50B700._screen_space_y[0]; - v65 = 0; - max_y = stru_50B700._screen_space_y[0]; - if ( !stru_50B700.field_0 ) + min_y = PortalFace._screen_space_y[0]; + min_y_ID = 0; + max_y = PortalFace._screen_space_y[0]; + //face direction( ) + if ( !PortalFace.direction ) { - v63 = 1; - v64 = -1; + direction1 = 1; + direction2 = -1; } else { - v63 = -1; - v64 = 1; + direction1 = -1; + direction2 = 1; } - for ( v6 = 1; v6 < pNumVertices; ++v6 ) + //get min and max y for portal( y ) + for ( uint i = 1; i < pNumVertices; ++i ) { - if ( stru_50B700._screen_space_y[v6] >= min_y ) + if (PortalFace._screen_space_y[i] < min_y) { - if ( stru_50B700._screen_space_y[v6] > max_y ) - max_y = stru_50B700._screen_space_y[v6]; + min_y_ID = i; + min_y = PortalFace._screen_space_y[i]; } - if ( stru_50B700._screen_space_y[v6] < min_y ) + else if (PortalFace._screen_space_y[i] > max_y) { - v65 = v6; - min_y = stru_50B700._screen_space_y[v6]; + max_y = PortalFace._screen_space_y[i]; } } if ( max_y == min_y ) return false; - v10 = v65; - a2->_viewport_space_y = min_y; - a2->_viewport_space_w = max_y; - v55 = v65; - - for ( v68 = 0; v68 < pNumVertices; ++v68 ) + //***************************************************************************************************************************** + far_portal->_viewport_space_y = min_y; + far_portal->_viewport_space_w = max_y; + current_ID = min_y_ID; + min_y_ID2 = min_y_ID; + + for ( uint i = 0; i < pNumVertices; ++i ) { - v10 += v64; - if ( v10 < pNumVertices ) + current_ID += direction2; + if ( current_ID < pNumVertices ) { - if ( v10 < 0 ) - v10 += pNumVertices; + if ( current_ID < 0 ) + current_ID += pNumVertices; } else - v10 -= pNumVertices; - if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] ) + current_ID -= pNumVertices; + if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )// { - v55 = v10; - v65 = v10; + min_y_ID2 = current_ID; + min_y_ID = current_ID; } - if ( stru_50B700._screen_space_y[v10] == max_y ) + if ( PortalFace._screen_space_y[current_ID] == max_y ) break; } - v13 = v55 + v64; + + v13 = min_y_ID2 + direction2; if ( v13 < pNumVertices ) { if ( v13 < 0 ) @@ -6971,18 +6322,20 @@ } else v13 -= pNumVertices; - if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) + if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] ) { - v62 = stru_50B700._screen_space_x[v55] << 16; - v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]); - a2->viewport_left_side[min_y] = LOWORD(stru_50B700._screen_space_x[v55]); + v62 = PortalFace._screen_space_x[min_y_ID2] << 16; + 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]); + far_portal->viewport_left_side[min_y] = (short)PortalFace._screen_space_x[min_y_ID2]; } - v15 = v65; - v61 = v65; - + //**************************************************************************************************************************************** + // + v15 = min_y_ID; + v61 = min_y_ID; for ( v69 = 0; v69 < pNumVertices; ++v69 ) { - v15 += v63; + v15 += direction1; if ( v15 < pNumVertices ) { if ( v15 < 0 ) @@ -6990,15 +6343,15 @@ } else v15 -= pNumVertices; - if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] ) + if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] ) { v61 = v15; - v65 = v15; + min_y_ID = v15; } - if ( stru_50B700._screen_space_y[v15] == max_y ) + if ( PortalFace._screen_space_y[v15] == max_y ) break; } - v18 = v63 + v61; + v18 = direction1 + v61; if ( v18 < pNumVertices ) { if ( v18 < 0 ) @@ -7008,23 +6361,23 @@ v18 -= pNumVertices; v19 = v18; v20 = v61; - if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] ) + if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) { - v61 = stru_50B700._screen_space_x[v20] << 16; - v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20]; - a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]); + v61 = PortalFace._screen_space_x[v20] << 16; + v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / + (PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]); + far_portal->viewport_right_side[max_y] = (short)PortalFace._screen_space_x[v20]; } + //**************************************************************************************************************************************** v22 = min_y; if ( min_y <= max_y ) { - //v56 = &a2->array_3D8[v7]; - //v23 = &a2->array_18[v7]; for ( v70 = min_y; v70 <= max_y; ++v70 ) { v24 = v13; - if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != max_y ) + if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) { - v13 = v64 + v13; + v13 = direction2 + v13; if ( v13 < pNumVertices ) { if ( v13 < 0 ) @@ -7033,17 +6386,16 @@ else v13 -= pNumVertices; v26 = v13; - //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; - if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 ) + if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) { - v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; - v62 = stru_50B700._screen_space_x[v24] << 16; + v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / (PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]); + v62 = PortalFace._screen_space_x[v24] << 16; } } v29 = v18; - if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != max_y ) + if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) { - v18 += v63; + v18 += direction1; if ( v18 < pNumVertices ) { if ( v18 < 0 ) @@ -7052,253 +6404,168 @@ else v18 -= pNumVertices; v31 = v18; - //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; - if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 ) + if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) { - v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; - v61 = stru_50B700._screen_space_x[v29] << 16; + v53 = ((PortalFace._screen_space_x[v31] - PortalFace._screen_space_x[v29]) << 16) / (PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]); + v61 = PortalFace._screen_space_x[v29] << 16; } } - //v34 = (char *)a2->array_18 - (char *)a2->array_3D8; - //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34); - //v35 = HIWORD(v62); - a2->viewport_left_side[v70] = HIWORD(v62); - a2->viewport_right_side[v70] = HIWORD(v61); - //v34 = &a2->array_3D8[v70]; - //v35 = a2->array_3D8[v70]; - if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] ) + far_portal->viewport_left_side[v70] = HIWORD(v62); + far_portal->viewport_right_side[v70] = HIWORD(v61); + if ( far_portal->viewport_left_side[v70] > far_portal->viewport_right_side[v70] ) { - v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70]; - v37 = a2->viewport_right_side[v70]; - a2->viewport_left_side[v70] = v36; - v38 = v37 ^ v36; - a2->viewport_left_side[v70] ^= v38; - a2->viewport_right_side[v70] = v38; + v36 = far_portal->viewport_left_side[v70] ^ far_portal->viewport_right_side[v70]; + //v37 = far_portal->viewport_right_side[v70]; + far_portal->viewport_left_side[v70] = v36; + v38 = far_portal->viewport_right_side[v70] ^ v36; + far_portal->viewport_left_side[v70] ^= v38; + far_portal->viewport_right_side[v70] = v38; } - //++v56; v62 += v54; v22 = v70 + 1; v61 += v53; - //++v23; } } - if ( max_y < a3->_viewport_space_y ) - return false; - if ( min_y > a3->_viewport_space_w ) + //***************************************************************************************************************************** + // check portals coordinates and determine max, min( , - ) + if ( max_y < near_portal->_viewport_space_y ) return false; - if ( min_y < a3->_viewport_space_y ) - min_y = a3->_viewport_space_y; - if ( max_y > a3->_viewport_space_w ) - max_y = a3->_viewport_space_w; + if ( min_y > near_portal->_viewport_space_w ) + return false; + if ( min_y < near_portal->_viewport_space_y ) + min_y = near_portal->_viewport_space_y; + if ( max_y > near_portal->_viewport_space_w ) + max_y = near_portal->_viewport_space_w; if ( min_y <= max_y ) { - //a3a = (char *)a2 - (char *)a3; - //v42 = &a3->array_3D8[v7]; - //v57 = *(__int16 *)((char *)v42 + a3a); - for ( v71 = min_y; v71 <= max_y; ++v71 ) + for ( min_y; min_y <= max_y; ++min_y ) { - if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] ) + if ( far_portal->viewport_right_side[min_y] >= near_portal->viewport_left_side[min_y] + && far_portal->viewport_left_side[min_y] <= near_portal->viewport_right_side[min_y] ) break; - //++v57; - ++min_y; - //++v42; } } if ( max_y < min_y ) return false; - //a3a = (char *)a2 - (char *)a3; - //v43 = &a3->array_3D8[v8]; - //v58 = *(__int16 *)((char *)v43 + a3a); - for ( v72 = max_y; v72 >= min_y; --v72 ) + for ( max_y; max_y >= min_y; --max_y ) { - if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] ) + if ( far_portal->viewport_right_side[max_y] >= near_portal->viewport_left_side[max_y] + && far_portal->viewport_left_side[max_y] <= near_portal->viewport_right_side[max_y] ) break; - //--v58; - --max_y; - //--v43; - //v8 = v8; } if ( min_y >= max_y ) return false; - //a3b = (char *)a3 - (char *)a2; + //************************************************************************************************************************************* v59 = min_y; - //v45 = &a2->array_18[v7]; - for ( v46 = max_y - min_y + 1; v46; --v46 ) { - //v47 = *(__int16 *)((char *)v45 + a3b); - if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] ) - a2->viewport_left_side[v59] = a3->viewport_left_side[v59]; - if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] ) - a2->viewport_right_side[v59] = a3->viewport_right_side[v59]; + if ( far_portal->viewport_left_side[v59] < near_portal->viewport_left_side[v59] ) + far_portal->viewport_left_side[v59] = near_portal->viewport_left_side[v59]; + if ( far_portal->viewport_right_side[v59] > near_portal->viewport_right_side[v59] ) + far_portal->viewport_right_side[v59] = near_portal->viewport_right_side[v59]; ++v59; - //++v45; } - a2->_viewport_space_y = min_y; - a2->_viewport_space_w = max_y; - a2->field_8 = a2->viewport_left_side[min_y]; - //v48 = a2->viewport_right_side[v7]; - a2->field_10 = min_y; - a2->field_14 = min_y; - a2->field_C = a2->viewport_right_side[min_y]; + far_portal->_viewport_space_y = min_y; + far_portal->_viewport_space_w = max_y; + far_portal->_viewport_space_x = far_portal->viewport_left_side[min_y]; + far_portal->_viewport_space_z = far_portal->viewport_right_side[min_y]; + far_portal->_viewport_x_minID = min_y; + far_portal->_viewport_z_maxID = min_y; v49 = min_y + 1; if ( v49 <= max_y ) { - //v50 = &a2->array_3D8[v49]; for ( v49; v49 <= max_y; ++v49 ) { - //v51 = a2->array_18[v49]; - if ( a2->viewport_left_side[v49] < a2->field_8 ) + if ( far_portal->viewport_left_side[v49] < far_portal->_viewport_space_x ) { - a2->field_8 = a2->viewport_left_side[v49]; - a2->field_10 = v49; + far_portal->_viewport_space_x = far_portal->viewport_left_side[v49]; + far_portal->_viewport_x_minID = v49; } - if ( a2->viewport_right_side[v49] > a2->field_C ) + if ( far_portal->viewport_right_side[v49] > far_portal->_viewport_space_z ) { - a2->field_C = a2->viewport_right_side[v49]; - a2->field_14 = v49; + far_portal->_viewport_space_z = far_portal->viewport_right_side[v49]; + far_portal->_viewport_z_maxID = v49; } - //++v50; } } return true; } //----- (00423B5D) -------------------------------------------------------- -int __fastcall sub_423B5D(unsigned int uFaceID) +int __fastcall GetPortalScreenCoord(unsigned int uFaceID) { BLVFace *pFace; // ebx@1 - //Vec3_short_ *v2; // esi@1 - //int v3; // ST28_4@1 - //__int16 v4; // ST2C_2@1 - //signed int v5; // esi@1 - //Vec3_short_ *v6; // eax@4 - //signed int v7; // edi@5 - //signed int bFound; // eax@5 - //signed int v9; // ecx@10 - //int v10; // eax@10 - //int v11; // edx@11 - int t; - //signed int v13; // edx@12 - //signed __int64 v14; // qtt@12 - //char *v15; // ebx@12 - //int v16; // ST28_4@14 - //signed int v17; // eax@14 - //signed __int64 v18; // qtt@14 - signed int v19; // edx@15 - signed int v20; // edx@17 - signed int v21; // ebx@19 - signed int v22; // esi@20 - int v23; // edi@21 - int v24; // eax@21 - int v25; // eax@22 - int v26; // eax@22 - signed int v27; // ST30_4@24 - signed __int64 v28; // qtt@24 - int v29; // ST18_4@25 - int v30; // eax@26 - int v31; // eax@27 - int v32; // eax@27 - signed int v33; // ST30_4@29 - signed __int64 v34; // qtt@29 - int v35; // ST30_4@30 - signed int v36; // edi@31 - unsigned int v37; // eax@31 - bool v38; // edx@31 - int v39; // ecx@31 - int v40; // ecx@32 - int v41; // esi@32 - int v42; // eax@34 - signed int v43; // ebx@41 - unsigned int v44; // eax@41 - signed int v45; // ecx@42 - int v46; // esi@42 - int v47; // eax@44 - signed int v48; // edi@51 - unsigned int v49; // eax@51 - bool v50; // edx@51 - int v51; // ecx@51 - int v52; // ecx@52 - int v53; // esi@52 - int v54; // eax@54 - int v55; // ebx@61 - unsigned int v56; // eax@61 - signed int v57; // ecx@62 - int v58; // esi@62 - int v59; // eax@64 - char v61; // zf@72 + int pNextVertices; // edx@11 + int t; // ST28_4@12 + int pScreenX; // eax@22 + int pScreenY; // eax@27 + signed int left_num_vertices; // edi@31 + signed int right_num_vertices; // ebx@41 + signed int top_num_vertices; // edi@51 + int bottom_num_vertices; // ebx@61 signed int v62; // edx@75 int v63; // ecx@76 int v64; // esi@76 int v65; // ecx@83 - //signed int v66; // [sp+14h] [bp-14h]@3 - int v67; // [sp+14h] [bp-14h]@34 - int v68; // [sp+14h] [bp-14h]@44 - int v69; // [sp+14h] [bp-14h]@54 - int v70; // [sp+14h] [bp-14h]@64 signed int v71; // [sp+14h] [bp-14h]@75 - //IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 - int thisb; // [sp+18h] [bp-10h]@12 - int thisc; // [sp+18h] [bp-10h]@20 - bool thisd; // [sp+18h] [bp-10h]@41 - bool thise; // [sp+18h] [bp-10h]@61 int thisf; // [sp+18h] [bp-10h]@74 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 int v80; // [sp+1Ch] [bp-Ch]@76 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 - bool v82; // [sp+20h] [bp-8h]@32 - bool v83; // [sp+20h] [bp-8h]@42 - bool v84; // [sp+20h] [bp-8h]@52 - bool v85; // [sp+20h] [bp-8h]@62 - //signed int v86; // [sp+24h] [bp-4h]@9 - signed int v87; // [sp+24h] [bp-4h]@19 - signed int v88; // [sp+24h] [bp-4h]@31 - signed int v89; // [sp+24h] [bp-4h]@41 - signed int v90; // [sp+24h] [bp-4h]@51 - signed int v91; // [sp+24h] [bp-4h]@61 pFace = &pIndoor->pFaces[uFaceID]; - memset(&stru_50B700, 0, sizeof(stru367)); - //_this = pGame->pIndoorCameraD3D; - //v2 = &pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]]; - //v3 = *(_DWORD *)pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x; - //v4 = pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z; - //v5 = 0; + memset(&PortalFace, 0, sizeof(stru367)); + + //get direction the face( )********************************************************************************* if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) { - stru_50B700.field_0 = 1; + PortalFace.direction = true; } else { - stru_50B700.field_0 = 0; + PortalFace.direction = false; if ( !(pFace->Portal()) ) return 0; } - //v66 = pFace->uNumVertices; + //***************************************************************************************************************************************** + //generate/cinvertetion in camera location coordinates(/ ) + + //for new coordinates: + //int x = 0x AAAA BBBB; + //AAAA - integer( ), BBBB - fractional() + //float v = HIWORD(x) + LOWORD(x) / 65535.0f; + //0x0351A281 849(351 ) A281 ( BBBB ) + //if in HIWORD: FFFF = -1 + //FFFE = -2 + //FFFD = -3 + //.... + //8000 = -32767 + //7FFF = 32767 + //7FFE = 32766 + // LOWORD FFFF , + // hiword loword FFFF FFFF , + // 7FFF /Nomad/ + if ( (signed int)pFace->uNumVertices > 0 ) { for (uint i = 0; i < pFace->uNumVertices; ++i) { - //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]]; - pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( - pIndoor->pVertices[pFace->pVertexIDs[i]].x, - pIndoor->pVertices[pFace->pVertexIDs[i]].y, - pIndoor->pVertices[pFace->pVertexIDs[i]].z, - &stru_50B700._view_transformed_xs[i + 3], - &stru_50B700._view_transformed_zs[i + 3], - &stru_50B700._view_transformed_ys[i + 3], - 0); + pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x, + pIndoor->pVertices[pFace->pVertexIDs[i]].y, + pIndoor->pVertices[pFace->pVertexIDs[i]].z, + &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); } } - //v7 = pFace->uNumVertices; + //***************************************************************************************************************************************** + //check vertices for the nearest plane( ) if ( pFace->uNumVertices <= 0 ) return 0; bool bFound = false; for (uint i = 0; i < pFace->uNumVertices; ++i) { - if ( stru_50B700._view_transformed_xs[i + 3] >= 524288 ) + if ( PortalFace._view_transformed_z[i + 3] >= 524288 )// 8.0(0x80000) { bFound = true; break; @@ -7306,338 +6573,299 @@ } if ( !bFound ) return 0; - + //***************************************************************************************************************************************** + //check for near clip plane( ) + // + // v0 v1 + // ._________________. + // / \ + // / \ + // v5. . v2 + // | | + // | | + // | | + // ---------------------------- 8.0(near_clip) + // | | + // ._______________________. + // v4 v3 depth_num_vertices = 0; - stru_50B700._view_transformed_xs[pFace->uNumVertices + 3] = stru_50B700._view_transformed_xs[3]; - stru_50B700._view_transformed_zs[pFace->uNumVertices + 3] = stru_50B700._view_transformed_zs[3]; - stru_50B700._view_transformed_ys[pFace->uNumVertices + 3] = stru_50B700._view_transformed_ys[3]; - current_vertices_flag = stru_50B700._view_transformed_xs[3] >= 524288; - //v86 = 1; + PortalFace._view_transformed_z[pFace->uNumVertices + 3] = PortalFace._view_transformed_z[3]; + PortalFace._view_transformed_x[pFace->uNumVertices + 3] = PortalFace._view_transformed_x[3]; + PortalFace._view_transformed_y[pFace->uNumVertices + 3] = PortalFace._view_transformed_y[3]; + current_vertices_flag = PortalFace._view_transformed_z[3] >= 524288;// 8.0(0x80000) if ( pFace->uNumVertices >= 1 ) { for ( uint i = 1; i <= pFace->uNumVertices; ++i) { - //v9 = v86; - //v10 = stru_50B700._view_transformed_xs[v86 + 3]; - next_vertices_flag = stru_50B700._view_transformed_xs[i + 3] >= 524288; - if ( current_vertices_flag ^ next_vertices_flag ) + next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000) + if ( current_vertices_flag ^ next_vertices_flag )// { - //v11 = stru_50B700._view_transformed_xs[i + 2]; - if ( next_vertices_flag ) + if ( next_vertices_flag )// { - //t = near_clip - v0.z/v1.z - v0.z - // near_clip = 8.0(524288) - t = 524288 - stru_50B700._view_transformed_xs[i + 2] / stru_50B700._view_transformed_xs[i + 3] - stru_50B700._view_transformed_xs[i + 2]; - // new_x = (v1.x - v0.x) * t + v0.x - stru_50B700._view_transformed_zs[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_zs[i + 3] - - stru_50B700._view_transformed_zs[i + 2]) * t + stru_50B700._view_transformed_zs[i + 2]; - //new_y = (v1.y - v0.y)*t + v0.y - stru_50B700._view_transformed_ys[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_ys[i + 3] - stru_50B700._view_transformed_ys[i + 2]) - * t + stru_50B700._view_transformed_ys[i + 2]; - stru_50B700._view_transformed_xs[depth_num_vertices] = 524288; + //t = near_clip - v0.z / v1.z - v0.z + t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 2], PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]); + //New_x = (v1.x - v0.x)*t + v0.x + PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3] + - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2]; + //New_y = (v1.y - v0.y)*t + v0.y + PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2]) + * t) >> 16) + PortalFace._view_transformed_y[i + 2]; + //New_z = 8.0(0x80000) + PortalFace._view_transformed_z[depth_num_vertices] = 524288; } - else + else// { - //t = near_clip - v1.z/v0.z - v1.z - t = 524288 - stru_50B700._view_transformed_xs[i + 3] / stru_50B700._view_transformed_xs[i + 2] - stru_50B700._view_transformed_xs[i + 3]; - // new_x = (v0.x - v1.x) * t + v1.x - stru_50B700._view_transformed_zs[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_zs[i + 2] - - stru_50B700._view_transformed_zs[i + 3]) * t + stru_50B700._view_transformed_zs[i + 3]; - //new_y = (v0.y - v1.y)*t + v1.y - stru_50B700._view_transformed_ys[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_ys[i + 2] - stru_50B700._view_transformed_ys[i + 3]) - * t + stru_50B700._view_transformed_ys[i + 3]; - stru_50B700._view_transformed_xs[depth_num_vertices] = 524288; + //t = near_clip - v1.z / v0.z - v1.z + t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 3], PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]); + //New_x = (v0.x - v1.x)*t + v1.x + PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2] + - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3]; + //New_y = (v0.x - v1.y)*t + v1.y + PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3]) + * t) >> 16) + PortalFace._view_transformed_y[i + 3]; + //New_z = 8.0(0x80000) + PortalFace._view_transformed_z[depth_num_vertices] = 524288; } - v19 = depth_num_vertices++; - //v7 = pFace->uNumVertices; - //stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15; - //stru_50B700._view_transformed_xs[v19] = 524288; + depth_num_vertices++; } - if ( next_vertices_flag ) + if ( next_vertices_flag )// { - v20 = depth_num_vertices++; - stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[i + 3]; - stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[i + 3]; - stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[i + 3]; + pNextVertices = depth_num_vertices++; + PortalFace._view_transformed_z[pNextVertices] = PortalFace._view_transformed_z[i + 3]; + PortalFace._view_transformed_x[pNextVertices] = PortalFace._view_transformed_x[i + 3]; + PortalFace._view_transformed_y[pNextVertices] = PortalFace._view_transformed_y[i + 3]; } current_vertices_flag = next_vertices_flag; } } - - - v21 = depth_num_vertices; - stru_50B700._view_transformed_xs[depth_num_vertices] = stru_50B700._view_transformed_xs[0]; - stru_50B700._view_transformed_zs[depth_num_vertices] = stru_50B700._view_transformed_zs[0]; - stru_50B700._view_transformed_ys[depth_num_vertices] = stru_50B700._view_transformed_ys[0]; - for ( v87 = 0; v87 < depth_num_vertices; ++v87 ) + //: ( ) + //************************************************************************************************************************************ + //convertion in screen coordinates( ) + PortalFace._view_transformed_z[depth_num_vertices] = PortalFace._view_transformed_z[0]; + PortalFace._view_transformed_x[depth_num_vertices] = PortalFace._view_transformed_x[0]; + PortalFace._view_transformed_y[depth_num_vertices] = PortalFace._view_transformed_y[0]; + for ( uint i = 0; i < depth_num_vertices; ++i ) { - v22 = v87; - thisc = abs(stru_50B700._view_transformed_xs[v87]); - if ( (abs(stru_50B700._view_transformed_zs[v87]) >> 13) <= thisc ) - { - v27 = stru_50B700._view_transformed_zs[v22]; - LODWORD(v28) = v27 << 16; - HIDWORD(v28) = v27 >> 16; - v26 = v28 / stru_50B700._view_transformed_xs[v22]; - v23 = 0; - } + if ( (abs(PortalFace._view_transformed_x[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) + pScreenX = fixpoint_div(PortalFace._view_transformed_x[i], PortalFace._view_transformed_z[i]); else { - v23 = 0; - v24 = 0; - if ( stru_50B700._view_transformed_zs[v22] >= 0 ) + if ( PortalFace._view_transformed_x[i] >= 0 ) { - //LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - //v26 = ((v24 - 1) & 0xFF800000) + 4194304; - if (stru_50B700._view_transformed_xs[v22] >= 0) - v26 = 0x400000; // 64.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenX = 0x400000; // 64.0 else - v26 = 0xFFC00000; + pScreenX = 0xFFC00000; // -63.0 } else { - //LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - //v25 = v24 - 1; - //v26 = (v25 & 0x800000) - 4194304; - if (stru_50B700._view_transformed_xs[v22] >= 0) - v26 = 0xFFC00000; // -63.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenX = 0xFFC00000; // -63.0 else - v26 = 0x400000; + pScreenX = 0x400000; // 64.0 } } - v29 = stru_50B700._view_transformed_ys[v22]; - stru_50B700._screen_space_x[v22 + 12] = v26; - if ( (abs(v29) >> 13) <= thisc ) - { - v33 = stru_50B700._view_transformed_ys[v22]; - LODWORD(v34) = v33 << 16; - HIDWORD(v34) = v33 >> 16; - v32 = v34 / stru_50B700._view_transformed_xs[v22]; - } + if ( (abs(PortalFace._view_transformed_y[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) + pScreenY = fixpoint_div(PortalFace._view_transformed_y[i], PortalFace._view_transformed_z[i]); else { - v30 = 0; - if ( stru_50B700._view_transformed_ys[v22] >= v23 ) + if ( PortalFace._view_transformed_y[i] >= 0 ) { - //LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - //v32 = ((v30 - 1) & 0xFF800000) + 4194304; - if (stru_50B700._view_transformed_xs[v22] >= v23) - v32 = 0x400000; // 64.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenY = 0x400000; // 64.0 else - v32 = 0xFFC00000; + pScreenY = 0xFFC00000; // -63.0 } else { - //LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - //v31 = v30 - 1; - //v32 = (v31 & 0x800000) - 4194304; - if (stru_50B700._view_transformed_xs[v22] >= v23) - v32 = 0xFFC00000; // -63.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenY = 0xFFC00000; // -63.0 else - v32 = 0x400000; + pScreenY = 0x400000; // 64.0 } } - stru_50B700._screen_space_y[v22 + 12] = v32; - stru_50B700._screen_space_x[v22 + 12] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) - * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16; - v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16; - stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12]; - stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35; - //++v87; + PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16); + PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16); } - v36 = 0; - stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12]; - stru_50B700._screen_space_y[v21 + 12] = stru_50B700._screen_space_y[12]; - v37 = pBLVRenderParams->uViewportX; - v38 = stru_50B700._screen_space_x[12] < (signed int)pBLVRenderParams->uViewportX; - LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX; - v39 = 1; - v88 = 1; + // : , , () + //****************************************************************************************************************************************** + // - ,.. + // . , x() = 8, = 468( ), . + // + //check for left_clip plane( ) + left_num_vertices = 0; + PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12]; + PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12]; + current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;//8.0 if ( depth_num_vertices < 1 ) return 0; - do + for ( uint i = 1; i <= depth_num_vertices; ++i ) { - v40 = v39; - v41 = stru_50B700._screen_space_x[v40 + 12]; - v82 = v41 >= (signed int)v37; - if ( v38 ^ v82 ) + next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v41 >= (signed int)v37 ) + if ( next_vertices_flag ) { - v67 = (signed int)(v37 - stru_50B700._screen_space_x[v40 + 11]) - * (signed __int64)(stru_50B700._screen_space_y[v40 + 12] - stru_50B700._screen_space_y[v40 + 11]) - / (v41 - stru_50B700._screen_space_x[v40 + 11]); - v42 = stru_50B700._screen_space_y[v40 + 11]; + //t = left_clip - v0.x / v1.x - v0.x + t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11], PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]); + //New_y = (v1.y - v0.y)*t + v0.y + PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)((PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) + * t) >> 16) + PortalFace._screen_space_y[i + 11]; + //New_x = left_clip + PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; } else { - v67 = (signed int)(v37 - v41) - * (signed __int64)(stru_50B700._screen_space_y[v40 + 11] - stru_50B700._screen_space_y[v40 + 12]) - / (stru_50B700._screen_space_x[v40 + 11] - v41); - v42 = stru_50B700._screen_space_y[v40 + 12]; + //t = left_clip - v1.x / v0.x - v1.x + t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12], PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]); + //New_y = (v0.y - v1.y)*t + v1.y + PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)(( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) + * t) >> 16) + PortalFace._screen_space_y[i + 12]; + //New_x = left_clip + PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; } - ++v36; - stru_50B700._screen_space_y[v36 + 8] = v67 + v42; - v37 = pBLVRenderParams->uViewportX; - stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX; + left_num_vertices++; } - v38 = v82; - if ( v82 ) + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[v40 + 12]; - stru_50B700._screen_space_y[v36++ + 9] = stru_50B700._screen_space_y[v40 + 12]; + pNextVertices = left_num_vertices++; + PortalFace._screen_space_x[pNextVertices + 9] = PortalFace._screen_space_x[i + 12]; + PortalFace._screen_space_y[pNextVertices + 9] = PortalFace._screen_space_y[i + 12]; } - v39 = v88++ + 1; + current_vertices_flag = next_vertices_flag; } - while ( v88 <= depth_num_vertices ); - if ( !v36 - || (v43 = 0, - stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9], - stru_50B700._screen_space_y[v36 + 9] = stru_50B700._screen_space_y[9], - v44 = pBLVRenderParams->uViewportZ, - thisd = stru_50B700._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ, - v89 = 1, - v36 < 1) ) +//********************************************************************************************************************************* +//for right_clip plane( ) + right_num_vertices = 0; + PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9]; + PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9]; + current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ;//468.0 + if (left_num_vertices < 1) return 0; - do + for ( uint i = 1; i <= left_num_vertices; ++i ) { - v45 = v89; - v46 = stru_50B700._screen_space_x[v89 + 9]; - v83 = v46 <= (signed int)v44; - if ( thisd ^ v83 ) + next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v46 <= (signed int)v44 ) + if ( next_vertices_flag ) { - v68 = (signed int)(v44 - stru_50B700._screen_space_x[v45 + 8]) - * (signed __int64)(stru_50B700._screen_space_y[v45 + 9] - stru_50B700._screen_space_y[v45 + 8]) - / (v46 - stru_50B700._screen_space_x[v45 + 8]); - v47 = stru_50B700._screen_space_y[v45 + 8]; + //t = right_clip - v1.x / v0.x - v1.x + t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8], PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]); + //New_y = (v0.y - v1.y)*t + v1.y + PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) + * t) >> 16) + PortalFace._screen_space_y[i + 8]; + //New_x = right_clip + PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; } else { - v68 = (signed int)(v44 - v46) - * (signed __int64)(stru_50B700._screen_space_y[v45 + 8] - stru_50B700._screen_space_y[v45 + 9]) - / (stru_50B700._screen_space_x[v45 + 8] - v46); - v47 = stru_50B700._screen_space_y[v45 + 9]; + //t = right_clip - v0.x / v1.x - v0.x + t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9], PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]); + //New_y = (v1.y - v0.y)*t + v0.y + PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) + * t) >> 16) + PortalFace._screen_space_y[i + 9]; + //New_x = right_clip + PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; } - ++v43; - stru_50B700._screen_space_y[v43 + 5] = v68 + v47; - v44 = pBLVRenderParams->uViewportZ; - stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ; + right_num_vertices++; } - if ( v83 ) + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[v45 + 9]; - stru_50B700._screen_space_y[v43++ + 6] = stru_50B700._screen_space_y[v45 + 9]; + pNextVertices = right_num_vertices++; + PortalFace._screen_space_x[pNextVertices + 6] = PortalFace._screen_space_x[i + 9]; + PortalFace._screen_space_y[pNextVertices + 6] = PortalFace._screen_space_y[i + 9]; } - ++v89; - thisd = v83; + current_vertices_flag = next_vertices_flag; } - while ( v89 <= v36 ); - if ( !v43 - || (v48 = 0, - stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[6], - stru_50B700._screen_space_y[v43 + 6] = stru_50B700._screen_space_y[6], - v49 = pBLVRenderParams->uViewportY, - v50 = stru_50B700._screen_space_y[6] < (signed int)pBLVRenderParams->uViewportY, - LOBYTE(v50) = stru_50B700._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY, - v51 = 1, - v90 = 1, - v43 < 1) ) + //************************************************************************************************************************************ + // for top clip plane + top_num_vertices = 0; + PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6]; + PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6]; + + current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY;//8.0 + if ( right_num_vertices < 1 ) return 0; - do + for ( uint i = 1; i <= right_num_vertices; ++i ) { - v52 = v51; - v53 = stru_50B700._screen_space_y[v52 + 6]; - v84 = v53 >= (signed int)v49; - if ( v50 ^ v84 ) + next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v53 >= (signed int)v49 ) + if ( next_vertices_flag ) { - v69 = (signed int)(v49 - stru_50B700._screen_space_y[v52 + 5]) - * (signed __int64)(stru_50B700._screen_space_x[v52 + 6] - stru_50B700._screen_space_x[v52 + 5]) - / (v53 - stru_50B700._screen_space_y[v52 + 5]); - v54 = stru_50B700._screen_space_x[v52 + 5]; + t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5], PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); + PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) + * t) >> 16) + PortalFace._screen_space_x[i + 5]; + PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; } else { - v69 = (signed int)(v49 - v53) - * (signed __int64)(stru_50B700._screen_space_x[v52 + 5] - stru_50B700._screen_space_x[v52 + 6]) - / (stru_50B700._screen_space_y[v52 + 5] - v53); - v54 = stru_50B700._screen_space_x[v52 + 6]; + t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6], PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); + PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) + * t) >> 16) + PortalFace._screen_space_x[i + 6]; + PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; } - ++v48; - stru_50B700._screen_space_x[v48 + 2] = v69 + v54; - v49 = pBLVRenderParams->uViewportY; - stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY; + top_num_vertices++; } - v50 = v84; - if ( v84 ) + current_vertices_flag = next_vertices_flag; + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[v52 + 6]; - stru_50B700._screen_space_y[v48++ + 3] = stru_50B700._screen_space_y[v52 + 6]; + pNextVertices = top_num_vertices++; + PortalFace._screen_space_x[pNextVertices + 3] = PortalFace._screen_space_x[i + 6]; + PortalFace._screen_space_y[pNextVertices + 3] = PortalFace._screen_space_y[i + 6]; } - v51 = v90++ + 1; } - while ( v90 <= v43 ); - if ( !v48 - || (v55 = 0, - stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[3], - stru_50B700._screen_space_y[v48 + 3] = stru_50B700._screen_space_y[3], - v56 = pBLVRenderParams->uViewportW, - thise = stru_50B700._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW, - v91 = 1, - v48 < 1) ) +//********************************************************************************************************************************** +//for bottom_clip plane( ) + bottom_num_vertices = 0; + PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3]; + PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3]; + current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW;//351.0 + if ( top_num_vertices < 1 ) return 0; - do + for ( uint i =1; i <= top_num_vertices; ++i ) { - v57 = v91; - v58 = stru_50B700._screen_space_y[v91 + 3]; - v85 = v58 <= (signed int)v56; - if ( thise ^ v85 ) + next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v58 <= (signed int)v56 ) + if ( next_vertices_flag ) { - v70 = (signed int)(v56 - stru_50B700._screen_space_y[v57 + 2]) - * (signed __int64)(stru_50B700._screen_space_x[v57 + 3] - stru_50B700._screen_space_x[v57 + 2]) - / (v58 - stru_50B700._screen_space_y[v57 + 2]); - v59 = stru_50B700._screen_space_x[v57 + 2]; + t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2], PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); + PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) + * t) >> 16) + PortalFace._screen_space_x[i + 2]; + PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; } else { - v70 = (signed int)(v56 - v58) - * (signed __int64)(stru_50B700._screen_space_x[v57 + 2] - stru_50B700._screen_space_x[v57 + 3]) - / (stru_50B700._screen_space_y[v57 + 2] - v58); - v59 = stru_50B700._screen_space_x[v57 + 3]; + t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3], PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); + PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) + * t) >> 16) + PortalFace._screen_space_x[i + 3]; + PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; } - ++v55; - //stru_50B700._screen_space_y[v55 + 59] = v70 + v59; - stru_50B700._screen_space_x[v55 - 1] = v70 + v59; - v56 = pBLVRenderParams->uViewportW; - //stru_50B700._view_transformed_xs[v55 + 47] = pBLVRenderParams->uViewportW; - stru_50B700._screen_space_y[v55 - 1] = pBLVRenderParams->uViewportW; + bottom_num_vertices++; } - if ( v85 ) + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[v57 + 3]; - stru_50B700._screen_space_y[v55++] = stru_50B700._screen_space_y[v57 + 3]; + pNextVertices = bottom_num_vertices++; + PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3]; + PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3]; } - ++v91; - thise = v85; + current_vertices_flag = next_vertices_flag; } - while ( v91 <= v48 ); - if ( !v55 ) +//*************************************************************************************************************************************** + + if ( !bottom_num_vertices ) return 0; - v61 = pRenderer->pRenderD3D == 0; - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; - stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; - if ( v61 && v55 > 3 ) + PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; + PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; +//check for software( ) + if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 ) { - stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1]; - stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1]; - thisf = 2 * (stru_50B700.field_0 != 0) - 1; - if ( v55 > 0 ) + PortalFace._screen_space_x[bottom_num_vertices + 1] = PortalFace._screen_space_x[1]; + PortalFace._screen_space_y[bottom_num_vertices + 1] = PortalFace._screen_space_y[1]; + thisf = PortalFace.direction == true ? 1 : - 1; + if ( bottom_num_vertices > 0 ) { v62 = 1; v71 = 1; @@ -7646,17 +6874,16 @@ v63 = v62 - 1; v64 = v62 + 1; v80 = v62 + 1; - if ( v62 - 1 >= v55 ) - v63 -= v55; - if ( v62 >= v55 ) - v62 -= v55; - if ( v64 >= v55 ) - v64 -= v55; - if ( thisf - * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) - * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63]) - - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) - * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 ) + if ( v62 - 1 >= bottom_num_vertices ) + v63 -= bottom_num_vertices; + if ( v62 >= bottom_num_vertices ) + v62 -= bottom_num_vertices; + if ( v64 >= bottom_num_vertices ) + v64 -= bottom_num_vertices; + if ( thisf * ((PortalFace._screen_space_y[v64] - PortalFace._screen_space_y[v63]) + * (PortalFace._screen_space_x[v62] - PortalFace._screen_space_x[v63]) + - (PortalFace._screen_space_y[v62] - PortalFace._screen_space_y[v63]) + * (PortalFace._screen_space_x[v64] - PortalFace._screen_space_x[v63])) < 0 ) { v62 = v80; v71 = v80; @@ -7665,24 +6892,20 @@ { v62 = v71; v65 = v71; - if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) ) + if ( v71 < bottom_num_vertices || (v65 = v71 - bottom_num_vertices, v71 - bottom_num_vertices < bottom_num_vertices) ) { - memcpy( - &stru_50B700._screen_space_y[v65], - &stru_50B700._screen_space_y[v65 + 1], - 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); - memcpy( - &stru_50B700._screen_space_x[v65], - &stru_50B700._screen_space_x[v65 + 1], - 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); + memcpy(&PortalFace._screen_space_y[v65], &PortalFace._screen_space_y[v65 + 1], + 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); + memcpy(&PortalFace._screen_space_x[v65], &PortalFace._screen_space_x[v65 + 1], + 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); } - --v55; + --bottom_num_vertices; } } - while ( v62 - 1 < v55 ); + while ( v62 - 1 < bottom_num_vertices ); } - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; - stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; + PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; + PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; } - return v55; + return bottom_num_vertices; } \ No newline at end of file