Mercurial > mm7
changeset 1319:2ddb0af0f437
m
author | Ritor1 |
---|---|
date | Fri, 28 Jun 2013 11:34:09 +0600 |
parents | 0ec2f944fccc |
children | 2e3deb510de3 |
files | Indoor.cpp mm7_2.cpp stru10.cpp |
diffstat | 3 files changed, 129 insertions(+), 148 deletions(-) [+] |
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); + } }
--- a/mm7_2.cpp Wed Jun 26 14:22:02 2013 +0600 +++ b/mm7_2.cpp Fri Jun 28 11:34:09 2013 +0600 @@ -7583,7 +7583,7 @@ v127 = v9; v126 = v124; LABEL_268: - v116 = word_4EE088_sound_ids[v2->spell_id]; + v116 = word_4EE088_sound_ids[v2->spell_id - 1]; LABEL_269: v125 = v116 + 1; goto LABEL_29;
--- a/stru10.cpp Wed Jun 26 14:22:02 2013 +0600 +++ b/stru10.cpp Fri Jun 28 11:34:09 2013 +0600 @@ -184,35 +184,29 @@ } } - + RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24 + v1.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].x; + v1.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].y; + v1.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].z; + memcpy(&pOutVertices[0], &v1, sizeof(RenderVertexSoft)); - auto p1 = &pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]]; - RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24 - v1.vWorldPosition.x = (float)p1->x; - v1.vWorldPosition.y = (float)p1->y; - v1.vWorldPosition.z = (float)p1->z; - memcpy(pOutVertices + 0, &v1, sizeof(RenderVertexSoft)); - - auto p2 = &pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]]; RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24 - v2.vWorldPosition.x = (float)p2->x; - v2.vWorldPosition.y = (float)p2->y; - v2.vWorldPosition.z = (float)p2->z; - memcpy(pOutVertices + 1, &v2, sizeof(RenderVertexSoft)); + v2.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].x; + v2.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].y; + v2.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].z; + memcpy(&pOutVertices[1], &v2, sizeof(RenderVertexSoft)); - auto p3 = &pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]]; RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24 - v3.vWorldPosition.x = (float)p3->x; - v3.vWorldPosition.y = (float)p3->y; - v3.vWorldPosition.z = (float)p3->z; - memcpy(pOutVertices + 2, &v3, sizeof(RenderVertexSoft)); + v3.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].x; + v3.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].y; + v3.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].z; + memcpy(&pOutVertices[2], &v3, sizeof(RenderVertexSoft)); - auto p4 = &pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]]; RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24 - v4.vWorldPosition.x = (double)p4->x; - v4.vWorldPosition.y = (double)p4->y; - v4.vWorldPosition.z = (double)p4->z; - memcpy(pOutVertices + 3, &v4, sizeof(RenderVertexSoft)); + v4.vWorldPosition.x = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].x; + v4.vWorldPosition.y = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].y; + v4.vWorldPosition.z = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].z; + memcpy(&pOutVertices[3], &v4, sizeof(RenderVertexSoft)); } @@ -259,7 +253,7 @@ switch (pFace->uPolygonType) { case POLYGON_VerticalWall: - a1.x = -pFace->pFacePlane.vNormal.y; + a1.x = -pFace->pFacePlane.vNormal.y;// направление полигона a1.y = pFace->pFacePlane.vNormal.x; a1.z = 0.0f; a1.Normalize(); @@ -300,12 +294,12 @@ } if (pFace->uAttributes & 0x0200) { - face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2; + face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;// центр полигона face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2; face_center_z = (pFaceLimits[1].vWorldPosition.z + pFaceLimits[3].vWorldPosition.z) / 2; - a3 = face_center_x - pFaceLimits[0].vWorldPosition.x; - var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z; + a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;//от центра до верхнего края + var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z;// высота от центра if (pFace->uPolygonType == POLYGON_VerticalWall) a3 /= a1.x; @@ -771,7 +765,7 @@ { RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1 - CalcPolygonLimits(pFace, pLimits); + CalcPolygonLimits(pFace, pLimits);//определение границ портала //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) // pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997); if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding))