Mercurial > mm7
changeset 1784:d73f4668ef94
BuildingVerticesClipping
author | Ritor1 |
---|---|
date | Thu, 03 Oct 2013 18:07:55 +0600 |
parents | 53c0453f4eb2 |
children | 644d10ad682e |
files | Indoor.cpp mm7_3.cpp mm7_6.cpp mm7_data.h |
diffstat | 4 files changed, 42 insertions(+), 149 deletions(-) [+] |
line wrap: on
line diff
--- a/Indoor.cpp Wed Oct 02 17:11:15 2013 +0600 +++ b/Indoor.cpp Thu Oct 03 18:07:55 2013 +0600 @@ -6477,6 +6477,7 @@ signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 int v80; // [sp+1Ch] [bp-Ch]@76 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 + //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 pFace = &pIndoor->pFaces[uFaceID]; memset(&PortalFace, 0, sizeof(stru367));
--- a/mm7_3.cpp Wed Oct 02 17:11:15 2013 +0600 +++ b/mm7_3.cpp Thu Oct 03 18:07:55 2013 +0600 @@ -4640,7 +4640,7 @@ } if ( v49 ) { - v32 = sr_424EE0_MakeFanFromTriangle(uNumVertices); + v32 = BuildingVerticesClipping(uNumVertices); LABEL_76: v7->uNumVertices = v32; uNumVertices = v32;
--- a/mm7_6.cpp Wed Oct 02 17:11:15 2013 +0600 +++ b/mm7_6.cpp Thu Oct 03 18:07:55 2013 +0600 @@ -43,169 +43,61 @@ //----- (00424EE0) -------------------------------------------------------- -int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID) +int BuildingVerticesClipping(unsigned int uNumVertices) { - //unsigned int v1; // edx@1 - double v2; // st7@1 - signed int v3; // edi@1 - char *v4; // esi@4 - char *v5; // ecx@4 - //unsigned int v6; // eax@4 - char *v7; // edx@4 - double v8; // st6@10 - double v9; // st5@10 - double v10; // st6@11 - unsigned __int8 v11; // c2@15 - unsigned __int8 v12; // c3@15 - void *v13; // edi@22 - char *v14; // eax@22 - double v15; // st6@22 - char *v16; // ecx@22 - signed int result; // eax@24 - unsigned int v18; // [sp+8h] [bp-2Ch]@4 - bool v19; // [sp+Ch] [bp-28h]@6 - char *v20; // [sp+10h] [bp-24h]@4 - char *v21; // [sp+14h] [bp-20h]@4 - signed int v22; // [sp+18h] [bp-1Ch]@1 - char *v23; // [sp+1Ch] [bp-18h]@4 - RenderVertexSoft *v24; // [sp+20h] [bp-14h]@4 - char *v25; // [sp+24h] [bp-10h]@4 - char *v26; // [sp+28h] [bp-Ch]@4 - char *v27; // [sp+2Ch] [bp-8h]@4 - char *v28; // [sp+30h] [bp-4h]@4 + signed int previous_vertices_flag; // edi@1 + double t; // st6@10 + bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 + signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 + int pNextVertices; + //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 - v2 = (double)pODMRenderParams->shading_dist_mist; - memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); - v3 = 0; - v22 = 0; - if ( array_50AC10[0].vWorldViewPosition.x <= (double)pODMRenderParams->shading_dist_mist ) - v3 = 1; - if ( (signed int)(uVertexID + 1) <= 1 ) + memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); + depth_num_vertices = 0; + previous_vertices_flag = 0; + if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) + previous_vertices_flag = 1;//предыдущая грань меньше границы видимости + if ( (signed int)uNumVertices <= 0 ) return 0; - v4 = (char *)&array_507D30[0].vWorldViewPosition.z; - v5 = (char *)&array_507D30[0].vWorldViewPosition.y; - v23 = (char *)&array_507D30[0].flt_2C; - v26 = (char *)&array_507D30[0]._rhw; - v24 = array_507D30; - v20 = (char *)&array_507D30[0].vWorldViewPosition.z; - v21 = (char *)&array_507D30[0].vWorldViewPosition.y; - v25 = (char *)&array_507D30[0].vWorldViewPosition; - v27 = (char *)&array_507D30[0].v; - v28 = (char *)&array_507D30[0].u; - v7 = (char *)&array_50AC10[0].v; - for ( v18 = 1; v18 <= uVertexID; ++v18 ) + for ( uint i = 1; i <= uNumVertices; ++i ) { - v19 = v2 >= array_50AC10[v18].vWorldViewPosition.x; - if ( v3 != v19 ) + current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; + if ( previous_vertices_flag != current_vertices_flag )//одна из граней за границей видимости { - if ( v19 ) - { - v8 = (v2 - array_50AC10[v18 - 1].vWorldViewPosition.x) / (array_50AC10[v18].vWorldViewPosition.x - array_50AC10[v18 - 1].vWorldViewPosition.x); - *(float *)v5 = (array_50AC10[v18].vWorldViewPosition.y - array_50AC10[v18 - 1].vWorldViewPosition.y) * v8 + array_50AC10[v18 - 1].vWorldViewPosition.y; - *(float *)v4 = (array_50AC10[v18].vWorldViewPosition.z - array_50AC10[v18 - 1].vWorldViewPosition.z) * v8 + array_50AC10[v18 - 1].vWorldViewPosition.z; - *(float *)v28 = (array_50AC10[v18].u - array_50AC10[v18 - 1].u) * v8 + array_50AC10[v18 - 1].u; - v9 = (array_50AC10[v18].v - array_50AC10[v18 - 1].v) * v8 + array_50AC10[v18 - 1].v; - } - else - { - v10 = (v2 - array_50AC10[v18].vWorldViewPosition.x) / (array_50AC10[v18 - 1].vWorldViewPosition.x - array_50AC10[v18].vWorldViewPosition.x); - *(float *)v5 = (array_50AC10[v18 - 1].vWorldViewPosition.y - array_50AC10[v18].vWorldViewPosition.y) * v10 + array_50AC10[v18].vWorldViewPosition.y; - *(float *)v4 = (array_50AC10[v18 - 1].vWorldViewPosition.z - array_50AC10[v18].vWorldViewPosition.z) * v10 + array_50AC10[v18].vWorldViewPosition.z; - *(float *)v28 = (array_50AC10[v18 - 1].u - array_50AC10[v18].u) * v10 + array_50AC10[v18].u; - v9 = (array_50AC10[v18 - 1].v - array_50AC10[v18].v) * v10 + array_50AC10[v18].v; - } - *(float *)v27 = v9; - *(float *)v25 = v2; - *(float *)v26 = 1.0 / v2; - if ( v3 ) + if ( current_vertices_flag )//текущая грань меньше границы видимости(предыдущая грань за пределами видимости) { - if ( v2 == *((float *)v7 - 7) && *(float *)v5 == *((float *)v7 - 6) ) - { - v11 = 0; - v12 = *(float *)v4 == *((float *)v7 - 5); - if ( ! (v12 | v11) ) - { - v26 += 48; - ++v24; - v25 += 48; - v27 += 48; - v28 += 48; - v5 += 48; - v4 += 48; - ++v22; - v23 += 48; - v21 = v5; - v20 = v4; - } - } + //t = far_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) + t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); + array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; + array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; + array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; + array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; } - else + else//предыдущая грань меньше границы видимости(текущая грань вышла за пределы видимости) { - if ( v2 == *((float *)v7 + 5) && *(float *)v5 == *((float *)v7 + 6) ) - { - v11 = 0; - v12 = *(float *)v4 == *((float *)v7 + 7); - if ( !(v12 | v11) ) - { - v26 += 48; - ++v24; - v25 += 48; - v27 += 48; - v28 += 48; - v5 += 48; - v4 += 48; - ++v22; - v23 += 48; - v21 = v5; - v20 = v4; - } - } + //t = far_clip - v1.x / v0.x - v1.x + t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); + array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; + array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; + array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; + array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; } - v26 += 48; - ++v24; - v25 += 48; - v27 += 48; - v28 += 48; - v5 += 48; - v4 += 48; - ++v22; - v23 += 48; - v21 = v5; - v20 = v4; + array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; + array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; + ++depth_num_vertices; } - if ( v19 ) + if ( current_vertices_flag )//оба в границе видимости { - v13 = v24; - v14 = v26; - v21 += 48; - v15 = 1.0 / (*((float *)v7 + 5) + 0.0000001); - v20 += 48; - ++v22; - v28 += 48; - v27 += 48; - v25 += 48; - ++v24; - v26 += 48; - memcpy(v13, v7 + 8, 0x30u); - v16 = v23; - v23 += 48; - v4 = v20; - *(float *)v14 = v15; - *(int *)v16 = *((int *)v7 + 13); - v5 = v21; + pNextVertices = depth_num_vertices++; + memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); } - v3 = v19; - v7 += 48; - //--v18; + previous_vertices_flag = current_vertices_flag; } - //while ( v18 ); - result = v22; - if ( v22 < 3 ) + if ( depth_num_vertices < 3 ) return 0; - return result; + return depth_num_vertices; } - //----- (00426A5A) -------------------------------------------------------- void stru319::LootActor(Actor *pActor) {
--- a/mm7_data.h Wed Oct 02 17:11:15 2013 +0600 +++ b/mm7_data.h Thu Oct 03 18:07:55 2013 +0600 @@ -1099,7 +1099,7 @@ int __fastcall GetPortalScreenCoord(unsigned int uFaceID); bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); int sr_424CD7(unsigned int uVertexID); // idb -int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb +int BuildingVerticesClipping(unsigned int uNumVertices); void __fastcall GivePartyExp(unsigned int pEXPNum); bool __fastcall sub_427769_spell(unsigned int uSpellID); void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6);