![]() |
|
render.drawPoly() issue with concave polygons - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: render.drawPoly() issue with concave polygons (/thread-3637.html) |
render.drawPoly() issue with concave polygons - The17thDoctor - 14-05-2021 When drawing a polygon, if a vertex intersects the shape of the polygon without that vertex, it will not render properly I've added a rough sketch of what should happen vs what happens. RE: render.drawPoly() issue with concave polygons - 57e11a - 15-05-2021 At the moment, that is just undefined behavior, as the docs say Code: Vertices should be in clockwise order, starting at the upper-left most, and form a convex shape.RE: render.drawPoly() issue with concave polygons - The17thDoctor - 15-05-2021 (15-05-2021, 03:53 AM)Consolio Wrote: At the moment, that is just undefined behavior, as the docs say The thing is that the function supports concave polys up to a point. Could be nice to have full support instead RE: render.drawPoly() issue with concave polygons - Veegi - 15-05-2021 The built-in function does not support concave polys, as it uses a triangle fan method to render the polygon. In some cases it might work by coincidence. If it was simple (performance wise) to implement an algorithm to split concave polys into multiple convex polys, we would already be using that. What could be worth it would be to implement an algorithm that can split arbitrary concave polygons into convex polygons and then use that as a preprocessing step (only once, outside of rendering hooks), feeding the convex polygons to DrawPoly. Link to the GLua function if you are curious: https://wiki.facepunch.com/gmod/surface.DrawPoly Polygon triangulation in general: https://en.wikipedia.org/wiki/Polygon_triangulation Triangle fan triangulation: https://en.wikipedia.org/wiki/Fan_triangulation (It works on a small subset of concave polygons, and is what DrawPoly uses) |