From f651a91bf649a0e1bae857bbbf78a7effa0f2783 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 25 Apr 2022 21:51:03 +1000 Subject: [PATCH] perf(zones): debug Iterate polygon userdata directly, instead of creating a new table each frame. --- imports/zones/client.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/imports/zones/client.lua b/imports/zones/client.lua index cccf69b..3fe9e80 100644 --- a/imports/zones/client.lua +++ b/imports/zones/client.lua @@ -6,16 +6,18 @@ local function removeZone(self) end local function debug(self) - local points = self.polygon() - for i = 1, #points do - if i == #points then - DrawPoly(points[i], points[1], self.centroid, 255, 0, 0, 50) - DrawPoly(points[1], points[i], self.centroid, 255, 0, 0, 50) - else - DrawPoly(points[i], points[i + 1], self.centroid, 255, 0, 0, 50) - DrawPoly(points[i + 1], points[i], self.centroid, 255, 0, 0, 50) - end - end + local polygon = self.polygon + local polyCount = #self.polygon + + for i = 1, polyCount do + if i == polyCount then + DrawPoly(polygon[i], polygon[1], self.centroid, 255, 0, 0, 50) + DrawPoly(polygon[1], polygon[i], self.centroid, 255, 0, 0, 50) + else + DrawPoly(polygon[i], polygon[i + 1], self.centroid, 255, 0, 0, 50) + DrawPoly(polygon[i + 1], polygon[i], self.centroid, 255, 0, 0, 50) + end + end end local inside = {}