Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tyanmahou committed Dec 23, 2024
1 parent 3cbc88e commit 676e342
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Re-Abyss/app/components/Actor/Common/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,25 @@ namespace abyss::Actor
}
s3d::RectF Body::region() const
{
Vec2 pos = this->getOffsetedPos();
if (m_anchor == BodyAnchor::BottomCenter) {
return { m_pos + m_offset - Vec2{m_size.x /2.0, m_size.y}, m_size };
return { pos - Vec2{m_size.x /2.0, m_size.y}, m_size };
} else if (m_anchor == BodyAnchor::TopCenter) {
return { m_pos + m_offset - Vec2{m_size.x / 2.0, 0}, m_size };
return { pos - Vec2{m_size.x / 2.0, 0}, m_size };
} else {
return { m_pos + m_offset - m_size / 2, m_size };
return { pos - m_size / 2, m_size };
}
}
s3d::RectF Body::prevRegion() const
{
Vec2 pos = this->getOffsetedPosPrev();

if (m_anchor == BodyAnchor::BottomCenter) {
return { m_prevPos + m_offsetPrev - Vec2{m_sizePrev.x / 2.0, m_sizePrev.y}, m_sizePrev };
return { pos - Vec2{m_sizePrev.x / 2.0, m_sizePrev.y}, m_sizePrev };
} else if (m_anchor == BodyAnchor::TopCenter) {
return { m_prevPos + m_offsetPrev - Vec2{m_sizePrev.x / 2.0, 0}, m_sizePrev };
return { pos - Vec2{m_sizePrev.x / 2.0, 0}, m_sizePrev };
} else {
return { m_prevPos + m_offsetPrev - m_sizePrev / 2, m_sizePrev };
return { pos - m_sizePrev / 2, m_sizePrev };
}
}
}

0 comments on commit 676e342

Please sign in to comment.