[q3map2] subtle regression on warning cleaning
See c75d474 for commit introducing the regression.
This was a change made to clean some warnings, the change discussed in this issue is this one:
/* walk candidate luxels */
VectorClear( average );
numLuxels = 0;
totalColor = 0.0f;
for ( y2 = 0; y2 < b->sh && numLuxels < MAX_STITCH_LUXELS; y2++ ) {
for ( x2 = 0; x2 < b->sw && numLuxels < MAX_STITCH_LUXELS; x2++ ) {
/* ignore same luxels */
if ( a == b && abs( x - x2 ) <= 1 && abs( y - y2 ) <= 1 ) {
continue;
}
/* ignore unmapped/unlit luxels */
cluster2 = SUPER_CLUSTER( x2, y2 );
if ( *cluster2 == CLUSTER_UNMAPPED ) {
continue;
}
luxel2 = SUPER_LUXEL( 0, x2, y2 );
if ( luxel2[ 3 ] <= 0.0f ) {
continue;
}
/* get particulars */
origin2 = SUPER_ORIGIN( x2, y2 );
normal2 = SUPER_NORMAL( x2, y2 );
/* test normal */
if ( DotProduct( normal, normal2 ) < 0.5f ) {
continue;
}
/* test bounds */
if ( fabs( origin[ 0 ] - origin2[ 0 ] ) > sampleSize ||
fabs( origin[ 1 ] - origin2[ 1 ] ) > sampleSize ||
fabs( origin[ 2 ] - origin2[ 2 ] ) > sampleSize ) {
continue;
}
/* add luxel */
//% VectorSet( luxel2, 255, 0, 255 );
- luxels[ numLuxels++ ] = luxel2;
VectorAdd( average, luxel2, average );
totalColor += luxel2[ 3 ];
}
}
/* early out */
if ( numLuxels == 0 ) {
continue;
}
/* scale average */
ootc = 1.0f / totalColor;
VectorScale( average, ootc, luxel );
luxel[ 3 ] = 1.0f;
numStitched++;
I guess luxels
array was never used, hence the removing of that line. It means numLuxels
is never incremented anymore and the “early out” test is always true. So in a future clean-up someone will remove this test…
I haven't figured which regression this deleted line have produced, but there is probably one, that “scale average” code seems to be never reached.
I guess the proper modification would have to be:
/* add luxel */
//% VectorSet( luxel2, 255, 0, 255 );
- luxels[ numLuxels++ ] = luxel2;
+ numLuxels++;
VectorAdd( average, luxel2, average );
totalColor += luxel2[ 3 ];