Mercurial > mm7
changeset 2531:f6de3e15d4a5
for light in indoor
author | Ritor1 |
---|---|
date | Sun, 23 Nov 2014 15:30:17 +0600 |
parents | dc6f29bb0ec4 |
children | 9ec6b8be16fe |
files | Engine/Graphics/DecalBuilder.cpp Engine/Graphics/Indoor.cpp Engine/Graphics/IndoorCameraD3D.cpp Engine/Graphics/LightmapBuilder.cpp Engine/Graphics/LightmapBuilder.h Engine/Graphics/Render.cpp |
diffstat | 6 files changed, 461 insertions(+), 668 deletions(-) [+] |
line wrap: on
line diff
--- a/Engine/Graphics/DecalBuilder.cpp Mon Oct 13 17:52:23 2014 +0300 +++ b/Engine/Graphics/DecalBuilder.cpp Sun Nov 23 15:30:17 2014 +0600 @@ -209,40 +209,31 @@ } //----- (0049B790) -------------------------------------------------------- -char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, Bloodsplat *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags) +char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, Bloodsplat *blood, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags) { - Decal *v13; // edi@2 + Decal *decal; // edi@2 double v28; // st7@5 char result; // al@6 int v34; // eax@19 std::string v37; // [sp-4h] [bp-24h]@15 - //int a6a; - //RenderVertexSoft *a8a; unsigned int a8b = 0; - //v12 = this; if ( a6 == 0.0 ) return 1; - v13 = &this->std__vector_pDecals[this->field_308008]; - //v14 = &this->std__vector_pDecals[this->field_308008].field_C1C; - this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4; + decal = &this->std__vector_pDecals[this->field_308008]; + this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)blood; this->std__vector_pDecals[this->field_308008].field_C1C = 0; if ( a3 & 2 ) this->std__vector_pDecals[this->field_308008].field_C1C = 1; - //v15 = a6 - a8; this->field_30C028 = a6 - a8; - //v16 = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028); this->field_30C02C = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028); - //v17 = a5; - //v18 = a9; + this->flt_30C030 = 1.0 - (a6 - this->field_30C02C) / a6; - v13->field_C08 = (signed __int64)(a4->x - a8 * a9->field_4.x); - v13->field_C0A = (signed __int64)(a4->y - a8 * a9->field_4.y); - //v19 = a6; - v13->field_C0C = (signed __int64)(a4->z - a8 * a9->field_4.z); - //v20 = a6 * this->flt_30C030; - //a8a = v13->pVertices; + decal->field_C08 = (signed __int64)(blood->x - a8 * a9->field_4.x); + decal->field_C0A = (signed __int64)(blood->y - a8 * a9->field_4.y); + decal->field_C0C = (signed __int64)(blood->z - a8 * a9->field_4.z); + this->field_30C034 = a6 * this->flt_30C030; this->field_30C010 = this->field_30C034 * a9->field_10.x; this->field_30C014 = this->field_30C034 * a9->field_10.y; @@ -251,65 +242,52 @@ this->field_30C01C = this->field_30C034 * a9->field_1C.x; this->field_30C020 = this->field_30C034 * a9->field_1C.y; this->field_30C024 = this->field_30C034 * a9->field_1C.z; - //a6a = v13->field_C08; - //v21 = (double)v13->field_C08; - //v22 = (double)v13->field_C08 - this->field_30C01C; - //a6a = v13->field_C0A; - v13->pVertices[0].vWorldPosition.x = (double)v13->field_C08 - this->field_30C01C + this->field_30C010; - v13->pVertices[0].vWorldPosition.y = (double)v13->field_C0A - this->field_30C020 + this->field_30C014; - v13->pVertices[0].vWorldPosition.z = (double)v13->field_C0A - this->field_30C024 + this->field_30C018; - v13->pVertices[0].u = 0.0; - v13->pVertices[0].v = 0.0; + + decal->pVertices[0].vWorldPosition.x = (double)decal->field_C08 - this->field_30C01C + this->field_30C010; + decal->pVertices[0].vWorldPosition.y = (double)decal->field_C0A - this->field_30C020 + this->field_30C014; + decal->pVertices[0].vWorldPosition.z = (double)decal->field_C0A - this->field_30C024 + this->field_30C018; + decal->pVertices[0].u = 0.0; + decal->pVertices[0].v = 0.0; - v13->pVertices[1].vWorldPosition.x = (double)v13->field_C08 - this->field_30C01C - this->field_30C010; - v13->pVertices[1].vWorldPosition.y = (double)v13->field_C0A - this->field_30C020 - this->field_30C014; - v13->pVertices[1].vWorldPosition.z = (double)v13->field_C0A - this->field_30C024 - this->field_30C018; - v13->pVertices[1].u = 0.0; - v13->pVertices[1].v = 1.0; + decal->pVertices[1].vWorldPosition.x = (double)decal->field_C08 - this->field_30C01C - this->field_30C010; + decal->pVertices[1].vWorldPosition.y = (double)decal->field_C0A - this->field_30C020 - this->field_30C014; + decal->pVertices[1].vWorldPosition.z = (double)decal->field_C0A - this->field_30C024 - this->field_30C018; + decal->pVertices[1].u = 0.0; + decal->pVertices[1].v = 1.0; - v13->pVertices[2].vWorldPosition.x = (double)v13->field_C08 + this->field_30C01C - this->field_30C010; - v13->pVertices[2].vWorldPosition.y = (double)v13->field_C0A + this->field_30C020 - this->field_30C014; - v13->pVertices[2].vWorldPosition.z = (double)v13->field_C0A + this->field_30C024 - this->field_30C018; - v13->pVertices[2].u = 1.0; - v13->pVertices[2].v = 1.0; + decal->pVertices[2].vWorldPosition.x = (double)decal->field_C08 + this->field_30C01C - this->field_30C010; + decal->pVertices[2].vWorldPosition.y = (double)decal->field_C0A + this->field_30C020 - this->field_30C014; + decal->pVertices[2].vWorldPosition.z = (double)decal->field_C0A + this->field_30C024 - this->field_30C018; + decal->pVertices[2].u = 1.0; + decal->pVertices[2].v = 1.0; - v13->pVertices[3].vWorldPosition.x = (double)v13->field_C08 + this->field_30C01C + this->field_30C010; - v13->pVertices[3].vWorldPosition.y = (double)v13->field_C0A + this->field_30C020 + this->field_30C014; - v13->pVertices[3].vWorldPosition.z = (double)v13->field_C0A + this->field_30C024 + this->field_30C018; - v13->pVertices[3].u = 1.0; - v13->pVertices[3].v = 0.0; + decal->pVertices[3].vWorldPosition.x = (double)decal->field_C08 + this->field_30C01C + this->field_30C010; + decal->pVertices[3].vWorldPosition.y = (double)decal->field_C0A + this->field_30C020 + this->field_30C014; + decal->pVertices[3].vWorldPosition.z = (double)decal->field_C0A + this->field_30C024 + this->field_30C018; + decal->pVertices[3].u = 1.0; + decal->pVertices[3].v = 0.0; for ( uint i = 0; i < 4; ++i ) { - v28 = a9->field_4.x * v13->pVertices[i].vWorldPosition.x - + a9->field_4.y * v13->pVertices[i].vWorldPosition.y - + a9->field_4.z * v13->pVertices[i].vWorldPosition.z + v28 = a9->field_4.x * decal->pVertices[i].vWorldPosition.x + + a9->field_4.y * decal->pVertices[i].vWorldPosition.y + + a9->field_4.z * decal->pVertices[i].vWorldPosition.z + a9->dist; - v13->pVertices[i].vWorldPosition.x = v13->pVertices[i].vWorldPosition.x - v28 * a9->field_4.x; - v13->pVertices[i].vWorldPosition.y = v13->pVertices[i].vWorldPosition.y - v28 * a9->field_4.y; - v13->pVertices[i].vWorldPosition.z = v13->pVertices[i].vWorldPosition.z - v28 * a9->field_4.z; - //v25 += 48; + decal->pVertices[i].vWorldPosition.x = decal->pVertices[i].vWorldPosition.x - v28 * a9->field_4.x; + decal->pVertices[i].vWorldPosition.y = decal->pVertices[i].vWorldPosition.y - v28 * a9->field_4.y; + decal->pVertices[i].vWorldPosition.z = decal->pVertices[i].vWorldPosition.z - v28 * a9->field_4.z; } - v13->uColorMultiplier = uColorMultiplier; - //v40 = (unsigned int *)&v13->uNumVertices; - //v39 = v13->pVertices; - v13->uNumVertices = 4; - v13->field_C14 = a2; - //v29 = a9->field_4.z; - //a6a = (unsigned int *)&v13->uNumVertices; - //v38 = a9->field_4.z; - result = pGame->pStru9Instance->_4980B9(a11, a10, a9->field_4.x, a9->field_4.y, a9->field_4.z, v13->pVertices, (unsigned int*)&v13->uNumVertices); + decal->uColorMultiplier = uColorMultiplier; + decal->uNumVertices = 4; + decal->field_C14 = a2; + result = pGame->pStru9Instance->_4980B9(a11, a10, a9->field_4.x, a9->field_4.y, a9->field_4.z, decal->pVertices, (unsigned int*)&decal->uNumVertices); if ( result ) { - //v31 = a6a; - if ( !v13->uNumVertices ) + if ( !decal->uNumVertices ) return 1; - //v32 = a8a; - //v40 = *a6a; - //v39 = a8a; - pGame->pIndoorCameraD3D->ViewTransform(v13->pVertices, (unsigned int)v13->uNumVertices); - //v40 = 0; - pGame->pIndoorCameraD3D->Project(v13->pVertices, v13->uNumVertices, 0); + + pGame->pIndoorCameraD3D->ViewTransform(decal->pVertices, (unsigned int)decal->uNumVertices); + pGame->pIndoorCameraD3D->Project(decal->pVertices, decal->uNumVertices, 0); if ( !(uClipFlags & 1) ) { ++this->field_308008; @@ -325,22 +303,13 @@ { if ( uClipFlags & 2 ) { - //v40 = (int)&a8; - //v39 = this->pVertices; - //__debugbreak(); // warning C4700: uninitialized local variable 'v31' used - pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v13->pVertices, v13->uNumVertices, this->pVertices, &a8b); - //v40 = (int)v31; - //v39 = this->pVertices; - pGame->pIndoorCameraD3D->_437143(a8b, v13->pVertices, this->pVertices, (unsigned int *)&v13->uNumVertices); + pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(decal->pVertices, decal->uNumVertices, this->pVertices, &a8b); + pGame->pIndoorCameraD3D->_437143(a8b, decal->pVertices, this->pVertices, (unsigned int *)&decal->uNumVertices); } else if ( uClipFlags & 4 ) { - //v40 = (int)&a8; - //v39 = this->pVertices; - pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v13->pVertices, v13->uNumVertices, this->pVertices, &a8b); - //v40 = (int)v31; - //v39 = this->pVertices; - pGame->pIndoorCameraD3D->_437143(a8b, v13->pVertices, this->pVertices, (unsigned int *)&v13->uNumVertices); + pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(decal->pVertices, decal->uNumVertices, this->pVertices, &a8b); + pGame->pIndoorCameraD3D->_437143(a8b, decal->pVertices, this->pVertices, (unsigned int *)&decal->uNumVertices); } else MessageBoxA(nullptr, "Undefined clip flag specified", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258", 0); @@ -466,11 +435,12 @@ //float v29; // [sp+2Ch] [bp-10h]@7 float v30; // [sp+30h] [bp-Ch]@6 float v31; // [sp+34h] [bp-8h]@6 - bool v32; // [sp+38h] [bp-4h]@2 + //bool v32; // [sp+38h] [bp-4h]@2 float a3; this->uNumDecals = 0; - result = pBloodsplatContainer->std__vector_pBloodsplats_size != 0; + if ( !pBloodsplatContainer->std__vector_pBloodsplats_size ) + return false; // v24 = this; v23 = pBloodsplatContainer->std__vector_pBloodsplats_size; if ( pBloodsplatContainer->std__vector_pBloodsplats_size ) @@ -480,7 +450,7 @@ { //v8 = a5; //v9 = _a3; - for ( v32 = 0; v32 < (signed int)v23; ++v32 ) + for ( uint i = 0; i < (signed int)v23; ++i ) { if ( uStripType == 4 ) { @@ -518,50 +488,50 @@ //v21 = uStripType; v28 = pGame->pIndoorCameraD3D->GetPolygonMinZ(a5, uStripType); v26 = pGame->pIndoorCameraD3D->GetPolygonMaxZ(a5, uStripType); - if ( a3 - pBloodsplatContainer->std__vector_pBloodsplats[v32].radius < pBloodsplatContainer->std__vector_pBloodsplats[v32].x && - v31 + pBloodsplatContainer->std__vector_pBloodsplats[v32].radius > pBloodsplatContainer->std__vector_pBloodsplats[v32].x && - v30 - pBloodsplatContainer->std__vector_pBloodsplats[v32].radius < pBloodsplatContainer->std__vector_pBloodsplats[v32].y && - v12 + pBloodsplatContainer->std__vector_pBloodsplats[v32].radius > pBloodsplatContainer->std__vector_pBloodsplats[v32].y && - v28 - pBloodsplatContainer->std__vector_pBloodsplats[v32].radius < pBloodsplatContainer->std__vector_pBloodsplats[v32].z && - v26 + pBloodsplatContainer->std__vector_pBloodsplats[v32].radius > pBloodsplatContainer->std__vector_pBloodsplats[v32].z ) + if ( a3 - pBloodsplatContainer->std__vector_pBloodsplats[i].radius < pBloodsplatContainer->std__vector_pBloodsplats[i].x && + v31 + pBloodsplatContainer->std__vector_pBloodsplats[i].radius > pBloodsplatContainer->std__vector_pBloodsplats[i].x && + v30 - pBloodsplatContainer->std__vector_pBloodsplats[i].radius < pBloodsplatContainer->std__vector_pBloodsplats[i].y && + v12 + pBloodsplatContainer->std__vector_pBloodsplats[i].radius > pBloodsplatContainer->std__vector_pBloodsplats[i].y && + v28 - pBloodsplatContainer->std__vector_pBloodsplats[i].radius < pBloodsplatContainer->std__vector_pBloodsplats[i].z && + v26 + pBloodsplatContainer->std__vector_pBloodsplats[i].radius > pBloodsplatContainer->std__vector_pBloodsplats[i].z ) { Vec3_float_::NegDot(&a5->vWorldPosition, _a3, a4); - v26 = _a3->y * pBloodsplatContainer->std__vector_pBloodsplats[v32].y - + _a3->z * pBloodsplatContainer->std__vector_pBloodsplats[v32].z - + _a3->x * pBloodsplatContainer->std__vector_pBloodsplats[v32].x + v26 = _a3->y * pBloodsplatContainer->std__vector_pBloodsplats[i].y + + _a3->z * pBloodsplatContainer->std__vector_pBloodsplats[i].z + + _a3->x * pBloodsplatContainer->std__vector_pBloodsplats[i].x + *a4; - v22 = v26 + 6.7553994e15; + v22 = v26 + 0.5f; //v25 = LODWORD(v22); v14 = (double)SLODWORD(v22); v28 = v14; - if ( v14 <= pBloodsplatContainer->std__vector_pBloodsplats[v32].radius ) + if ( v14 <= pBloodsplatContainer->std__vector_pBloodsplats[i].radius ) { //v15 = a2->flags; if ( a2->flags & 2 || a2->flags & 0x100 ) { - v16 = pBloodsplatContainer->std__vector_pBloodsplats[v32].field_1C; - if ( !(pBloodsplatContainer->std__vector_pBloodsplats[v32].field_1C & 1) ) + v16 = pBloodsplatContainer->std__vector_pBloodsplats[i].field_1C; + if ( !(pBloodsplatContainer->std__vector_pBloodsplats[i].field_1C & 1) ) { LOBYTE(v16) = v16 | 1; - pBloodsplatContainer->std__vector_pBloodsplats[v32].field_1C = v16; - pBloodsplatContainer->std__vector_pBloodsplats[v32].field_20 = pEventTimer->Time(); + pBloodsplatContainer->std__vector_pBloodsplats[i].field_1C = v16; + pBloodsplatContainer->std__vector_pBloodsplats[i].field_20 = pEventTimer->Time(); } } //v17 = v32; - pBloodsplatContainer->std__vector_pBloodsplats[v32].dot_dist = LODWORD(v28); + pBloodsplatContainer->std__vector_pBloodsplats[i].dot_dist = LODWORD(v28); //v18 = this; - this->std__vector_30B00C[this->uNumDecals] = v32; + this->std__vector_30B00C[this->uNumDecals] = i; ++this->uNumDecals; } } //++v32; //++v10; - result = v32; + result = i; } } } - LOBYTE(result) = 1; - return result; + //LOBYTE(result) = 1; + return true; }
--- a/Engine/Graphics/Indoor.cpp Mon Oct 13 17:52:23 2014 +0300 +++ b/Engine/Graphics/Indoor.cpp Sun Nov 23 15:30:17 2014 +0600 @@ -448,8 +448,9 @@ static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa ) { a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel); - v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) - | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8); + v17 = (248 - (SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel) << 3)) + | (((248 - (SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel) << 3)) + | ((248 - (SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel) << 3)) << 8)) << 8); sub_4B0E07(uFaceID); pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); @@ -465,7 +466,7 @@ stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; } - if (stru_F8AD28.uNumLightsApplied > 0 && !pFace->Indoor_sky()) + if (stru_F8AD28.uNumLightsApplied > 0 && !pFace->Indoor_sky()) //for torchlight(для света факелов) pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); if (pDecalBuilder->uNumDecals > 0)//отрисовка пятен крови
--- a/Engine/Graphics/IndoorCameraD3D.cpp Mon Oct 13 17:52:23 2014 +0300 +++ b/Engine/Graphics/IndoorCameraD3D.cpp Sun Nov 23 15:30:17 2014 +0600 @@ -1056,121 +1056,77 @@ void IndoorCameraD3D::_436F09_mess_with_lightmap__clipflag_4(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) { unsigned int *pOutNumVertices_; // ebx@1 - double v6; // st7@2 signed int v7; // esi@2 - char *v8; // edx@5 - unsigned int v9; // eax@10 - RenderVertexSoft *v10; // ecx@11 double v11; // st6@11 - double v12; // st6@12 - unsigned int v13; // edi@14 unsigned __int8 v14; // c2@16 unsigned __int8 v15; // c3@16 - unsigned int v16; // edi@17 bool a1a; // [sp+Ch] [bp+8h]@7 - int a4a; // [sp+18h] [bp+14h]@5 pOutNumVertices_ = pOutNumVertices; *pOutNumVertices = 0; if ( uNumInVertices ) { memcpy(&pInVertices[uNumInVertices], pInVertices, sizeof(pInVertices[uNumInVertices])); - v6 = (double)pODMRenderParams->shading_dist_mist; v7 = 0; - if ( v6 >= pInVertices->vWorldViewPosition.x ) + if ( (double)pODMRenderParams->shading_dist_mist >= pInVertices->vWorldViewPosition.x ) v7 = 1; - if ( uNumInVertices + 1 > 1 ) + for ( uint i = 0; i < uNumInVertices; i++ ) { - a4a = uNumInVertices; - v8 = (char *)&pInVertices[1].u; - do + a1a = (double)pODMRenderParams->shading_dist_mist >= pInVertices[i + 1].vWorldViewPosition.x; + if ( v7 != a1a ) { - a1a = v6 >= *((float *)v8 - 6); - if ( v7 == a1a ) + if (a1a) { - v10 = pOutVertices; - //goto LABEL_23; + v11 = ((double)pODMRenderParams->shading_dist_mist - pInVertices[i].vWorldViewPosition.x) / (pInVertices[i + 1].vWorldViewPosition.x - pInVertices[i].vWorldViewPosition.x); + pOutVertices[*pOutNumVertices_].vWorldViewPosition.y = (pInVertices[i + 1].vWorldViewPosition.y - pInVertices[i].vWorldViewPosition.y) * v11 + pInVertices[i].vWorldViewPosition.y; + pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (pInVertices[i + 1].vWorldViewPosition.z - pInVertices[i].vWorldViewPosition.z) * v11 + pInVertices[i].vWorldViewPosition.z; + pOutVertices[*pOutNumVertices_].u = (pInVertices[i + 1].u - pInVertices[i].u) * v11 + pInVertices[i].u; + pOutVertices[*pOutNumVertices_].v = (pInVertices[i + 1].v - pInVertices[i].v) * v11 + pInVertices[i].v; + } + else + { + v11 = ((double)pODMRenderParams->shading_dist_mist - pInVertices[i + 1].vWorldViewPosition.x) / (pInVertices[i].vWorldViewPosition.x - pInVertices[i + 1].vWorldViewPosition.x); + pOutVertices[*pOutNumVertices_].vWorldViewPosition.y = (pInVertices[i].vWorldViewPosition.y - pInVertices[i + 1].vWorldViewPosition.y) * v11 + pInVertices[i + 1].vWorldViewPosition.y; + pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (pInVertices[i].vWorldViewPosition.z - pInVertices[i + 1].vWorldViewPosition.z) * v11 + pInVertices[i + 1].vWorldViewPosition.z; + pOutVertices[*pOutNumVertices_].u = (pInVertices[i].u - pInVertices[i + 1].u) * v11 + pInVertices[i + 1].u; + pOutVertices[*pOutNumVertices_].v = (pInVertices[i].v - pInVertices[i + 1].v) * v11 + pInVertices[i + 1].v; } - else - { - - v9 = *pOutNumVertices_; - if (a1a) - { - v10 = pOutVertices; - v11 = (v6 - *((float *)v8 - 18)) / (*((float *)v8 - 6) - *((float *)v8 - 18)); - pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 5) - *((float *)v8 - 17)) * v11 + *((float *)v8 - 17); - pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 4) - *((float *)v8 - 16)) * v11 - + *((float *)v8 - 16); - pOutVertices[*pOutNumVertices_].u = (*(float *)v8 - *((float *)v8 - 12)) * v11 + *((float *)v8 - 12); - pOutVertices[*pOutNumVertices_].v = (*((float *)v8 + 1) - *((float *)v8 - 11)) * v11 + *((float *)v8 - 11); - } - else - { - v12 = (v6 - *((float *)v8 - 6)) / (*((float *)v8 - 18) - *((float *)v8 - 6)); - pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 17) - *((float *)v8 - 5)) * v12 + *((float *)v8 - 5); - pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 16) - *((float *)v8 - 4)) * v12 - + *((float *)v8 - 4); - pOutVertices[*pOutNumVertices_].u = (*((float *)v8 - 12) - *(float *)v8) * v12 + *(float *)v8; - pOutVertices[*pOutNumVertices_].v = (*((float *)v8 - 11) - *((float *)v8 + 1)) * v12 + *((float *)v8 + 1); - v10 = pOutVertices; - } - v10[*pOutNumVertices_].vWorldViewPosition.x = v6; - v10[*pOutNumVertices_]._rhw = 1.0 / v6; - if (v7) - { - v13 = (unsigned int)&v10[*pOutNumVertices_]; - if (*(float *)(v13 + 12) != *((float *)v8 - 18) || *(float *)(v13 + 16) != *((float *)v8 - 17)) - { - ++*pOutNumVertices_; - //goto LABEL_23; - } - else - { - v14 = 0; - v15 = *(float *)(v13 + 20) == *((float *)v8 - 16); - if (!(v15 | v14)) - { - //goto LABEL_21; - ++*pOutNumVertices_; - //goto LABEL_23; - } - } - } - else - { - v16 = (unsigned int)&v10[*pOutNumVertices_]; - if (*(float *)(v16 + 12) != *((float *)v8 - 6) || *(float *)(v16 + 16) != *((float *)v8 - 5)) - { - //LABEL_21: - ++*pOutNumVertices_; - //goto LABEL_23; - } - else - { - v14 = 0; - v15 = *(float *)(v16 + 20) == *((float *)v8 - 4); - if (!(v15 | v14)) - { - //goto LABEL_21; - ++*pOutNumVertices_; - //goto LABEL_23; - } - } - } - } - //LABEL_23: - if ( a1a ) + pOutVertices[*pOutNumVertices_].vWorldViewPosition.x = (double)pODMRenderParams->shading_dist_mist; + pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (double)pODMRenderParams->shading_dist_mist; + if (v7) + { + if (pOutVertices[*pOutNumVertices_].vWorldViewPosition.x != pInVertices[i].vWorldViewPosition.x + || pOutVertices[*pOutNumVertices_].vWorldViewPosition.y != pInVertices[i].vWorldViewPosition.y) + ++*pOutNumVertices_; + else + { + v14 = 0; + v15 = pOutVertices[*pOutNumVertices_].vWorldViewPosition.z == pInVertices[i].vWorldViewPosition.z; + if (!(v15 | v14)) + ++*pOutNumVertices_; + } + } + else { - memcpy(&v10[*pOutNumVertices_], v8 - 36, sizeof(v10[*pOutNumVertices_])); - pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (*((float *)v8 - 6) + 0.0000001); - pOutVertices[(*pOutNumVertices_)++].flt_2C = *((float *)v8 + 2); + if (pOutVertices[*pOutNumVertices_].vWorldViewPosition.x != pInVertices[i + 1].vWorldViewPosition.x + || pOutVertices[*pOutNumVertices_].vWorldViewPosition.y != pInVertices[i + 1].vWorldViewPosition.y) + ++*pOutNumVertices_; + else + { + v14 = 0; + v15 = pOutVertices[*pOutNumVertices_].vWorldViewPosition.z == pInVertices[i + 1].vWorldViewPosition.z; + if (!(v15 | v14)) + ++*pOutNumVertices_; + } } - v7 = a1a; - v8 += 48; - --a4a; } - while ( a4a ); + if ( a1a ) + { + memcpy(&pOutVertices[*pOutNumVertices_], &pInVertices[i + 1], sizeof(pOutVertices[*pOutNumVertices_])); + pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (pInVertices[i + 1].vWorldViewPosition.x + 0.0000001); + pOutVertices[(*pOutNumVertices_)++].flt_2C = pInVertices[i + 1].flt_2C; + } + v7 = a1a; } if ( (signed int)*pOutNumVertices_ < 3 ) *pOutNumVertices_ = 0; @@ -1181,15 +1137,10 @@ void IndoorCameraD3D::_436CDC_mess_with_lightmap__clipflag_2(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) { signed int v5; // esi@2 - char *v6; // edx@5 - unsigned int v7; // eax@10 - RenderVertexSoft *v8; // ecx@11 double v9; // st6@11 double v10; // st6@12 - unsigned int v11; // edi@14 unsigned __int8 v12; // c2@16 unsigned __int8 v13; // c3@16 - unsigned int v14; // edi@17 bool a1a; // [sp+Ch] [bp+8h]@7 if ( uNumInVertices ) @@ -1201,71 +1152,61 @@ v5 = 1; if ( uNumInVertices + 1 > 1 ) { - v6 = (char *)&pInVertices[1].u; - do + for ( uint i = 1; i <= uNumInVertices; i++ ) { - a1a = *((float *)v6 - 6) >= 8.0; + a1a = pInVertices[i].vWorldViewPosition.x >= 8.0; if ( v5 == a1a ) - { - v8 = pOutVertices; goto LABEL_23; - } - v7 = *pOutNumVertices; if ( a1a ) { - v8 = pOutVertices; - v9 = (8.0 - *((float *)v6 - 18)) / (*((float *)v6 - 6) - *((float *)v6 - 18)); - pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 5) - *((float *)v6 - 17)) * v9 + *((float *)v6 - 17); - pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 4) - *((float *)v6 - 16)) * v9 - + *((float *)v6 - 16); - pOutVertices[*pOutNumVertices].u = (*(float *)v6 - *((float *)v6 - 12)) * v9 + *((float *)v6 - 12); - pOutVertices[*pOutNumVertices].v = (*((float *)v6 + 1) - *((float *)v6 - 11)) * v9 + *((float *)v6 - 11); + v9 = (8.0 - pInVertices[i - 1].vWorldViewPosition.x) / (pInVertices[i].vWorldViewPosition.x - pInVertices[i - 1].vWorldViewPosition.x); + pOutVertices[*pOutNumVertices].vWorldViewPosition.y = (pInVertices[i].vWorldViewPosition.y - pInVertices[i - 1].vWorldViewPosition.y) * v9 + pInVertices[i - 1].vWorldViewPosition.y; + pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (pInVertices[i].vWorldViewPosition.z - pInVertices[i - 1].vWorldViewPosition.z) * v9 + pInVertices[i - 1].vWorldViewPosition.z; + pOutVertices[*pOutNumVertices].u = (pInVertices[i].u - pInVertices[i - 1].u) * v9 + pInVertices[i - 1].u; + pOutVertices[*pOutNumVertices].v = (pInVertices[i].v - pInVertices[i - 1].v) * v9 + pInVertices[i - 1].v; } else { - v10 = (8.0 - *((float *)v6 - 6)) / (*((float *)v6 - 18) - *((float *)v6 - 6)); - pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 17) - *((float *)v6 - 5)) * v10 + *((float *)v6 - 5); - pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 16) - *((float *)v6 - 4)) * v10 - + *((float *)v6 - 4); - pOutVertices[*pOutNumVertices].u = (*((float *)v6 - 12) - *(float *)v6) * v10 + *(float *)v6; - pOutVertices[*pOutNumVertices].v = (*((float *)v6 - 11) - *((float *)v6 + 1)) * v10 + *((float *)v6 + 1); - v8 = pOutVertices; + v10 = (8.0 - pInVertices[i].vWorldViewPosition.x) / (pInVertices[i - 1].vWorldViewPosition.x - pInVertices[i].vWorldViewPosition.x); + pOutVertices[*pOutNumVertices].vWorldViewPosition.y = (pInVertices[i - 1].vWorldViewPosition.y - pInVertices[i].vWorldViewPosition.y) * v10 + pInVertices[i].vWorldViewPosition.y; + pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (pInVertices[i - 1].vWorldViewPosition.z - pInVertices[i].vWorldViewPosition.z) * v10 + pInVertices[i].vWorldViewPosition.z; + pOutVertices[*pOutNumVertices].u = (pInVertices[i - 1].u - pInVertices[i].u) * v10 + pInVertices[i].u; + pOutVertices[*pOutNumVertices].v = (pInVertices[i - 1].v - pInVertices[i].v) * v10 + pInVertices[i].v; } - v8[*pOutNumVertices].vWorldViewPosition.x = 8.0; - v8[*pOutNumVertices]._rhw = 0.125; + pOutVertices[*pOutNumVertices].vWorldViewPosition.x = 8.0; + pOutVertices[*pOutNumVertices]._rhw = 0.125; if ( v5 ) { - v11 = (unsigned int)&v8[*pOutNumVertices]; - if ( *(float *)(v11 + 12) != *((float *)v6 - 18) || *(float *)(v11 + 16) != *((float *)v6 - 17) ) - goto LABEL_21; - v12 = 0; - v13 = *(float *)(v11 + 20) == *((float *)v6 - 16); - } - else - { - v14 = (unsigned int)&v8[*pOutNumVertices]; - if ( *(float *)(v14 + 12) != *((float *)v6 - 6) || *(float *)(v14 + 16) != *((float *)v6 - 5) ) + if ( pOutVertices[*pOutNumVertices].vWorldViewPosition.x != pInVertices[i - 1].vWorldViewPosition.x + || pOutVertices[*pOutNumVertices].vWorldViewPosition.y != pInVertices[i - 1].vWorldViewPosition.y ) { -LABEL_21: ++*pOutNumVertices; goto LABEL_23; } v12 = 0; - v13 = *(float *)(v14 + 20) == *((float *)v6 - 4); + v13 = pOutVertices[*pOutNumVertices].vWorldViewPosition.z == pInVertices[i - 1].vWorldViewPosition.z; + } + else + { + if ( pOutVertices[*pOutNumVertices].vWorldViewPosition.x != pInVertices[i].vWorldViewPosition.x + || pOutVertices[*pOutNumVertices].vWorldViewPosition.y != pInVertices[i].vWorldViewPosition.y ) + { + ++*pOutNumVertices; + goto LABEL_23; + } + v12 = 0; + v13 = pOutVertices[*pOutNumVertices].vWorldViewPosition.z == pInVertices[i].vWorldViewPosition.z; } if ( !(v13 | v12) ) - goto LABEL_21; + ++*pOutNumVertices; LABEL_23: if ( a1a ) { - memcpy(&v8[*pOutNumVertices], v6 - 36, sizeof(v8[*pOutNumVertices])); - pOutVertices[(*pOutNumVertices)++]._rhw = 1.0 / (*((float *)v6 - 6) + 0.0000001); + memcpy(&pOutVertices[*pOutNumVertices], &pInVertices[i], sizeof(pOutVertices[*pOutNumVertices])); + pOutVertices[(*pOutNumVertices)++]._rhw = 1.0 / (pInVertices[i].vWorldViewPosition.x + 0.0000001); } v5 = a1a; - v6 += 48; - --uNumInVertices; } - while ( uNumInVertices ); } if ( (signed int)*pOutNumVertices < 3 ) *pOutNumVertices = 0; @@ -1391,23 +1332,13 @@ //----- (00436A6D) -------------------------------------------------------- double IndoorCameraD3D::GetPolygonMinZ(RenderVertexSoft *pVertices, unsigned int uStripType) { - unsigned int v3; // edx@1 double result; // st7@1 - float *v5; // ecx@2 - v3 = uStripType; - result = 3.402823466385289e38; - if ( (signed int)uStripType > 0 ) + result = FLT_MAX; + for ( uint i = 0; i < uStripType; i++ ) { - v5 = &pVertices->vWorldPosition.z; - do - { - if ( *v5 < result ) - result = *v5; - v5 += 12; - --v3; - } - while ( v3 ); + if ( pVertices[i].vWorldPosition.z < FLT_MAX ) + result = pVertices[i].vWorldPosition.z; } return result; }
--- a/Engine/Graphics/LightmapBuilder.cpp Mon Oct 13 17:52:23 2014 +0300 +++ b/Engine/Graphics/LightmapBuilder.cpp Sun Nov 23 15:30:17 2014 +0600 @@ -119,7 +119,7 @@ //----- (0045BE86) -------------------------------------------------------- bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag) { - Lightmap *v11; // edi@3 + Lightmap *lightmap; // edi@3 double v17; // st7@5 double v24; // st7@6 double v38; // st7@14 @@ -127,128 +127,120 @@ double v40; // st7@16 int v45; // eax@24 - if (fabsf(radius) < 1e-6f) + if (radius < 0.0f) return true; - v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] : + lightmap = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] : &std__vector_183808[std__vector_183808_size]; - flt_3C8C24 = radius - dot_dist; - flt_3C8C28 = sqrt((radius + dot_dist) * (radius - dot_dist)); + tex_light_radius = radius - dot_dist; + flt_3C8C28 = sqrt((radius + radius - tex_light_radius) * tex_light_radius); + //flt_3C8C28 = sqrt(tex_light_radius * tex_light_radius); flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius; - v11->field_C08 = (double)pos->x - dot_dist * a7->field_4.x; - v11->field_C0A = (double)pos->y - dot_dist * a7->field_4.y; - v11->field_C0C = (double)pos->z - dot_dist * a7->field_4.z; + lightmap->field_C08 = (double)pos->x - dot_dist * a7->field_4.x; + lightmap->field_C0A = (double)pos->y - dot_dist * a7->field_4.y; + lightmap->field_C0C = (double)pos->z - dot_dist * a7->field_4.z; - v17 = radius * flt_3C8C2C_lightmaps_brightness; - flt_3C8C30 = v17; - flt_3C8C0C = v17 * a7->field_10.x; - flt_3C8C10 = v17 * a7->field_10.y; - flt_3C8C14 = v17 * a7->field_10.z; - flt_3C8C18 = v17 * a7->field_1C.x; - flt_3C8C1C = v17 * a7->field_1C.y; - flt_3C8C20 = v17 * a7->field_1C.z; + flt_3C8C30 = radius * flt_3C8C2C_lightmaps_brightness; + flt_3C8C0C = flt_3C8C30 * a7->field_10.x; + flt_3C8C10 = flt_3C8C30 * a7->field_10.y; + flt_3C8C14 = flt_3C8C30 * a7->field_10.z; + + flt_3C8C18 = flt_3C8C30 * a7->field_1C.x; + flt_3C8C1C = flt_3C8C30 * a7->field_1C.y; + flt_3C8C20 = flt_3C8C30 * a7->field_1C.z; - /* - v11->pVertices[0].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C; - v11->pVertices[0].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10; - v11->pVertices[0].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14; - v11->pVertices[0].u = 0.0; - v11->pVertices[0].v = 0.0; + lightmap->pVertices[0].vWorldPosition.x = lightmap->field_C08 - flt_3C8C18 + flt_3C8C0C; + lightmap->pVertices[0].vWorldPosition.y = lightmap->field_C0A - flt_3C8C1C + flt_3C8C10; + lightmap->pVertices[0].vWorldPosition.z = lightmap->field_C0C - flt_3C8C20 + flt_3C8C14; + lightmap->pVertices[0].u = 0.0; + lightmap->pVertices[0].v = 0.0; - v11->pVertices[1].vWorldPosition.x = v11->field_C08 - flt_3C8C18 - flt_3C8C0C; - v11->pVertices[1].vWorldPosition.y = v11->field_C0A - flt_3C8C1C - flt_3C8C10; - v11->pVertices[1].vWorldPosition.z = v11->field_C0C - flt_3C8C20 - flt_3C8C14; - v11->pVertices[1].u = 0.0; - v11->pVertices[1].v = 1.0; + lightmap->pVertices[1].vWorldPosition.x = lightmap->field_C08 - flt_3C8C18 - flt_3C8C0C; + lightmap->pVertices[1].vWorldPosition.y = lightmap->field_C0A - flt_3C8C1C - flt_3C8C10; + lightmap->pVertices[1].vWorldPosition.z = lightmap->field_C0C - flt_3C8C20 - flt_3C8C14; + lightmap->pVertices[1].u = 0.0; + lightmap->pVertices[1].v = 1.0; - v11->pVertices[2].vWorldPosition.x = v11->field_C08 + flt_3C8C18 - flt_3C8C0C; - v11->pVertices[2].vWorldPosition.y = v11->field_C0A + flt_3C8C1C - flt_3C8C10; - v11->pVertices[2].vWorldPosition.z = v11->field_C0C + flt_3C8C20 - flt_3C8C14; - v11->pVertices[2].u = 1.0; - v11->pVertices[2].v = 1.0; + lightmap->pVertices[2].vWorldPosition.x = lightmap->field_C08 + flt_3C8C18 - flt_3C8C0C; + lightmap->pVertices[2].vWorldPosition.y = lightmap->field_C0A + flt_3C8C1C - flt_3C8C10; + lightmap->pVertices[2].vWorldPosition.z = lightmap->field_C0C + flt_3C8C20 - flt_3C8C14; + lightmap->pVertices[2].u = 1.0; + lightmap->pVertices[2].v = 1.0; - v11->pVertices[3].vWorldPosition.x = v11->field_C08 + flt_3C8C18 + flt_3C8C0C; - v11->pVertices[3].vWorldPosition.y = v11->field_C0A + flt_3C8C1C + flt_3C8C10; - v11->pVertices[3].vWorldPosition.z = v11->field_C0C + flt_3C8C20 + flt_3C8C14; - v11->pVertices[3].u = 1.0; - v11->pVertices[3].v = 0.0; - */ + lightmap->pVertices[3].vWorldPosition.x = lightmap->field_C08 + flt_3C8C18 + flt_3C8C0C; + lightmap->pVertices[3].vWorldPosition.y = lightmap->field_C0A + flt_3C8C1C + flt_3C8C10; + lightmap->pVertices[3].vWorldPosition.z = lightmap->field_C0C + flt_3C8C20 + flt_3C8C14; + lightmap->pVertices[3].u = 1.0; + lightmap->pVertices[3].v = 0.0; for (uint i = 0; i < 4; ++i) { - v11->pVertices[i].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C; - v11->pVertices[i].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10; - v11->pVertices[i].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14; - v11->pVertices[i].u = 0.0; - v11->pVertices[i].v = 0.0; - - v24 = a7->field_4.y * v11->pVertices[i].vWorldPosition.y - + a7->field_4.z * v11->pVertices[i].vWorldPosition.z - + a7->field_4.x * v11->pVertices[i].vWorldPosition.x + v24 = a7->field_4.y * lightmap->pVertices[i].vWorldPosition.y + + a7->field_4.z * lightmap->pVertices[i].vWorldPosition.z + + a7->field_4.x * lightmap->pVertices[i].vWorldPosition.x + a7->dist; - v11->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x; - v11->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y; - v11->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z; + lightmap->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x; + lightmap->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y; + lightmap->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z; } - v11->uColorMask = uColorMask; - v11->uNumVertices = 4; + lightmap->uColorMask = uColorMask; + lightmap->uNumVertices = 4; + //Brightness(яркость)///////////////////////////////// if (~pGame->uFlags2 & 4) - v11->fBrightness = flt_3C8C2C_lightmaps_brightness; + lightmap->fBrightness = flt_3C8C2C_lightmaps_brightness; else { Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8 - a1.x = (double)pos->x - v11->field_C08; - a1.y = (double)pos->y - v11->field_C0A; - a1.z = (double)pos->z - v11->field_C0C; + a1.x = (double)pos->x - lightmap->field_C08; + a1.y = (double)pos->y - lightmap->field_C0A; + a1.z = (double)pos->z - lightmap->field_C0C; a1.Normalize(); - auto dist_x = abs(pos->x - v11->field_C08), //v31 - dist_y = abs(pos->y - v11->field_C0A), //v32 arg0a - dist_z = abs(pos->z - v11->field_C0C); //v33 _v64 + auto temp1 = lightmap->field_C08 + 0.5f, + temp2 = lightmap->field_C0A + 0.5f, + temp3 = lightmap->field_C0C + 0.5f; + + auto dist_x = abs(pos->x - temp1), //v31 + dist_y = abs(pos->y - temp2), //v32 arg0a + dist_z = abs(pos->z - temp3); //v33 _v64 v38 = int_get_vector_length(dist_x, dist_y, dist_z); if (v38 > radius) return true; //radius = (1 / radius) * v38; if ( uLightType & 4 ) { - //v59 = (void *)v37; - //uLightType = flt_4D86CC; - //v58 = v37; v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y); v40 = v39 * 1.0 * flt_4D86CC; - v11->fBrightness = v40 - (1 / radius) * v38 * v40; + lightmap->fBrightness = v40 - ((1 / radius) * v38) * v40; } else if ( uLightType & 8 ) { v40 = 1.0 * 1.0; - v11->fBrightness = v40 - (1 / radius) * v38; + lightmap->fBrightness = v40 - ((1 / radius) * v38); } else MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0); } + //Brightness(яркость)///////////////////////////////////////////////////// if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices, a7->field_4.x, a7->field_4.y, a7->field_4.z, - v11->pVertices, &v11->uNumVertices)) + lightmap->pVertices, &lightmap->uNumVertices)) return false; - //v44 = &v11->uNumVertices; - if (!v11->uNumVertices) + if (!lightmap->uNumVertices) return true; - v45 = _45C6D6(uNumVertices, a9, v11); + v45 = _45C6D6(uNumVertices, a9, lightmap); if ( v45 != uNumVertices && v45 > 0 ) - _45C4B9(uNumVertices, a9, v11); - //v59 = v11->uNumVertices; - //v46 = (RenderVertexSoft *)pLightmapVertices_; - pGame->pIndoorCameraD3D->ViewTransform(v11->pVertices, v11->uNumVertices); - //v59 = 0; - //v58 = v11->uNumVertices; - pGame->pIndoorCameraD3D->Project(v11->pVertices, v11->uNumVertices, 0); + _45C4B9(uNumVertices, a9, lightmap); + + pGame->pIndoorCameraD3D->ViewTransform(lightmap->pVertices, lightmap->uNumVertices); + pGame->pIndoorCameraD3D->Project(lightmap->pVertices, lightmap->uNumVertices, 0); unsigned int _a4 = 0; if ( !(uClipFlag & 1) ) @@ -257,29 +249,13 @@ { if ( uClipFlag & 2 ) { - //v59 = &a4; - //v58 = (unsigned int)field_3C8C34; - //v57 = *v44; - pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4); - - //v59 = v44; - //v58 = (unsigned int)field_3C8C34; - //v57 = (int)v46; - //v56 = a4; - pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices); + pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(lightmap->pVertices, lightmap->uNumVertices, field_3C8C34, &_a4); + pGame->pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->uNumVertices); } else if ( uClipFlag & 4 ) { - //v59 = &a4; - //v58 = (unsigned int)field_3C8C34; - //v57 = *v44; - pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4); - - //v59 = v44; - //v58 = (unsigned int)field_3C8C34; - //v57 = (int)v46; - //v56 = a4; - pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices); + pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(lightmap->pVertices, lightmap->uNumVertices, field_3C8C34, &_a4); + pGame->pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->uNumVertices); } else MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0); @@ -291,19 +267,11 @@ { if (uLightType & 1) { - //v48 = (char *)&std__vector_000004_size; - //v49 = std__vector_000004_size; - //v51 = __OFSUB__(std__vector_000004_size, 511); - //v50 = std__vector_000004_size - 511 < 0; if (std__vector_000004_size < 512 - 1) ++std__vector_000004_size; } else { - //v48 = (char *)&std__vector_183808_size; - //v49 = std__vector_183808_size; - //v51 = __OFSUB__(std__vector_183808_size, 767); - //v50 = std__vector_183808_size - 767 < 0; if (std__vector_183808_size < 768 - 1) ++std__vector_183808_size; } @@ -316,14 +284,7 @@ //----- (0045C4B9) -------------------------------------------------------- int LightmapBuilder::_45C4B9(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) { - Lightmap *v4; // edi@1 - int v5; // eax@1 - signed int v6; // ecx@1 - RenderVertexSoft *v7; // ebx@2 - int v8; // edx@3 RenderVertexSoft *v9; // esi@3 - int v10; // eax@6 -// char *v11; // edi@7 RenderVertexSoft *v12; // ecx@8 char v13; // bl@17 signed int v14; // edx@17 @@ -331,120 +292,100 @@ double v16; // st6@21 double v17; // st6@24 signed int v18; // edx@33 - int v20; // [sp+4h] [bp-1Ch]@3 - //int v21; // [sp+8h] [bp-18h]@8 float v22; // [sp+Ch] [bp-14h]@23 float v23; // [sp+10h] [bp-10h]@20 int v24; // [sp+14h] [bp-Ch]@1 - RenderVertexSoft *v25; // [sp+18h] [bp-8h]@2 char v26; // [sp+1Eh] [bp-2h]@17 char v27; // [sp+1Fh] [bp-1h]@17 - //__debugbreak();//Ritor1: needed cleaning - - v4 = pLightmap; - v5 = 0; - v6 = pLightmap->uNumVertices; v24 = 0; - if ( v6 > 0 ) + for ( uint i = 0; i < pLightmap->uNumVertices; i++) { - v7 = pLightmap->pVertices; - v25 = pLightmap->pVertices; - do + v9 = &pLightmap->pVertices[(i + 1) % pLightmap->uNumVertices]; + if ( pLightmap->pVertices[i].vWorldPosition.x != v9->vWorldPosition.x + || pLightmap->pVertices[i].vWorldPosition.y != v9->vWorldPosition.y + || pLightmap->pVertices[i].vWorldPosition.z != v9->vWorldPosition.z ) { - v20 = v5 + 1; - v8 = (v5 + 1) % v6; - v9 = &v4->pVertices[v8]; - if ( v7->vWorldPosition.x != v9->vWorldPosition.x - || v7->vWorldPosition.y != v4->pVertices[v8].vWorldPosition.y - || v7->vWorldPosition.z != v4->pVertices[v8].vWorldPosition.z ) + for ( uint j = 0; j < a2; ++j ) { - //v10 = 0; - if ( a2 > 0 ) + v12 = &a3[(j + 1) % a2]; + if ((a3[j].vWorldPosition.x != v12->vWorldPosition.x + || a3[j].vWorldPosition.y != v12->vWorldPosition.y + || a3[j].vWorldPosition.z != v12->vWorldPosition.z) + && pLightmap->pVertices[i].vWorldPosition.x == a3[j].vWorldPosition.x + && pLightmap->pVertices[i].vWorldPosition.y == a3[j].vWorldPosition.y + && pLightmap->pVertices[i].vWorldPosition.z == a3[j].vWorldPosition.z + && (v9->vWorldPosition.x != v12->vWorldPosition.x + || v9->vWorldPosition.y != v12->vWorldPosition.y + || v9->vWorldPosition.z != v12->vWorldPosition.z) ) { - //v11 = (char *)&a3->vWorldPosition.z; - for ( v10 = 1; v10 <= a2; ++v10 ) - { - //v21 = v10 + 1; - v12 = &a3[v10 % a2]; - if ((a3[v10].vWorldPosition.x != v12->vWorldPosition.x - || a3[v10].vWorldPosition.y != v12->vWorldPosition.y || a3[v10].vWorldPosition.z != v12->vWorldPosition.z) - && v7->vWorldPosition.x == a3[v10].vWorldPosition.x - && v7->vWorldPosition.y == a3[v10].vWorldPosition.y && v7->vWorldPosition.z == a3[v10].vWorldPosition.z - && (v9->vWorldPosition.x != v12->vWorldPosition.x - || v9->vWorldPosition.y != v12->vWorldPosition.y || v9->vWorldPosition.z != v12->vWorldPosition.z) ) - { - v13 = 0; - v14 = 0; - v27 = 0; - v26 = 0; - if ( v9->vWorldPosition.x <= (double)v12->vWorldPosition.x ) - v15 = v12->vWorldPosition.x - v9->vWorldPosition.x; - else - v15 = v9->vWorldPosition.x - v12->vWorldPosition.x; - v23 = v15; + v13 = 0; + v14 = 0; + v27 = 0; + v26 = 0; + + if ( v9->vWorldPosition.x <= (double)v12->vWorldPosition.x ) + v15 = v12->vWorldPosition.x - v9->vWorldPosition.x; + else + v15 = v9->vWorldPosition.x - v12->vWorldPosition.x; + v23 = v15; + + if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y ) + v16 = v12->vWorldPosition.y - v9->vWorldPosition.y; + else + v16 = v9->vWorldPosition.y - v12->vWorldPosition.y; + v22 = v16; + + if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z ) + v17 = v12->vWorldPosition.z - v9->vWorldPosition.z; + else + v17 = v9->vWorldPosition.z - v12->vWorldPosition.z; - if ( v9->vWorldPosition.y <= (double)v12->vWorldPosition.y ) - v16 = v12->vWorldPosition.y - v9->vWorldPosition.y; - else - v16 = v9->vWorldPosition.y - v12->vWorldPosition.y; - v22 = v16; + if ( v23 < 1.0 ) + { + v13 = 1; + v14 = 1; + } + + if ( v22 < 1.0 ) + { + v27 = 1; + ++v14; + } + + if ( v17 < 1.0 ) + { + v26 = 1; + ++v14; + } - if ( v9->vWorldPosition.z <= (double)v12->vWorldPosition.z ) - v17 = v12->vWorldPosition.z - v9->vWorldPosition.z; - else - v17 = v9->vWorldPosition.z - v12->vWorldPosition.z; - if ( v23 < 1.0 ) - { - v13 = 1; - v14 = 1; - } - if ( v22 < 1.0 ) - { - v27 = 1; - ++v14; - } - if ( v17 < 1.0 ) - { - v26 = 1; - ++v14; - } - if ( v14 > 1 ) - { - v18 = 0; - if ( v13 && v9->vWorldPosition.x != v12->vWorldPosition.x ) - { - v18 = 1; - v9->vWorldPosition.x = v12->vWorldPosition.x; - } - if ( v27 && v9->vWorldPosition.y != v12->vWorldPosition.y ) - { - ++v18; - v9->vWorldPosition.y = v12->vWorldPosition.y; - } - if ( v26 && v9->vWorldPosition.z != v12->vWorldPosition.z ) - { - ++v18; - v9->vWorldPosition.z = v12->vWorldPosition.z; - } - if ( v18 > 0 ) - ++v24; - } - v7 = v25; + if ( v14 > 1 ) + { + v18 = 0; + if ( v13 && v9->vWorldPosition.x != v12->vWorldPosition.x ) + { + v18 = 1; + v9->vWorldPosition.x = v12->vWorldPosition.x; } - //++v10; - //v11 += 48; + + if ( v27 && v9->vWorldPosition.y != v12->vWorldPosition.y ) + { + ++v18; + v9->vWorldPosition.y = v12->vWorldPosition.y; + } + + if ( v26 && v9->vWorldPosition.z != v12->vWorldPosition.z ) + { + ++v18; + v9->vWorldPosition.z = v12->vWorldPosition.z; + } + + if ( v18 > 0 ) + ++v24; } - //while ( v21 < a2 ); - v4 = pLightmap; } } - v5 = v20; - v6 = v4->uNumVertices; - ++v7; - v25 = v7; } - while ( v20 < v6 ); } return v24; } @@ -919,7 +860,7 @@ // 4E94D2: using guessed type char _4E94D2_light_type; //----- (0045D036) -------------------------------------------------------- -bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a2, RenderVertexSoft *a3, unsigned int uStripType, bool bLightBackfaces) +bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *Light_tile_dist, RenderVertexSoft *a3, unsigned int uStripType, bool bLightBackfaces) { /*int v6; // esi@1 //LightmapBuilder *v7; // edi@1 @@ -966,26 +907,26 @@ // bool __stdcall sub_45D036(struct Vec3<float> *pNormal, int a2, struct RenderVertex *a3, int a4, signed int X) //{ // float v6; // ebx@2 - unsigned int v10; // [sp+Ch] [bp-4h]@1 - int i; + unsigned int num_lights; // [sp+Ch] [bp-4h]@1 + int i; - v10 = 0; + num_lights = 0; stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level; for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) { - if ( v10 >= 20 ) + if ( num_lights >= 20 ) break; - StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10); + StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights); } for (i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) { - if ( v10 >= 20 ) + if ( num_lights >= 20 ) break; - StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10); + StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights); } - stru_F8AD28.uNumLightsApplied = v10; + stru_F8AD28.uNumLightsApplied = num_lights; return true; } @@ -994,145 +935,86 @@ //----- (0045D0D5) -------------------------------------------------------- bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot) { - StationaryLight *v8; // edi@1 bool result; // eax@1 - RenderVertexSoft *v11; // ebx@2 - float v12; // eax@3 - float v13; // eax@4 double maxz; // st7@11 - double v16; // st7@11 - double v17; // st6@11 char v20; // c2@11 - Vec3_float_ *v49; // esi@17 signed int v52; // ecx@17 - unsigned int *v53; // esi@18 - int v54; // eax@18 - unsigned int v55; // ebx@18 char v57; // dl@18 std::string v58; // [sp-18h] [bp-38h]@10 - const char *v59; // [sp-8h] [bp-28h]@10 - signed int v60; // [sp-4h] [bp-24h]@10 double v61; // [sp+Ch] [bp-14h]@11 float minz; // [sp+14h] [bp-Ch]@11 - int v63; // [sp+18h] [bp-8h]@1 - float v64; // [sp+1Ch] [bp-4h]@5 + float tX_0; + float tX_1; + float tY_0; + float tY_1; // [sp+1Ch] [bp-4h]@5 - v8 = pLight; - result = pLight->uRadius; - v63 = pLight->uRadius; - if ( result <= 0 ) + if ( pLight->uRadius <= 0 ) return 0; - //v10 = uStripType; - v11 = a1; if ( uStripType == 4 ) { - pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x); - v12 = a1[3].vWorldPosition.x; - //uStripType = LODWORD(v12); - a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); - v13 = v11->vWorldPosition.y; + tX_0 = a1->vWorldPosition.x; + tX_1 = a1[3].vWorldPosition.x; + tY_0 = a1[1].vWorldPosition.y; + tY_1 = a1->vWorldPosition.y; } - else + else // uStripType == 3 { if ( uStripType != 3 ) - { MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0); - //goto LABEL_11; - } - else if ((unsigned char)X) + else if ((unsigned char)X) { - pLight = (StationaryLight *)LODWORD(a1->vWorldPosition.x); - uStripType = LODWORD(a1[2].vWorldPosition.x); - a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); - v13 = v11[2].vWorldPosition.y; - v64 = v13; - //goto LABEL_11; - //goto LABEL_5; + tX_0 = a1->vWorldPosition.x; + tX_1 = a1[2].vWorldPosition.x; + tY_0 = a1[1].vWorldPosition.y; + tY_1 = a1[2].vWorldPosition.y; } - else - { - pLight = (StationaryLight *)LODWORD(a1[1].vWorldPosition.x); - v12 = a1[2].vWorldPosition.x; - a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); - v13 = v11->vWorldPosition.y; - v64 = v13; - //uStripType = LODWORD(v12); - a1 = (RenderVertexSoft *)LODWORD(a1[1].vWorldPosition.y); - v13 = v11->vWorldPosition.y; - } + else + { + tX_0 = a1[1].vWorldPosition.x; + tX_1 = a1[2].vWorldPosition.x; + tY_0 = a1[1].vWorldPosition.y; + tY_1 = a1->vWorldPosition.y; + } } -//LABEL_11: - //v60 = v10; - v59 = (const char *)v11; - v60 = v12;//uStripType; - minz = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, uStripType); - maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, uStripType); - result = v8->vPosition.x; - *((float *)&v61 + 1) = maxz; - v16 = (double)result; - *(float *)&X = (double)v63; - v17 = *(float *)&pLight - *(float *)&X; - //UNDEF(v18); - //v19 = v16 < v17; - v20 = 0; - //v21 = v16 == v17; -/* BYTE1(result) = HIBYTE(v18); - if ( v16 <= v17 - || (v22 = *(float *)&X + *(float *)&uStripType, - //UNDEF(v23), - v24 = v16 < v22, - v25 = 0, - v26 = v16 == v22, - BYTE1(result) = HIBYTE(v23), - v16 >= v22) - || (result = v8->vPosition.y, - pLight = (StationaryLight *)v8->vPosition.y, - v27 = (double)(signed int)pLight, - v28 = *(float *)&a1 - *(float *)&X, - //UNDEF(v29), - v30 = v27 < v28, - v31 = 0, - v32 = v27 == v28, - BYTE1(result) = HIBYTE(v29), - v27 <= v28) - || (v33 = *(float *)&X + v64, - //UNDEF(v34), - v35 = v27 < v33, - v36 = 0, - v37 = v27 == v33, - BYTE1(result) = HIBYTE(v34), - v27 >= v33) - || (result = v8->vPosition.z, - pLight = (StationaryLight *)v8->vPosition.z, - v38 = (double)(signed int)pLight, - v39 = minz - *(float *)&X, - //UNDEF(v40), - v41 = v38 < v39, - v42 = 0, - v43 = v38 == v39, - BYTE1(result) = HIBYTE(v40), - v38 <= v39) - || (v44 = *(float *)&X + *((float *)&v61 + 1), - //UNDEF(v45), - v46 = v38 < v44, - v47 = 0, - v48 = v38 == v44, - BYTE1(result) = HIBYTE(v45), - v38 >= v44) - || (v49 = pNormal, - Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3), - X = v8->vPosition.y, - v50 = (double)X * v49->y, - X = v8->vPosition.z, - v51 = (double)X * v49->z, - X = v8->vPosition.x, - *(float *)&a3 = v50 + v51 + (double)X * v49->x + *a3, - v61 = *(float *)&a3 + 6.7553994e15, - result = LODWORD(v61), - X = LODWORD(v61), - v52 = v63, - SLODWORD(v61) > v63) )*/ + minz = pGame->pIndoorCameraD3D->GetPolygonMinZ(a1, uStripType); + maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(a1, uStripType); + + float bounding_x1 = tX_0 - (float)pLight->uRadius; //13 976 - 128 = 13848.0 + float bounding_y1 = tY_0 - (float)pLight->uRadius; // 3 800 - 128 = 3672.0 + float bounding_z1 = minz - (float)pLight->uRadius; // -26.0 + + float bounding_x2 = (float)pLight->uRadius + tX_1; //13 877 + 128 = 14005.0 + float bounding_y2 = (float)pLight->uRadius + tY_1; //3 792 + 128 = 3920.0 + float bounding_z2 = (float)pLight->uRadius + maxz;// 260.0 + + if ( (float)pLight->vPosition.x <= bounding_x1 || (float)pLight->vPosition.x >= bounding_x2 + || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2 + || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 ) + return 0; + + Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3); + float p_dot = (float)pLight->vPosition.x * pNormal->x + + (float)pLight->vPosition.y * pNormal->y + + (float)pLight->vPosition.z * pNormal->z + *a3; + p_dot = p_dot + 0.5f; + if ( (//v49 = pNormal, + //Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3), + //X = v8->vPosition.y, + //v50 = (double)v8->vPosition.y * v49->y, + //X = v8->vPosition.z, + //v51 = (double)v8->vPosition.z * v49->z, + //X = v8->vPosition.x, + //*(float *)&a3 = (double)pLight->vPosition.y * pNormal->y + //+ (double)pLight->vPosition.z * pNormal->z + //+ (double)pLight->vPosition.x * pNormal->x + *a3, + //v61 = *(float *)&a3 + 0.5f, + //result = LODWORD(v61), + //X = LODWORD(v61), + //v52 = v63, + p_dot > pLight->uRadius) ) + return 0; +/* v49 = pNormal; Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3); *(float *)a3 = (double)v8->vPosition.x * v49->x @@ -1141,42 +1023,39 @@ v61 = *(float *)a3 + 6.7553994e15; result = LODWORD(v61); X = LODWORD(v61); - v52 = v63; - if ( SLODWORD(v61) > v63) - return 0; - v53 = pSlot; - v60 = X; - stru_F8AD28._blv_lights_radii[*pSlot] = v63; - stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v63; - stru_F8AD28._blv_lights_xs[*v53] = v8->vPosition.x; - stru_F8AD28._blv_lights_ys[*v53] = v8->vPosition.y; - stru_F8AD28._blv_lights_zs[*v53] = v8->vPosition.z; - //a3 = (float *)v8->uLightColorR; - stru_F8AD28._blv_lights_rs[*v53] = v8->uLightColorR / 255.0f; - //a3 = (float *)v8->uLightColorG; - stru_F8AD28._blv_lights_gs[*v53] = v8->uLightColorG / 255.0f; - //a3 = (float *)v8->uLightColorB; - stru_F8AD28._blv_lights_bs[*v53] = v8->uLightColorB / 255.0f; - v54 = abs(v63); - v55 = pRenderer->bUsingSpecular; - stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54; - stru_F8AD28._blv_lights_types[*v53] = v8->uLightType; - //v56 = pRenderer->pRenderD3D; - v57 = stru_F8AD28._blv_lights_types[*v53]; - if ( /*pRenderer->pRenderD3D &&*/ v55 && v57 & 4 ) + v52 = radius_1; + if ( SLODWORD(v61) > radius_1)*/ + //v53 = pSlot; + //v60 = X; + stru_F8AD28._blv_lights_radii[*pSlot] = pLight->uRadius; + stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; + stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; + stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; + stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; + + stru_F8AD28._blv_lights_rs[*pSlot] = pLight->uLightColorR / 255.0f; + stru_F8AD28._blv_lights_gs[*pSlot] = pLight->uLightColorG / 255.0f; + stru_F8AD28._blv_lights_bs[*pSlot] = pLight->uLightColorB / 255.0f; + + stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(p_dot); + stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; + + v57 = stru_F8AD28._blv_lights_types[*pSlot]; + if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && stru_F8AD28._blv_lights_types[*pSlot] & 4 ) v57 = _4E94D2_light_type; - stru_F8AD28._blv_lights_types[*v53] = v57; - result = 4 * *v53; - if ( /*v56 &&*/ v55 ) + stru_F8AD28._blv_lights_types[*pSlot] = v57; + + result = 4 * *pSlot; + if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular ) { - if ( stru_F8AD28._blv_lights_types[*v53] & 4 ) + if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) { stru_F8AD28._blv_lights_rs[result] = stru_F8AD28._blv_lights_rs[result] * 0.3300000131130219; stru_F8AD28._blv_lights_gs[result] = stru_F8AD28._blv_lights_gs[result] * 0.3300000131130219; stru_F8AD28._blv_lights_bs[result] = stru_F8AD28._blv_lights_bs[result] * 0.3300000131130219; } } - ++*v53; + ++*pSlot; return 1; }
--- a/Engine/Graphics/LightmapBuilder.h Mon Oct 13 17:52:23 2014 +0300 +++ b/Engine/Graphics/LightmapBuilder.h Sun Nov 23 15:30:17 2014 +0600 @@ -73,7 +73,7 @@ float flt_3C8C18; float flt_3C8C1C; float flt_3C8C20; - float flt_3C8C24; + float tex_light_radius;//flt_3C8C24; float flt_3C8C28; float flt_3C8C2C_lightmaps_brightness; float flt_3C8C30;
--- a/Engine/Graphics/Render.cpp Mon Oct 13 17:52:23 2014 +0300 +++ b/Engine/Graphics/Render.cpp Sun Nov 23 15:30:17 2014 +0600 @@ -279,28 +279,28 @@ unsigned int Start_X, End_X, Start_Z, End_Z; if ( direction >= 0 && direction < 1.0 )//East(B) - NorthEast(CB) { - Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; - Start_Z = 0, End_Z = 127; + Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128; + Start_Z = 0, End_Z = 128; } else if (direction >= 1.0 && direction < 3.0)//NorthEast(CB) - WestNorth(CЗ) { - Start_X = 0, End_X = 127; + Start_X = 0, End_X = 128; Start_Z = 0, End_Z = pODMRenderParams->uMapGridCellZ + 1; } else if (direction >= 3.0 && direction < 5.0)//WestNorth(CЗ) - SouthWest(ЮЗ) { Start_X = 0, End_X = pODMRenderParams->uMapGridCellX + 2; - Start_Z = 0, End_Z = 127; + Start_Z = 0, End_Z = 128; } else if ( direction >= 5.0 && direction < 7.0 )//SouthWest(ЮЗ) - //SouthEast(ЮВ) { - Start_X = 0, End_X = 127; - Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 127; + Start_X = 0, End_X = 128; + Start_Z = pODMRenderParams->uMapGridCellZ - 2, End_Z = 128; } else//SouthEast(ЮВ) - East(B) { - Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 127; - Start_Z = 0, End_Z = 127; + Start_X = pODMRenderParams->uMapGridCellX - 2, End_X = 128; + Start_Z = 0, End_Z = 128; } for (unsigned int z = Start_Z; z < End_Z; ++z) { @@ -348,9 +348,33 @@ pTilePolygon->uNumVertices = 4; pTilePolygon->field_59 = 5; + if ( array_73D150[0].vWorldViewPosition.x < 8.0 + && array_73D150[1].vWorldViewPosition.x < 8.0 + && array_73D150[2].vWorldViewPosition.x < 8.0 + && array_73D150[3].vWorldViewPosition.x < 8.0 ) + continue; + if ( (double)pODMRenderParams->shading_dist_mist < array_73D150[0].vWorldViewPosition.x + && (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 ) + continue; + //---------------------------------------------------------------------------- + + ++pODMRenderParams->uNumPolygons; + ++pODMRenderParams->field_44; + assert(pODMRenderParams->uNumPolygons < 20000); + + pTilePolygon->uBModelID = 0; + pTilePolygon->uBModelFaceID = 0; + pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; + for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) + { + memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); + array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); + } //shading (затенение)---------------------------------------------------------------------------- //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; - uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; + uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1]; assert(norm_idx < uNumTerrainNormals); Vec3_float_* norm = &pTerrainNormals[norm_idx]; @@ -364,26 +388,14 @@ norm = &pTerrainNormals[norm_idx]; if (for_refactoring) { - MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); - __debugbreak(); - } - //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &Light_tile_dist, array_50AC10, 4, 1);//Ritor1: slows + //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0); + //__debugbreak(); + + 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; - assert(pODMRenderParams->uNumPolygons < 20000); - - pTilePolygon->uBModelID = 0; - pTilePolygon->uBModelFaceID = 0; - pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; - for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) - { - memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); - array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); - } + } + unsigned int a5 = 4; + //---------Draw distance(Дальность отрисовки)------------------------------- int temp = pODMRenderParams->shading_dist_mist; if ( draw_terrain_dist_mist ) @@ -397,21 +409,21 @@ || (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);*/ + 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 ) { @@ -4664,8 +4676,8 @@ { d3d_vertex_buffer[i].specular = 0; } - __debugbreak(); // warning C4700: uninitialized local variable 'v20' used - d3d_vertex_buffer[i].specular = v20; + //__debugbreak(); // warning C4700: uninitialized local variable 'v20' used + //d3d_vertex_buffer[i].specular = v20; d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; }