Mercurial > mm7
changeset 1903:79ac2dbedfb9
ODM_NearClip and ODM_FarClip
author | Ritor1 |
---|---|
date | Mon, 21 Oct 2013 17:08:14 +0600 |
parents | 39b6d789cbfc |
children | 1a1c4040bee4 |
files | Render.cpp _deleted.cpp mm7_1.cpp mm7_data.h |
diffstat | 4 files changed, 62 insertions(+), 144 deletions(-) [+] |
line wrap: on
line diff
--- a/Render.cpp Mon Oct 21 10:07:32 2013 +0600 +++ b/Render.cpp Mon Oct 21 17:08:14 2013 +0600 @@ -8727,9 +8727,60 @@ break; } } - +//----- (00424CD7) -------------------------------------------------------- +int ODM_NearClip(unsigned int num_vertices) +{ + bool current_vertices_flag; // edi@1 + bool next_vertices_flag; // [sp+Ch] [bp-24h]@6 + double t; // st6@10 + int pNextVertices; + + if (!num_vertices) + return 0; + + memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); + current_vertices_flag = 0; + if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) + current_vertices_flag = 1; + + int out_num_vertices = 0; + for (int i = 0; i < num_vertices; ++i) + { + next_vertices_flag = array_50AC10[i + 1].vWorldViewPosition.x >= 8.0; + if ( current_vertices_flag != next_vertices_flag ) + { + if ( next_vertices_flag ) + { + //t = neer_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) + t = (8.0 - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); + array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; + array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; + array_507D30[out_num_vertices].u = (array_50AC10[i + 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; + array_507D30[out_num_vertices].v = (array_50AC10[i + 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; + } + else + { + t = (8.0 - array_50AC10[i + 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x); + array_507D30[out_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t + array_50AC10[i + 1].vWorldViewPosition.y; + array_507D30[out_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t + array_50AC10[i + 1].vWorldViewPosition.z; + array_507D30[out_num_vertices].u = (array_50AC10[i].u - array_50AC10[i + 1].u) * t + array_50AC10[i + 1].u; + array_507D30[out_num_vertices].v = (array_50AC10[i].v - array_50AC10[i + 1].v) * t + array_50AC10[i + 1].v; + } + array_507D30[out_num_vertices].vWorldViewPosition.x = 8.0; + array_507D30[out_num_vertices]._rhw = 1.0 / 8.0; + ++out_num_vertices; + } + if ( next_vertices_flag ) + { + pNextVertices = out_num_vertices++; + memcpy(&array_507D30[pNextVertices], &array_50AC10[i + 1], 0x30); + } + current_vertices_flag = next_vertices_flag; + } + return out_num_vertices >= 3 ? out_num_vertices : 0; +} //----- (00424EE0) -------------------------------------------------------- -int BuildingVerticesClipping(unsigned int uNumVertices) +int ODM_FarClip(unsigned int uNumVertices) { signed int previous_vertices_flag; // edi@1 double t; // st6@10 @@ -8960,13 +9011,13 @@ pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); if ( v50 ) { - array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = sr_424CD7(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); + array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_NearClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); } if ( v49 ) { - array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = BuildingVerticesClipping(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); + array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = ODM_FarClip(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); }
--- a/_deleted.cpp Mon Oct 21 10:07:32 2013 +0600 +++ b/_deleted.cpp Mon Oct 21 17:08:14 2013 +0600 @@ -8804,7 +8804,7 @@ { if ( this_3 ) { - v36 = sr_424CD7(v34); + v36 = ODM_NearClip(v34); pTile->uNumVertices = v36; ODMRenderParams::Project(v36); } @@ -8948,7 +8948,7 @@ { if ( this_3a ) { - v56 = sr_424CD7(v55); + v56 = ODM_NearClip(v55); } else { @@ -9072,7 +9072,7 @@ goto LABEL_154; if ( this_3b ) { - v73 = sr_424CD7(v72); + v73 = ODM_NearClip(v72); } else { @@ -9335,7 +9335,7 @@ while ( v20 < (signed int)v5 ); if ( v20 >= (signed int)v5 ) return 0; - result = sr_424CD7(v5); + result = ODM_NearClip(v5); if ( result > 0 ) { __asm { fild pBLVRenderParams->field_40 }
--- a/mm7_1.cpp Mon Oct 21 10:07:32 2013 +0600 +++ b/mm7_1.cpp Mon Oct 21 17:08:14 2013 +0600 @@ -378,137 +378,4 @@ uGameUIFontShadow = TargetColor(255, 255, 255); } else Error("Invalid alignment type: %u", align); -} - -//----- (00424CD7) -------------------------------------------------------- -int sr_424CD7(unsigned int num_vertices) -{ - //unsigned int v1; // edx@1 - signed int v2; // edi@1 - char *v3; // esi@4 - char *v4; // ecx@4 - //unsigned int v5; // eax@4 - char *v6; // edx@4 - double v7; // st6@10 - double v8; // st5@10 - double v9; // st6@11 - unsigned __int8 v10; // c2@15 - unsigned __int8 v11; // c3@15 - RenderVertexSoft *v12; // edi@22 - char *v13; // eax@22 - double v14; // st6@22 - //signed int result; // eax@24 - //unsigned int v16; // [sp+8h] [bp-28h]@4 - bool v17; // [sp+Ch] [bp-24h]@6 - char *v18; // [sp+10h] [bp-20h]@4 - char *v19; // [sp+14h] [bp-1Ch]@4 - //signed int v20; // [sp+18h] [bp-18h]@1 - RenderVertexSoft *v21; // [sp+1Ch] [bp-14h]@4 - char *v22; // [sp+20h] [bp-10h]@4 - char *v23; // [sp+24h] [bp-Ch]@4 - char *v24; // [sp+28h] [bp-8h]@4 - char *v25; // [sp+2Ch] [bp-4h]@4 - - if (!num_vertices) - return 0; - - //v1 = uVertexID; - memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); - v2 = 0; - //v20 = 0; - if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) - v2 = 1; - v3 = (char *)&array_507D30[0].vWorldViewPosition.z; - v4 = (char *)&array_507D30[0].vWorldViewPosition.y; - //v5 = v1; - v23 = (char *)&array_507D30[0]._rhw; - v21 = array_507D30; - v18 = (char *)&array_507D30[0].vWorldViewPosition.z; - v19 = (char *)&array_507D30[0].vWorldViewPosition.y; - v22 = (char *)&array_507D30[0].vWorldViewPosition; - v24 = (char *)&array_507D30[0].v; - v25 = (char *)&array_507D30[0].u; - v6 = (char *)&array_50AC10[0].v; - //v16 = v1; - - int out_num_vertices = 0; - for (int i = 0; i < num_vertices; ++i) - { - v17 = *((float *)v6 + 5) >= 8.0; - if ( v2 != v17 ) - { - if ( v17 ) - { - v7 = (8.0 - *((float *)v6 - 7)) / (*((float *)v6 + 5) - *((float *)v6 - 7)); - *(float *)v4 = (*((float *)v6 + 6) - *((float *)v6 - 6)) * v7 + *((float *)v6 - 6); - *(float *)v3 = (*((float *)v6 + 7) - *((float *)v6 - 5)) * v7 + *((float *)v6 - 5); - *(float *)v25 = (*((float *)v6 + 11) - *((float *)v6 - 1)) * v7 + *((float *)v6 - 1); - v8 = (*((float *)v6 + 12) - *(float *)v6) * v7 + *(float *)v6; - } - else - { - v9 = (8.0 - *((float *)v6 + 5)) / (*((float *)v6 - 7) - *((float *)v6 + 5)); - *(float *)v4 = (*((float *)v6 - 6) - *((float *)v6 + 6)) * v9 + *((float *)v6 + 6); - *(float *)v3 = (*((float *)v6 - 5) - *((float *)v6 + 7)) * v9 + *((float *)v6 + 7); - *(float *)v25 = (*((float *)v6 - 1) - *((float *)v6 + 11)) * v9 + *((float *)v6 + 11); - v8 = (*(float *)v6 - *((float *)v6 + 12)) * v9 + *((float *)v6 + 12); - } - *(float *)v24 = v8; - *(float *)v22 = 8.0; - *(int *)v23 = 0x3E000000u; - if ( v2 ) - { - if ( 8.0 == *((float *)v6 - 7) && *(float *)v4 == *((float *)v6 - 6) ) - { - v10 = 0; - v11 = *(float *)v3 == *((float *)v6 - 5); - if ( v11 | v10 ) - goto LABEL_21; - } - } - else - { - if ( 8.0 == *((float *)v6 + 5) && *(float *)v4 == *((float *)v6 + 6) ) - { - v10 = 0; - v11 = *(float *)v3 == *((float *)v6 + 7); - if ( v11 | v10 ) - goto LABEL_21; - } - } - ++v21; - v22 += 48; - v24 += 48; - v25 += 48; - v4 += 48; - v3 += 48; - ++out_num_vertices; - v23 += 48; - v19 = v4; - v18 = v3; - } -LABEL_21: - if ( v17 ) - { - v12 = v21; - v13 = v23; - v19 += 48; - v18 += 48; - v14 = 1.0 / (*((float *)v6 + 5) + 0.0000001); - ++out_num_vertices; - v25 += 48; - v24 += 48; - v22 += 48; - ++v21; - v23 += 48; - memcpy(v12, v6 + 8, 0x30u); - v4 = v19; - v3 = v18; - *(float *)v13 = v14; - } - v2 = v17; - v6 += 48; - } - - return out_num_vertices >= 3 ? out_num_vertices : 0; -} +} \ No newline at end of file
--- a/mm7_data.h Mon Oct 21 10:07:32 2013 +0600 +++ b/mm7_data.h Mon Oct 21 17:08:14 2013 +0600 @@ -1092,8 +1092,8 @@ void reset_some_strus_flt_2Cs(); 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 BuildingVerticesClipping(unsigned int uNumVertices); +int ODM_NearClip(unsigned int uVertexID); // idb +int ODM_FarClip(unsigned int uNumVertices); 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); void _42ECB5_PlayerAttacksActor();