Skip to content

Commit

Permalink
[io] remove warnings in gltf mikktspace.c
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Aug 29, 2023
1 parent 6a4274a commit bf49105
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions src/IO/Gltf/internal/GLTFConverter/mikktspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1599,20 +1601,20 @@ 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;
int edgenum_A, edgenum_B = 0; // 0,1 or 2
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
Expand All @@ -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;
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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] );
Expand All @@ -1920,17 +1922,17 @@ 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;
psTspace[iOffs + iMissingIndex] = psTspace[iOffs + iVert];
bNotFound = TFALSE;
}
else
++i;
++i_l;
}
assert( !bNotFound );
}
Expand Down

0 comments on commit bf49105

Please sign in to comment.