Mercurial > mm7
changeset 1301:18665b8f66b2
yellow points remove
author | Ritor1 |
---|---|
date | Mon, 24 Jun 2013 13:47:13 +0600 |
parents | bedc304ab617 |
children | 0aa57a8d4804 |
files | Indoor.cpp Render.cpp stru9.cpp stru9.h |
diffstat | 4 files changed, 163 insertions(+), 133 deletions(-) [+] |
line wrap: on
line diff
--- a/Indoor.cpp Thu Jun 20 15:24:09 2013 +0600 +++ b/Indoor.cpp Mon Jun 24 13:47:13 2013 +0600 @@ -1304,7 +1304,17 @@ auto pFace = &pIndoor->pFaces[uFaceID]; auto p = &nodes[node_id]; - +for (int i = 0; i < pIndoor->uNumFaces; ++i) +{ + if (pIndoor->pFaces[i].Portal()) + { + if ( pIndoor->pFaces[i].uSectorID == nodes[0].uSectorID ) + { + Log::Warning(L"portal id = %u", i); + //pIndoor->pFaces[i].uBitmapID = 9; + } + } +} if (!pFace->Portal()) { if (num_faces < 1000) @@ -7180,16 +7190,16 @@ int __fastcall sub_423B5D(unsigned int uFaceID) { BLVFace *pFace; // ebx@1 - Vec3_short_ *v2; // esi@1 + //Vec3_short_ *v2; // esi@1 //int v3; // ST28_4@1 //__int16 v4; // ST2C_2@1 - signed int v5; // esi@1 + //signed int v5; // esi@1 //Vec3_short_ *v6; // eax@4 - signed int v7; // edi@5 - signed int v8; // eax@5 - signed int v9; // ecx@10 - int v10; // eax@10 - int v11; // edx@11 + //signed int v7; // edi@5 + //signed int bFound; // eax@5 + //signed int v9; // ecx@10 + //int v10; // eax@10 + //int v11; // edx@11 int v12; // ST28_4@12 signed int v13; // edx@12 signed __int64 v14; // qtt@12 @@ -7243,27 +7253,27 @@ int v63; // ecx@76 int v64; // esi@76 int v65; // ecx@83 - signed int v66; // [sp+14h] [bp-14h]@3 + //signed int v66; // [sp+14h] [bp-14h]@3 int v67; // [sp+14h] [bp-14h]@34 int v68; // [sp+14h] [bp-14h]@44 int v69; // [sp+14h] [bp-14h]@54 int v70; // [sp+14h] [bp-14h]@64 signed int v71; // [sp+14h] [bp-14h]@75 - IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1 - bool thisa; // [sp+18h] [bp-10h]@9 + //IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1 + bool current_vertices_flag; // [sp+18h] [bp-10h]@9 int thisb; // [sp+18h] [bp-10h]@12 int thisc; // [sp+18h] [bp-10h]@20 bool thisd; // [sp+18h] [bp-10h]@41 bool thise; // [sp+18h] [bp-10h]@61 int thisf; // [sp+18h] [bp-10h]@74 - signed int v79; // [sp+1Ch] [bp-Ch]@9 + signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 int v80; // [sp+1Ch] [bp-Ch]@76 - bool v81; // [sp+20h] [bp-8h]@10 + bool next_vertices_flag; // [sp+20h] [bp-8h]@10 bool v82; // [sp+20h] [bp-8h]@32 bool v83; // [sp+20h] [bp-8h]@42 bool v84; // [sp+20h] [bp-8h]@52 bool v85; // [sp+20h] [bp-8h]@62 - signed int v86; // [sp+24h] [bp-4h]@9 + //signed int v86; // [sp+24h] [bp-4h]@9 signed int v87; // [sp+24h] [bp-4h]@19 signed int v88; // [sp+24h] [bp-4h]@31 signed int v89; // [sp+24h] [bp-4h]@41 @@ -7271,11 +7281,12 @@ signed int v91; // [sp+24h] [bp-4h]@61 pFace = &pIndoor->pFaces[uFaceID]; - _this = pGame->pIndoorCameraD3D; - v2 = &pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]]; + memset(&stru_50B700, 0, sizeof(stru367)); + //_this = pGame->pIndoorCameraD3D; + //v2 = &pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]]; //v3 = *(_DWORD *)pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x; //v4 = pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z; - v5 = 0; + //v5 = 0; if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) @@ -7285,111 +7296,110 @@ else { stru_50B700.field_0 = 0; - if ( !(pFace->uAttributes & 1) ) + if ( !(pFace->Portal()) ) return 0; } - v66 = pFace->uNumVertices; + //v66 = pFace->uNumVertices; if ( (signed int)pFace->uNumVertices > 0 ) { - do + for (uint i = 0; i < pFace->uNumVertices; ++i) { //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]]; pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( - pIndoor->pVertices[pFace->pVertexIDs[v5]].x, - pIndoor->pVertices[pFace->pVertexIDs[v5]].y, - pIndoor->pVertices[pFace->pVertexIDs[v5]].z, - &stru_50B700._view_transformed_xs[v5 + 3], - &stru_50B700._view_transformed_zs[v5 + 3], - &stru_50B700._view_transformed_ys[v5 + 3], + pIndoor->pVertices[pFace->pVertexIDs[i]].x, + pIndoor->pVertices[pFace->pVertexIDs[i]].y, + pIndoor->pVertices[pFace->pVertexIDs[i]].z, + &stru_50B700._view_transformed_xs[i + 3], + &stru_50B700._view_transformed_zs[i + 3], + &stru_50B700._view_transformed_ys[i + 3], 0); - ++v5; } - while ( v5 < v66 ); - } - v7 = v66; - v8 = 0; - if ( v66 <= 0 ) + } + //v7 = pFace->uNumVertices; + if ( pFace->uNumVertices <= 0 ) return 0; - do - { - if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 ) + bool bFound = false; + for (uint i = 0; i < pFace->uNumVertices; ++i) + { + if ( stru_50B700._view_transformed_xs[i + 3] >= 524288 ) + { + bFound = true; break; - ++v8; - } - while ( v8 < v66 ); - if ( v8 >= v66 ) + } + } + if ( !bFound ) return 0; - v79 = 0; - stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3]; - stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3]; - stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3]; - thisa = stru_50B700._view_transformed_xs[3] >= 524288; - v86 = 1; - if ( v66 >= 1 ) - { - do + + depth_num_vertices = 0; + stru_50B700._view_transformed_xs[pFace->uNumVertices + 3] = stru_50B700._view_transformed_xs[3]; + stru_50B700._view_transformed_zs[pFace->uNumVertices + 3] = stru_50B700._view_transformed_zs[3]; + stru_50B700._view_transformed_ys[pFace->uNumVertices + 3] = stru_50B700._view_transformed_ys[3]; + current_vertices_flag = stru_50B700._view_transformed_xs[3] >= 524288; + //v86 = 1; + if ( pFace->uNumVertices >= 1 ) + { + for ( uint i = 1; i <= pFace->uNumVertices; ++i) { - v9 = v86; - v10 = stru_50B700._view_transformed_xs[v86 + 3]; - v81 = v10 >= 524288; - if ( thisa ^ v81 ) + //v9 = v86; + //v10 = stru_50B700._view_transformed_xs[v86 + 3]; + next_vertices_flag = stru_50B700._view_transformed_xs[i + 3] >= 524288; + if ( current_vertices_flag ^ next_vertices_flag ) { - v11 = stru_50B700._view_transformed_xs[v9 + 2]; - if ( v10 >= 524288 ) + //v11 = stru_50B700._view_transformed_xs[i + 2]; + if ( stru_50B700._view_transformed_xs[i + 3] >= 524288 ) { - v12 = v10 - v11; - v13 = 524288 - v11; + v12 = stru_50B700._view_transformed_xs[i + 3] - stru_50B700._view_transformed_xs[i + 2]; + v13 = 524288 - stru_50B700._view_transformed_xs[i + 2]; LODWORD(v14) = v13 << 16; HIDWORD(v14) = v13 >> 16; - v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2]; - stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3] - - stru_50B700._view_transformed_zs[v9 + 2]) + v15 = (char *)&stru_50B700._view_transformed_ys[i + 2]; + stru_50B700._view_transformed_zs[depth_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i + 3] + - stru_50B700._view_transformed_zs[i + 2]) * v14 / v12) >> 16) - + stru_50B700._view_transformed_zs[v9 + 2]; - thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2]) + + stru_50B700._view_transformed_zs[i + 2]; + thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i + 3] - stru_50B700._view_transformed_ys[i + 2]) * v14 / v12) >> 16; } else { - v16 = v11 - v10; - v17 = 524288 - v10; + v16 = stru_50B700._view_transformed_xs[i + 2] - stru_50B700._view_transformed_xs[i + 3]; + v17 = 524288 - stru_50B700._view_transformed_xs[i + 3]; LODWORD(v18) = v17 << 16; HIDWORD(v18) = v17 >> 16; - v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3]; - stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2] - - stru_50B700._view_transformed_zs[v9 + 3]) + v15 = (char *)&stru_50B700._view_transformed_ys[i + 3]; + stru_50B700._view_transformed_zs[depth_num_vertices] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i + 2] + - stru_50B700._view_transformed_zs[i + 3]) * v18 / v16) >> 16) - + stru_50B700._view_transformed_zs[v9 + 3]; - thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3]) + + stru_50B700._view_transformed_zs[i + 3]; + thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i + 2] - stru_50B700._view_transformed_ys[i + 3]) * v18 / v16) >> 16; } - v19 = v79++; - v7 = v66; + v19 = depth_num_vertices++; + //v7 = pFace->uNumVertices; stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15; stru_50B700._view_transformed_xs[v19] = 524288; } - if ( v81 ) + if ( next_vertices_flag ) { - v20 = v79++; - stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3]; - stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3]; - stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3]; + v20 = depth_num_vertices++; + stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[i + 3]; + stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[i + 3]; + stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[i + 3]; } - ++v86; - thisa = v81; + current_vertices_flag = next_vertices_flag; } - while ( v86 <= v7 ); - } + } + v87 = 0; - v21 = v79; - stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0]; - stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0]; - for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0]; - v87 < v79; + v21 = depth_num_vertices; + stru_50B700._view_transformed_xs[depth_num_vertices] = stru_50B700._view_transformed_xs[0]; + stru_50B700._view_transformed_zs[depth_num_vertices] = stru_50B700._view_transformed_zs[0]; + for ( stru_50B700._view_transformed_ys[depth_num_vertices] = stru_50B700._view_transformed_ys[0]; + v87 < depth_num_vertices; stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 ) { v22 = v87; @@ -7408,16 +7418,25 @@ v24 = 0; if ( stru_50B700._view_transformed_zs[v22] >= 0 ) { - LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - v26 = ((v24 - 1) & 0xFF800000) + 4194304; + //LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; + //v26 = ((v24 - 1) & 0xFF800000) + 4194304; + if (stru_50B700._view_transformed_xs[v22] >= 0) + v26 = 0x400000; // 64.0 + else + v26 = 0xFFC00000; } else { - LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - v25 = v24 - 1; - v26 = (v25 & 0x800000) - 4194304; + //LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; + //v25 = v24 - 1; + //v26 = (v25 & 0x800000) - 4194304; + if (stru_50B700._view_transformed_xs[v22] >= 0) + v26 = 0xFFC00000; // -63.0 + else + v26 = 0x400000; } } + v29 = stru_50B700._view_transformed_ys[v22]; stru_50B700._screen_space_x[v22 + 12] = v26; if ( abs(v29) >> 13 <= thisc ) @@ -7432,14 +7451,22 @@ v30 = 0; if ( stru_50B700._view_transformed_ys[v22] >= v23 ) { - LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - v32 = ((v30 - 1) & 0xFF800000) + 4194304; + //LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; + //v32 = ((v30 - 1) & 0xFF800000) + 4194304; + if (stru_50B700._view_transformed_xs[v22] >= v23) + v32 = 0x400000; // 64.0 + else + v32 = 0xFFC00000; } else { - LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - v31 = v30 - 1; - v32 = (v31 & 0x800000) - 4194304; + //LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; + //v31 = v30 - 1; + //v32 = (v31 & 0x800000) - 4194304; + if (stru_50B700._view_transformed_xs[v22] >= v23) + v32 = 0xFFC00000; // -63.0 + else + v32 = 0x400000; } } stru_50B700._screen_space_y[v22 + 12] = v32; @@ -7457,7 +7484,7 @@ LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX; v39 = 1; v88 = 1; - if ( v79 < 1 ) + if ( depth_num_vertices < 1 ) return 0; do { @@ -7493,7 +7520,7 @@ } v39 = v88++ + 1; } - while ( v88 <= v79 ); + while ( v88 <= depth_num_vertices ); if ( !v36 || (v43 = 0, stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9],
--- a/Render.cpp Thu Jun 20 15:24:09 2013 +0600 +++ b/Render.cpp Mon Jun 24 13:47:13 2013 +0600 @@ -1830,7 +1830,8 @@ else { v6 = v8->uTileBitmapID; - transparent = true; + if ( !_strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5) ) + transparent = true; } assert(v6 < 1000); // many random crashes here
--- a/stru9.cpp Thu Jun 20 15:24:09 2013 +0600 +++ b/stru9.cpp Mon Jun 24 13:47:13 2013 +0600 @@ -175,71 +175,73 @@ //----- (004985FB) -------------------------------------------------------- -bool stru9::CalcPortalShape(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *a3, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused) +bool stru9::CalcPortalShape(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused) { - RenderVertexSoft *v9; // ecx@1 - Vec3_float_ *v10; // esi@1 + //RenderVertexSoft *v9; // ecx@1 + //Vec3_float_ *v10; // esi@1 //char *v11; // ebx@1 - RenderVertexSoft *v12; // edi@1 - double v13; // st7@1 + //RenderVertexSoft *pVertices; // edi@1 + double pLinelength1; // st7@1 //bool result; // eax@4 signed int v15; // edx@9 - RenderVertexSoft *v16; // ecx@9 - double v17; // st7@9 - double v18; // st6@12 + RenderVertexSoft *pLineEnd; // ecx@9 + double pLinelength2; // st7@9 + double t; // st6@12 signed int v19; // [sp+Ch] [bp-Ch]@7 - float v20; // [sp+10h] [bp-8h]@1 + //float v20; // [sp+10h] [bp-8h]@1 bool v21; // [sp+14h] [bp-4h]@2 - v9 = a1; - v10 = a5; + //v9 = a1; + //v10 = a5; //v11 = (char *)&a1->vWorldPosition.z; - auto v11 = a1; - v12 = a3; - v13 = a1->vWorldPosition.y * a5->y + a5->x * a1->vWorldPosition.x + a1->vWorldPosition.z * a5->z; - v20 = v13; - v21 = v13 >= a6; + auto pLineStart = &a1[0]; + //pVertices = a3; + pLinelength1 = a5->x * a1[0].vWorldPosition.x + a1[0].vWorldPosition.y * a5->y + a1[0].vWorldPosition.z * a5->z; + //v20 = v13; + v21 = pLinelength1 >= a6; *pOutNumVertices = 0; if ( a2 <= 0 ) return false; v19 = 1; + while ( 1 ) { if ( v21 ) { - ++a3; - memcpy(v12, v11, sizeof(RenderVertexSoft)); + //++pVertices; + memcpy(pVertices, pLineStart, sizeof(RenderVertexSoft)); ++*pOutNumVertices; - v10 = a5; - v12 = a3; - v9 = a1; + //v10 = a5; + pVertices++; + //v9 = a1; } v15 = 0; - v16 = &v9[v19 % a2]; - v17 = v16->vWorldPosition.z * v10->z + v16->vWorldPosition.y * v10->y + v10->x * v16->vWorldPosition.x; - if ( v17 >= a6 ) + pLineEnd = &a1[v19 % a2]; + pLinelength2 = a5->x * pLineEnd->vWorldPosition.x + pLineEnd->vWorldPosition.y * a5->y + pLineEnd->vWorldPosition.z * a5->z; + if ( pLinelength2 >= a6 ) v15 = 1; + if ( v21 != v15 ) { - v18 = (a6 - v20) / (v17 - v20); - v12->vWorldPosition.x = (v16->vWorldPosition.x - v11->vWorldPosition.x) * v18 + v11->vWorldPosition.x; - v12->vWorldPosition.y = (v16->vWorldPosition.y - v11->vWorldPosition.y) * v18 + v11->vWorldPosition.y; - v12->vWorldPosition.z = (v16->vWorldPosition.z - v11->vWorldPosition.z) * v18 + v11->vWorldPosition.z; - v12->u = (v16->u - v11->u) * v18 + v11->u; - v12->v = (v16->v - v11->v) * v18 + v11->v; - ++v12; - a3 = v12; + t = (a6 - pLinelength1) / (pLinelength2 - pLinelength1); + pVertices->vWorldPosition.x = pLineStart->vWorldPosition.x + (pLineEnd->vWorldPosition.x - pLineStart->vWorldPosition.x) * t; + pVertices->vWorldPosition.y = pLineStart->vWorldPosition.y + (pLineEnd->vWorldPosition.y - pLineStart->vWorldPosition.y) * t; + pVertices->vWorldPosition.z = pLineStart->vWorldPosition.z + (pLineEnd->vWorldPosition.z - pLineStart->vWorldPosition.z) * t; + pVertices->u = pLineStart->u + (pLineEnd->u - pLineStart->u) * t; + pVertices->v = pLineStart->v + (pLineEnd->v - pLineStart->v) * t; + ++pVertices; + //a3 = pVertices; ++*pOutNumVertices; *a7 = 1; } - v11++; + pLineStart++; v21 = v15; - v20 = v17; + pLinelength1 = pLinelength2; if ( v19 >= a2 ) break; - v9 = a1; + //v9 = a1; v19++; }
--- a/stru9.h Thu Jun 20 15:24:09 2013 +0600 +++ b/stru9.h Mon Jun 24 13:47:13 2013 +0600 @@ -52,7 +52,7 @@ bool _4980B9(struct RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices); bool _498377(struct RenderVertexSoft *pPortalBounding, unsigned int uNumVertices, struct IndoorCameraD3D_Vec4 *pVertices, struct RenderVertexSoft *pVertices2, unsigned int *pOutNumVertices); - bool CalcPortalShape(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *a3, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused); + bool CalcPortalShape(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused); void AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex); bool _498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5); bool AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3);