Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing on triangles with both short sides on the left #1

Open
bamert opened this issue Nov 29, 2017 · 1 comment
Open

Failing on triangles with both short sides on the left #1

bamert opened this issue Nov 29, 2017 · 1 comment

Comments

@bamert
Copy link

bamert commented Nov 29, 2017

Hey Josh,

thanks a lot for the code, I'm using it to rasterize triangles in a Delaunay triangulation. I discovered an issue in the case of triangles with both short sides on the left; the spans in this case reach from x1 to x2, where x1 > x2 and so no pixels are drawn in:

for(int x = span.X1; x < span.X2; x++) {

The failure cases are exemplified in the image below (black triangles: failure case, gray: successfully rasterized)
example

I've fixed it by simply swapping the range limits if x2>x1.

@joshb
Copy link
Owner

joshb commented Dec 31, 2017

Hey there,

That's cool! Glad to hear you found it useful. It's been a while since I worked on this, but it looks like the Span constructor ensures that X1 is less than X2, so I think that case should already be handled in the original code (it probably does make more sense to do the swapping when drawing the span, though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants