Concave polygons

Things that we aren't going to implement
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Concave polygons

Post 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.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Concave polygons

Post by darkfrei »

+1 for multiple ways to define polygons.
viewtopic.php?t=80171&p=492321
Last edited by darkfrei on Fri Jan 22, 2021 6:32 pm, edited 1 time in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14591
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Concave polygons

Post 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.
If you want to get ahold of me I'm almost always on Discord.
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Concave polygons

Post by PFQNiet »

Understandable. Rendering individual triangles works and is fine in my case (an arched arrow to show a projectile trajectory)
posila
Factorio Staff
Factorio Staff
Posts: 5408
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Concave polygons

Post by posila »

Unfortunatelly, draw_polygon is misleading. It's drawing a triangle strip
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Concave polygons

Post 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!
Koub
Global Moderator
Global Moderator
Posts: 7918
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Concave polygons

Post by Koub »

[Koub] Moving this to "won't implement" then.
Koub - Please consider English is not my native language.
Post Reply

Return to “Won't implement”