Mercurial > mm7
changeset 164:4b61b82a0bf7
Слияние
author | Ritor1 |
---|---|
date | Thu, 14 Feb 2013 09:27:19 +0600 |
parents | a0e7ad5425d4 (current diff) 3235bc4cf78e (diff) |
children | 572d821561f3 |
files | Keyboard.cpp |
diffstat | 2 files changed, 221 insertions(+), 288 deletions(-) [+] |
line wrap: on
line diff
--- a/Render.h Thu Feb 14 09:27:09 2013 +0600 +++ b/Render.h Thu Feb 14 09:27:19 2013 +0600 @@ -70,6 +70,11 @@ unsigned __int16 uPaletteSubindex; unsigned int uTintColor; SpriteFrame *pSpriteFrame; + + inline float GetFloatZ() const + { + return LOWORD(sZValue) / 65535.0f + (float)HIWORD(sZValue); + } }; #pragma pack(pop)
--- a/Vis.cpp Thu Feb 14 09:27:09 2013 +0600 +++ b/Vis.cpp Thu Feb 14 09:27:19 2013 +0600 @@ -1410,9 +1410,9 @@ memcpy(&v12, &v5[v8], sizeof(v12)); memcpy(&v5[v8], v15, sizeof(v5[v8])); memcpy(v15, &v12, 0x20u); - __debugbreak(); - //SortVerticesByX(v5, uStart, v8 - 1); - //SortVerticesByX(a2, v8 + 1, uEnd); + //__debugbreak(); + SortVerticesByX(v5, uStart, v8 - 1); + SortVerticesByX(a2, v8 + 1, uEnd); } return true; } @@ -1426,114 +1426,112 @@ int i; // ecx@2 int v8; // esi@3 int v9; // esi@5 - RenderVertexSoft *v10; // eax@8 + //RenderVertexSoft *v10; // eax@8 + const void *v10; RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8 RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2 - float v13; // [sp+4Ch] [bp-24h]@4 + //float v13; // [sp+4Ch] [bp-24h]@4 int v14; // [sp+64h] [bp-Ch]@7 - Vis *thisa; // [sp+68h] [bp-8h]@1 - RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2 - - //__debugbreak(); + //Vis *thisa; // [sp+68h] [bp-8h]@1 + void *thisa; + //RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2 + const void *v16; - result = sRight; thisa = this; - if ( sRight > sLeft ) + if (sRight <= sLeft) + return true; + v5 = pArray; + v16 = &pArray[sRight]; + v6 = sLeft - 1; + memcpy(&v12, &pArray[sRight], sizeof(v12)); + for ( i = sRight; ; i = v14 ) { - v5 = pArray; - v16 = &pArray[sRight]; - v6 = sLeft - 1; - memcpy(&v12, &pArray[sRight], sizeof(v12)); - for ( i = sRight; ; i = v14 ) + v8 = (int)&v5[v6].vWorldViewProjX; + do { - v8 = (int)&v5[v6].vWorldViewProjX; - do - { - v8 += 48; - ++v6; - } - while ( *(float *)v8 < (double)v13 ); - v9 = (int)&v5[i].vWorldViewProjX; - do - { - v9 -= 48; - --i; - } - while ( *(float *)v9 > (double)v13 ); - v14 = i; - if ( v6 >= i ) - break; - v10 = &v5[i]; - memcpy(&v11, &pArray[v6], sizeof(v11)); - v5 = pArray; - memcpy(&pArray[v6], v10, sizeof(pArray[v6])); - memcpy(v10, &v11, 0x30u); + v8 += 48; + ++v6; + } + while ( *(float *)v8 < v12.vWorldViewProjX); + v9 = (int)&v5[i].vWorldViewProjX; + do + { + v9 -= 48; + --i; } - memcpy(&v11, &v5[v6], sizeof(v11)); - memcpy(&v5[v6], v16, sizeof(v5[v6])); - memcpy(v16, &v11, 0x30u); - sort_objects_2(v5, sLeft, v6 - 1); - sort_objects_2(pArray, v6 + 1, sRight); + while ( *(float *)v9 > v12.vWorldViewProjX); + v14 = i; + if ( v6 >= i ) + break; + v10 = &v5[i]; + memcpy(&v11, &pArray[v6], sizeof(v11)); + v5 = pArray; + memcpy(&pArray[v6], v10, sizeof(pArray[v6])); + memcpy((void *)v10, &v11, sizeof(0x30u)); } + memcpy(&v11, &v5[v6], sizeof(v11)); + memcpy(&v5[v6], v16, sizeof(v5[v6])); + memcpy((void *)v16, &v11, sizeof(0x30u)); + sort_objects_2(v5, sLeft, v6 - 1); + sort_objects_2(pArray, v6 + 1, sRight); return true; } //----- (004C297E) -------------------------------------------------------- bool Vis::sort_objects_3(RenderVertexSoft *pArray, int sLeft, int sRight) { - bool result; // eax@1 + //bool result; // eax@1 RenderVertexSoft *v5; // edx@2 int v6; // ebx@2 int i; // ecx@2 int v8; // esi@3 int v9; // esi@5 - RenderVertexSoft *v10; // eax@8 - char v11; // [sp+4h] [bp-6Ch]@8 + //RenderVertexSoft *v10; // eax@8 + const void *v10; + //char v11; // [sp+4h] [bp-6Ch]@8 + RenderVertexSoft v11; RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2 - float v13; // [sp+50h] [bp-20h]@4 + //float v13; // [sp+50h] [bp-20h]@4 int v14; // [sp+64h] [bp-Ch]@7 - Vis *thisa; // [sp+68h] [bp-8h]@1 + //Vis *thisa; // [sp+68h] [bp-8h]@1 RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2 - result = sRight; - thisa = this; - if ( sRight > sLeft ) + if (sRight <= sLeft) + return true; + v5 = pArray; + v16 = &pArray[sRight]; + v6 = sLeft - 1; + memcpy(&v12, &pArray[sRight], sizeof(v12)); + for ( i = sRight; ; i = v14 ) { - v5 = pArray; - v16 = &pArray[sRight]; - v6 = sLeft - 1; - memcpy(&v12, &pArray[sRight], sizeof(v12)); - for ( i = sRight; ; i = v14 ) + v8 = (int)&v5[v6].vWorldViewProjY; + do + { + v8 += 48; + ++v6; + } + while ( *(float *)v8 < v12.vWorldViewProjY); + v9 = (int)&v5[v6].vWorldViewProjY; + do { - v8 = (int)&v5[v6].vWorldViewProjY; - do - { - v8 += 48; - ++v6; - } - while ( *(float *)v8 < (double)v13 ); - v9 = (int)&v5[i].vWorldViewProjY; - do - { - v9 -= 48; - --i; - } - while ( *(float *)v9 > (double)v13 ); - v14 = i; - if ( v6 >= i ) - break; - v10 = &v5[i]; - memcpy(&v11, &pArray[v6], 0x30u); - v5 = pArray; - memcpy(&pArray[v6], v10, sizeof(pArray[v6])); - memcpy(v10, &v11, 0x30u); + v9 -= 48; + --i; } - memcpy(&v11, &v5[v6], 0x30u); - memcpy(&v5[v6], v16, sizeof(v5[v6])); - memcpy(v16, &v11, 0x30u); - sort_objects_3(v5, sLeft, v6 - 1); - sort_objects_3(pArray, v6 + 1, sRight); + while ( *(float *)v9 > v12.vWorldViewProjY); + v14 = i; + if ( v6 >= i ) + break; + v10 = &v5[i]; + memcpy(&v11, &pArray[v6], sizeof(0x30)); + v5 = pArray; + memcpy(&pArray[v6], v10, sizeof(pArray[v6])); + memcpy((void *)v10, &v11, sizeof(0x30)); } + memcpy(&v11, &v5[v6], sizeof(0x30)); + memcpy(&v5[v6], v16, sizeof(v5[v6])); + memcpy((void *)v16, &v11, sizeof(0x30)); + sort_objects_3(v5, sLeft, v6 - 1); + sort_objects_3(pArray, v6 + 1, sRight); return true; } @@ -1759,232 +1757,162 @@ //----- (004C091D) -------------------------------------------------------- bool Vis::DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx) { - unsigned int v3; // esi@3 - bool result; // eax@3 - int v5; // ecx@4 - double v6; // st7@4 - __int16 v7; // fps@4 - double v8; // st7@4 - unsigned __int8 v9; // c0@4 - char v10; // c2@4 - unsigned __int8 v11; // c3@4 - Vis_stru1_stru0 *v12; // eax@10 - __int16 v13; // fps@16 - double v14; // st7@16 - char v15; // c0@16 - char v16; // c2@16 - char v17; // c3@16 - double v18; // st7@18 - double v19; // st6@18 - double v20; // st4@18 - float v21; // ST0C_4@22 - float v22; // ST08_4@22 - signed int v23; // eax@27 - double v24; // st7@32 - double v25; // st6@32 - float v26; // eax@32 - double v27; // st7@36 - double v28; // st6@36 - __int16 v29; // fps@36 - char v30; // c0@36 - char v31; // c2@36 - char v32; // c3@36 - double v33; // st6@37 - __int16 v34; // fps@37 - char v35; // c0@37 - char v36; // c2@37 - char v37; // c3@37 - __int16 v38; // fps@38 - double v39; // st6@38 - unsigned __int8 v40; // c0@38 - char v41; // c2@38 - unsigned __int8 v42; // c3@38 - __int16 v43; // fps@39 - double v44; // st6@39 - char v45; // c0@39 - char v46; // c2@39 - char v47; // c3@39 - Vis *v48; // esi@40 - float v49; // ST08_4@40 - Vis_stru1_stru0 *v50; // eax@45 - RenderVertexSoft pRay[2]; // [sp+20h] [bp-DCh]@5 - RenderVertexSoft a3[2]; // [sp+80h] [bp-7Ch]@22 - float v53; // [sp+E0h] [bp-1Ch]@33 - float v54; // [sp+E4h] [bp-18h]@32 - float fBillboardCenterX; // [sp+E8h] [bp-14h]@5 - float fBillboardCenterY; // [sp+ECh] [bp-10h]@5 - unsigned int v57; // [sp+F0h] [bp-Ch]@5 - float v58; // [sp+F4h] [bp-8h]@17 - Vis *thisa; // [sp+F8h] [bp-4h]@1 - signed int a3a; // [sp+108h] [bp+Ch]@17 - float a3b; // [sp+108h] [bp+Ch]@32 - - thisa = this; + int v3; // eax@3 + //signed int v5; // ecx@4 + //float v6; // ST04_4@6 + //float v7; // ST00_4@7 + int v8; // eax@10 + unsigned int v9; // eax@12 + int v10; // eax@17 + double v11; // st6@18 + double v12; // st7@18 + double v13; // st4@18 + float v14; // ST0C_4@22 + float v15; // ST08_4@22 + //float v16; // ST04_4@23 + //float v17; // ST00_4@24 + signed int v18; // eax@27 + unsigned int v19; // eax@29 + double v20; // st6@32 + double v21; // st7@32 + int v22; // eax@32 + double v23; // st7@36 + //void *v24; // esi@40 + float v25; // ST08_4@40 + //float v26; // ST04_4@41 + //float v27; // ST00_4@42 + int v28; // eax@45 + unsigned int v29; // eax@47 + char result; // al@48 + struct RenderVertexSoft pPickingRay[2]; + //int v31; // [sp+20h] [bp-DCh]@5 + struct RenderVertexSoft local_80[2]; + //int v32; // [sp+80h] [bp-7Ch]@22 + float v33; // [sp+E0h] [bp-1Ch]@33 + float v34; // [sp+E4h] [bp-18h]@32 + int v35; // [sp+E8h] [bp-14h]@5 + int v36; // [sp+ECh] [bp-10h]@5 + unsigned int v37; // [sp+F0h] [bp-Ch]@5 + float v38; // [sp+F4h] [bp-8h]@17 + //void *v39; // [sp+F8h] [bp-4h]@1 + signed int v40; // [sp+108h] [bp+Ch]@17 + float v41; // [sp+108h] [bp+Ch]@32 static Vis_stru1 Vis_static_stru_F91E10; - Vis_static_stru_F91E10.uNumPointers = 0; - v3 = uD3DBillboardIdx; - result = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].uParentBillboardID; - if ( result != -1 - && (v5 = pBillboardRenderList[result].sZValue, - v6 = (double)(unsigned __int16)pBillboardRenderList[result].sZValue, - result = v5 >> 16, - v8 = v6 * 0.000015259022 + (double)(v5 >> 16), - //UNDEF(v7), - v9 = v8 < fDepth, - v10 = 0, - v11 = v8 == fDepth, - //BYTE1(result) = HIBYTE(v7), - v9 | v11) ) + v3 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].uParentBillboardID; + if (v3 == -1) + return false; + if (pBillboardRenderList[v3].GetFloatZ() > fDepth) { - LOWORD(v5) = 0; - v57 = v5; - GetPolygonCenter( - pRenderer->pBillboardRenderListD3D[v3].pQuards, - 4u, - &fBillboardCenterX, - &fBillboardCenterY); - CastPickRay(pRay, fBillboardCenterX, fBillboardCenterY, fDepth); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - PickIndoor(fDepth, pRay, &Vis_static_stru_F91E10, &a5); +LABEL_49: + return false; + } + else + { + v37 = pBillboardRenderList[v3].sZValue & 0xFFFF0000; + GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuards, 4, (float *)&v35, (float *)&v36); + this->CastPickRay(pPickingRay, *(float *)&v35, *(float *)&v36, fDepth); + if (uCurrentlyLoadedLevelType == 1) + PickIndoor(fDepth, pPickingRay, &Vis_static_stru_F91E10, &a5); else - PickOutdoor(fDepth, pRay, &Vis_static_stru_F91E10, &a5, 0); + PickOutdoor(fDepth, pPickingRay, &Vis_static_stru_F91E10, &a5, 0); Vis_static_stru_F91E10.create_object_pointers(0); sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1); - HIWORD(result) = HIWORD(Vis_static_stru_F91E10.uNumPointers); - if ( Vis_static_stru_F91E10.uNumPointers - && ((signed int)Vis_static_stru_F91E10.uNumPointers <= 0 ? (v12 = 0) : (v12 = Vis_static_stru_F91E10.array_1804[0]), - result = v12->sZValue, - LOWORD(result) = 0, - result <= v57) - || (double)(signed int)pViewport->uScreenX > fBillboardCenterX - || (double)(signed int)pViewport->uScreenZ < fBillboardCenterX - || (double)(signed int)pViewport->uScreenY > fBillboardCenterY - || (v14 = (double)(signed int)pViewport->uScreenW, - //UNDEF(v13), - v15 = v14 < fBillboardCenterY, - v16 = 0, - v17 = v14 == fBillboardCenterY, - //BYTE1(result) = HIBYTE(v13), - v14 < fBillboardCenterY) ) + if (Vis_static_stru_F91E10.uNumPointers) { - a3a = 0; - result = (bool)&pRenderer->pBillboardRenderListD3D[v3].pQuards[0].pos.y; - - __debugbreak(); - { - LODWORD(v58) = (int)((char *)&pRenderer + v3 * 156 + 1062620);// pBillboardRenderListD3D+0x0C - } - + if (Vis_static_stru_F91E10.uNumPointers <= 0) + v8 = 0; + else v8 = (int)Vis_static_stru_F91E10.array_1804; + v9 = *(_DWORD *)(v8 + 4); + LOWORD(v9) = 0; + if (v9 > v37) + return 1; + } + else if ((double)(pViewport->uScreenX) <= *(float *)&v35 && + (double)pViewport->uScreenZ >= *(float *)&v35 && + (double)pViewport->uScreenY <= *(float *)&v36 && + (double)pViewport->uScreenW >= *(float *)&v36) + return 1; + v40 = 0; + v10 = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y; + LODWORD(v38) = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y; while ( 1 ) { - v18 = *(float *)(result - 4); - v19 = *(float *)result; - v20 = *(float *)(result - 4); + v12 = *(float *)(v10 - 4); + v11 = *(float *)v10; + v13 = *(float *)(v10 - 4); Vis_static_stru_F91E10.uNumPointers = 0; - if ( v20 >= (double)(signed int)pViewport->uScreenX ) + if ( v13 >= (double)(pViewport->uScreenX)) { - if ( v18 <= (double)(signed int)pViewport->uScreenZ - && v19 >= (double)(signed int)pViewport->uScreenY - && v19 <= (double)(signed int)pViewport->uScreenW ) + if ( v12 <= (double)pViewport->uScreenZ ) { - v21 = v19; - v22 = v18; - CastPickRay(a3, v22, v21, fDepth); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - PickIndoor(fDepth, a3, &Vis_static_stru_F91E10, &a5); - else - PickOutdoor(fDepth, a3, &Vis_static_stru_F91E10, &a5, 0); - Vis_static_stru_F91E10.create_object_pointers(0); - sort_object_pointers( - Vis_static_stru_F91E10.array_1804, - 0, - Vis_static_stru_F91E10.uNumPointers - 1); - result = Vis_static_stru_F91E10.uNumPointers; - if ( !Vis_static_stru_F91E10.uNumPointers ) - break; - v23 = (signed int)(Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : Vis_static_stru_F91E10.array_1804[0]); - result = *(int *)(v23 + 4); - LOWORD(result) = 0; - if ( result > v57 ) - break; + if ( v11 >= (double)pViewport->uScreenY ) + { + if ( v11 <= (double)pViewport->uScreenW ) + { + v14 = v11; + v15 = v12; + CastPickRay(local_80, SLODWORD(v15), v14, fDepth); + if ( uCurrentlyLoadedLevelType == 1 ) + PickIndoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5); + else + PickOutdoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5, 0); + Vis_static_stru_F91E10.create_object_pointers(0); + sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1); + if ( !Vis_static_stru_F91E10.uNumPointers ) + break; + v18 = Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : (int)Vis_static_stru_F91E10.array_1804; + v19 = *(_DWORD *)(v18 + 4); + LOWORD(v19) = 0; + if ( v19 > v37 ) + break; + } + } } } - ++a3a; - result = LODWORD(v58) + 32; - LODWORD(v58) += 32; - if ( a3a >= 4 ) + ++v40; + v10 = LODWORD(v38) + 32; + LODWORD(v38) += 32; + if ( v40 >= 4 ) { - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) - goto LABEL_49; - v24 = pRenderer->pBillboardRenderListD3D[v3].pQuards[0].pos.x; - v25 = pRenderer->pBillboardRenderListD3D[v3].pQuards[3].pos.x; - v26 = pRenderer->pBillboardRenderListD3D[v3].pQuards[0].pos.y; - v54 = pRenderer->pBillboardRenderListD3D[v3].pQuards[3].pos.x; - v58 = v26; - result = LODWORD(pRenderer->pBillboardRenderListD3D[v3].pQuards[1].pos.y); - a3b = pRenderer->pBillboardRenderListD3D[v3].pQuards[1].pos.y; - if ( v24 > v25 ) + if ( uCurrentlyLoadedLevelType != 2 ) + return false; + v21 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.x; + v20 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x; + v22 = *(int *)(&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y); + v34 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x; + LODWORD(v38) = v22; + v41 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[1].pos.y; + if ( v21 > v20 ) { - v53 = v24; - v24 = v54; - v25 = v53; + v33 = v21; + v21 = v34; + v20 = v33; } - if ( v58 > (double)a3b ) - a3b = v58; - if ( (Vis_static_stru_F91E10.uNumPointers = 0, - v27 = (v25 - v24) * 0.5, - v28 = (double)(signed int)pViewport->uScreenX, - //UNDEF(v29), - v30 = v27 < v28, - v31 = 0, - v32 = v27 == v28, - BYTE1(result) = HIBYTE(v29), - v27 < v28) - || (v33 = (double)(signed int)pViewport->uScreenZ, - //UNDEF(v34), - v35 = v27 < v33, - v36 = 0, - v37 = v27 == v33, - BYTE1(result) = HIBYTE(v34), - v27 > v33) - || (v39 = (double)(signed int)pViewport->uScreenY, - //UNDEF(v38), - v40 = v39 < a3b, - v41 = 0, - v42 = v39 == a3b, - BYTE1(result) = HIBYTE(v38), - !(v40 | v42)) - || (v44 = (double)(signed int)pViewport->uScreenW, - //UNDEF(v43), - v45 = v44 < a3b, - v46 = 0, - v47 = v44 == a3b, - BYTE1(result) = HIBYTE(v43), - v44 < a3b) - || ((v48 = thisa, v49 = v27, CastPickRay(a3, v49, a3b, fDepth), uCurrentlyLoadedLevelType != LEVEL_Indoor) ? PickOutdoor(fDepth, a3, &Vis_static_stru_F91E10, &a5, 0) : PickIndoor(fDepth, a3, &Vis_static_stru_F91E10, &a5), - (Vis_static_stru_F91E10.create_object_pointers(0), - sort_object_pointers( - Vis_static_stru_F91E10.array_1804, - 0, - Vis_static_stru_F91E10.uNumPointers - 1), - (result = Vis_static_stru_F91E10.uNumPointers) != 0) - && ((signed int)Vis_static_stru_F91E10.uNumPointers <= 0 ? (v50 = 0) : (v50 = Vis_static_stru_F91E10.array_1804[0]), - result = v50->sZValue, - LOWORD(result) = 0, - result <= v57)) ) - goto LABEL_49; + if ( v38 > (double)v41 ) + v41 = v38; + Vis_static_stru_F91E10.uNumPointers = 0; + v23 = (v20 - v21) * 0.5; + if ( v23 < (double)(pViewport->uScreenX) + || v23 > (double)pViewport->uScreenZ + || (double)pViewport->uScreenY > v41 + || (double)pViewport->uScreenW < v41 + || ((v25 = v23, CastPickRay(local_80, SLODWORD(v25), v41, fDepth), uCurrentlyLoadedLevelType != 1) ? + (PickOutdoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5, 0)) : + (PickIndoor(fDepth, local_80, &Vis_static_stru_F91E10, &a5)), + (Vis_static_stru_F91E10.create_object_pointers(0), + sort_object_pointers(Vis_static_stru_F91E10.array_1804, 0, Vis_static_stru_F91E10.uNumPointers - 1), + Vis_static_stru_F91E10.uNumPointers) + && (Vis_static_stru_F91E10.uNumPointers <= 0 ? (v28 = 0) : (v28 = (int)Vis_static_stru_F91E10.array_1804), + v29 = *(_DWORD *)(v28 + 4), + LOWORD(v29) = 0, + v29 <= v37)) ) + return false; break; } } - } - LOBYTE(result) = 1; - } - else - { -LABEL_49: - return false; + result = 1; } return result; }