Mercurial > mm7
diff Engine/Graphics/DecalBuilder.cpp @ 2531:f6de3e15d4a5
for light in indoor
author | Ritor1 |
---|---|
date | Sun, 23 Nov 2014 15:30:17 +0600 |
parents | 491f0babd563 |
children | 9ec6b8be16fe |
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; }