From bf491050989f49a6b7f37ad45031b650babe2f4b Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Tue, 29 Aug 2023 08:32:17 +0200 Subject: [PATCH] [io] remove warnings in gltf mikktspace.c --- .../Gltf/internal/GLTFConverter/mikktspace.c | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/src/IO/Gltf/internal/GLTFConverter/mikktspace.c b/src/IO/Gltf/internal/GLTFConverter/mikktspace.c index 1bffdd66cef..6cdc9bd9194 100644 --- a/src/IO/Gltf/internal/GLTFConverter/mikktspace.c +++ b/src/IO/Gltf/internal/GLTFConverter/mikktspace.c @@ -568,12 +568,12 @@ static void GenerateSharedVerticesIndexList( int piTriList_in_and_out[], if ( pTmpVert != NULL ) { for ( e = 0; e < iEntries; e++ ) { - int i = pTable[e]; - const SVec3 vP = GetPosition( pContext, piTriList_in_and_out[i] ); + int i_l = pTable[e]; + const SVec3 vP = GetPosition( pContext, piTriList_in_and_out[i_l] ); pTmpVert[e].vert[0] = vP.x; pTmpVert[e].vert[1] = vP.y; pTmpVert[e].vert[2] = vP.z; - pTmpVert[e].index = i; + pTmpVert[e].index = i_l; } MergeVertsFast( piTriList_in_and_out, pTmpVert, pContext, 0, iEntries - 1 ); } @@ -741,7 +741,8 @@ static void MergeVertsSlow( int piTriList_in_and_out[], static void GenerateSharedVerticesIndexListSlow( int piTriList_in_and_out[], const SMikkTSpaceContext* pContext, const int iNrTrianglesIn ) { - int iNumUniqueVerts = 0, t = 0, i = 0; + // int iNumUniqueVerts = 0; + int t = 0, i = 0; for ( t = 0; t < iNrTrianglesIn; t++ ) { for ( i = 0; i < 3; i++ ) { const int offs = t * 3 + i; @@ -771,7 +772,7 @@ static void GenerateSharedVerticesIndexListSlow( int piTriList_in_and_out[], assert( bFound ); // if we found our own - if ( index2rec == index ) { ++iNumUniqueVerts; } + // if ( index2rec == index ) { ++iNumUniqueVerts; } piTriList_in_and_out[offs] = index2rec; } @@ -827,14 +828,14 @@ static int GenerateInitialVerticesIndexList( STriInfo pTriInfos[], else if ( distSQ_13 < distSQ_02 ) bQuadDiagIs_02 = TFALSE; else { - const SVec3 P0 = GetPosition( pContext, i0 ); - const SVec3 P1 = GetPosition( pContext, i1 ); - const SVec3 P2 = GetPosition( pContext, i2 ); - const SVec3 P3 = GetPosition( pContext, i3 ); - const float distSQ_02 = LengthSquared( vsub( P2, P0 ) ); - const float distSQ_13 = LengthSquared( vsub( P3, P1 ) ); - - bQuadDiagIs_02 = distSQ_13 < distSQ_02 ? TFALSE : TTRUE; + const SVec3 P0 = GetPosition( pContext, i0 ); + const SVec3 P1 = GetPosition( pContext, i1 ); + const SVec3 P2 = GetPosition( pContext, i2 ); + const SVec3 P3 = GetPosition( pContext, i3 ); + const float distSQ_02_l = LengthSquared( vsub( P2, P0 ) ); + const float distSQ_13_l = LengthSquared( vsub( P3, P1 ) ); + + bQuadDiagIs_02 = distSQ_13_l < distSQ_02_l ? TFALSE : TTRUE; } if ( bQuadDiagIs_02 ) { @@ -1242,7 +1243,9 @@ static tbool GenerateTSpaces( STSpace psTspace[], STSpace* pSubGroupTspace = NULL; SSubGroup* pUniSubGroups = NULL; int* pTmpMembers = NULL; - int iMaxNrFaces = 0, iUniqueTspaces = 0, g = 0, i = 0; + int iMaxNrFaces = 0; + // int iUniqueTspaces = 0; + int g = 0, i = 0; for ( g = 0; g < iNrActiveGroups; g++ ) if ( iMaxNrFaces < pGroups[g].iNrFaces ) iMaxNrFaces = pGroups[g].iNrFaces; @@ -1259,7 +1262,7 @@ static tbool GenerateTSpaces( STSpace psTspace[], return TFALSE; } - iUniqueTspaces = 0; + // iUniqueTspaces = 0; for ( g = 0; g < iNrActiveGroups; g++ ) { const SGroup* pGroup = &pGroups[g]; int iUniqueSubGroups = 0, s = 0; @@ -1348,9 +1351,8 @@ static tbool GenerateTSpaces( STSpace psTspace[], int* pIndices = (int*)malloc( sizeof( int ) * iMembers ); if ( pIndices == NULL ) { // clean up and return false - int s = 0; - for ( s = 0; s < iUniqueSubGroups; s++ ) - free( pUniSubGroups[s].pTriMembers ); + for ( int s_l = 0; s_l < iUniqueSubGroups; s_l++ ) + free( pUniSubGroups[s_l].pTriMembers ); free( pUniSubGroups ); free( pTmpMembers ); free( pSubGroupTspace ); @@ -1393,7 +1395,7 @@ static tbool GenerateTSpaces( STSpace psTspace[], // clean up and offset iUniqueTspaces for ( s = 0; s < iUniqueSubGroups; s++ ) free( pUniSubGroups[s].pTriMembers ); - iUniqueTspaces += iUniqueSubGroups; + // iUniqueTspaces += iUniqueSubGroups; } // clean up @@ -1599,9 +1601,9 @@ static void BuildNeighborsFast( STriInfo pTriInfos[], // pair up, adjacent triangles for ( i = 0; i < iEntries; i++ ) { - const int i0 = pEdges[i].i0; - const int i1 = pEdges[i].i1; - const int f = pEdges[i].f; + const int i0 = pEdges[i].i0; + const int i1 = pEdges[i].i1; + const int f_l = pEdges[i].f; tbool bUnassigned_A; int i0_A, i1_A; @@ -1609,10 +1611,10 @@ static void BuildNeighborsFast( STriInfo pTriInfos[], GetEdge( &i0_A, &i1_A, &edgenum_A, - &piTriListIn[f * 3], + &piTriListIn[f_l * 3], i0, i1 ); // resolve index ordering and edge_num - bUnassigned_A = pTriInfos[f].FaceNeighbors[edgenum_A] == -1 ? TTRUE : TFALSE; + bUnassigned_A = pTriInfos[f_l].FaceNeighbors[edgenum_A] == -1 ? TTRUE : TFALSE; if ( bUnassigned_A ) { // get true index ordering @@ -1638,10 +1640,10 @@ static void BuildNeighborsFast( STriInfo pTriInfos[], } if ( !bNotFound ) { - int t = pEdges[j].f; - pTriInfos[f].FaceNeighbors[edgenum_A] = t; + int t_l = pEdges[j].f; + pTriInfos[f_l].FaceNeighbors[edgenum_A] = t_l; // assert(pTriInfos[t].FaceNeighbors[edgenum_B]==-1); - pTriInfos[t].FaceNeighbors[edgenum_B] = f; + pTriInfos[t_l].FaceNeighbors[edgenum_B] = f_l; } } } @@ -1816,11 +1818,11 @@ static void DegenPrologue( STriInfo pTriInfos[], // search for the first good triangle. tbool bJustADegenerate = TTRUE; while ( bJustADegenerate && iNextGoodTriangleSearchIndex < iTotTris ) { - const tbool bIsGood = + const tbool bIsGood_l = ( pTriInfos[iNextGoodTriangleSearchIndex].iFlag & MARK_DEGENERATE ) == 0 ? TTRUE : TFALSE; - if ( bIsGood ) + if ( bIsGood_l ) bJustADegenerate = TFALSE; else ++iNextGoodTriangleSearchIndex; @@ -1905,7 +1907,7 @@ static void DegenEpilogue( STSpace psTspace[], // other triangle is degenerate if ( ( pTriInfos[t].iFlag & QUAD_ONE_DEGEN_TRI ) != 0 ) { SVec3 vDstP; - int iOrgF = -1, i = 0; + int iOrgF = -1, i_l = 0; tbool bNotFound; unsigned char* pV = pTriInfos[t].vert_num; int iFlag = ( 1 << pV[0] ) | ( 1 << pV[1] ) | ( 1 << pV[2] ); @@ -1920,9 +1922,9 @@ static void DegenEpilogue( STSpace psTspace[], iOrgF = pTriInfos[t].iOrgFaceNumber; vDstP = GetPosition( pContext, MakeIndex( iOrgF, iMissingIndex ) ); bNotFound = TTRUE; - i = 0; - while ( bNotFound && i < 3 ) { - const int iVert = pV[i]; + i_l = 0; + while ( bNotFound && i_l < 3 ) { + const int iVert = pV[i_l]; const SVec3 vSrcP = GetPosition( pContext, MakeIndex( iOrgF, iVert ) ); if ( veq( vSrcP, vDstP ) == TTRUE ) { const int iOffs = pTriInfos[t].iTSpacesOffs; @@ -1930,7 +1932,7 @@ static void DegenEpilogue( STSpace psTspace[], bNotFound = TFALSE; } else - ++i; + ++i_l; } assert( !bNotFound ); }