Mercurial > mm7
changeset 2322:a59892f99d31
for draw terrain
author | Ritor1 |
---|---|
date | Sun, 23 Mar 2014 19:55:59 +0600 |
parents | 53c9d34024d6 |
children | b2e3ac05f2b3 defd2526c94c |
files | LightmapBuilder.cpp Outdoor.cpp Render.cpp Render.h _deleted.cpp |
diffstat | 5 files changed, 1414 insertions(+), 1386 deletions(-) [+] |
line wrap: on
line diff
--- a/LightmapBuilder.cpp Sat Mar 22 18:06:41 2014 +0600 +++ b/LightmapBuilder.cpp Sun Mar 23 19:55:59 2014 +0600 @@ -1167,7 +1167,16 @@ X = LODWORD(v61), v52 = v63, SLODWORD(v61) > v63) )*/ - if (0) + v49 = pNormal; + Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3); + *(float *)a3 = (double)v8->vPosition.x * v49->x + + (double)v8->vPosition.y * v49->y + + (double)v8->vPosition.z * v49->z + *a3; + v61 = *(float *)a3 + 6.7553994e15; + result = LODWORD(v61); + X = LODWORD(v61); + v52 = v63; + if ( SLODWORD(v61) > v63) return 0; v53 = pSlot; v60 = X;
--- a/Outdoor.cpp Sat Mar 22 18:06:41 2014 +0600 +++ b/Outdoor.cpp Sun Mar 23 19:55:59 2014 +0600 @@ -111,6 +111,7 @@ pRenderer->DrawOutdoorSkyD3D(); pRenderer->DrawBuildingsD3D(); pRenderer->RenderTerrainD3D(); + //pRenderer->DrawBezierTerrain(); } /*else {
--- a/Render.cpp Sat Mar 22 18:06:41 2014 +0600 +++ b/Render.cpp Sun Mar 23 19:55:59 2014 +0600 @@ -228,7 +228,7 @@ { int v6; // ecx@8 struct Polygon *pTilePolygon; // ebx@8 - float a3a; + float Light_tile_dist; //warning: the game uses CW culling by default, ccw is incosistent pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); @@ -286,7 +286,7 @@ } else if (direction >= 3.0 && direction < 5.0)//WestNorth(CЗ) - SouthWest(ЮЗ) { - Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 1; + Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; Start_Z = 0, End_Z = 127; } else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ЮЗ) - //SouthEast(ЮВ) @@ -359,9 +359,10 @@ norm = 0; else norm = &pTerrainNormals[norm_idx]; - //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows - //pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1); -//----------------------------------------------------------------------------------------------- + //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows + //pDecalBuilder->_49BE8A(pTilePolygon, norm, &Light_tile_dist, array_50AC10, 4, 1); + //unsigned int a5 = 4; +//---------------------------------------------------------------------------- ++pODMRenderParams->uNumPolygons; ++pODMRenderParams->field_44; @@ -387,6 +388,23 @@ || (double)pODMRenderParams->shading_dist_mist < array_73D150[1].vWorldViewPosition.x || (double)pODMRenderParams->shading_dist_mist < array_73D150[2].vWorldViewPosition.x || (double)pODMRenderParams->shading_dist_mist < array_73D150[3].vWorldViewPosition.x; + + /* int v33 = 0; + static stru154 static_sub_0048034E_stru_154; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( neer_clip ) + v33 = 3; + else + v33 = far_clip != 0 ? 5 : 0; + static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - pTilePolygon->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);*/ + if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) { //if ( neer_clip ) //Ritor1: Даёт искажения на подъёме, возможно требуется ф-ция Безье @@ -436,7 +454,6 @@ } } - //----- (004811A3) -------------------------------------------------------- void Render::DrawBorderTiles(struct Polygon *poly) { @@ -1026,9 +1043,9 @@ { if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) { - v14 = decor_desc->uColoredLightRed; - v15 = decor_desc->uColoredLightGreen; - v16 = decor_desc->uColoredLightBlue; + v14 = 255;//decor_desc->uColoredLightRed; + v15 = 255;//decor_desc->uColoredLightGreen; + v16 = 255;//decor_desc->uColoredLightBlue; } else {
--- a/Render.h Sat Mar 22 18:06:41 2014 +0600 +++ b/Render.h Sun Mar 23 19:55:59 2014 +0600 @@ -361,9 +361,9 @@ void PrepareDecorationsRenderList_ODM(); void DrawSpriteObjects_ODM(); void TransformBillboardsAndSetPalettesODM(); - //float DrawBezierTerrain(); + float DrawBezierTerrain(); void RenderTerrainD3D(); - //void DrawTerrainD3D(int a1, int edx0, int a3, int unk4); + void DrawTerrainD3D(int a1, int edx0, int a3, int unk4); //void DrawTerrainSW(int a1, int a2, int a3, int a4); //void ExecOutdoorDrawSW(); void ChangeBetweenWinFullscreenModes();
--- a/_deleted.cpp Sat Mar 22 18:06:41 2014 +0600 +++ b/_deleted.cpp Sun Mar 23 19:55:59 2014 +0600 @@ -2426,796 +2426,6 @@ return result; } -//----- (0047F5C6) -------------------------------------------------------- -float Render::DrawBezierTerrain() -{ - unsigned int pDirectionIndicator1; // ebx@1 - unsigned int pDirectionIndicator2; // edi@1 - unsigned int v2; // eax@1 - int v3; // eax@3 - int v4; // edi@3 - int v5; // ebx@3 - int v6; // esi@3 - unsigned int v7; // eax@3 - int v8; // eax@4 - unsigned int v9; // eax@6 - int v10; // eax@7 - //int v11; // ebx@9 - //int v12; // edi@9 - int v13; // eax@21 - int v14; // eax@31 - int v15; // edi@33 - int v16; // eax@34 - int v17; // edx@34 - int v18; // ebx@34 - int v19; // eax@36 - int v20; // eax@39 - int v21; // ecx@43 - //char v22; // zf@44 - int v23; // ecx@47 - //int v24; // edi@52 - int v25; // eax@54 - int v26; // ecx@54 - int v27; // eax@56 - int v28; // edx@60 - int v29; // ecx@61 - int v30; // ecx@64 - int v31; // ecx@68 - int v32; // eax@70 - //int v33; // ecx@71 - int v34; // eax@73 - int v35; // ecx@77 - int v36; // ecx@81 - int v37; // ecx@86 - int v38; // eax@88 - int v39; // ecx@88 - int v40; // eax@90 - int v41; // edx@94 - //int v42; // ecx@95 - int v43; // ecx@98 - int v44; // ecx@102 - int v45; // eax@104 - int v46; // eax@107 - int v47; // ecx@111 - int v48; // ecx@115 - int v49; // edi@120 - int v50; // eax@122 - int v51; // ecx@122 - int v52; // eax@124 - int v53; // edx@128 - int v54; // ecx@129 - int v55; // ecx@132 - int v56; // eax@139 - int v57; // ecx@140 - int v58; // eax@142 - int v59; // ecx@146 - //int v60; // ecx@147 - int v61; // ecx@150 - int v62; // ecx@155 - int v63; // eax@157 - int v64; // ecx@157 - int v65; // eax@159 - int v66; // edx@163 - int v67; // ecx@164 - int v68; // ecx@167 - //int v69; // eax@173 - int v70; // edi@178 - //int v71; // eax@178 - //int v72; // ecx@178 - //int x; // ebx@180 - //int v74; // eax@182 - //int v75; // eax@184 - IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 - int uStartZ; // ecx@184 - int v79; // ebx@185 - int v127; // esi@185 - int v86; // edi@196 - //int v87; // eax@196 - //int v88; // ecx@196 - //int v89; // eax@198 - //int v90; // ecx@200 - int v92; // ebx@203 - //int v93; // ST08_4@204 - int v97; // ST08_4@204 - float result; // eax@212 - //struct - //{ - int v106; // [sp+Ch] [bp-68h]@191 - int v103; // [sp+10h] [bp-64h]@190 - int v104; // [sp+12h] [bp-62h]@190 - //} v102; - int v105; // [sp+1Ch] [bp-58h]@1 - int v107; // [sp+20h] [bp-54h]@3 - int uEndZ; // [sp+24h] [bp-50h]@3 - int v108; // [sp+28h] [bp-4Ch]@9 - int v109; // [sp+2Ch] [bp-48h]@9 - int v110; // [sp+30h] [bp-44h]@9 - int v111; // [sp+34h] [bp-40h]@3 - int v112; // [sp+38h] [bp-3Ch]@6 - IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 - int v114; // [sp+40h] [bp-34h]@9 - int v115; // [sp+44h] [bp-30h]@9 - int v116; // [sp+48h] [bp-2Ch]@9 - //int v117; // [sp+4Ch] [bp-28h]@9 - int v118; // [sp+50h] [bp-24h]@9 - int v119; // [sp+54h] [bp-20h]@1 - int v120; // [sp+58h] [bp-1Ch]@1 - int i; // [sp+5Ch] [bp-18h]@1 - int v122; // [sp+60h] [bp-14h]@1 - int v123; // [sp+64h] [bp-10h]@1 - int v124; // [sp+68h] [bp-Ch]@1 - int v125; // [sp+6Ch] [bp-8h]@9 - int v126; // [sp+70h] [bp-4h]@9 - - v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 - pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 - pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 - v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88 - v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66 - v120 = pODMRenderParams->outdoor_grid_band_3 + v124;//+- range X - v119 = pODMRenderParams->outdoor_grid_band_3 + v123; - v2 = pODMRenderParams->uCameraFovInDegrees + 15;//90 - i = v124 - pODMRenderParams->outdoor_grid_band_3; - v122 = v123 - pODMRenderParams->outdoor_grid_band_3; - - if ( v2 > 90 ) - v2 = 90; - //v3 = (v2 << 11) / 720; - v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - ((v2 << 11) / 720)); - v5 = stru_5C6E00->uDoublePiMask & (((v2 << 11) / 720) + pDirectionIndicator1); - - v106 = stru_5C6E00->Cos(v4); - uEndZ = stru_5C6E00->Sin(v4); - - v111 = stru_5C6E00->Cos(v5); - v6 = stru_5C6E00->Sin(v5); - - v7 = v4 & stru_5C6E00->uPiMask; - if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) - v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; - else - v8 = stru_5C6E00->pTanTable[v7]; - v112 = abs(v8); - - v9 = v5 & stru_5C6E00->uPiMask; - if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) - v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; - else - v10 = stru_5C6E00->pTanTable[v9]; - v108 = abs(v10); - - //v11 = v124; - //v12 = v123; - v114 = 0; - v115 = 0; - pIndoorCameraD3D_4 = 0; - v125 = 0; - v126 = v124; - v118 = v123; - - v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; - v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; - uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; - v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; - - uint _i = 1; - uint j = 1; - - terrain_76DDC8[0] = -1; - terrain_76DFC8[0] = -1; - terrain_76E1C8[0] = -1; - terrain_76E3C8[0] = -1; - - for( uint _i = 1; _i < 128; _i++) - { - if ( v112 >= 0x10000 ) - { - int v1, v2; - //v111 = 4294967296i64 / v112; - //v114 += v111; - //if ( v114 >= 65536 ) - //{ - // v11 += v110; - // v114 = (unsigned __int16)v114; - //} - //v12 += v109; - } - else - { - v124 += v110; - v115 += v112; - if ( v112 + v115 >= 65536 ) - { - v123 += v109; - v115 = (unsigned __int16)v115; - } - } - if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 ) - break; - //v13 = v116++; - terrain_76E3C8[_i] = v124; - terrain_76E1C8[_i] = v123; - } - - for( j = 1; j < 128; j++ ) - { - if ( v108 >= 65536 ) - { - v111 = 4294967296i64 / v108; - v114 += v111;// - if ( v111 + v114 >= 65536 ) - { - v126 += uEndZ; - v114 = (unsigned __int16)v114;// - } - v118 += v106; - } - else - { - v125 += v108; - v126 += uEndZ; - if ( v125 >= 65536 ) - { - v118 += v106; - v125 = (unsigned __int16)v125; - } - } - //if ( v117 >= 128 ) - //break; - if ( v126 < _i ) - break; - if ( v126 > v120 ) - break; - v14 = v118; - if ( v118 < v122 ) - break; - if ( v118 > v119 ) - break; - terrain_76DFC8[j] = v126; - terrain_76DDC8[j] = v14; - } - v16 = 0; - v126 = 0; - v17 = j - 1; - v18 = _i - 1; - - switch ( v105 )//напрвление камеры - { - case 0: - case 7: - { - //v116 = terrain_76DFC8[v17]; - if ( v120 > terrain_76DFC8[v17] ) - { - v125 = v120; - memset32(terrain_76D9C8.data(), v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1)); - v19 = v120; - do - terrain_76DBC8[v126++] = v19--; - while ( v19 >= terrain_76DFC8[v17] ); - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) - { - do - v20 = terrain_76DDC8[v17-- -1]; - while ( v20 == terrain_76DDC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - - //while ( 1 ) - for ( v21 = terrain_76DFC8[v17]; v21 < v124; v21 = terrain_76DFC8[v17] - 1; ) - { - //v125 = terrain_76DFC8[v17]; - terrain_76DBC8[v16] = v21; - //v22 = terrain_76DDC8[v17] == 65535; - terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; - if ( terrain_76DDC8[v17] == 65535 ) - { - terrain_76D9C8[v16] = v123 + 1; - break; - } - if ( !v17 ) - break; - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) - { - do - v23 = terrain_76DDC8[v17-- -1]; - while ( v23 == terrain_76DDC8[v17 -1] ); - } - --v17; - ++v16; - } - v16 = 0; - //v24 = terrain_76E3C8[v18]; - v126 = 0; - if ( v120 > terrain_76E3C8[v18] ) - { - v125 = v120; - memset32(terrain_76D5C8.data(), v122, 4 * (v120 - terrain_76E3C8[v18] + 1)); - do - { - v25 = v126; - v26 = v125--; - ++v126; - terrain_76D7C8[v25] = v26; - } - while ( v125 >= terrain_76E3C8[v18] ); - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v27 = terrain_76E1C8[v18-- -1]; - while ( v27 == terrain_76E1C8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v28 = terrain_76E3C8[v18]; - while ( v28 >= v124 ) - { - v29 = terrain_76E1C8[v18]; - terrain_76D7C8[v16] = v28; - terrain_76D5C8[v16] = v29; - if ( v29 == 65535 ) - { - v31 = v123; - terrain_76D5C8[v16] = v31; - break; - } - if ( !v18 ) - break; - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v30 = terrain_76E1C8[v18-- -1]; - while ( v30 == terrain_76E1C8[v18 -1] ); - } - --v18; - --v28; - ++v16; - } - break; - } - case 1: - case 2: - { - //v116 = terrain_76DDC8[v17]; - if ( v122 < terrain_76DDC8[v17] ) - { - v106 = v122; - memset32(terrain_76DBC8.data(), v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); - for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++) - terrain_76D9C8[v126++] = v32; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v34 = terrain_76DBC8[v17-- -1]; - while ( v34 == terrain_76DBC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v35 = terrain_76DDC8[v17]; - v125 = terrain_76DDC8[v17]; - while ( v35 <= v123 ) - { - //v22 = terrain_76DFC8[v17] == 65535; - terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; - terrain_76D9C8[v16] = v125; - if ( terrain_76DFC8[v17] == 65535 ) - { - terrain_76DBC8[v16] = v124 + 1; - break; - } - if ( !v17 ) - break; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v36 = terrain_76DBC8[v17-- -1]; - while ( v36 == terrain_76DBC8[v17 -1] ); - } - --v17; - ++v125; - v35 = v125; - ++v16; - } - v16 = 0; - v126 = 0; - v37 = terrain_76E1C8[v18]; - if ( v122 < v37 ) - { - v114 = v122; - memset32(terrain_76D7C8.data(), i, 4 * (v37 - v122 + 1)); - do - { - v38 = v126; - v39 = v114; - ++v126; - ++v114; - terrain_76D5C8[v38] = v39; - } - while ( v114 <= terrain_76E1C8[v18] ); - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v40 = terrain_76DFC8[v18-- -1]; - while ( v40 == terrain_76DFC8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v41 = terrain_76E1C8[v18]; - while ( v41 <= v123 ) - { - terrain_76D5C8[v16] = v41; - terrain_76D7C8[v16] = terrain_76E3C8[v18]; - if ( terrain_76E3C8[v18] == 65535 ) - { - terrain_76D7C8[v16] = v124; - break; - } - if ( !v18 ) - break; - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v43 = terrain_76DFC8[v18-- -1]; - while ( v43 == terrain_76DFC8[v18 -1] ); - } - --v18; - ++v41; - ++v16; - } - break; - } - case 5: - case 6: - { - //v116 = terrain_76DDC8[v17]; - if ( v119 > terrain_76DDC8[v17] ) - { - v106 = v119; - memset32(terrain_76DBC8.data(), i, 4 * (v119 - terrain_76DDC8[v17] + 1)); - for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--) - terrain_76D9C8[v126++] = v45; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v46 = terrain_76DBC8[v17-- -1]; - while ( v46 == terrain_76DBC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v47 = terrain_76DDC8[v17]; - v125 = terrain_76DDC8[v17]; - while ( v47 >= v123 ) - { - //v22 = terrain_76DFC8[v17] == 65535; - terrain_76DBC8[v16] = terrain_76DFC8[v17]; - terrain_76D9C8[v16] = terrain_76DDC8[v17]; - if ( terrain_76DFC8[v17] == 65535 ) - { - terrain_76DBC8[v16] = v124; - break; - } - if ( !v17 ) - break; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v48 = terrain_76DBC8[v17-- -1]; - while ( v48 == terrain_76DBC8[v17 -1] ); - } - --v17; - --v125; - v47 = v125; - ++v16; - } - v16 = 0; - v49 = terrain_76E1C8[v18]; - v126 = 0; - if ( v119 > v49 ) - { - v125 = v119; - memset32(terrain_76D7C8.data(), v120 + 1, 4 * (v119 - v49 + 1)); - do - { - v50 = v126; - v51 = v125--; - ++v126; - terrain_76D5C8[v50] = v51; - } - while ( v125 >= terrain_76E1C8[v18] ); - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v52 = terrain_76DFC8[v18-- -1]; - while ( v52 == terrain_76DFC8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v53 = terrain_76E1C8[v18]; - while ( v53 >= v123 ) - { - v54 = terrain_76E3C8[v18]; - terrain_76D5C8[v16] = v53; - terrain_76D7C8[v16] = v54 + 1; - if ( v54 == 65535 ) - { - terrain_76D7C8[v16] = v124 + 1; - break; - } - if ( !v18 ) - break; - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v55 = terrain_76DFC8[v18-- -1]; - while ( v55 == terrain_76DFC8[v18 -1] ); - } - --v18; - --v53; - ++v16; - } - break; - } - case 3: - case 4: - { - //v116 = terrain_76DFC8[v17]; - if ( i < terrain_76DFC8[v17] ) - { - v106 = i; - memset32(terrain_76D9C8.data(), v122, 4 * (terrain_76DFC8[v17] - i + 1)); - v56 = i; - do - { - v57 = v126++; - terrain_76DBC8[v57] = v56++; - } - while ( v56 <= terrain_76DFC8[v17] ); - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) - { - do - v58 = terrain_76DDC8[v17-- -1]; - while ( v58 == terrain_76DDC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v59 = terrain_76DFC8[v17]; - while ( 1 ) - { - v125 = terrain_76DFC8[v17]; - if ( terrain_76DFC8[v17] > v124 ) - break; - terrain_76DBC8[v16] = terrain_76DFC8[v17]; - //v60 = terrain_76DDC8[v17]; - terrain_76D9C8[v16] = terrain_76DDC8[v17]; - if ( terrain_76DDC8[v17] == 65535 ) - { - terrain_76D9C8[v16] = v123; - break; - } - if ( !v17 ) - break; - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) - { - do - v61 = terrain_76DDC8[v17-- -1]; - while ( v61 == terrain_76DDC8[v17 -1] ); - } - --v17; - v59 = v125 + 1; - ++v16; - } - v16 = 0; - v126 = 0; - v62 = terrain_76E3C8[v18]; - if ( i < v62 ) - { - v114 = i; - memset32(terrain_76D5C8.data(), v119 + 1, 4 * (v62 - i + 1)); - do - { - v63 = v126; - v64 = v114; - ++v126; - ++v114; - terrain_76D7C8[v63] = v64; - } - while ( v114 <= terrain_76E3C8[v18] ); - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v65 = terrain_76E1C8[v18-- -1]; - while ( v65 == terrain_76E1C8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v66 = terrain_76E3C8[v18]; - while ( v66 <= v124 ) - { - v67 = terrain_76E1C8[v18]; - terrain_76D7C8[v16] = v66; - terrain_76D5C8[v16] = terrain_76E1C8[v18] + 1; - if ( terrain_76E1C8[v18] == 65535 ) - { - v31 = v123 + 1; - terrain_76D5C8[v16] = v31; - break; - } - if ( !v18 ) - break; - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v68 = terrain_76E1C8[v18-- -1]; - while ( v68 == terrain_76E1C8[v18 -1] ); - } - --v18; - ++v66; - ++v16; - } - break; - } - default: - break; - } - //v69 = v16 - 1; - ptr_801A08 = pVerticesSR_806210; - ptr_801A04 = pVerticesSR_801A10; - //v126 = v69; - - if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//блок, ориентация камеры 1(СВ), 2(С), 5(ЮЗ), 6(Ю) - { - for ( i = v16 - 1; i >= 1; --i ) - { - //v70 = i; - //v71 = terrain_76D7C8[i];//88 - //v72 = terrain_76DBC8[i];//0 - if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap - { - terrain_76DBC8[i] = terrain_76D7C8[i]; - terrain_76D7C8[i] = terrain_76DBC8[i]; - } - //x = terrain_76DBC8[i];//0 - v111 = 0; - if ( terrain_76DBC8[i] <= 0 ) - terrain_76DBC8[i] = -terrain_76DBC8[i]; - //v74 = terrain_76D7C8[i]; - if ( terrain_76D7C8[i] <= 0 ) - terrain_76D7C8[i] = -terrain_76D7C8[i]; - uEndZ = terrain_76D7C8[i] + 2; - //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; - //uEndZ = v75; - //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; - uStartZ = terrain_76DBC8[i] - 2; - if ( terrain_76DBC8[i] - 2 < uEndZ ) - { - v127 = 0; - //v79 = (v73 - 66) << 9; - //v116 = v77; - //pHeight = v79; - v111 = uEndZ - uStartZ; - for (int z = uStartZ; z < uEndZ; ++z) - { - ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; - ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; - ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); - - ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; - ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; - ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); - - if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) - { - pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); - pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); - - pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); - pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); - } - //v79 += 512; - v127 ++; - //++v116; - //pHeight = v79; - } - //while ( v116 < v107 ); - } - v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); - v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); - if ( pRenderer->pRenderD3D )//Ritor1: do comment to test - Render::DrawTerrainD3D(v111, 0, v103, v104); - //Render::RenderTerrainD3D(); - else - Render::DrawTerrainSW(v111, 0, v103, v104); - } - } - else//ориентация камеры 0(В), 3(СЗ), 4(З), 7(ЮВ) - { - for ( i = v16 - 1; i >= 1; --i ) - { - //v86 = i; - //v87 = terrain_76D5C8[i]; - //v88 = terrain_76D9C8[i]; - if ( terrain_76D5C8[i] < terrain_76D9C8[i] ) - { - terrain_76D9C8[i] = terrain_76D5C8[i]; - terrain_76D5C8[i] = terrain_76D9C8[i]; - } - //v89 = terrain_76D9C8[i]; - v111 = 0; - if ( terrain_76D9C8[i] <= 0 ) - terrain_76D9C8[i] = -terrain_76D9C8[i]; - //v90 = terrain_76D5C8[i]; - if ( terrain_76D5C8[i] <= 0 ) - terrain_76D5C8[i] = -terrain_76D5C8[i]; - pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; - v107 = terrain_76D5C8[i] + 2; - if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 ) - { - v86 = 0; - //v116 = terrain_76D9C8[i] - 2; - v92 = (66 - terrain_76D9C8[i]) << 9; - //pHeight = (66 - terrain_76D9C8[i]) << 9; - v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2); - //do - for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) - { - ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9; - ptr_801A08[v86].vWorldPosition.y = v92; - ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); - - ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9; - ptr_801A04[v86].vWorldPosition.y = v92; - ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); - if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) - { - pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); - pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); - pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); - pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); - } - v92 -= 512; - v86 += 48; - //++v116; - //pHeight = v92; - } - //while ( v116 < v107 ); - } - v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); - v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); - if ( pRenderer->pRenderD3D ) - Render::DrawTerrainD3D(v111, 1, v103, v104); - else - Render::DrawTerrainSW(v111, 1, v103, v104); - } - } - result = v126; - pODMRenderParams->field_40 = v126; - return result; -} //----- (00482E07) -------------------------------------------------------- signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget) { @@ -8527,589 +7737,7 @@ return result; } -//----- (0048034E) -------------------------------------------------------- -void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) -{ - //int v3; // esi@1 - int v4; // edi@1 - int v5; // ebx@2 - int v6; // eax@2 - int v7; // eax@3 - RenderVertexSoft *v8; // edi@3 - RenderVertexSoft *v9; // ebx@4 - RenderVertexSoft *v10; // ecx@4 - float v11; // eax@6 - double v12; // ST5C_8@6 - double v13; // ST2C_8@6 - int v14; // eax@6 - double v15; // st7@6 - struct Polygon *pTile; // ebx@12 - unsigned __int16 v17; // ax@12 - int v18; // eax@13 - signed int v22; // eax@13 - Vec3_float_ *norm; // eax@15 - //double v24; // st6@17 - double v25; // ST54_8@17 - unsigned __int8 v26; // sf@17 - unsigned __int8 v27; // of@17 - double v28; // st5@19 - double v29; // st5@19 - double v30; // st5@19 - double v31; // st5@19 - struct struct8 *v32; // esi@21 - double v3a; // st7@32 - int v33; // edi@38 - unsigned int v34; // ecx@47 - char v35; // zf@47 - unsigned int v36; // eax@50 - int v37; // eax@54 - //Polygon *v38; // ecx@55 - unsigned int v39; // eax@59 - struct Polygon *v40; // ebx@62 - unsigned __int16 pTileBitmapsID; // ax@62 - int v42; // eax@63 - LightmapBuilder *v43; // ecx@63 - int v44; // eax@63 - int v45; // eax@63 - int v46; // eax@63 - signed int v47; // eax@63 - Vec3_float_ *v48; // eax@65 - double v49; // st6@67 - double v50; // ST4C_8@67 - double v51; // st5@71 - double v52; // st5@71 - double v53; // st5@71 - double v54; // st7@84 - unsigned int v55; // ecx@98 - unsigned int v56; // eax@101 - int v57; // eax@105 - unsigned int v58; // eax@109 - struct Polygon *v59; // esi@112 - unsigned __int16 v60; // ax@112 - int v61; // eax@113 - signed int v62; // eax@113 - Vec3_float_ *v63; // eax@114 - double v64; // st6@116 - double v65; // ST3C_8@116 - double v66; // st5@120 - double v67; // st5@120 - double v68; // st5@120 - double v69; // st7@133 - int v70; // edi@138 - struct Polygon *v71; // esi@147 - unsigned int v72; // ecx@147 - unsigned int v73; // eax@150 - int v74; // eax@154 - unsigned int v75; // eax@158 - //unsigned int v76; // [sp-10h] [bp-E0h]@61 - int v77; // [sp-Ch] [bp-DCh]@61 - IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 - //int v79; // [sp-4h] [bp-D4h]@61 - bool v80; // [sp+0h] [bp-D0h]@59 - bool v81; // [sp+0h] [bp-D0h]@109 - int v82; // [sp+54h] [bp-7Ch]@1 - int v83; // [sp+60h] [bp-70h]@1 - int v84; // [sp+6Ch] [bp-64h]@1 - int v85; // [sp+70h] [bp-60h]@63 - float a4; // [sp+74h] [bp-5Ch]@73 - float v87; // [sp+78h] [bp-58h]@122 - int v88; // [sp+7Ch] [bp-54h]@1 - int v89; // [sp+80h] [bp-50h]@6 - int v93; // [sp+90h] [bp-40h]@2 - int X; // [sp+94h] [bp-3Ch]@1 - float v95; // [sp+98h] [bp-38h]@21 - LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 - int v97; // [sp+A0h] [bp-30h]@6 - int sX; // [sp+A4h] [bp-2Ch]@6 - unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 - int v100; // [sp+ACh] [bp-24h]@122 - int sY; // [sp+B0h] [bp-20h]@6 - RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 - unsigned int a5; // [sp+B8h] [bp-18h]@21 - RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 - Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 - RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 - RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 - char v108; // [sp+CFh] [bp-1h]@36 - float thisd; // [sp+D8h] [bp+8h]@6 - float thise; // [sp+D8h] [bp+8h]@6 - float thisf; // [sp+D8h] [bp+8h]@17 - IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 - float thisg; // [sp+D8h] [bp+8h]@67 - IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 - float thish; // [sp+D8h] [bp+8h]@116 - IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 - char this_3; // [sp+DBh] [bp+Bh]@30 - char this_3a; // [sp+DBh] [bp+Bh]@82 - char this_3b; // [sp+DBh] [bp+Bh]@131 - - __debugbreak(); - static stru154 static_sub_0048034E_stru_154; - static stru154 stru_76D5A8; - //v3 = a1; - v82 = a2; - v83 = a3; - X = abs(unk4); - v4 = 0; - v88 = 0; - v84 = a1 - 1; - if ( a1 - 1 > 0 ) - { - while ( 1 ) - { - v5 = abs(X);//v5 = 13108 - v6 = abs(v83);//v6 = 13108 - --X; - //__debugbreak(); // uncoment & refactor following large if - v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; - if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), - v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), - ((a8 = v9, - pVertices = &pVerticesSR_801A10[1] + v7, - v11 = v8->vWorldPosition.x, - v101 = v10, - v12 = v11 + 6.755399441055744e15, - sX = LODWORD(v12), - v13 = v8->vWorldPosition.y + 6.755399441055744e15, - sY = LODWORD(v13), - thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, - v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X - v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, - v89 = v14, - thise = v15 * 0.5, - _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z - WorldPosToGridCellX(sX), - WorldPosToGridCellZ(sY), - !byte_4D864C) - || !(pGame->uFlags & 0x80)) - && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) ) - if ( !&terrain_76E5C8[(v5 << 7) + v6] ) - goto LABEL_162 - v8 = &pVerticesSR_806210[v4]; - //pVertices2 = &pVerticesSR_801A10[v4 + 1]; - //v102 = v8; - if (!v82) - { - pVertices = &pVerticesSR_801A10[v4]; - v101 = &pVerticesSR_806210[v4 + 1]; - } - else - { - pVertices = &pVerticesSR_801A10[v4 + 1]; - v101 = &pVerticesSR_806210[v4]; - } - sX = floorf(v8->vWorldPosition.x + 0.5f); - sY = floorf(v8->vWorldPosition.z + 0.5f); - v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); - v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); - /*WorldPosToGridCellX(sX); - WorldPosToGridCellZ(sY); - if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) - if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y - || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) - break; - pTile = &array_77EC08[pODMRenderParams->uNumPolygons]; - pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( pTile->uTileBitmapID != -1 ) - { - pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); - pTile->field_32 = 0; - pTile->field_59 = 1; - pTile->terrain_grid_x = (char)v97; - __debugbreak(); // warning C4700: uninitialized local variable 'v93' used - pTile->field_34 = *(_WORD *)(v93 + 2); - pTile->terrain_grid_z = v89; - v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; - if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) - norm = 0; - else - norm = &pTerrainNormals[v22]; - thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - - (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - - (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; - //v25 = thisf + 6.7553994e15; - //v27 = pODMRenderParams->uNumPolygons > 1999; - //v26 = pODMRenderParams->uNumPolygons - 1999 < 0; - pTile->dimming_level = floorf(thisf + 0.5f); - if ( pODMRenderParams->uNumPolygons >= 1999 ) - return; - ++pODMRenderParams->uNumPolygons; - //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary - //goto LABEL_126; - //{ - //--pODMRenderParams->uNumPolygons; - //goto LABEL_162; - //} - __debugbreak(); // warning C4700: uninitialized local variable 'v102' used - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); - array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[3].u = 1.0; - array_50AC10[3].v = 0.0; - if ( !(_76D5C0_static_init_flag & 1) ) - { - _76D5C0_static_init_flag |= 1u; - stru154(stru_76D5A8); - atexit(loc_481199); - } - v32 = (struct8 *)array_50AC10; - v97 = (int)pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); - pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); - a5 = 4; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisa = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) - goto LABEL_162; - thisa->ViewTransform(array_50AC10, a5); - thisa->Project(array_50AC10, a5, 0); - } - this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v3a = (double)pODMRenderParams->shading_dist_mist; - v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x - || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; - v33 = 0; - pGame->pLightmapBuilder->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3 ) - v33 = 3; - else - v33 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); - v34 = a5; - //v35 = byte_4D864C == 0; - pTile->uNumVertices = a5; - if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) - { - if ( this_3 ) - { - v36 = ODM_NearClip(v34); - pTile->uNumVertices = v36; - ODMRenderParams::Project(v36); - } - if ( v108 ) - { - v36 = sr_424EE0_MakeFanFromTriangle(v34); - pTile->uNumVertices = v36; - ODMRenderParams::Project(v36); - } - } - //v37 = *(int *)&v16->flags; - if ( ~pTile->flags & 1 ) - { - if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v39 = pTile->uTileBitmapID; - v80 = true; - } - //v79 = 0; - //v78 = pBitmaps_LOD->pHardwareTextures[v39]; - pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary - v77 = (int)pTile; - //v76 = v16->uNumVertices; -//LABEL_161: - pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); - goto LABEL_162; - } -LABEL_56: - pTile->DrawBorderTiles(); - } -LABEL_162: - v4 = v88 + 1; - if ( ++v88 >= v84 ) - return; - } - v40 = &array_77EC08[pODMRenderParams->uNumPolygons]; - v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v40->uTileBitmapID == -1 ) - goto LABEL_162; - v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); - BYTE1(v42) |= 0x80u; - v43 = pGame->pLightmapBuilder; - *(int *)&v40->flags = v42; - v44 = v93; - v40->field_59 = 1; - v40->terrain_grid_x = (char)v43; - v40->field_34 = *(_WORD *)(v44 + 2); - v45 = v89; - v40->terrain_grid_z = v89; - v46 = 4 * ((char)v43 + (v45 << 7)); - v85 = v46; - v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; - if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) - v48 = 0; - else - v48 = &pTerrainNormals[v47]; - v49 = v92 * v48->y; - //v99 = v48; - thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; - v50 = thisg + 6.755399441055744e15; - v40->dimming_level = LOBYTE(v50); - if ( LOBYTE(v50) < 0 ) - v40->dimming_level = 0; - if ( pODMRenderParams->uNumPolygons >= 1999 ) - return; - ++pODMRenderParams->uNumPolygons; - if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary - //goto LABEL_77; - { - --pODMRenderParams->uNumPolygons; - goto LABEL_112; - } - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - static stru154 static_sub_0048034E_stru_76D590; - static bool __init_flag2 = false; - if (!__init_flag2) - { - __init_flag2 = true; - stru154::stru154(&static_sub_0048034E_stru_76D590); - } - if ( !(_76D5C0_static_init_flag & 2) ) - { - _76D5C0_static_init_flag |= 2; - Polygon(stru_76D590); - atexit(loc_48118F); - } - v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); - pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); - uNumVertices = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisb = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) - { -//LABEL_77: - --pODMRenderParams->uNumPolygons; - goto LABEL_112; - } - thisb->ViewTransform(array_50AC10, uNumVertices); - thisb->Project(array_50AC10, uNumVertices, 0); - } - this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v54 = (double)pODMRenderParams->shading_dist_mist; - v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; - pVertices = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3a ) - pVertices = (RenderVertexSoft *)3; - else - pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); - //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); - static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); - v55 = uNumVertices; - //v35 = byte_4D864C == 0; - v40->uNumVertices = uNumVertices; - if ( !_76D5C0_static_init_flag || !(pGame->uFlags & 0x80) ) - { - if ( this_3a ) - { - v56 = ODM_NearClip(v55); - } - else - { - if ( !v108 ) - goto LABEL_105; - v56 = sr_424EE0_MakeFanFromTriangle(v55); - } - v40->uNumVertices = v56; - ODMRenderParams::Project(v56); - } -LABEL_105: - v57 = *(int *)&v40->flags; - if ( BYTE1(v57) & 1 ) - { - v40->DrawBorderTiles(); - } - else - { - if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v81 = false; - v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v58 = v40->uTileBitmapID; - v81 = true; - } - pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); - } -LABEL_112: - v59 = &array_77EC08[pODMRenderParams->uNumPolygons]; - //a8 = (RenderVertexSoft *)&array_77EC08[pODMRenderParams->uNumPolygons]; - v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v59->uTileBitmapID == -1 ) - goto LABEL_162; - *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); - v61 = v93; - v59->field_59 = 1; - v59->field_34 = *(_WORD *)(v61 + 2); - v59->terrain_grid_z = v89; - v59->terrain_grid_x = v97; - v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); - if ( v62 > (signed int)(uNumTerrainNormals - 1) ) - v63 = 0; - else - v63 = &pTerrainNormals[v62]; - v64 = v92 * v63->y; - //v99 = v63; - thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; - v59->dimming_level = floorf(thish + 0.5f); - if ( v59->dimming_level < 0 ) - v59->dimming_level = 0; - if ( pODMRenderParams->uNumPolygons >= 1999 ) - return; - ++pODMRenderParams->uNumPolygons; - if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) - { -//LABEL_126: - --pODMRenderParams->uNumPolygons; - goto LABEL_162; - } - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 1.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 0.0; - static stru154 static_sub_0048034E_stru_76D578; - static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; - stru154::stru154(&static_sub_0048034E_stru_76D578); - } - v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); - pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); - v100 = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisc = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) - //goto LABEL_126; - { - --pODMRenderParams->uNumPolygons; - goto LABEL_162; - } - thisc->ViewTransform(array_50AC10, v100); - thisc->Project(array_50AC10, v100, 0); - } - this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0; - v69 = (double)pODMRenderParams->shading_dist_mist; - v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; - v70 = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3b ) - v70 = 3; - else - v70 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); - v71 = v59; - v72 = v100; - //v35 = byte_4D864C == 0; - v59->uNumVertices = v100;//??? - if ( !byte_4D864C && pGame->uFlags & 0x80 ) - goto LABEL_154; - if ( this_3b ) - { - v73 = ODM_NearClip(v72); - } - else - { - if ( !v108 ) - { -LABEL_154: - v74 = v71->flags; - if ( !(BYTE1(v74) & 1) ) - { - if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v75 = v71->uTileBitmapID; - v80 = true; - } - //v79 = 0; - v78 = pBitmaps_LOD->pHardwareTextures[v75]; - v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary - //v77 = (int)v71; - //v76 = v71->uNumVertices; - //goto LABEL_161; - pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); - goto LABEL_162; - } - v38 = (Polygon *)v71; - goto LABEL_56; - } - v73 = sr_424EE0_MakeFanFromTriangle(v72); - } - v71->uNumVertices = v73; - ODMRenderParams::Project(v73); - goto LABEL_154; - } - } + //----- (00424579) -------------------------------------------------------- int __fastcall sr_424579(int uFaceID, stru320 *a2) { @@ -14642,5 +13270,1378 @@ } return result; } - +//----- (0047F5C6) -------------------------------------------------------- +float Render::DrawBezierTerrain() +{ + unsigned int pDirectionIndicator1; // ebx@1 + unsigned int pDirectionIndicator2; // edi@1 + unsigned int v2; // eax@1 + int v3; // eax@3 + int v4; // edi@3 + int v5; // ebx@3 + int v6; // esi@3 + unsigned int v7; // eax@3 + int v8; // eax@4 + unsigned int v9; // eax@6 + int v10; // eax@7 + //int v11; // ebx@9 + //int v12; // edi@9 + int v13; // eax@21 + int v14; // eax@31 + int v15; // edi@33 + int v16; // eax@34 + int v17; // edx@34 + int v18; // ebx@34 + int v19; // eax@36 + int v20; // eax@39 + int v21; // ecx@43 + //char v22; // zf@44 + int v23; // ecx@47 + //int v24; // edi@52 + int v25; // eax@54 + int v26; // ecx@54 + int v27; // eax@56 + int v28; // edx@60 + int v29; // ecx@61 + int v30; // ecx@64 + int v31; // ecx@68 + int v32; // eax@70 + //int v33; // ecx@71 + int v34; // eax@73 + int v35; // ecx@77 + int v36; // ecx@81 + int v37; // ecx@86 + int v38; // eax@88 + int v39; // ecx@88 + int v40; // eax@90 + int v41; // edx@94 + //int v42; // ecx@95 + int v43; // ecx@98 + int v44; // ecx@102 + int v45; // eax@104 + int v46; // eax@107 + int v47; // ecx@111 + int v48; // ecx@115 + int v49; // edi@120 + int v50; // eax@122 + int v51; // ecx@122 + int v52; // eax@124 + int v53; // edx@128 + int v54; // ecx@129 + int v55; // ecx@132 + int v56; // eax@139 + int v57; // ecx@140 + int v58; // eax@142 + int v59; // ecx@146 + //int v60; // ecx@147 + int v61; // ecx@150 + int v62; // ecx@155 + int v63; // eax@157 + int v64; // ecx@157 + int v65; // eax@159 + int v66; // edx@163 + int v67; // ecx@164 + int v68; // ecx@167 + //int v69; // eax@173 + int v70; // edi@178 + //int v71; // eax@178 + //int v72; // ecx@178 + //int x; // ebx@180 + //int v74; // eax@182 + //int v75; // eax@184 + IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 + int uStartZ; // ecx@184 + int v79; // ebx@185 + int v127; // esi@185 + int v86; // edi@196 + //int v87; // eax@196 + //int v88; // ecx@196 + //int v89; // eax@198 + //int v90; // ecx@200 + int v92; // ebx@203 + //int v93; // ST08_4@204 + int v97; // ST08_4@204 + float result; // eax@212 + //struct + //{ + int v106; // [sp+Ch] [bp-68h]@191 + int v103; // [sp+10h] [bp-64h]@190 + int v104; // [sp+12h] [bp-62h]@190 + //} v102; + int v105; // [sp+1Ch] [bp-58h]@1 + int v107; // [sp+20h] [bp-54h]@3 + int uEndZ; // [sp+24h] [bp-50h]@3 + int v108; // [sp+28h] [bp-4Ch]@9 + int v109; // [sp+2Ch] [bp-48h]@9 + int v110; // [sp+30h] [bp-44h]@9 + int v111; // [sp+34h] [bp-40h]@3 + int v112; // [sp+38h] [bp-3Ch]@6 + IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 + int v114; // [sp+40h] [bp-34h]@9 + int v115; // [sp+44h] [bp-30h]@9 + int v116; // [sp+48h] [bp-2Ch]@9 + //int v117; // [sp+4Ch] [bp-28h]@9 + int v118; // [sp+50h] [bp-24h]@9 + int v119; // [sp+54h] [bp-20h]@1 + int v120; // [sp+58h] [bp-1Ch]@1 + int i; // [sp+5Ch] [bp-18h]@1 + int v122; // [sp+60h] [bp-14h]@1 + int v123; // [sp+64h] [bp-10h]@1 + int v124; // [sp+68h] [bp-Ch]@1 + int v125; // [sp+6Ch] [bp-8h]@9 + int v126; // [sp+70h] [bp-4h]@9 + + v105 = pGame->pIndoorCameraD3D->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 + pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pGame->pIndoorCameraD3D->sRotationY);//1536 + pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 + v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88 + v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66 + v120 = pODMRenderParams->outdoor_grid_band_3 + v124;//+- range X + v119 = pODMRenderParams->outdoor_grid_band_3 + v123; + v2 = pODMRenderParams->uCameraFovInDegrees + 15;//90 + i = v124 - pODMRenderParams->outdoor_grid_band_3; + v122 = v123 - pODMRenderParams->outdoor_grid_band_3; + + if ( v2 > 90 ) + v2 = 90; + //v3 = (v2 << 11) / 720; + v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - ((v2 << 11) / 720)); + v5 = stru_5C6E00->uDoublePiMask & (((v2 << 11) / 720) + pDirectionIndicator1); + + v106 = stru_5C6E00->Cos(v4); + uEndZ = stru_5C6E00->Sin(v4); + + v111 = stru_5C6E00->Cos(v5); + v6 = stru_5C6E00->Sin(v5); + + v7 = v4 & stru_5C6E00->uPiMask; + if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) + v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; + else + v8 = stru_5C6E00->pTanTable[v7]; + v112 = abs(v8); + + v9 = v5 & stru_5C6E00->uPiMask; + if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) + v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; + else + v10 = stru_5C6E00->pTanTable[v9]; + v108 = abs(v10); + + //v11 = v124; + //v12 = v123; + v114 = 0; + v115 = 0; + pIndoorCameraD3D_4 = 0; + v125 = 0; + v126 = v124; + v118 = v123; + + v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; + v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; + uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; + v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; + + uint _i = 1; + uint j = 1; + + terrain_76DDC8[0] = -1; + terrain_76DFC8[0] = -1; + terrain_76E1C8[0] = -1; + terrain_76E3C8[0] = -1; + + for( uint _i = 1; _i < 128; _i++) + { + if ( v112 >= 0x10000 ) + { + int v1, v2; + //v111 = 4294967296i64 / v112; + //v114 += v111; + //if ( v114 >= 65536 ) + //{ + // v11 += v110; + // v114 = (unsigned __int16)v114; + //} + //v12 += v109; + } + else + { + v124 += v110; + v115 += v112; + if ( v112 + v115 >= 65536 ) + { + v123 += v109; + v115 = (unsigned __int16)v115; + } + } + if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 ) + break; + //v13 = v116++; + terrain_76E3C8[_i] = v124; + terrain_76E1C8[_i] = v123; + } + + for( j = 1; j < 128; j++ ) + { + if ( v108 >= 65536 ) + { + v111 = 4294967296i64 / v108; + v114 += v111;// + if ( v111 + v114 >= 65536 ) + { + v126 += uEndZ; + v114 = (unsigned __int16)v114;// + } + v118 += v106; + } + else + { + v125 += v108; + v126 += uEndZ; + if ( v125 >= 65536 ) + { + v118 += v106; + v125 = (unsigned __int16)v125; + } + } + //if ( v117 >= 128 ) + //break; + if ( v126 < _i ) + break; + if ( v126 > v120 ) + break; + v14 = v118; + if ( v118 < v122 ) + break; + if ( v118 > v119 ) + break; + terrain_76DFC8[j] = v126; + terrain_76DDC8[j] = v14; + } + v16 = 0; + v126 = 0; + v17 = j - 1; + v18 = _i - 1; + + switch ( v105 )//напрвление камеры + { + case 0: + case 7: + { + //v116 = terrain_76DFC8[v17]; + if ( v120 > terrain_76DFC8[v17] ) + { + v125 = v120; + memset32(terrain_76D9C8.data(), v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1)); + v19 = v120; + do + terrain_76DBC8[v126++] = v19--; + while ( v19 >= terrain_76DFC8[v17] ); + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) + { + do + v20 = terrain_76DDC8[v17-- -1]; + while ( v20 == terrain_76DDC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + + //while ( 1 ) + for ( v21 = terrain_76DFC8[v17]; v21 < v124; v21 = terrain_76DFC8[v17] - 1; ) + { + //v125 = terrain_76DFC8[v17]; + terrain_76DBC8[v16] = v21; + //v22 = terrain_76DDC8[v17] == 65535; + terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; + if ( terrain_76DDC8[v17] == 65535 ) + { + terrain_76D9C8[v16] = v123 + 1; + break; + } + if ( !v17 ) + break; + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) + { + do + v23 = terrain_76DDC8[v17-- -1]; + while ( v23 == terrain_76DDC8[v17 -1] ); + } + --v17; + ++v16; + } + v16 = 0; + //v24 = terrain_76E3C8[v18]; + v126 = 0; + if ( v120 > terrain_76E3C8[v18] ) + { + v125 = v120; + memset32(terrain_76D5C8.data(), v122, 4 * (v120 - terrain_76E3C8[v18] + 1)); + do + { + v25 = v126; + v26 = v125--; + ++v126; + terrain_76D7C8[v25] = v26; + } + while ( v125 >= terrain_76E3C8[v18] ); + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v27 = terrain_76E1C8[v18-- -1]; + while ( v27 == terrain_76E1C8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v28 = terrain_76E3C8[v18]; + while ( v28 >= v124 ) + { + v29 = terrain_76E1C8[v18]; + terrain_76D7C8[v16] = v28; + terrain_76D5C8[v16] = v29; + if ( v29 == 65535 ) + { + v31 = v123; + terrain_76D5C8[v16] = v31; + break; + } + if ( !v18 ) + break; + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v30 = terrain_76E1C8[v18-- -1]; + while ( v30 == terrain_76E1C8[v18 -1] ); + } + --v18; + --v28; + ++v16; + } + break; + } + case 1: + case 2: + { + //v116 = terrain_76DDC8[v17]; + if ( v122 < terrain_76DDC8[v17] ) + { + v106 = v122; + memset32(terrain_76DBC8.data(), v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); + for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++) + terrain_76D9C8[v126++] = v32; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v34 = terrain_76DBC8[v17-- -1]; + while ( v34 == terrain_76DBC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v35 = terrain_76DDC8[v17]; + v125 = terrain_76DDC8[v17]; + while ( v35 <= v123 ) + { + //v22 = terrain_76DFC8[v17] == 65535; + terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; + terrain_76D9C8[v16] = v125; + if ( terrain_76DFC8[v17] == 65535 ) + { + terrain_76DBC8[v16] = v124 + 1; + break; + } + if ( !v17 ) + break; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v36 = terrain_76DBC8[v17-- -1]; + while ( v36 == terrain_76DBC8[v17 -1] ); + } + --v17; + ++v125; + v35 = v125; + ++v16; + } + v16 = 0; + v126 = 0; + v37 = terrain_76E1C8[v18]; + if ( v122 < v37 ) + { + v114 = v122; + memset32(terrain_76D7C8.data(), i, 4 * (v37 - v122 + 1)); + do + { + v38 = v126; + v39 = v114; + ++v126; + ++v114; + terrain_76D5C8[v38] = v39; + } + while ( v114 <= terrain_76E1C8[v18] ); + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v40 = terrain_76DFC8[v18-- -1]; + while ( v40 == terrain_76DFC8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v41 = terrain_76E1C8[v18]; + while ( v41 <= v123 ) + { + terrain_76D5C8[v16] = v41; + terrain_76D7C8[v16] = terrain_76E3C8[v18]; + if ( terrain_76E3C8[v18] == 65535 ) + { + terrain_76D7C8[v16] = v124; + break; + } + if ( !v18 ) + break; + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v43 = terrain_76DFC8[v18-- -1]; + while ( v43 == terrain_76DFC8[v18 -1] ); + } + --v18; + ++v41; + ++v16; + } + break; + } + case 5: + case 6: + { + //v116 = terrain_76DDC8[v17]; + if ( v119 > terrain_76DDC8[v17] ) + { + v106 = v119; + memset32(terrain_76DBC8.data(), i, 4 * (v119 - terrain_76DDC8[v17] + 1)); + for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--) + terrain_76D9C8[v126++] = v45; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v46 = terrain_76DBC8[v17-- -1]; + while ( v46 == terrain_76DBC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v47 = terrain_76DDC8[v17]; + v125 = terrain_76DDC8[v17]; + while ( v47 >= v123 ) + { + //v22 = terrain_76DFC8[v17] == 65535; + terrain_76DBC8[v16] = terrain_76DFC8[v17]; + terrain_76D9C8[v16] = terrain_76DDC8[v17]; + if ( terrain_76DFC8[v17] == 65535 ) + { + terrain_76DBC8[v16] = v124; + break; + } + if ( !v17 ) + break; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v48 = terrain_76DBC8[v17-- -1]; + while ( v48 == terrain_76DBC8[v17 -1] ); + } + --v17; + --v125; + v47 = v125; + ++v16; + } + v16 = 0; + v49 = terrain_76E1C8[v18]; + v126 = 0; + if ( v119 > v49 ) + { + v125 = v119; + memset32(terrain_76D7C8.data(), v120 + 1, 4 * (v119 - v49 + 1)); + do + { + v50 = v126; + v51 = v125--; + ++v126; + terrain_76D5C8[v50] = v51; + } + while ( v125 >= terrain_76E1C8[v18] ); + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v52 = terrain_76DFC8[v18-- -1]; + while ( v52 == terrain_76DFC8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v53 = terrain_76E1C8[v18]; + while ( v53 >= v123 ) + { + v54 = terrain_76E3C8[v18]; + terrain_76D5C8[v16] = v53; + terrain_76D7C8[v16] = v54 + 1; + if ( v54 == 65535 ) + { + terrain_76D7C8[v16] = v124 + 1; + break; + } + if ( !v18 ) + break; + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v55 = terrain_76DFC8[v18-- -1]; + while ( v55 == terrain_76DFC8[v18 -1] ); + } + --v18; + --v53; + ++v16; + } + break; + } + case 3: + case 4: + { + //v116 = terrain_76DFC8[v17]; + if ( i < terrain_76DFC8[v17] ) + { + v106 = i; + memset32(terrain_76D9C8.data(), v122, 4 * (terrain_76DFC8[v17] - i + 1)); + v56 = i; + do + { + v57 = v126++; + terrain_76DBC8[v57] = v56++; + } + while ( v56 <= terrain_76DFC8[v17] ); + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) + { + do + v58 = terrain_76DDC8[v17-- -1]; + while ( v58 == terrain_76DDC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v59 = terrain_76DFC8[v17]; + while ( 1 ) + { + v125 = terrain_76DFC8[v17]; + if ( terrain_76DFC8[v17] > v124 ) + break; + terrain_76DBC8[v16] = terrain_76DFC8[v17]; + //v60 = terrain_76DDC8[v17]; + terrain_76D9C8[v16] = terrain_76DDC8[v17]; + if ( terrain_76DDC8[v17] == 65535 ) + { + terrain_76D9C8[v16] = v123; + break; + } + if ( !v17 ) + break; + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) + { + do + v61 = terrain_76DDC8[v17-- -1]; + while ( v61 == terrain_76DDC8[v17 -1] ); + } + --v17; + v59 = v125 + 1; + ++v16; + } + v16 = 0; + v126 = 0; + v62 = terrain_76E3C8[v18]; + if ( i < v62 ) + { + v114 = i; + memset32(terrain_76D5C8.data(), v119 + 1, 4 * (v62 - i + 1)); + do + { + v63 = v126; + v64 = v114; + ++v126; + ++v114; + terrain_76D7C8[v63] = v64; + } + while ( v114 <= terrain_76E3C8[v18] ); + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v65 = terrain_76E1C8[v18-- -1]; + while ( v65 == terrain_76E1C8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v66 = terrain_76E3C8[v18]; + while ( v66 <= v124 ) + { + v67 = terrain_76E1C8[v18]; + terrain_76D7C8[v16] = v66; + terrain_76D5C8[v16] = terrain_76E1C8[v18] + 1; + if ( terrain_76E1C8[v18] == 65535 ) + { + v31 = v123 + 1; + terrain_76D5C8[v16] = v31; + break; + } + if ( !v18 ) + break; + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v68 = terrain_76E1C8[v18-- -1]; + while ( v68 == terrain_76E1C8[v18 -1] ); + } + --v18; + ++v66; + ++v16; + } + break; + } + default: + break; + } + //v69 = v16 - 1; + ptr_801A08 = pVerticesSR_806210; + ptr_801A04 = pVerticesSR_801A10; + //v126 = v69; + + if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//блок, ориентация камеры 1(СВ), 2(С), 5(ЮЗ), 6(Ю) + { + for ( i = v16 - 1; i >= 1; --i ) + { + //v70 = i; + //v71 = terrain_76D7C8[i];//88 + //v72 = terrain_76DBC8[i];//0 + if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap + { + terrain_76DBC8[i] = terrain_76D7C8[i]; + terrain_76D7C8[i] = terrain_76DBC8[i]; + } + //x = terrain_76DBC8[i];//0 + v111 = 0; + if ( terrain_76DBC8[i] <= 0 ) + terrain_76DBC8[i] = -terrain_76DBC8[i]; + //v74 = terrain_76D7C8[i]; + if ( terrain_76D7C8[i] <= 0 ) + terrain_76D7C8[i] = -terrain_76D7C8[i]; + uEndZ = terrain_76D7C8[i] + 2; + //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; + //uEndZ = v75; + //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; + uStartZ = terrain_76DBC8[i] - 2; + if ( terrain_76DBC8[i] - 2 < uEndZ ) + { + v127 = 0; + //v79 = (v73 - 66) << 9; + //v116 = v77; + //pHeight = v79; + v111 = uEndZ - uStartZ; + for (int z = uStartZ; z < uEndZ; ++z) + { + ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; + ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; + ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); + + ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; + ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; + ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); + + if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) + { + pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); + pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); + + pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); + pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); + } + //v79 += 512; + v127 ++; + //++v116; + //pHeight = v79; + } + //while ( v116 < v107 ); + } + v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); + v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); + if ( pRenderer->pRenderD3D )//Ritor1: do comment to test + Render::DrawTerrainD3D(v111, 0, v103, v104); + //Render::RenderTerrainD3D(); + //else + //Render::DrawTerrainSW(v111, 0, v103, v104); + } + } + else//ориентация камеры 0(В), 3(СЗ), 4(З), 7(ЮВ) + { + for ( i = v16 - 1; i >= 1; --i ) + { + //v86 = i; + //v87 = terrain_76D5C8[i]; + //v88 = terrain_76D9C8[i]; + if ( terrain_76D5C8[i] < terrain_76D9C8[i] ) + { + terrain_76D9C8[i] = terrain_76D5C8[i]; + terrain_76D5C8[i] = terrain_76D9C8[i]; + } + //v89 = terrain_76D9C8[i]; + v111 = 0; + if ( terrain_76D9C8[i] <= 0 ) + terrain_76D9C8[i] = -terrain_76D9C8[i]; + //v90 = terrain_76D5C8[i]; + if ( terrain_76D5C8[i] <= 0 ) + terrain_76D5C8[i] = -terrain_76D5C8[i]; + pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; + v107 = terrain_76D5C8[i] + 2; + if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 ) + { + v86 = 0; + //v116 = terrain_76D9C8[i] - 2; + v92 = (66 - terrain_76D9C8[i]) << 9; + //pHeight = (66 - terrain_76D9C8[i]) << 9; + v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2); + //do + for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) + { + ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9; + ptr_801A08[v86].vWorldPosition.y = v92; + ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); + + ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9; + ptr_801A04[v86].vWorldPosition.y = v92; + ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); + if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) + { + pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); + pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); + pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); + pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); + } + v92 -= 512; + v86 += 48; + //++v116; + //pHeight = v92; + } + //while ( v116 < v107 ); + } + v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); + v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); + if ( pRenderer->pRenderD3D ) + Render::DrawTerrainD3D(v111, 1, v103, v104); + //else + //Render::DrawTerrainSW(v111, 1, v103, v104); + } + } + result = v126; + pODMRenderParams->field_40 = v126; + return result; +} + +//----- (0048034E) -------------------------------------------------------- +void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) +{ + //int v3; // esi@1 + int v4; // edi@1 + int v5; // ebx@2 + int v6; // eax@2 + int v7; // eax@3 + RenderVertexSoft *v8; // edi@3 + RenderVertexSoft *v9; // ebx@4 + RenderVertexSoft *v10; // ecx@4 + float v11; // eax@6 + double v12; // ST5C_8@6 + double v13; // ST2C_8@6 + int v14; // eax@6 + double v15; // st7@6 + struct Polygon *pTile; // ebx@12 + unsigned __int16 v17; // ax@12 + int v18; // eax@13 + signed int v22; // eax@13 + Vec3_float_ *norm; // eax@15 + //double v24; // st6@17 + double v25; // ST54_8@17 + unsigned __int8 v26; // sf@17 + unsigned __int8 v27; // of@17 + double v28; // st5@19 + double v29; // st5@19 + double v30; // st5@19 + double v31; // st5@19 + struct struct8 *v32; // esi@21 + double v3a; // st7@32 + int v33; // edi@38 + unsigned int v34; // ecx@47 + char v35; // zf@47 + unsigned int v36; // eax@50 + int v37; // eax@54 + //Polygon *v38; // ecx@55 + unsigned int v39; // eax@59 + struct Polygon *v40; // ebx@62 + unsigned __int16 pTileBitmapsID; // ax@62 + int v42; // eax@63 + LightmapBuilder *v43; // ecx@63 + int v44; // eax@63 + int v45; // eax@63 + int v46; // eax@63 + signed int v47; // eax@63 + Vec3_float_ *v48; // eax@65 + double v49; // st6@67 + double v50; // ST4C_8@67 + double v51; // st5@71 + double v52; // st5@71 + double v53; // st5@71 + double v54; // st7@84 + unsigned int v55; // ecx@98 + unsigned int v56; // eax@101 + int v57; // eax@105 + unsigned int v58; // eax@109 + struct Polygon *v59; // esi@112 + unsigned __int16 v60; // ax@112 + int v61; // eax@113 + signed int v62; // eax@113 + Vec3_float_ *v63; // eax@114 + double v64; // st6@116 + double v65; // ST3C_8@116 + double v66; // st5@120 + double v67; // st5@120 + double v68; // st5@120 + double v69; // st7@133 + int v70; // edi@138 + struct Polygon *v71; // esi@147 + unsigned int v72; // ecx@147 + unsigned int v73; // eax@150 + int v74; // eax@154 + unsigned int v75; // eax@158 + //unsigned int v76; // [sp-10h] [bp-E0h]@61 + int v77; // [sp-Ch] [bp-DCh]@61 + IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 + //int v79; // [sp-4h] [bp-D4h]@61 + bool v80; // [sp+0h] [bp-D0h]@59 + bool v81; // [sp+0h] [bp-D0h]@109 + int v82; // [sp+54h] [bp-7Ch]@1 + int v83; // [sp+60h] [bp-70h]@1 + int v84; // [sp+6Ch] [bp-64h]@1 + int v85; // [sp+70h] [bp-60h]@63 + float a4; // [sp+74h] [bp-5Ch]@73 + float v87; // [sp+78h] [bp-58h]@122 + int v88; // [sp+7Ch] [bp-54h]@1 + int v89; // [sp+80h] [bp-50h]@6 + int v93; // [sp+90h] [bp-40h]@2 + int X; // [sp+94h] [bp-3Ch]@1 + float v95; // [sp+98h] [bp-38h]@21 + LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 + int v97; // [sp+A0h] [bp-30h]@6 + int sX; // [sp+A4h] [bp-2Ch]@6 + unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 + int v100; // [sp+ACh] [bp-24h]@122 + int sY; // [sp+B0h] [bp-20h]@6 + RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 + unsigned int a5; // [sp+B8h] [bp-18h]@21 + RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 + Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 + RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 + RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 + char v108; // [sp+CFh] [bp-1h]@36 + float thisd; // [sp+D8h] [bp+8h]@6 + float thise; // [sp+D8h] [bp+8h]@6 + float thisf; // [sp+D8h] [bp+8h]@17 + IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 + float thisg; // [sp+D8h] [bp+8h]@67 + IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 + float thish; // [sp+D8h] [bp+8h]@116 + IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 + char this_3; // [sp+DBh] [bp+Bh]@30 + char this_3a; // [sp+DBh] [bp+Bh]@82 + char this_3b; // [sp+DBh] [bp+Bh]@131 + + __debugbreak(); + static stru154 static_sub_0048034E_stru_154; + static stru154 stru_76D5A8; + //v3 = a1; + v82 = a2; + v83 = a3; + X = abs(unk4); + v4 = 0; + v88 = 0; + v84 = a1 - 1; + if ( a1 - 1 > 0 ) + { + while ( 1 ) + { + v5 = abs(X);//v5 = 13108 + v6 = abs(v83);//v6 = 13108 + --X; + //__debugbreak(); // uncoment & refactor following large if + v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; + if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), + v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), + ((a8 = v9, + pVertices = &pVerticesSR_801A10[1] + v7, + v11 = v8->vWorldPosition.x, + v101 = v10, + v12 = v11 + 6.755399441055744e15, + sX = LODWORD(v12), + v13 = v8->vWorldPosition.y + 6.755399441055744e15, + sY = LODWORD(v13), + thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, + v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X + v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, + v89 = v14, + thise = v15 * 0.5, + _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z + WorldPosToGridCellX(sX), + WorldPosToGridCellZ(sY), + !byte_4D864C) + || !(pGame->uFlags & 0x80)) + && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) ) + if ( !&terrain_76E5C8[(v5 << 7) + v6] ) + goto LABEL_162 + v8 = &pVerticesSR_806210[v4]; + //pVertices2 = &pVerticesSR_801A10[v4 + 1]; + //v102 = v8; + if (!v82) + { + pVertices = &pVerticesSR_801A10[v4]; + v101 = &pVerticesSR_806210[v4 + 1]; + } + else + { + pVertices = &pVerticesSR_801A10[v4 + 1]; + v101 = &pVerticesSR_806210[v4]; + } + sX = floorf(v8->vWorldPosition.x + 0.5f); + sY = floorf(v8->vWorldPosition.z + 0.5f); + v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); + v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); + WorldPosToGridCellX(sX); + WorldPosToGridCellZ(sY); + if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) + if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y + || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) + break; + pTile = &array_77EC08[pODMRenderParams->uNumPolygons]; + pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( pTile->uTileBitmapID != -1 ) + { + pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); + pTile->field_32 = 0; + pTile->field_59 = 1; + pTile->terrain_grid_x = (char)v97; + __debugbreak(); // warning C4700: uninitialized local variable 'v93' used + pTile->field_34 = *(_WORD *)(v93 + 2); + pTile->terrain_grid_z = v89; + v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; + if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) + norm = 0; + else + norm = &pTerrainNormals[v22]; + thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - + (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - + (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; + //v25 = thisf + 6.7553994e15; + //v27 = pODMRenderParams->uNumPolygons > 1999; + //v26 = pODMRenderParams->uNumPolygons - 1999 < 0; + pTile->dimming_level = floorf(thisf + 0.5f); + if ( pODMRenderParams->uNumPolygons >= 1999 ) + return; + ++pODMRenderParams->uNumPolygons; + //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary + //goto LABEL_126; + //{ + //--pODMRenderParams->uNumPolygons; + //goto LABEL_162; + //} + __debugbreak(); // warning C4700: uninitialized local variable 'v102' used + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); + array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[3].u = 1.0; + array_50AC10[3].v = 0.0; + if ( !(_76D5C0_static_init_flag & 1) ) + { + _76D5C0_static_init_flag |= 1u; + stru154(stru_76D5A8); + atexit(loc_481199); + } + v32 = (struct8 *)array_50AC10; + v97 = (int)pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); + pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); + a5 = 4; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisa = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) + goto LABEL_162; + thisa->ViewTransform(array_50AC10, a5); + thisa->Project(array_50AC10, a5, 0); + } + this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v3a = (double)pODMRenderParams->shading_dist_mist; + v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x + || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; + v33 = 0; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3 ) + v33 = 3; + else + v33 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); + v34 = a5; + //v35 = byte_4D864C == 0; + pTile->uNumVertices = a5; + if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) + { + if ( this_3 ) + { + v36 = ODM_NearClip(v34); + pTile->uNumVertices = v36; + ODMRenderParams::Project(v36); + } + if ( v108 ) + { + v36 = ODM_FarClip(v34); + pTile->uNumVertices = v36; + ODMRenderParams::Project(v36); + } + } + //v37 = *(int *)&v16->flags; + if ( ~pTile->flags & 1 ) + { + if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v39 = pTile->uTileBitmapID; + v80 = true; + } + //v79 = 0; + //v78 = pBitmaps_LOD->pHardwareTextures[v39]; + pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary + v77 = (int)pTile; + //v76 = v16->uNumVertices; +//LABEL_161: + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); + goto LABEL_162; + } +LABEL_56: + pTile->DrawBorderTiles(); + } +LABEL_162: + v4 = v88 + 1; + if ( ++v88 >= v84 ) + return; + } + v40 = &array_77EC08[pODMRenderParams->uNumPolygons]; + v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v40->uTileBitmapID == -1 ) + goto LABEL_162; + v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); + BYTE1(v42) |= 0x80u; + v43 = pGame->pLightmapBuilder; + *(int *)&v40->flags = v42; + v44 = v93; + v40->field_59 = 1; + v40->terrain_grid_x = (char)v43; + v40->field_34 = *(_WORD *)(v44 + 2); + v45 = v89; + v40->terrain_grid_z = v89; + v46 = 4 * ((char)v43 + (v45 << 7)); + v85 = v46; + v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; + if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) + v48 = 0; + else + v48 = &pTerrainNormals[v47]; + v49 = v92 * v48->y; + //v99 = v48; + thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; + v50 = thisg + 6.755399441055744e15; + v40->dimming_level = LOBYTE(v50); + if ( LOBYTE(v50) < 0 ) + v40->dimming_level = 0; + if ( pODMRenderParams->uNumPolygons >= 1999 ) + return; + ++pODMRenderParams->uNumPolygons; + if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary + //goto LABEL_77; + { + --pODMRenderParams->uNumPolygons; + goto LABEL_112; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + static stru154 static_sub_0048034E_stru_76D590; + static bool __init_flag2 = false; + if (!__init_flag2) + { + __init_flag2 = true; + stru154::stru154(&static_sub_0048034E_stru_76D590); + } + if ( !(_76D5C0_static_init_flag & 2) ) + { + _76D5C0_static_init_flag |= 2; + Polygon(stru_76D590); + atexit(loc_48118F); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); + pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); + uNumVertices = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisb = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) + { +//LABEL_77: + --pODMRenderParams->uNumPolygons; + goto LABEL_112; + } + thisb->ViewTransform(array_50AC10, uNumVertices); + thisb->Project(array_50AC10, uNumVertices, 0); + } + this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v54 = (double)pODMRenderParams->shading_dist_mist; + v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; + pVertices = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3a ) + pVertices = (RenderVertexSoft *)3; + else + pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); + //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); + static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); + v55 = uNumVertices; + //v35 = byte_4D864C == 0; + v40->uNumVertices = uNumVertices; + if ( !_76D5C0_static_init_flag || !(pGame->uFlags & 0x80) ) + { + if ( this_3a ) + { + v56 = ODM_NearClip(v55); + } + else + { + if ( !v108 ) + goto LABEL_105; + v56 = sr_424EE0_MakeFanFromTriangle(v55); + } + v40->uNumVertices = v56; + ODMRenderParams::Project(v56); + } +LABEL_105: + v57 = *(int *)&v40->flags; + if ( BYTE1(v57) & 1 ) + { + v40->DrawBorderTiles(); + } + else + { + if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v81 = false; + v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v58 = v40->uTileBitmapID; + v81 = true; + } + pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); + } +LABEL_112: + v59 = &array_77EC08[pODMRenderParams->uNumPolygons]; + //a8 = (RenderVertexSoft *)&array_77EC08[pODMRenderParams->uNumPolygons]; + v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v59->uTileBitmapID == -1 ) + goto LABEL_162; + *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); + v61 = v93; + v59->field_59 = 1; + v59->field_34 = *(_WORD *)(v61 + 2); + v59->terrain_grid_z = v89; + v59->terrain_grid_x = v97; + v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); + if ( v62 > (signed int)(uNumTerrainNormals - 1) ) + v63 = 0; + else + v63 = &pTerrainNormals[v62]; + v64 = v92 * v63->y; + //v99 = v63; + thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; + v59->dimming_level = floorf(thish + 0.5f); + if ( v59->dimming_level < 0 ) + v59->dimming_level = 0; + if ( pODMRenderParams->uNumPolygons >= 1999 ) + return; + ++pODMRenderParams->uNumPolygons; + if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) + { +//LABEL_126: + --pODMRenderParams->uNumPolygons; + goto LABEL_162; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 1.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 0.0; + static stru154 static_sub_0048034E_stru_76D578; + static bool __init_flag1 = false; + if (!__init_flag1) + { + __init_flag1 = true; + stru154::stru154(&static_sub_0048034E_stru_76D578); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); + pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); + v100 = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisc = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) + //goto LABEL_126; + { + --pODMRenderParams->uNumPolygons; + goto LABEL_162; + } + thisc->ViewTransform(array_50AC10, v100); + thisc->Project(array_50AC10, v100, 0); + } + this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0; + v69 = (double)pODMRenderParams->shading_dist_mist; + v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; + v70 = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3b ) + v70 = 3; + else + v70 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); + v71 = v59; + v72 = v100; + //v35 = byte_4D864C == 0; + v59->uNumVertices = v100;//??? + if ( !byte_4D864C && pGame->uFlags & 0x80 ) + goto LABEL_154; + if ( this_3b ) + { + v73 = ODM_NearClip(v72); + } + else + { + if ( !v108 ) + { +LABEL_154: + v74 = v71->flags; + if ( !(BYTE1(v74) & 1) ) + { + if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v75 = v71->uTileBitmapID; + v80 = true; + } + //v79 = 0; + v78 = pBitmaps_LOD->pHardwareTextures[v75]; + v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary + //v77 = (int)v71; + //v76 = v71->uNumVertices; + //goto LABEL_161; + pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); + goto LABEL_162; + } + v38 = (Polygon *)v71; + goto LABEL_56; + } + v73 = sr_424EE0_MakeFanFromTriangle(v72); + } + v71->uNumVertices = v73; + ODMRenderParams::Project(v73); + goto LABEL_154; + } + } */ \ No newline at end of file