Mercurial > mm7
changeset 1073:d4a1a46192ba
some Render cleaning
author | zipi |
---|---|
date | Sat, 25 May 2013 12:24:35 +0100 |
parents | 48168499f52e |
children | d6bea22f8b53 |
files | Render.cpp |
diffstat | 1 files changed, 97 insertions(+), 196 deletions(-) [+] |
line wrap: on
line diff
--- a/Render.cpp Sat May 25 11:24:10 2013 +0100 +++ b/Render.cpp Sat May 25 12:24:35 2013 +0100 @@ -4468,40 +4468,28 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); } - if ( (signed int)uNumVertices > 0 ) - { - v45 = (char *)&array_50AC10[0].vWorldViewPosition; - v57 = (int)&d3d_vertex_buffer[0].pos.y; - v55 = uNumVertices; - do + for (uint i = 0; i < uNumVertices; ++i) + { + + d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; + d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; + d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); + d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); + d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); + pGame->AlterGamma_ODM(a4, &d3d_vertex_buffer[i].diffuse); + + if ( this->bUsingSpecular ) { - a2 = ::GetActorTintColor(a3->dimming_level, 0, *(float *)v45, 0, 0); - pGame->AlterGamma_ODM(a4, &a2); - v46 = v57; - v47 = *(float *)v45 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; - *(int *)(v57 - 4) = *((int *)v45 + 3); - *(int *)v57 = *((int *)v45 + 4); - *(int *)(v57 + 12) = a2; - *(float *)(v57 + 4) = 1.0 - 1.0 / v47; - *(float *)(v57 + 8) = 1.0 / (*(float *)v45 + 0.0000001); - if ( v5->bUsingSpecular ) - { - v48 = sub_47C3D7_get_fog_related_stuff(0, 0, *(float *)v45); - v46 = v57; - } - else - { - v48 = 0; - } - *(int *)(v46 + 16) = v48; - *(int *)(v46 + 20) = *((int *)v45 + 6); - *(int *)(v46 + 24) = *((int *)v45 + 7); - v45 += 48; - v18 = v55-- == 1; - v57 = v46 + 32; + d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); } - while ( !v18 ); - } + else + { + d3d_vertex_buffer[i].specular = 0; + } + d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; + d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; + + } if (a4->uAttributes & FACE_OUTLINED) { @@ -4523,45 +4511,27 @@ } else { - if ( (signed int)uNumVertices > 0 ) - { - v9 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; - v10 = (char *)&array_50AC10[0].vWorldViewPosition; - a4 = (ODMFace *)&d3d_vertex_buffer[0].pos.y; - v56 = uNumVertices; - while ( 1 ) + for (uint i = 0; i < uNumVertices; ++i) + { + + d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; + d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; + d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); + d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); + d3d_vertex_buffer[i].diffuse = GetActorTintColor(a3->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); + if ( this->bUsingSpecular ) { - v11 = *(float *)v10 * 1000.0; - *((int *)v9 - 1) = *((int *)v10 + 3); - v12 = v11 / (double)pOutdoorCamera->shading_dist_mist; - v9->pFacePlane.vNormal.x = *((int *)v10 + 4); - *(float *)&v9->pFacePlane.vNormal.y = 1.0 - 1.0 / v12; - *(float *)&v9->pFacePlane.vNormal.z = 1.0 / (*(float *)v10 + 0.0000001); - v13 = GetActorTintColor(a3->dimming_level, 0, *(float *)v10, 0, 0); - v14 = a4; - v15 = *(float *)v10; - a4->pFacePlane.dist = v13; - if ( v5->bUsingSpecular ) - { - v16 = v15; - v17 = sub_47C3D7_get_fog_related_stuff(0, 0, v16); - v14 = a4; - } - else - { - v17 = 0; - } - v14->zCalc1 = v17; - v14->zCalc2 = *((int *)v10 + 6); - v14->zCalc3 = *((int *)v10 + 7); - v10 += 48; - v18 = v56-- == 1; - a4 = (ODMFace *)((char *)v14 + 32); - if ( v18 ) - break; - v9 = a4; + d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); } - } + else + { + d3d_vertex_buffer[i].specular = 0; + } + d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; + d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; + + } + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); if (bUsingSpecular) @@ -4577,18 +4547,10 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); //(*(void (**)(void))(*(int *)v50 + 88))(); v53->_45D74F_MessWithLight(-1, 0); - v23 = uNumVertices; - if ( (signed int)uNumVertices > 0 ) - { - v24 = (char *)&d3d_vertex_buffer[0].diffuse; - do - { - *(int *)v24 = a2; - v24 += 32; - --v23; - } - while ( v23 ); - } + for (uint i = 0; i < uNumVertices; ++i) + { + d3d_vertex_buffer[i].diffuse = a2; + } ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); if ( !pRenderer->bUsingSpecular ) @@ -4606,20 +4568,12 @@ { ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); - v33 = uNumVertices; - if ( (signed int)uNumVertices > 0 ) - { - v34 = (char *)&d3d_vertex_buffer[0].specular; - do - { - v35 = *(int *)v34; - *(int *)v34 = 0; - v34 += 32; - --v33; - *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000; - } - while ( v33 ); - } + for (uint i = 0; i < uNumVertices; ++i) + { + d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; + d3d_vertex_buffer[i].specular = 0; + } + ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA)); @@ -7436,46 +7390,28 @@ this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); } } - if (uNumVertices > 0) - { - v51 = (int)&d3d_vertex_buffer[0].pos.y; - v52 = (char *)&array_50AC10[0].vWorldViewPosition; - a7 = (int)&d3d_vertex_buffer[0].pos.y; - v66 = uNumVertices; - while ( 1 ) + + for (uint i = 0; i < uNumVertices; ++i) + { + + d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; + d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; + d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); + d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); + d3d_vertex_buffer[i].diffuse = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); + if ( this->bUsingSpecular ) { - v53 = *(float *)v52 * 1000.0; - *(int *)(v51 - 4) = *((int *)v52 + 3); - v54 = v53 / (double)pOutdoorCamera->shading_dist_mist; - *(int *)v51 = *((int *)v52 + 4); - *(float *)(v51 + 4) = 1.0 - 1.0 / v54; - *(float *)(v51 + 8) = 1.0 / (*(float *)v52 + 0.0000001); - v55 = ::GetActorTintColor(a4->dimming_level, 0, *(float *)v52, 0, 0); - v56 = a7; - v57 = *(float *)v52; - *(int *)(a7 + 12) = v55; - if ( this->bUsingSpecular ) - { - v58 = v57; - v59 = sub_47C3D7_get_fog_related_stuff(0, 0, v58); - v56 = a7; - } - else - { - v59 = 0; - } - *(int *)(v56 + 16) = v59; - *(int *)(v56 + 20) = *((int *)v52 + 6); - *(int *)(v56 + 24) = *((int *)v52 + 7); - v52 += 48; - v21 = v66-- == 1; - a7 = v56 + 32; - if ( v21 ) - break; - v51 = a7; + d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); } - } - this->pRenderD3D->pDevice->SetTexture(0, a5); + else + { + d3d_vertex_buffer[i].specular = 0; + } + d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; + d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; + } + + this->pRenderD3D->pDevice->SetTexture(0, a5); this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, d3d_vertex_buffer, uNumVertices, 16); if (transparent) { @@ -7486,45 +7422,26 @@ } else { - if ( (signed int)uNumVertices > 0 ) - { - v12 = (int)&d3d_vertex_buffer[0].pos.y; - v13 = (char *)&array_50AC10[0].vWorldViewPosition; - a7 = (int)&d3d_vertex_buffer[0].pos.y; - a6a = uNumVertices; - while ( 1 ) + for (uint i = 0; i < uNumVertices; ++i) + { + + d3d_vertex_buffer[i].pos.x = array_50AC10[i].vWorldViewProjX; + d3d_vertex_buffer[i].pos.y = array_50AC10[i].vWorldViewProjY; + d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / ((array_50AC10[i].vWorldViewPosition.x * 1000) / (double)pOutdoorCamera->shading_dist_mist); + d3d_vertex_buffer[i].rhw = 1.0 / (array_50AC10[i].vWorldViewPosition.x + 0.0000001); + d3d_vertex_buffer[i].diffuse = GetActorTintColor(a4->dimming_level, 0, array_50AC10[i].vWorldViewPosition.x, 0, 0); + if ( this->bUsingSpecular ) { - v14 = *(float *)v13 * 1000.0; - *(int *)(v12 - 4) = *((int *)v13 + 3); - v15 = v14 / (double)pOutdoorCamera->shading_dist_mist; - *(int *)v12 = *((int *)v13 + 4); - *(float *)(v12 + 4) = 1.0 - 1.0 / v15; - *(float *)(v12 + 8) = 1.0 / (*(float *)v13 + 0.0000001); - v16 = GetActorTintColor(a4->dimming_level, 0, *(float *)v13, 0, 0); - v17 = a7; - v18 = *(float *)v13; - *(int *)(a7 + 12) = v16; - if ( this->bUsingSpecular ) - { - v19 = v18; - v20 = sub_47C3D7_get_fog_related_stuff(0, 0, v19); - v17 = a7; - } - else - { - v20 = 0; - } - *(int *)(v17 + 16) = v20; - *(int *)(v17 + 20) = *((int *)v13 + 6); - *(int *)(v17 + 24) = *((int *)v13 + 7); - v13 += 48; - v21 = a6a-- == 1; - a7 = v17 + 32; - if ( v21 ) - break; - v12 = a7; + d3d_vertex_buffer[i].specular = sub_47C3D7_get_fog_related_stuff(0, 0, array_50AC10[i].vWorldViewPosition.x); } - } + else + { + d3d_vertex_buffer[i].specular = 0; + } + 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; + } ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); if (pRenderer->bUsingSpecular) @@ -7540,18 +7457,10 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); //(*(void (**)(void))(*(int *)v63 + 88))(); pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); - v26 = uNumVertices; - if ( (signed int)uNumVertices > 0 ) - { - v27 = (char *)&d3d_vertex_buffer[0].diffuse; - do - { - *(int *)v27 = -1; - v27 += 32; - --v26; - } - while ( v26 ); - } + for (uint i = 0; i < uNumVertices; ++i) + { + d3d_vertex_buffer[i].diffuse = -1; + } ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); if ( !pRenderer->bUsingSpecular ) @@ -7570,20 +7479,12 @@ { ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); - v37 = uNumVertices; - if ( (signed int)uNumVertices > 0 ) - { - v38 = (char *)&d3d_vertex_buffer[0].specular; - do - { - v39 = *(int *)v38; - *(int *)v38 = 0; - v38 += 32; - --v37; - *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000; - } - while ( v37 ); - } + for (uint i = 0; i < uNumVertices; ++i) + { + d3d_vertex_buffer[i].diffuse = pRenderer->uFogColor | d3d_vertex_buffer[i].specular & 0xFF000000; + d3d_vertex_buffer[i].specular = 0; + } + ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));//problem ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));