Skip to content

Commit

Permalink
Polygon のバウンディングボックスの計算速度、精度を改善
Browse files Browse the repository at this point in the history
  • Loading branch information
Raclamusi committed Nov 14, 2023
1 parent 3d367aa commit 783f2ce
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Siv3D/src/Siv3D/Polygon/PolygonDetail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ namespace s3d
{
namespace detail
{
template <class Type>
static RectF CalculateBoundingRect(const Vector2D<Type>* const pVertex, const size_t vertexSize)
static RectF CalculateBoundingRect(const Vec2* const pVertex, const size_t vertexSize)
{
assert(pVertex != nullptr);
assert(vertexSize != 0);
Expand Down Expand Up @@ -209,7 +208,7 @@ namespace s3d
m_indices = std::move(indices);

// [5 of 5]
m_boundingRect = detail::CalculateBoundingRect(pOuterVertex, vertexSize);
m_boundingRect = detail::CalculateBoundingRect(m_polygon.outer().data(), m_polygon.outer().size());
}

const Array<Vec2>& Polygon::PolygonDetail::outer() const noexcept
Expand Down Expand Up @@ -370,7 +369,7 @@ namespace s3d
m_holes.back().insert(m_holes.back().end(), hole.begin(), hole.end());
}

m_boundingRect = detail::CalculateBoundingRect(m_vertices.data(), m_vertices.size());
m_boundingRect = detail::CalculateBoundingRect(m_polygon.outer().data(), m_polygon.outer().size());
}

void Polygon::PolygonDetail::transform(const double s, const double c, const Vec2& pos)
Expand Down Expand Up @@ -417,7 +416,7 @@ namespace s3d
m_holes.back().insert(m_holes.back().end(), hole.begin(), hole.end());
}

m_boundingRect = detail::CalculateBoundingRect(m_vertices.data(), m_vertices.size());
m_boundingRect = detail::CalculateBoundingRect(m_polygon.outer().data(), m_polygon.outer().size());
}

void Polygon::PolygonDetail::scale(const double s)
Expand Down

0 comments on commit 783f2ce

Please sign in to comment.