Page 1 of 1

Concave polygons

Posted: Thu Oct 29, 2020 8:28 pm
by PFQNiet
Just found out the hard way that attempting to call rendering.draw_polygon with vertices that aren't a convex hull results in odd and unpredictable results.

My workaround is having to break the shape down into convex parts myself and render them separately, which is not ideal.

Could support for concave polygons be added?

EDIT: Or at least update the API docs to specify that only convex polygons are supported, because I spent way too long "debugging" this!
EDIT2: Turns out that even with concave shapes, an alpha value on the colour doesn't work well as some parts are drawn over multiple times. I finally had to break my shape down all the way to individual triangles to get it working properly.

Re: Concave polygons

Posted: Thu Jan 21, 2021 10:25 pm
by darkfrei
+1 for multiple ways to define polygons.
viewtopic.php?t=80171&p=492321

Re: Concave polygons

Posted: Fri Jan 22, 2021 2:08 am
by Rseding91
Sorry but this isn't likely to happen. As far as I know; the polygon function in LuaRendering was thrown in "because we already have the function on the C++ side" and so if anyone wanted to use it they could. We aren't looking to expand or change how it functions on the C++ side. It was created to draw exactly what it supports and nothing more; to be as fast as it possibly can be.

Re: Concave polygons

Posted: Fri Jan 22, 2021 9:05 am
by PFQNiet
Understandable. Rendering individual triangles works and is fine in my case (an arched arrow to show a projectile trajectory)

Re: Concave polygons

Posted: Fri Jan 22, 2021 10:57 am
by posila
Unfortunatelly, draw_polygon is misleading. It's drawing a triangle strip

Re: Concave polygons

Posted: Fri Jan 22, 2021 5:49 pm
by PFQNiet
Yup, that's what I figured out the hard way XD Might be a nice touch to add that to the API docs so others don't run afoul of the problem I had.

draw_polygon is perfectly fine for drawing convex, solid shapes. I only ran into extra problems because I wanted semi-transparent colour, which exposed the underlying triangle strip!

Re: Concave polygons

Posted: Fri Jan 22, 2021 8:31 pm
by Koub
[Koub] Moving this to "won't implement" then.