From 83cff4daf0b1b176344fa4e86e7fffaa4db32f1a Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Fri, 11 Aug 2023 07:43:42 +1000 Subject: [PATCH] fix(client/utils): limit number of drawn sprites --- client/utils.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/utils.lua b/client/utils.lua index f129fe8..21fa46a 100644 --- a/client/utils.lua +++ b/client/utils.lua @@ -31,7 +31,8 @@ function utils.getTexture() return lib.requestStreamedTextureDict('shared'), 'emptydot_32' end -local drawZoneSprites = GetConvarInt('ox_target:drawSprite', 1) == 1 +-- SetDrawOrigin is limited to 32 calls per frame. Set as 0 to disable. +local drawZoneSprites = GetConvarInt('ox_target:drawSprite', 24) local SetDrawOrigin = SetDrawOrigin local DrawSprite = DrawSprite local ClearDrawOrigin = ClearDrawOrigin @@ -44,6 +45,8 @@ local drawN = 0 local width = 0.02 local height = width * GetAspectRatio(false) +if drawZoneSprites == 0 then drawZoneSprites = -1 end + ---@param coords vector3 ---@return CZone[], boolean function utils.getNearbyZones(coords) @@ -61,7 +64,7 @@ function utils.getNearbyZones(coords) currentZones[n] = zone end - if drawZoneSprites and zone.drawSprite ~= false and (contains or (zone.distance or 7) < 7) then + if drawN <= drawZoneSprites and zone.drawSprite ~= false and (contains or (zone.distance or 7) < 7) then drawN += 1 drawZones[drawN] = zone zone.colour = contains and hover or nil