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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
alucherdi
Prole
Posts: 4
Joined: Mon Jul 06, 2015 5:18 am

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

Post 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!
Last edited by alucherdi on Thu Nov 10, 2016 10:49 pm, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Shadow raycast polygon fail (Help!)

Post 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.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Shadow raycast polygon fail (Help!)

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Shadow raycast polygon fail (Help!)

Post by davisdude »

GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Shadow raycast polygon fail (Help!)

Post by raidho36 »

It's not gonna be needed for this particular use, since it generates perfectly good triangle fans as it is.
alucherdi
Prole
Posts: 4
Joined: Mon Jul 06, 2015 5:18 am

Re: Shadow raycast polygon fail (Help!)

Post by alucherdi »

Ok ok let me do some test with that information
alucherdi
Prole
Posts: 4
Joined: Mon Jul 06, 2015 5:18 am

Re: Shadow raycast polygon fail (Help!)

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Shadow raycast polygon fail (Help!)

Post by raidho36 »

You just add that point again so that the triangle fan closes.

Also yes it is most definitely a triangle fan.
alucherdi
Prole
Posts: 4
Joined: Mon Jul 06, 2015 5:18 am

Re: Shadow raycast polygon fail (Help!)

Post 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
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

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

Post by davisdude »

I guess technically you're generating a triangle fan, but you're drawing a polygon.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 6 guests