From a8aa1716603e02c030594a9ab5b128a20925bb83 Mon Sep 17 00:00:00 2001 From: tyanmahou Date: Tue, 24 Dec 2024 23:48:53 +0900 Subject: [PATCH] update body --- Re-Abyss/app/components/Actor/Common/Body.cpp | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Re-Abyss/app/components/Actor/Common/Body.cpp b/Re-Abyss/app/components/Actor/Common/Body.cpp index e1a131d6..58049bf4 100644 --- a/Re-Abyss/app/components/Actor/Common/Body.cpp +++ b/Re-Abyss/app/components/Actor/Common/Body.cpp @@ -352,27 +352,24 @@ namespace abyss::Actor { return m_pos - m_prevPos; } - s3d::RectF Body::region() const + s3d::RectF CalcRect(const s3d::Vec2& pos, const s3d::Vec2& size, BodyAnchor anchor) { - Vec2 pos = this->getOffsetedPos(); - if (m_anchor == BodyAnchor::BottomCenter) { - return { pos - Vec2{m_size.x /2.0, m_size.y}, m_size }; - } else if (m_anchor == BodyAnchor::TopCenter) { - return { pos - Vec2{m_size.x / 2.0, 0}, m_size }; + if (anchor == BodyAnchor::BottomCenter) { + return RectF{ Arg::bottomCenter = pos, size }; + } else if (anchor == BodyAnchor::TopCenter) { + return RectF{ Arg::topCenter = pos, size }; } else { - return { pos - m_size / 2, m_size }; + return RectF{ Arg::center = pos, size }; } } + s3d::RectF Body::region() const + { + Vec2 pos = this->getOffsetedPos(); + return CalcRect(pos, m_size, m_anchor); + } s3d::RectF Body::prevRegion() const { Vec2 pos = this->getOffsetedPosPrev(); - - if (m_anchor == BodyAnchor::BottomCenter) { - return { pos - Vec2{m_sizePrev.x / 2.0, m_sizePrev.y}, m_sizePrev }; - } else if (m_anchor == BodyAnchor::TopCenter) { - return { pos - Vec2{m_sizePrev.x / 2.0, 0}, m_sizePrev }; - } else { - return { pos - m_sizePrev / 2, m_sizePrev }; - } + return CalcRect(pos, m_sizePrev, m_anchor); } }