Mercurial > mm7
diff Indoor.cpp @ 1319:2ddb0af0f437
m
author | Ritor1 |
---|---|
date | Fri, 28 Jun 2013 11:34:09 +0600 |
parents | 995d2f8ad71b |
children | 22cb507446a4 65379a50e4eb |
line wrap: on
line diff
--- a/Indoor.cpp Wed Jun 26 14:22:02 2013 +0600 +++ b/Indoor.cpp Fri Jun 28 11:34:09 2013 +0600 @@ -1262,7 +1262,7 @@ //stru170 *v4; // ebx@1 //BLVFace *v5; // eax@1 //int v6; // ecx@2 - unsigned __int16 v7; // ax@11 + unsigned __int16 pTransitionSector; // ax@11 Vec3_short_ *v8; // esi@15 int v9; // edx@15 //signed int v10; // eax@18 @@ -1273,7 +1273,7 @@ int v15; // edx@24 //int v16; // esi@29 //BLVFace *v17; // edi@34 - unsigned __int16 v18; // ax@34 + //unsigned __int16 v18; // ax@34 char *v19; // eax@38 signed int v20; // ecx@38 char *v21; // eax@42 @@ -1303,7 +1303,6 @@ //v39 = &pIndoor->pFaces[uFaceID]; auto pFace = &pIndoor->pFaces[uFaceID]; - auto p = &nodes[node_id]; if (!pFace->Portal()) { @@ -1315,127 +1314,115 @@ return; } - if (p->uFaceID == uFaceID) - return; - if (!node_id && - pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane - pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && - pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && - pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && - pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && - pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) + if (nodes[node_id].uFaceID == uFaceID) + return; + if (!node_id && + pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane + pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && + pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && + pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && + pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && + pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) + { + if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x + + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane { - if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x - + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y - + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane - { - v7 = pFace->uSectorID; - if ( nodes[0].uSectorID == v7 ) // draw back sector - v7 = pFace->uBackSectorID; - nodes[num_nodes].uSectorID = v7; - nodes[num_nodes].uFaceID = uFaceID; - nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; - 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, - pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); - AddBspNodeToRenderList(++num_nodes - 1); - return; - } - //v5 = v39; - //v6 = a0; + pTransitionSector = pFace->uSectorID; + if ( nodes[0].uSectorID == pTransitionSector ) // draw back sector + pTransitionSector = pFace->uBackSectorID; + nodes[num_nodes].uSectorID = pTransitionSector; + nodes[num_nodes].uFaceID = uFaceID; + nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; + 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, + pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); + AddBspNodeToRenderList(++num_nodes - 1); + return; } - - v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; - v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x) - + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y) - + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); - if (p->uSectorID != pFace->uSectorID) - v9 = -v9; - if (v9 >= 0) - return; - - auto num_vertices = sub_423B5D(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]; - 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]; - } + } + + v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) + + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) + + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z); + if (nodes[node_id].uSectorID != pFace->uSectorID) + v9 = -v9; + if (v9 >= 0) + return; + + auto num_vertices = sub_423B5D(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]; + 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]; + } //_screen_space_x = 719, 568, 493 //savegame: qw , 0Bh and 0x1D4h //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ - if (face_max_screenspace_x >= p->uViewportX && - face_min_screenspace_x <= p->uViewportZ && - face_max_screenspace_y >= p->uViewportY && - face_min_screenspace_y <= p->uViewportW && - sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID)) - { - //v17 = v39; - v18 = pFace->uSectorID; - if (p->uSectorID == v18 ) - v18 = pFace->uBackSectorID; - nodes[num_nodes].uSectorID = v18; - nodes[num_nodes].uFaceID = uFaceID; - nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; - nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; - nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; - nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; - //v38 = pGame->pStru10Instance; - //a0a = pGame->pIndoorCameraD3D; - v29 = false; - if (p->viewing_portal_id == -1) - { - v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); - } - else - { - static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; - static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; - - for (uint k = 0; k < pFace->uNumVertices; ++k) - { - static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; - static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; - static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; - } - - - unsigned int a2 = pFace->uNumVertices; - pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, - &a2, - static_subAddFaceToRenderList_d3d_stru_F79E08, - p->std__vector_0007AC, 4, 0, 0); - - v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2, - nodes[num_nodes].std__vector_0007AC, - nodes[num_nodes].pPortalBounding); - } - if ( 1 ) - { - assert(num_nodes < 150); - - nodes[num_nodes].viewing_portal_id = uFaceID; - AddBspNodeToRenderList(++num_nodes - 1); - } - if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) - pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); - //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); - } + if (face_max_screenspace_x >= nodes[node_id].uViewportX && + 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)) + { + pTransitionSector = pFace->uSectorID; + if (nodes[node_id].uSectorID == pTransitionSector ) + pTransitionSector = pFace->uBackSectorID; + nodes[num_nodes].uSectorID = pTransitionSector; + nodes[num_nodes].uFaceID = uFaceID; + nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; + nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; + nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; + nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; + v29 = false; + if (nodes[node_id].viewing_portal_id == -1)//первый портал на который я смотрю + v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); + else//следующие порталы в портале + { + static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; + static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; + + for (uint k = 0; k < pFace->uNumVertices; ++k) + { + static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; + static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; + static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; + } + + unsigned int pNewNumVertices = pFace->uNumVertices; + pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices, + static_subAddFaceToRenderList_d3d_stru_F79E08, nodes[node_id].std__vector_0007AC, 4, 0, 0); + + v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &pNewNumVertices, + nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); + } + if ( 1 ) + { + assert(num_nodes < 150); + + nodes[num_nodes].viewing_portal_id = uFaceID; + AddBspNodeToRenderList(++num_nodes - 1); + } + if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) + pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); + //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); + } }