Skip to content

Commit

Permalink
fix(client/utils): limit number of drawn sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Aug 10, 2023
1 parent 6160fdd commit 83cff4d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 83cff4d

Please sign in to comment.