Assert that tile calculation is correct.

This commit is contained in:
King_DuckZ 2018-03-05 10:35:15 +00:00
parent 6861329ab9
commit 9da16ca82d

View file

@ -135,9 +135,11 @@ namespace curry {
vec2us pixel_to_world_tile (const WorldGrid& parWorld, const vec2f& parPos) { vec2us pixel_to_world_tile (const WorldGrid& parWorld, const vec2f& parPos) {
assert(position_is_on_map(parWorld, parPos)); assert(position_is_on_map(parWorld, parPos));
return vector_cast<vec2us>( const auto retval = vector_cast<vec2us>(
parPos / vector_cast<vec2f>(parWorld.tile_size()) parPos / vector_cast<vec2f>(parWorld.tile_size())
); );
assert(world_tile_to_pixel(parWorld, retval) <= parPos);
return retval;
} }
vec2f world_tile_to_pixel (const WorldGrid& parWorld, const vec2us& parTile) { vec2f world_tile_to_pixel (const WorldGrid& parWorld, const vec2us& parTile) {