commit c256d6161e6ea80037b3bed42f6bc7731a0cc8c8 parent 602563bb7d561fbe3400a768b3b50a7543568afe Author: Michael Savage <mikejsavage@gmail.com> Date: Thu Dec 29 14:31:19 +0200 More MSVC warnings Diffstat:
heightmap.cc | | | 8 | ++++---- |
terrain_manager.cc | | | 2 | +- |
diff --git a/heightmap.cc b/heightmap.cc @@ -34,7 +34,7 @@ void heightmap_destroy( Heightmap * hm ) { } v3 Heightmap::point( u32 x, u32 y ) const { - return v3( x, y, pixels[ y * width + x ] ); + return v3( checked_cast< float >( x ), checked_cast< float >( y ), pixels[ y * width + x ] ); } u8 heightmap_height( const Heightmap * hm, u32 x, u32 y ) { @@ -44,8 +44,8 @@ u8 heightmap_height( const Heightmap * hm, u32 x, u32 y ) { } float Heightmap::bilerp_height( float x, float y ) const { - const float ix = floorf( x ); - const float iy = floorf( y ); + const u32 ix = checked_cast< u32 >( floorf( x ) ); + const u32 iy = checked_cast< u32 >( floorf( y ) ); return bilerp( point( ix, iy ), @@ -245,7 +245,7 @@ size_t heightmap_quadtree_max_nodes( const Heightmap * hm ) { // with a power of 2 + 1 sized quadtree it should be exactly 4/3 (1 + // 1/4 + 1/16 + ...) but with other sizes it gets funny. 1.34 seems to // work with minimal wasted space - return 1.34 * ( hm->width - 1 ) * ( hm->width - 1 ); + return size_t( 1.34 * ( hm->width - 1 ) * ( hm->width - 1 ) ); } HeightmapQuadTree heightmap_build_quadtree( const Heightmap * hm, array< HeightmapQuadTreeNode > & nodes ) { diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -557,7 +557,7 @@ bool segment_vs_terrain( const TerrainManager * tm, v3 seg_origin, v3 seg_end, f continue; } - v3 local_seg_origin = seg_origin - v3( tx * TILE_SIZE, ty * TILE_SIZE, 0 ); + v3 local_seg_origin = seg_origin - v3( checked_cast< float >( tx * TILE_SIZE ), checked_cast< float >( ty * TILE_SIZE ), 0 ); const HeightmapQuadTree * qt = &tm->decompressed_tiles[ tx ][ ty ].quadtree; // TODO: convert from tile t to global t