Mercurial > mm7
changeset 2075:24033aa2e1f8
ODM_GetFloorLevel() check height
author | Ritor1 |
---|---|
date | Wed, 04 Dec 2013 15:40:27 +0600 |
parents | a290d9fbdc95 |
children | 0d535449c04f |
files | Indoor.cpp Outdoor.cpp Outdoor.h mm7_data.cpp mm7_data.h |
diffstat | 5 files changed, 85 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/Indoor.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/Indoor.cpp Wed Dec 04 15:40:27 2013 +0600 @@ -3992,8 +3992,8 @@ static int blv_floor_id[50]; // 00721200 static int blv_floor_level[50]; // 007212C8 - static __int16 word_721390_ys[104]; // idb - static __int16 word_721460_xs[104]; // idb + static __int16 blv_floor_face_vert_coord_Y[104]; // word_721390_ys + static __int16 blv_floor_face_vert_coord_X[104]; // word_721460_xs BLVSector* pSector = &pIndoor->pSectors[uSectorID]; v55 = 0; @@ -4009,15 +4009,15 @@ { for (uint j = 0; j < pFloor->uNumVertices; ++j) { - word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; - word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; - word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; - word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; + blv_floor_face_vert_coord_X[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; + blv_floor_face_vert_coord_X[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; + blv_floor_face_vert_coord_Y[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; + blv_floor_face_vert_coord_Y[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; } - word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0]; - word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0]; - - v50 = word_721390_ys[0] >= y; + blv_floor_face_vert_coord_X[2 * pFloor->uNumVertices] = blv_floor_face_vert_coord_X[0]; + blv_floor_face_vert_coord_Y[2 * pFloor->uNumVertices] = blv_floor_face_vert_coord_Y[0]; + + v50 = blv_floor_face_vert_coord_Y[0] >= y; v53 = 0; for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j) @@ -4026,25 +4026,25 @@ break; v48 = v50; - v50 = word_721390_ys[j + 1] >= y; - - v13 = i; - if (v48 == v50) - continue; - - v14 = word_721460_xs[j + 1] >= x ? 0 : 2; - v15 = v14 | (word_721460_xs[j] < x); - - if (v15 == 3) - continue; - else if (!v15) - ++v53; - else - { - long long a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - long long res = fixpoint_mul((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); - - if (res + word_721460_xs[j] >= x) + v50 = blv_floor_face_vert_coord_Y[j + 1] >= y; + + v13 = i; + if (v48 == v50) + continue; + + v14 = blv_floor_face_vert_coord_X[j + 1] >= x ? 0 : 2; + v15 = v14 | (blv_floor_face_vert_coord_X[j] < x); + + if (v15 == 3) + continue; + else if (!v15) + ++v53; + else + { + long long a_div_b = fixpoint_div(y - blv_floor_face_vert_coord_Y[j], blv_floor_face_vert_coord_Y[j + 1] - blv_floor_face_vert_coord_Y[j]); + long long res = fixpoint_mul((signed int)blv_floor_face_vert_coord_X[j + 1] - (signed int)blv_floor_face_vert_coord_X[j], a_div_b); + + if (res + blv_floor_face_vert_coord_X[j] >= x) ++v53; } } @@ -4086,35 +4086,35 @@ { for (uint j = 0; j < portal->uNumVertices; ++j) { - word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; - word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; - word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; - word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; + blv_floor_face_vert_coord_X[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; + blv_floor_face_vert_coord_X[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; + blv_floor_face_vert_coord_Y[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; + blv_floor_face_vert_coord_Y[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; } - word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; - word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; + blv_floor_face_vert_coord_X[2 * portal->uNumVertices] = blv_floor_face_vert_coord_X[0]; + blv_floor_face_vert_coord_Y[2 * portal->uNumVertices] = blv_floor_face_vert_coord_Y[0]; v54 = 0; - v47 = word_721390_ys[0] >= y; + v47 = blv_floor_face_vert_coord_Y[0] >= y; for (uint j = 0; j < 2 * portal->uNumVertices; ++j) { v49 = v47; if ( v54 >= 2 ) break; - v47 = word_721390_ys[j + 1] >= y; + v47 = blv_floor_face_vert_coord_Y[j + 1] >= y; if ( v49 != v47 ) { - v28 = word_721460_xs[j + 1] >= x ? 0 : 2; - v29 = v28 | (word_721460_xs[j] < x); + v28 = blv_floor_face_vert_coord_X[j + 1] >= x ? 0 : 2; + v29 = v28 | (blv_floor_face_vert_coord_X[j] < x); if ( v29 != 3 ) { if ( !v29 ) ++v54; else { - long long a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - long long res = fixpoint_mul(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); - if (res + word_721460_xs[j] >= x) + long long a_div_b = fixpoint_div(y - blv_floor_face_vert_coord_Y[j], blv_floor_face_vert_coord_Y[j + 1] - blv_floor_face_vert_coord_Y[j]); + long long res = fixpoint_mul(blv_floor_face_vert_coord_X[j + 1] - blv_floor_face_vert_coord_X[j], a_div_b); + if (res + blv_floor_face_vert_coord_X[j] >= x) ++v54; } }
--- a/Outdoor.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/Outdoor.cpp Wed Dec 04 15:40:27 2013 +0600 @@ -3152,12 +3152,11 @@ int v24; // eax@36 signed int v25; // ecx@38 int result; // eax@42 - signed int v27; // ecx@43 + signed int current_floor_level; // ecx@43 int v28; // edi@44 signed int v29; // edx@44 int v30; // esi@45 int v31; // eax@45 - ODMFace *v32; // eax@57 int v33; // ecx@59 int v36; // [sp+14h] [bp-2Ch]@24 int v38; // [sp+1Ch] [bp-24h]@2 @@ -3168,7 +3167,7 @@ bool next_vertices_Y; // [sp+34h] [bp-Ch]@24 signed int v46; // [sp+3Ch] [bp-4h]@1 signed int number_hits; // [sp+58h] [bp+18h]@22 - signed int v49; // [sp+58h] [bp+18h]@43 + signed int next_floor_level; // [sp+58h] [bp+18h]@43 v46 = 1; dword_721160[0] = -1; @@ -3187,23 +3186,24 @@ for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) { pFace = &pBModel->pFaces[pFaceNum]; + if ( pFace->Ethereal() ) + continue; if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) - && !(pFace->uAttributes & 0x20000000) && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 ) { for ( uint i = 0; i < pFace->uNumVertices; ++i) { - FloorFaceVertCoord_X[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; - FloorFaceVertCoord_Y[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; - FloorFaceVertCoord_X[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; - FloorFaceVertCoord_Y[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; + odm_floor_face_vert_coord_X[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; + odm_floor_face_vert_coord_Y[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; + odm_floor_face_vert_coord_X[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; + odm_floor_face_vert_coord_Y[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; } - FloorFaceVertCoord_X[2 * pFace->uNumVertices] = FloorFaceVertCoord_X[0]; - FloorFaceVertCoord_Y[2 * pFace->uNumVertices] = FloorFaceVertCoord_Y[0]; - - current_vertices_Y = FloorFaceVertCoord_Y[0] >= Y; + odm_floor_face_vert_coord_X[2 * pFace->uNumVertices] = odm_floor_face_vert_coord_X[0]; + odm_floor_face_vert_coord_Y[2 * pFace->uNumVertices] = odm_floor_face_vert_coord_Y[0]; + + current_vertices_Y = odm_floor_face_vert_coord_Y[0] >= Y; number_hits = 0; if ( 2 * pFace->uNumVertices > 0 ) { @@ -3211,21 +3211,22 @@ { if ( number_hits >= 2 ) break; - v36 = FloorFaceVertCoord_Y[i + 1]; - next_vertices_Y = FloorFaceVertCoord_Y[i + 1] >= Y; + //v36 = odm_floor_face_vert_coord_Y[i + 1]; + next_vertices_Y = odm_floor_face_vert_coord_Y[i + 1] >= Y; if ( current_vertices_Y != next_vertices_Y )//проверка по Y { - v18 = FloorFaceVertCoord_X[i + 1] >= X ? 0 : 2; - v19 = v18 | (FloorFaceVertCoord_X[i] < X); + v18 = odm_floor_face_vert_coord_X[i + 1] >= X ? 0 : 2; + v19 = v18 | (odm_floor_face_vert_coord_X[i] < X); if ( v19 != 3 ) { if ( !v19 ) ++number_hits; else { - LODWORD(v23) = (Y - FloorFaceVertCoord_Y[i]) << 16; - HIDWORD(v23) = (Y - FloorFaceVertCoord_Y[i]) >> 16; - v22 = ((((FloorFaceVertCoord_X[i + 1] - FloorFaceVertCoord_X[i]) * v23 / (v36 - FloorFaceVertCoord_Y[i])) >> 16) + FloorFaceVertCoord_X[i]); + LODWORD(v23) = (Y - odm_floor_face_vert_coord_Y[i]) << 16; + HIDWORD(v23) = (Y - odm_floor_face_vert_coord_Y[i]) >> 16; + v22 = ((((odm_floor_face_vert_coord_X[i + 1] - odm_floor_face_vert_coord_X[i]) * v23 / (odm_floor_face_vert_coord_Y[i + 1] + - odm_floor_face_vert_coord_Y[i])) >> 16) + odm_floor_face_vert_coord_X[i]); if ( v22 >= X) ++number_hits; } @@ -3259,51 +3260,43 @@ *bmodel_pid = 0; return odm_floor_level[0]; } - v27 = 0; + current_floor_level = 0; + v29 = 0; if ( v46 <= 1 ) *bmodel_pid = 0; else { - //v29 = 1; - for ( v49 = 1; v49 < v46; ++v49 ) + current_floor_level = odm_floor_level[0]; + for ( uint i = 1; i < v46; ++i ) { - if ( odm_floor_level[v49] == odm_floor_level[0] ) - { - v27 = v49; - //++v29; - break; - } - if ( odm_floor_level[0] > Z + 5 ) + next_floor_level = odm_floor_level[i]; + if ( current_floor_level <= Z + 5 ) { - if ( odm_floor_level[v49] >= odm_floor_level[0] ) + if ( next_floor_level > current_floor_level && next_floor_level <= Z + 5 ) { - //++v29; - break; + current_floor_level = next_floor_level; + v29 = i; } - v27 = v49; - //++v29; - break; } - if ( odm_floor_level[v49] > odm_floor_level[0] && odm_floor_level[v49] <= Z + 5 ) + else if ( next_floor_level < current_floor_level ) { - v27 = v49; - //++v29; + current_floor_level = next_floor_level; + v29 = i; } } - if ( !v27 ) + if ( !v29 ) *bmodel_pid = 0; else - *bmodel_pid = dword_721110[v27] | (dword_721160[v27] << 6); + *bmodel_pid = dword_721110[v29] | (dword_721160[v29] << 6); } - if ( v27 ) + if ( v29 ) { - v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; *pIsOnWater = false; - if ( v32->Fluid()) + if ( pOutdoor->pBModels[dword_721160[v29]].pFaces[dword_721110[v29]].Fluid()) *pIsOnWater = true; } - if ( odm_floor_level[v27] >= odm_floor_level[0] ) - odm_floor_level[0] = odm_floor_level[v27]; + if ( odm_floor_level[v29] >= odm_floor_level[0] ) + odm_floor_level[0] = odm_floor_level[v29]; return odm_floor_level[0]; }
--- a/Outdoor.h Tue Dec 03 16:35:57 2013 +0600 +++ b/Outdoor.h Wed Dec 04 15:40:27 2013 +0600 @@ -89,6 +89,7 @@ inline bool Portal() const {return (uAttributes & FACE_PORTAL) != 0;} inline bool Fluid() const {return (uAttributes & FACE_FLUID) != 0;} inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;} + inline bool Ethereal() const {return (uAttributes & FACE_ETHEREAL) != 0;} struct Plane_int_ pFacePlane; int zCalc1;
--- a/mm7_data.cpp Tue Dec 03 16:35:57 2013 +0600 +++ b/mm7_data.cpp Wed Dec 04 15:40:27 2013 +0600 @@ -1234,8 +1234,8 @@ std::array<int, 20> dword_720E80; std::array<int, 20> dword_720ED0; std::array<int, 20> ceiling_height_level; -std::array<__int16, 777> FloorFaceVertCoord_Y; // idb -std::array<__int16, 777> FloorFaceVertCoord_X; // idb +std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 +std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 std::array<int, 777> dword_721110; // idb std::array<int, 777> dword_721160; // idb std::array<int, 20> odm_floor_level; // idb
--- a/mm7_data.h Tue Dec 03 16:35:57 2013 +0600 +++ b/mm7_data.h Wed Dec 04 15:40:27 2013 +0600 @@ -908,8 +908,8 @@ extern std::array<int, 20> dword_720E80; extern std::array<int, 20> dword_720ED0; extern std::array<int, 20> ceiling_height_level; -extern std::array<__int16, 777> FloorFaceVertCoord_Y; // idb -extern std::array<__int16, 777> FloorFaceVertCoord_X; // idb +extern std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 +extern std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 extern std::array<int, 777> dword_721110; // idb extern std::array<int, 777> dword_721160; // idb extern std::array<int, 20> odm_floor_level; // idb dword_7211B0