Mercurial > mm7
diff Indoor.cpp @ 791:346f7069676a
Indoor::GetSector and various stuff
author | Nomad |
---|---|
date | Mon, 25 Mar 2013 05:27:18 +0200 |
parents | f004c7ceb7bd |
children | 290afbd48b6b |
line wrap: on
line diff
--- a/Indoor.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/Indoor.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -23,6 +23,9 @@ #include "PaletteManager.h" #include "MapInfo.h" #include "IndoorCamera.h" +#include "GUIWindow.h" +#include "GUIButton.h" +#include "GUIFont.h" #include "mm7_data.h" @@ -375,10 +378,14 @@ if (viewparams->draw_d3d_outlines) _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; + _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; + _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; + //INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES + _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; _this.field_1C_mb_fov = 65; - _this.vPosition.x = pParty->vPosition.x - ((stru_5C6E00->Cos(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16); - _this.vPosition.y = pParty->vPosition.y - ((stru_5C6E00->Sin(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16); + _this.vPosition.x = pParty->vPosition.x - fixpoint_mul(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); + _this.vPosition.y = pParty->vPosition.y - fixpoint_mul(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; _this.sRotationX = pParty->sRotationX; _this.sRotationY = pParty->sRotationY; @@ -537,7 +544,7 @@ if (pDecalBuilder->uNumDecals > 0) pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); - if (pFace->Animated() && + if (pFace->Fluid() && pFace->uBitmapID == pRenderer->hd_water_tile_id ) { __debugbreak(); @@ -545,7 +552,7 @@ goto LABEL_42; } - if (pFace->Animated()) + if (pFace->Fluid()) { //auto v24 = GetTickCount() / 4; //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; @@ -1467,6 +1474,7 @@ } if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); + //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); } } @@ -3121,10 +3129,10 @@ ///Vec3_short_ *v29; // eax@26 //Vec3_short_ *v30; // edx@26 //int v31; // edx@26 - signed int v32; // edi@27 + //signed int v32; // edi@27 signed __int64 v33; // qtt@27 //Vec3_short_ *v34; // edx@27 - int v35; // edx@32 + //int v35; // edx@32 int v37; // edi@38 int pSectorID; // ebx@40 int v39; // eax@41 @@ -3150,12 +3158,10 @@ int v59; // [sp+110h] [bp-4h]@16 v4 = 0; - //v7 = __OFSUB__(this->uNumSectors, 1); - //v5 = this->uNumSectors == 1; - //v6 = this->uNumSectors - 1 < 0; + v43[0] = 0; + v55 = 0; - v43[0] = 0; - //v56 = 1; + if (uNumSectors < 2) return 0; @@ -3163,126 +3169,101 @@ { auto pSector = pSectors + i; - if (pSector->pBounding.x1 <= sX && pSector->pBounding.x2 >= sX) - if (pSector->pBounding.y1 <= sY && pSector->pBounding.y2 >= sY) - if (pSector->pBounding.z1 - 64 <= sZ && pSector->pBounding.z2 + 64 >= sZ) - { + if (pSector->pBounding.x1 > sX || pSector->pBounding.x2 < sX || + pSector->pBounding.y1 > sY || pSector->pBounding.y2 < sY || + pSector->pBounding.z1 - 64 > sZ || pSector->pBounding.z2 + 64 < sZ) + continue; + //Log::Warning(L"Sector[%u]", i); - v51 = pSector->uNumFloors + pSector->uNumPortals; - if (!v51) - continue; - - //v9 = pSector->uNumFloors; - //v10 = v9 + pSector->uNumPortals; - //v11 = 0; - //v44 = v9; - //v48 = 0; - - //v12 = -2 * v9; - //v53 = -2 * v9; - for (uint j = 0; j < v51; ++j) - { - unsigned int uFaceID; - if (j < pSector->uNumFloors) - uFaceID = pSector->pFloors[j]; - else - uFaceID = pSector->pPortals[j - pSector->uNumFloors]; - - auto pFace = pFaces + uFaceID; - //v14 = (signed __int16)v13; - //v15 = this->pFaces; - //v46 = v13; - //v14 *= 96; - //v45 = v13 * sizeof(BLVFace); - //v16 = pFaces + uFaceID; - //v17 = v16->uPolygonType; - if (pFace->uPolygonType == POLYGON_Floor || - pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) - { - //pVertexIDs = pFace->pVertexIDs; - //v19 = this->pVertices; - //v20 = pVertices[pFace->pVertexIDs[0]].y; - v54 = 0; - //v57 = 0; - //v5 = v16->uNumVertices == 0; - v59 = pVertices[pFace->pVertexIDs[0]].y >= sY; - - //v21 = pFace->pVertexIDs + 1; - for (uint k = 0; k < pFace->uNumVertices; k++) - { - if (v54 >= 2) - break; - - //v49 = &pVertices[pFace->pVertexIDs[k]]; - auto v2 = &pVertices[pFace->pVertexIDs[k]]; - //v22 = pVertex->y; - //v47 = pVertex->y; - v50 = v2->y >= sY; - if ( v59 != v50 ) - { - //v58 = &pVertices[pFace->pVertexIDs[k - 1]]; - auto v1 = &pVertices[pFace->pVertexIDs[k]]; - //v23 = v58->x; - //HIWORD(v24) = HIWORD(v49); - //LOWORD(v24) = v49->x; - //v49 = v24; - //v59 = v49->x; - v25 = v1->x >= sX ? 0 : 2; - v26 = v25 | v2->x < sX; - if ( v26 != 3 ) - { - if (!v26) - ++v54; - else - { - if (v1->x >= v2->x) - { - int _a58; + v51 = pSector->uNumFloors + pSector->uNumPortals; + if (!v51) + continue; + + + for (uint j = 0; j < v51; ++j) + { + uint uFaceID; + if (j < pSector->uNumFloors) + uFaceID = pSector->pFloors[j]; + else + uFaceID = pSector->pPortals[j - pSector->uNumFloors]; + + auto pFace = pFaces + uFaceID; + if (pFace->uPolygonType != POLYGON_Floor && + pFace->uPolygonType != POLYGON_InBetweenFloorAndWall) + continue; + + v54 = 0; + v50 = pVertices[pFace->pVertexIDs[0]].y >= sY; + + for (uint k = 1; k < pFace->uNumVertices; k++) + { + v59 = v50; + + if (v54 >= 2) + break; + + auto v2 = &pVertices[pFace->pVertexIDs[k]]; + v50 = v2->y >= sY; + + if ( v59 == v50 ) + continue; + + auto v1 = &pVertices[pFace->pVertexIDs[k - 1]]; + v25 = v2->x >= sX ? 0 : 2; + v26 = v25 | (v1->x < sX); + + if (v26 == 3) + continue; + + if (!v26) + ++v54; + else + { + if (v1->x >= v2->x) + { + /*int _a58; int _a59; v32 = v1->x - v2->x; LODWORD(v33) = v32 << 16; - HIDWORD(v33) = v32 >> 16; - _a58 = v33 / (v1->y - v2->y); - _a59 = (unsigned __int64)(_a58 * (__int64)(sY - v2->y)) >> 16; - - if (v59 + pVertices[k].x > sX) - ++v54; - } - else - { - int _a58; + HIDWORD(v33) = v32 >> 16;*/ + //fixpoint_div(v1->x - v2->x, v1->y - v2->y); + //_a58 = v33 / (v1->y - v2->y); + //_a59 = fixpoint_mul(_a58, sY - v2->y); + auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); + auto rval = fixpoint_mul(x_div_y, sY - v2->y); // a / b * c - looks like projection + if (rval + v2->x > sX) + ++v54; + } + else + { + auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); + auto res = fixpoint_mul(x_div_y, sY - v1->y); + + if (res + v1->x > sX) + ++v54; + + /*int _a58; int _a59; - v32 = v2->x - v1->x; + auto v32 = v2->x - v1->x; LODWORD(v33) = v32 << 16; HIDWORD(v33) = v32 >> 16; _a58 = v33 / (v2->y - v1->y); - _a59 = (unsigned __int64)(_a58 * (signed __int64)(sY - v1->y)) >> 16; + _a59 = fixpoint_mul(_a58, sY - v1->y); if (_a59 + pVertices[k].x > sX) - ++v54; - } - } - } - } - - v59 = v50; - } - - if (pFace->uNumVertices) - { - if (v54 == 1) - { - v35 = v55++; - v43[v35] = uFaceID; - } - } - } + ++v54;*/ } - v4 = v43[0]; } + } + + if (pFace->uNumVertices && v54 == 1) + v43[v55++] = uFaceID; + } } + v4 = v43[0]; if ( v55 == 1 ) return this->pFaces[v4].uSectorID; v37 = 0;