Skip to content

Commit

Permalink
Handle negative shape outline thickness
Browse files Browse the repository at this point in the history
  • Loading branch information
kimci86 committed Oct 28, 2023
1 parent bda5221 commit 5ff9901
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/SFML/Graphics/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void Shape::updateOutline()
// Decide whether to add a bevel or not
const float factor = 1.f + n1.dot(n2);
const float squaredLengthRatio = miterLimit * miterLimit * factor / 2.f;
const bool isConvexCorner = 0.f <= d1.dot(n2);
const bool isConvexCorner = 0.f <= d1.dot(n2) * m_outlineThickness;
const bool needsBevel = factor == 0.f || (squaredLengthRatio < 1.f && isConvexCorner);

if (needsBevel)
Expand All @@ -342,7 +342,8 @@ void Shape::updateOutline()
m_outlineVertices.resize(m_outlineVertices.getVertexCount() + 2);

// Interpolate how much we extend outline to have a smooth transition between mitter and bevel
const float extension = minExtension + (maxExtension - minExtension) * squaredLengthRatio;
const float absExtension = minExtension + (maxExtension - minExtension) * squaredLengthRatio;
const float extension = std::copysign(absExtension, m_outlineThickness);

// Update the outline points
m_outlineVertices[outlineIndex++].position = p1;
Expand Down

0 comments on commit 5ff9901

Please sign in to comment.