summaryrefslogtreecommitdiffhomepage
path: root/src/entity.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-19 16:48:20 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-19 16:48:27 +0100
commit01bad2db72d987890590607fb0a6042ea7c21c3a (patch)
tree502e7c3e6bdec28e805c06bc50f16ba226b42e66 /src/entity.cpp
parent86bd6a4411badecfc76fe3a9d29b4aa30c8fdba7 (diff)
fix scenery's json offset and rotation
Diffstat (limited to 'src/entity.cpp')
-rw-r--r--src/entity.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index 766b0093..41b22d5e 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -81,9 +81,10 @@ bool entity::can_rotate(global_coords coord, rotation new_r, rotation old_r, Vec
{
if (bbox_offset.isZero() && bbox_size[0] == bbox_size[1])
return true;
+ const auto offset_ = rotate_point(offset, old_r, new_r);
const auto bbox_offset_ = rotate_point(bbox_offset, old_r, new_r);
const auto bbox_size_ = rotate_size(bbox_size, old_r, new_r);
- return can_move_to({}, coord, offset, bbox_offset_, bbox_size_);
+ return can_move_to({}, coord, offset_, bbox_offset_, bbox_size_);
}
bool entity::can_rotate(rotation new_r)
@@ -94,7 +95,10 @@ bool entity::can_rotate(rotation new_r)
void entity::rotate(size_t, rotation new_r)
{
fm_assert(atlas->check_rotation(new_r));
- set_bbox(offset, rotate_point(bbox_offset, r, new_r), rotate_size(bbox_size, r, new_r), pass);
+ auto offset_ = is_dynamic() ? rotate_point(offset, r, new_r) : offset; // todo add boolean for this condition
+ auto bbox_offset_ = rotate_point(bbox_offset, r, new_r);
+ auto bbox_size_ = rotate_size(bbox_size, r, new_r);
+ set_bbox(offset_, bbox_offset_, bbox_size_, pass);
if (r != new_r && !is_dynamic())
c->mark_scenery_modified();
const_cast<rotation&>(r) = new_r;