Mercurial > mm7
changeset 1376:78671379d8da
PortalFrustrum
author | Ritor1 |
---|---|
date | Tue, 16 Jul 2013 11:55:36 +0600 |
parents | 87155494292c |
children | 437d4ed49f26 |
files | Indoor.cpp Indoor.h Indoor_stuff.h mm7_data.h |
diffstat | 4 files changed, 71 insertions(+), 103 deletions(-) [+] |
line wrap: on
line diff
--- a/Indoor.cpp Mon Jul 15 17:09:48 2013 +0600 +++ b/Indoor.cpp Tue Jul 16 11:55:36 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,7 +314,7 @@ } else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) { - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].field_C; + pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].PortalScreenData; IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); } } @@ -347,22 +347,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 ); } } } @@ -1337,7 +1337,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; @@ -1379,7 +1379,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 && - PortalFrustrum(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 +1481,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), @@ -1532,7 +1532,7 @@ && v23 <= *((short *)v20 + 2007) && v12 >= *((short *)v20 + 2006) && v22 <= *((short *)v20 + 2008) - && PortalFrustrum(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,7 +1587,7 @@ if ( v1 < (signed int)pIndoor->uNumFaces ) { v2 = pBspRenderer->faces[i].uFaceID; - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; + pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData; v3 = GetPortalScreenCoord(v2); if ( v3 ) { @@ -5734,7 +5734,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 +5746,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,9 +6831,8 @@ check_event_triggers(); } //----- (00424829) -------------------------------------------------------- -bool PortalFrustrum(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID) +bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID) { - //int v6; // eax@3 int min_y; // esi@5 int max_y; // edx@5 int current_ID; // eax@12 @@ -6865,11 +6864,8 @@ 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 v68; // [sp+34h] [bp-Ch]@12 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 if ( pNumVertices <= 1 ) return false; @@ -6906,8 +6902,8 @@ return false; //***************************************************************************************************************************** - a2->_viewport_space_y = min_y; - a2->_viewport_space_w = max_y; + 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; @@ -6942,7 +6938,7 @@ { 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]); - a2->viewport_left_side[min_y] = PortalFace._screen_space_x[min_y_ID2]; + far_portal->viewport_left_side[min_y] = PortalFace._screen_space_x[min_y_ID2]; } //**************************************************************************************************************************************** // @@ -6980,14 +6976,12 @@ { 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]; - a2->viewport_right_side[max_y] = PortalFace._screen_space_x[v20]; + far_portal->viewport_right_side[max_y] = 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; @@ -7002,7 +6996,6 @@ else v13 -= pNumVertices; v26 = v13; - //v27 = PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]; if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) { v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]; @@ -7021,113 +7014,88 @@ else v18 -= pNumVertices; v31 = v18; - //v32 = PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]; if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) { 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; + 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 = v37 ^ v36; - a2->viewport_left_side[v70] ^= v38; - a2->viewport_right_side[v70] = v38; + 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 ) + //***************************************************************************************************************************** + // check portals coordinates and determine max, min(проверка координат порталов и определение макс, мин-ой у) + if ( max_y < near_portal->_viewport_space_y ) return false; - if ( min_y > a3->_viewport_space_w ) + if ( min_y > near_portal->_viewport_space_w ) 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_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 ) - { - if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] ) + for ( max_y; max_y >= min_y; --max_y ) + { + 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; + return false;// incorect working portal faceID 1105(не доконца корректно работает портал фейс 1105 под определённым углом) + //************************************************************************************************************************************* 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_x_minID = min_y; + far_portal->_viewport_z_maxID = min_y; + far_portal->_viewport_space_z = far_portal->viewport_right_side[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;
--- a/Indoor.h Mon Jul 15 17:09:48 2013 +0600 +++ b/Indoor.h Tue Jul 16 11:55:36 2013 +0600 @@ -561,7 +561,7 @@ int field_70; int uViewportCenterX; int uViewportCenterY; - struct BspRenderer_stru2 *field_7C; + struct BspRenderer_PortalViewportData *field_7C; unsigned int uNumFacesRenderedThisFrame; int field_84; int field_88;
--- a/Indoor_stuff.h Mon Jul 15 17:09:48 2013 +0600 +++ b/Indoor_stuff.h Tue Jul 16 11:55:36 2013 +0600 @@ -6,21 +6,21 @@ /* 165 */ #pragma pack(push, 1) -struct BspRenderer_stru2 +struct BspRenderer_PortalViewportData { void GetViewportData(__int16 x, int y, __int16 z, int w); int _viewport_space_y; int _viewport_space_w; - int field_8; - int field_C; - int field_10; - int field_14; + int _viewport_space_x; + int _viewport_space_z; + int _viewport_x_minID; + int _viewport_z_maxID; __int16 viewport_left_side[480]; __int16 viewport_right_side[480]; }; #pragma pack(pop) -extern BspRenderer_stru2 stru_F8A590; +extern BspRenderer_PortalViewportData stru_F8A590; @@ -51,7 +51,7 @@ unsigned __int16 uViewportZ; unsigned __int16 uViewportW; __int16 field_A; - BspRenderer_stru2 field_C; + BspRenderer_PortalViewportData PortalScreenData; unsigned __int16 uFaceID; __int16 field_7A6; unsigned int viewing_portal_id; // portal through which we're seeing this node
--- a/mm7_data.h Mon Jul 15 17:09:48 2013 +0600 +++ b/mm7_data.h Tue Jul 16 11:55:36 2013 +0600 @@ -1151,7 +1151,7 @@ void __cdecl sub_423B4A(); int __fastcall GetPortalScreenCoord(unsigned int uFaceID); signed int __fastcall sub_424579(int uFaceID, struct stru320 *a2); -bool PortalFrustrum(int pNumVertices, struct BspRenderer_stru2 *a2, struct BspRenderer_stru2 *a3, int uFaceID); +bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb signed int __fastcall sr_4250FE(unsigned int uVertexID); // idb