Issue #1760

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Issue #1760

Post by pgimeno »

I've noticed this issue: https://github.com/love2d/love/issues/1760

I'm not on GitHub so I can't comment there, but I wanted to note that this is a problem with the default "miter" line join algorithm. The line drawing algorithm tries to draw a miter, but when there are duplicate points, doing a miter implies that the edges of the line at the joint would be parallel. See what happens when they are almost parallel:

Code: Select all

function love.draw()
  love.graphics.setLineWidth(2)
  love.graphics.line(750, 300, 400, 300, 750, 303)
end
In an 800x600 window, the miter extends well to the left of the centre of the screen, where the central point is located.

All three test cases work just fine after setting the line join to none:

Code: Select all

love.graphics.setLineJoin("none")
function love.draw()
      love.graphics.line(0, 0, 100, 100, 100, 100) -- a
      love.graphics.line(10, 0, 60, 50, 60, 50, 110, 100) --b
      love.graphics.line(20, 0, 70, 50, 120, 100, 70, 50) -- c
end
I don't think this is really a bug, but hinting at the line join as the culprit in the issue would probably help people work around it. If it's considered a bug, perhaps the solution would be to internally switch the line join to "none" for the vertices where the miter angle gets too extreme.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Issue #1760

Post by slime »

Thanks for the investigation!
pgimeno wrote: Sat Jan 22, 2022 11:43 pm perhaps the solution would be to internally switch the line join to "none" for the vertices where the miter angle gets too extreme.
I've wanted to add that for a long time now (maybe using 'bevel' instead of 'none', or whatever's easier), but I never got around to it because the line drawing code isn't the easiest to navigate. But it definitely adds extra incentive to doing so if it solves both issues at once.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Issue #1760

Post by pgimeno »

Using "bevel" with grump's test cases I get a weird result. The lines appear greyer than they actually are.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests