LessSimpleZone | A more precise & optimized extension of SimpleZone

Most excellent!

Thank you!
Looking forward to checking it out.

1 Like

Hello, I’ve appended the test place to the post.

1 Like

Package Version 90:

  • Changed LessSimpleZone:UpdateVolume() to use the new BVH.updateBVH() function I recently added for SimpleZone instead of completely reconstructing the BVH. Very nice!

Package Version 94:

  • Made Zone:IsPointWithinZone() traverse the BVH instead of looping through all leaves (except for BasePartVertexZone), this reduces time complexity from O(n) to O(1) (from my calculations, it’s probably very close to constant time tho :sob:)
    Yeah… look at that… it’s almost as fast as table indexing

The download link has been updated

Package Version 103:

  • Made :IsPointWithinZone return the part/box node/tetrahedron that contained the point as the 2nd argument
  • Added the QueryOptions constructor directly into LessSimpleZone instead of having to access SimpleZone first

having perf issues with this library


is there any solution?

Hi, there are several steps I would take here, if you haven’t already:

  1. Provide an OverlapParams to :BindToHeartbeat() so it doesn’t spend alot of time handling items
  2. Reduce QueryOptions.UpdateInterval to the necessary value, usually 1/30 is pretty good
  3. Turn on QueryOptions.InSeperateQuerySpace and manually copy items you wanna query via Zone:CopyToQuerySpace(), this reduces performance issues purely from Workspace containing alot of stuff

If after all this you still have performance issues I’d encourage you to send your microprofiler dump so I can see what’s taking up so much frametime (or just tell me xd)


image

do you have example?

Wait, what version are you using?

A test place is present on the SimpleZone post

image

1 Like

Ahh, the latest version is 108, I’ll update the download link real quick just incase that’s the problem

also i only had 2 different zone.

What constructor are you using? .fromParts and .fromBoxes tend to be the best

local zone = Zone.fromParts({ … }, options)

1 Like

Hmm, yeah I’d try just downloading the newest version (i updated the download link) and seeing if that fixes it, if not and query spaces still don’t work I guess i need to work on a new update!!!


just slightly better than before, and it will go down once more players joined
4 players in a server can get 40-55fps, but once it hit more than 5, it can go down over 30 or lower…

-- first zone
local Zone = require(Shared:WaitForChild("Zone"))

local options = Zone.SimpleZone.QueryOptions.new()
options.ThrottlingEnabled = true
options.UpdateInterval = 1/25
options.AcceptMetadata = false

local zone = Zone.fromParts(Helper.storage.GlobalConfig.SafeZoneArea:GetChildren(), options)
zone:BindToHeartbeat()
zone:ListenTo("Player", "Entered", function(player: Player)
	add(player, true)
end)
zone:ListenTo("Player", "Exited", function(player: Player)
	remove(player, true)
end)
-- second zone
local Zone = require(Shared:WaitForChild("Zone"))
	
local options = Zone.SimpleZone.QueryOptions.new()
options.ThrottlingEnabled = true
options.UpdateInterval = 1/24
options.AcceptMetadata = false

local zone = Zone.fromParts({ Helper.storage.GlobalConfig.KoHArea.Area }, options)
zone:BindToHeartbeat()
zone:ListenTo("Player", "Entered", function(player: Player)
	if player and player:HasTag("DataLoaded") and player.Character then
		table.insert(KoHController.in_zone, player)
	end
	update_koh()
end)
zone:ListenTo("Player", "Exited", function(player: Player)
	if player and table.find(KoHController.in_zone, player) then
		table.remove(KoHController.in_zone, table.find(KoHController.in_zone, player))
	end
	update_koh()
end)

i had migrated other zones (except these two) with this simple function

Helper.is_in_box = function(size: Vector3, c: CFrame)
	c = c:Inverse()
	size = size/2
	return @native function(pos: Vector3)
		pos = c * pos
		return not ((pos.X >= size.X) or (pos.X <= -size.X)
			or	(pos.Y >= size.Y) or (pos.Y <= -size.Y)
			or (pos.Z >= size.Z) or (pos.Z <= -size.Z)
		)
	end
end
1 Like

I’ll try seeing if I can replicate the performance issues, I’ll let you know when a fix has been implemented :+1: Just to confirm, can you send the amount of zone parts you have, and the rough size and shape of each one?

e.rbxm (14.0 KB)
here for the parts


this when 4-5 players in a server

when hit about 10-15, it can go down to 7-10 fps

1 Like

Hi, unfortunately i can’t replicate the performance issues :confused: Can you try providing an OverlapParams to :BindToHeartbeat()? If the zone is just detecting players this should be pretty easy to do