summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-10-09 13:03:55 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-10-09 13:03:55 +0200
commit71836ba506ca8c5ffc1f4416e5802f698fbdffd4 (patch)
tree5826614b7af5eeac76f28ce00df7eb8fdd81c5f4
parentec238c51933cfb752cb9b23cff841c24e5c598f5 (diff)
a
-rw-r--r--src/object.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/object.cpp b/src/object.cpp
index e7583463..0524a92c 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -112,29 +112,29 @@ void object::rotate(size_t, rotation new_r)
}
// todo rewrite using bitwise ops
-point object::normalize_coords(global_coords coord, Vector2b cur, Vector2i new_offset)
+point object::normalize_coords(global_coords coord, Vector2b cur, Vector2i new_off)
{
constexpr int tile_size[2] = { iTILE_SIZE2.x(), iTILE_SIZE2.y() };
constexpr int half_tile[2] = { tile_size[0]/2, tile_size[1]/2 };
- const int off_tmp[2] = { cur.x() + new_offset.x(), cur.y() + new_offset.y() };
- int off_new[2] = { off_tmp[0] % tile_size[0], off_tmp[1] % tile_size[1] };
- int tiles[2] = { off_tmp[0] / tile_size[0], off_tmp[1] / tile_size[1] };
+ int tmp[2] = { cur.x() + new_off.x(), cur.y() + new_off.y() };
+ int off[2] = { tmp[0] % tile_size[0], tmp[1] % tile_size[1] };
+ int tiles[2] = { tmp[0] / tile_size[0], tmp[1] / tile_size[1] };
fm_UNROLL_2
for (auto i = 0uz; i < 2; i++)
{
- auto& off = off_new[i];
- auto sign = Math::sign(off);
- auto absval = Math::abs(off);
- if (off >= half_tile[i]-1 || off < half_tile[i])
+ auto& x = off[i];
+ auto sign = Math::sign(x);
+ auto absval = Math::abs(x);
+ if (x >= half_tile[i] || x < -half_tile[i])
{
tiles[i] += sign;
- off = (tile_size[i] - absval)*-sign;
+ x = (tile_size[i] - absval)*-sign;
}
}
return {
coord + Vector2i(tiles[0], tiles[1]),
- { (int8_t)off_new[0], (int8_t)off_new[1] },
+ { (int8_t)off[0], (int8_t)off[1] },
};
}