Page 1 of 2

[Solved!] Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 10:08 am
by alucherdi
Hi! I'm having some problems creating a shadow raycast library.
The raycast is working perfectly
Image
But when I try to draw the shadow polygon it looks like the love.graphics.polygon is sort of "jumping" some of the points of the raycast
Image

Here's the code:
https://github.com/Alucherdi/Love2d-sha ... ee/develop

I hope you can help me with my problem, feel free to ask any question, I'll answer as soon as possible. Thanks!

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 11:57 am
by raidho36
If the polygon is a triangle fan, its first point must be in its center (i.e. where rays start), otherwise overlapping will occur, as seen on your image.

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 6:54 pm
by s-ol
raidho36 wrote:If the polygon is a triangle fan, its first point must be in its center (i.e. where rays start), otherwise overlapping will occur, as seen on your image.
And the Polygon must be "simple". There's a love.math function to tesselate complex polygons into multiple simple ones i believe.

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 8:42 pm
by davisdude

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 8:59 pm
by raidho36
It's not gonna be needed for this particular use, since it generates perfectly good triangle fans as it is.

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 9:53 pm
by alucherdi
Ok ok let me do some test with that information

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 10:09 pm
by alucherdi
Btw, it's not a triangle fan, I sort the angles and then make the polygon with the intersections. The first point in the center actually kind of worked! but there is a gap between 2 points. I also tryed to initialize the polygon points table with the last intersection but the overlap come back

Image

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 10:18 pm
by raidho36
You just add that point again so that the triangle fan closes.

Also yes it is most definitely a triangle fan.

Re: Shadow raycast polygon fail (Help!)

Posted: Thu Nov 10, 2016 10:44 pm
by alucherdi
It's not!, when I draw the polygon the points that intersects don't return to the origin uwu, and it worked! thanks a lot!!

Image

Thanks a lot, I'm pushing in git with the results

Re: [Solved!] Shadow raycast polygon fail (Help!)

Posted: Fri Nov 11, 2016 2:24 am
by davisdude
I guess technically you're generating a triangle fan, but you're drawing a polygon.