commit ae8065dee3c36406ef44c6c0be522cb331b68693 parent eaeeb469b8482835236fe934f9ffe496ad394f91 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Nov 13 22:17:19 +0200 Fix conversion warnings in pp Diffstat:
pp.cc | | | 14 | +++++++------- |
diff --git a/pp.cc b/pp.cc @@ -36,7 +36,7 @@ static void compute_row_of_horizons( size_t hull_size = 1; for( size_t x = 1; x < heightmap.w; x++ ) { - v2 p( x, heightmap( x, y ) ); + v2 p( checked_cast< float >( x ), heightmap( x, y ) ); while( hull_size > 1 && tan_theta( p, hull[ hull_size - 1 ] ) <= tan_theta( hull[ hull_size - 1 ], hull[ hull_size - 2 ] ) ) { hull_size--; @@ -64,18 +64,18 @@ static void compute_horizons( static void compute_normals( const array2d< u8 > heightmap, array2d< v3 > normals ) { for( size_t y = 0; y < heightmap.h; y++ ) { for( size_t x = 0; x < heightmap.w; x++ ) { - float x_plus_one = x + 1; - float x_minus_one = x - 1; - float y_plus_one = y + 1; - float y_minus_one = y - 1; + size_t x_plus_one = x + 1; + size_t x_minus_one = x - 1; + size_t y_plus_one = y + 1; + size_t y_minus_one = y - 1; if( x == 0 ) x_minus_one = x; if( x == heightmap.w - 1 ) x_plus_one = x; if( y == 0 ) y_minus_one = y; if( y == heightmap.h - 1 ) y_plus_one = y; - v3 tangent( x_plus_one - x_minus_one, 0, heightmap( x_plus_one, y ) - heightmap( x_minus_one, y ) ); - v3 bitangent( 0, y_plus_one - y_minus_one, heightmap( x, y_plus_one ) - heightmap( x, y_minus_one ) ); + v3 tangent( checked_cast< float >( x_plus_one - x_minus_one ), 0, heightmap( x_plus_one, y ) - heightmap( x_minus_one, y ) ); + v3 bitangent( 0, checked_cast< float >( y_plus_one - y_minus_one ), heightmap( x, y_plus_one ) - heightmap( x, y_minus_one ) ); normals( x, y ) = normalize( cross( tangent, bitangent ) ); }