mkafrin / PolyZone

PolyZone is a FiveM mod to define zones of different shapes and test whether a point is inside or outside of the zone
MIT License
202 stars 193 forks source link

Explore drawing walls of zone with DrawPoly instead of DrawLine #10

Closed mkafrin closed 4 years ago

mkafrin commented 4 years ago

Look into the performance of drawing the walls of the zone with DrawPoly instead of DrawLine

DrawPoly can only draw triangles, so you'd need two calls to make the rectangle necessary for the wall. Also it only draws the poly in one direction (see the native docs for more info), so to make both sides viewable, you'd need an additional two calls, for a total of 4 native calls per wall. This still is probably less than the number of DrawLine calls normally made for each wall currently, but actual testing would be needed to determine the performance impact.

mkafrin commented 4 years ago

This did indeed take 4 native calls per wall, but also was more performant due to 4 calls still being less than the number of calls to draw the horizontal lines.

Implemented in 9ef5368767ef961c21ba58f3628dc7788eb6b114