Mercurial > mm7
changeset 2150:701dc2f4956b
SortVectors_x, SortVerticesByX and SortVerticesByY
author | Ritor1 |
---|---|
date | Wed, 08 Jan 2014 17:25:34 +0600 |
parents | d4f00d622889 |
children | 92511cd8fcdb |
files | Vis.cpp Vis.h |
diffstat | 2 files changed, 72 insertions(+), 139 deletions(-) [+] |
line wrap: on
line diff
--- a/Vis.cpp Wed Jan 08 15:01:58 2014 +0600 +++ b/Vis.cpp Wed Jan 08 17:25:34 2014 +0600 @@ -470,61 +470,42 @@ } //----- (004C1ABA) -------------------------------------------------------- -bool Vis::SortVectors_x(RenderVertexSoft *a2, int a3, int a4) +void Vis::SortVectors_x(RenderVertexSoft *pArray, int start, int end) { - bool result; // eax@1 - RenderVertexSoft *v5; // edx@2 - int v6; // ebx@2 - int i; // ecx@2 - int v8; // esi@3 - int v9; // esi@5 - RenderVertexSoft *v10; // eax@8 - RenderVertexSoft v11; // [sp+4h] [bp-6Ch]@8 - RenderVertexSoft v12; // [sp+34h] [bp-3Ch]@2 - int v13; // [sp+64h] [bp-Ch]@7 - Vis *thisa; // [sp+68h] [bp-8h]@1 - RenderVertexSoft *v15; // [sp+6Ch] [bp-4h]@2 + int left_sort_index; // ebx@2 + int right_sort_index; // ecx@2 + RenderVertexSoft temp_array; // [sp+4h] [bp-6Ch]@8 + RenderVertexSoft max_array; // [sp+34h] [bp-3Ch]@2 - result = a4 != 0; - thisa = this; - if ( a4 > a3 ) + if ( end > start ) { - v5 = a2; - v15 = &a2[a4]; - v6 = a3 - 1; - memcpy(&v12, &a2[a4], sizeof(v12)); - for ( i = a4; ; i = v13 ) + left_sort_index = start - 1; + right_sort_index = end; + memcpy(&max_array, &pArray[end], sizeof(max_array)); + while ( 1 ) { - v8 = (int)&v5[v6].vWorldViewPosition; do { - v8 += 48; - ++v6; + ++left_sort_index; } - while ( *(float *)v8 < (double)v12.vWorldViewPosition.x ); - v9 = (int)&v5[i].vWorldViewPosition; + while ( pArray[left_sort_index].vWorldViewPosition.x < (double)max_array.vWorldViewPosition.x ); do { - v9 -= 48; - --i; + --right_sort_index; } - while ( *(float *)v9 > (double)v12.vWorldViewPosition.x ); - v13 = i; - if ( v6 >= i ) + while ( pArray[right_sort_index].vWorldViewPosition.x > (double)max_array.vWorldViewPosition.x ); + if ( left_sort_index >= right_sort_index ) break; - v10 = &v5[i]; - memcpy(&v11, &a2[v6], sizeof(v11)); - v5 = a2; - memcpy(&a2[v6], v10, sizeof(a2[v6])); - memcpy(v10, &v11, 0x30u); + memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); + memcpy(&pArray[left_sort_index], &pArray[right_sort_index], sizeof(pArray[left_sort_index])); + memcpy(&pArray[right_sort_index], &temp_array, sizeof(pArray[right_sort_index])); } - memcpy(&v11, &v5[v6], sizeof(v11)); - memcpy(&v5[v6], v15, sizeof(v5[v6])); - memcpy(v15, &v11, 0x30u); - SortVectors_x(v5, a3, v6 - 1); - SortVectors_x(a2, v6 + 1, a4); + memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); + memcpy(&pArray[left_sort_index], &pArray[end], sizeof(pArray[left_sort_index])); + memcpy(&pArray[end], &temp_array, sizeof(pArray[end])); + SortVectors_x(pArray, start, left_sort_index - 1); + SortVectors_x(pArray, left_sort_index + 1, end); } - return true; } //----- (004C1BAA) -------------------------------------------------------- @@ -1039,127 +1020,81 @@ } //----- (004C26D0) -------------------------------------------------------- -bool Vis::SortVerticesByX(RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd) +void Vis::SortVerticesByX(RenderVertexD3D3 *pArray, unsigned int uStart, unsigned int uEnd) { - bool result; // eax@1 - RenderVertexD3D3 *v5; // edx@2 - RenderVertexD3D3 *v6; // esi@2 - void *v7; // edi@2 - unsigned int v8; // ebx@2 - RenderVertexD3D3 *v9; // ecx@3 - RenderVertexD3D3 *v10; // ecx@5 - RenderVertexD3D3 *v11; // eax@8 - RenderVertexD3D3 v12; // [sp+4h] [bp-4Ch]@8 - RenderVertexD3D3 v13; // [sp+24h] [bp-2Ch]@2 - Vis *thisa; // [sp+44h] [bp-Ch]@1 - RenderVertexD3D3 *v15; // [sp+48h] [bp-8h]@2 - unsigned int v16; // [sp+4Ch] [bp-4h]@2 + unsigned int left_sort_index; // ebx@2 + RenderVertexD3D3 temp_array; // [sp+4h] [bp-4Ch]@8 + RenderVertexD3D3 max_array; // [sp+24h] [bp-2Ch]@2 + unsigned int right_sort_index; // [sp+4Ch] [bp-4h]@2 - result = uEnd; - thisa = this; if ( (signed int)uEnd > (signed int)uStart ) { - v5 = a2; - v6 = &a2[uEnd]; - v7 = &v13; - v15 = &a2[uEnd]; - v8 = uStart - 1; - v16 = uEnd; + left_sort_index = uStart - 1; + right_sort_index = uEnd; while ( 1 ) { - memcpy(v7, v6, 0x20u); - v9 = &v5[v8]; + memcpy(&max_array, &pArray[uEnd], sizeof(max_array)); do { - ++v9; - ++v8; + ++left_sort_index; } - while ( v9->pos.x < (double)v13.pos.x ); - v10 = &v5[v16]; + while ( pArray[left_sort_index].pos.x < (double)max_array.pos.x ); do { - --v10; - --v16; + --right_sort_index; } - while ( v10->pos.x > (double)v13.pos.x ); - if ( (signed int)v8 >= (signed int)v16 ) + while ( pArray[right_sort_index].pos.x > (double)max_array.pos.x ); + if ( (signed int)left_sort_index >= (signed int)right_sort_index ) break; - v11 = &v5[v16]; - memcpy(&v12, &a2[v8], sizeof(v12)); - v5 = a2; - memcpy(&a2[v8], v11, sizeof(a2[v8])); - v6 = &v12; - v7 = v11; + memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); + memcpy(&pArray[left_sort_index], &pArray[right_sort_index], sizeof(pArray[left_sort_index])); + memcpy(&pArray[right_sort_index], &temp_array, sizeof(pArray[right_sort_index])); } - memcpy(&v12, &v5[v8], sizeof(v12)); - memcpy(&v5[v8], v15, sizeof(v5[v8])); - memcpy(v15, &v12, 0x20u); - SortVerticesByX(v5, uStart, v8 - 1); - SortVerticesByX(a2, v8 + 1, uEnd); + memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); + memcpy(&pArray[left_sort_index], &pArray[uEnd], sizeof(pArray[left_sort_index])); + memcpy(&pArray[uEnd], &temp_array, sizeof(pArray[uEnd])); + SortVerticesByX(pArray, uStart, left_sort_index - 1); + SortVerticesByX(pArray, left_sort_index + 1, uEnd); } - return true; } //----- (004C27AD) -------------------------------------------------------- -bool Vis::SortVerticesByY(RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd) +void Vis::SortVerticesByY(RenderVertexD3D3 *pArray, unsigned int uStart, unsigned int uEnd) { - bool result; // eax@1 - RenderVertexD3D3 *v5; // edx@2 - RenderVertexD3D3 *v6; // esi@2 - void *v7; // edi@2 - unsigned int v8; // ebx@2 - float *v9; // ecx@3 - float *v10; // ecx@5 - RenderVertexD3D3 *v11; // eax@8 - RenderVertexD3D3 v12; // [sp+4h] [bp-4Ch]@8 - RenderVertexD3D3 v13; // [sp+24h] [bp-2Ch]@2 - Vis *thisa; // [sp+44h] [bp-Ch]@1 - RenderVertexD3D3 *v15; // [sp+48h] [bp-8h]@2 - unsigned int v16; // [sp+4Ch] [bp-4h]@2 + unsigned int left_sort_index; // ebx@2 + RenderVertexD3D3 temp_array; // [sp+4h] [bp-4Ch]@8 + RenderVertexD3D3 max_array; // [sp+24h] [bp-2Ch]@2 + unsigned int right_sort_index; // [sp+4Ch] [bp-4h]@2 - result = uEnd; - thisa = this; if ( (signed int)uEnd > (signed int)uStart ) { - v5 = a2; - v6 = &a2[uEnd]; - v7 = &v13; - v15 = &a2[uEnd]; - v8 = uStart - 1; - v16 = uEnd; + left_sort_index = uStart - 1; + right_sort_index = uEnd; while ( 1 ) { - memcpy(v7, v6, 0x20u); - v9 = &v5[v8].pos.y; + memcpy(&max_array, &pArray[uEnd], sizeof(max_array)); do { - v9+=8; - ++v8; + ++left_sort_index; } - while ( *v9 < (double)v13.pos.y ); - v10 = &v5[v16].pos.y; + while ( pArray[left_sort_index].pos.y < (double)max_array.pos.y ); do { - v10-=8; - --v16; + --right_sort_index; } - while ( *v10 > (double)v13.pos.y ); - if ( (signed int)v8 >= (signed int)v16 ) + while ( pArray[right_sort_index].pos.y > (double)max_array.pos.y ); + if ( (signed int)left_sort_index >= (signed int)right_sort_index ) break; - v11 = &v5[v16]; - memcpy(&v12, &a2[v8], sizeof(v12)); - v5 = a2; - memcpy(&a2[v8], v11, sizeof(a2[v8])); - v6 = &v12; - v7 = v11; + memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); + memcpy(&pArray[left_sort_index], &pArray[right_sort_index], sizeof(pArray[left_sort_index])); + memcpy(&pArray[right_sort_index], &temp_array, sizeof(pArray[right_sort_index])); } - memcpy(&v12, &v5[v8], sizeof(v12)); - memcpy(&v5[v8], v15, sizeof(v5[v8])); - memcpy(v15, &v12, 0x20u); - SortVerticesByY(v5, uStart, v8 - 1); - SortVerticesByY(a2, v8 + 1, uEnd); + memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); + memcpy(&pArray[left_sort_index], &pArray[uEnd], sizeof(pArray[left_sort_index])); + memcpy(&pArray[uEnd], &temp_array, sizeof(pArray[uEnd])); + SortVerticesByY(pArray, uStart, left_sort_index - 1); + SortVerticesByY(pArray, left_sort_index + 1, uEnd); } - return true; } //----- (004C288E) -------------------------------------------------------- @@ -1169,13 +1104,13 @@ int right_sort_index; // ecx@2 RenderVertexSoft temp_array; // [sp+4h] [bp-6Ch]@8 RenderVertexSoft max_array; // [sp+34h] [bp-3Ch]@2 - int v12; // [sp+64h] [bp-Ch]@7 if ( end > start ) { left_sort_index = start - 1; + right_sort_index = end; memcpy(&max_array, &pArray[end], sizeof(max_array)); - for ( right_sort_index = end; ; right_sort_index = v12 ) + while ( 1 ) { do { @@ -1187,7 +1122,6 @@ --right_sort_index; } while ( pArray[right_sort_index].vWorldViewProjX > (double)max_array.vWorldViewProjX ); - v12 = right_sort_index; if ( left_sort_index >= right_sort_index ) break; memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array)); @@ -1209,13 +1143,13 @@ int right_sort_index; // ecx@2 RenderVertexSoft temp_array; // [sp+4h] [bp-6Ch]@8 RenderVertexSoft max_array; // [sp+34h] [bp-3Ch]@2 - int v12; // [sp+64h] [bp-Ch]@7 if ( end > start ) { left_sort_index = start - 1; + right_sort_index = end; memcpy(&max_array, &pArray[end], sizeof(max_array)); - for ( right_sort_index = end; ; right_sort_index = v12 ) + while ( 1 ) { do { @@ -1227,7 +1161,6 @@ --right_sort_index; } while ( pArray[right_sort_index].vWorldViewProjY > (double)max_array.vWorldViewProjY ); - v12 = right_sort_index; if ( left_sort_index >= right_sort_index ) break; memcpy(&temp_array, &pArray[left_sort_index], sizeof(temp_array));
--- a/Vis.h Wed Jan 08 15:01:58 2014 +0600 +++ b/Vis.h Wed Jan 08 17:25:34 2014 +0600 @@ -108,7 +108,7 @@ bool IsPointInsideD3DBillboard(struct RenderBillboardD3D *a1, float x, float y); int PickClosestActor(int object_id, unsigned int pick_depth, int a4, int a5, int a6); void _4C1A02(); - bool SortVectors_x(RenderVertexSoft *a2, int a3, int a4); + void SortVectors_x(RenderVertexSoft *pArray, int start, int end); int get_object_zbuf_val(Vis_ObjectInfo *info); int get_picked_object_zbuf_val(); bool Intersect_Ray_Face(struct RenderVertexSoft *pRayStart, struct RenderVertexSoft *pRayEnd, float *pDepth, RenderVertexSoft *Intersection, BLVFace *pFace, signed int pBModelID); @@ -117,8 +117,8 @@ void ODM_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID); void CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth); void sort_object_pointers(Vis_ObjectInfo **pPointers, int start, int end); - bool SortVerticesByX(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd); - bool SortVerticesByY(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd); + void SortVerticesByX(struct RenderVertexD3D3 *pArray, unsigned int uStart, unsigned int uEnd); + void SortVerticesByY(struct RenderVertexD3D3 *pArray, unsigned int uStart, unsigned int uEnd); void SortByScreenSpaceX(struct RenderVertexSoft *pArray, int start, int end); void SortByScreenSpaceY(struct RenderVertexSoft *pArray, int start, int end);