Introducing OverlapParams - New Spatial Query API

The dude wrote over several pages of benchmarks and spent considerable time testing the performance of the new APIs, which many people wanted answers about, and for you to accuse him of faking this with no reasonable motive is very toxic.

I guess that some people just won’t accept the truth and would rather say it’s false and make up a stupid excuse

1 Like

even a roblox staff member said it’s inaccurate and false but ok

a question, how get touching parts work? it loop on all parts from workspace and make a math?cause people said me get touching parts be slower if have a lot of parts on workspace.

local Origin = CFrame.new(Vector3.new(-840, 0, -820))
local Size = Vector3.new(1000, 1000, 1000)

local Params = OverlapParams.new()
Params.FilterDescendantsInstances = {workspace.Trees["Big Bush"]} --> 'Big Bush' only contains two parts inside.
Params.FilterType = Enum.RaycastFilterType.Whitelist

local Time1 = os.clock()
workspace:GetPartBoundsInBox(Origin, Size, Params)
print(os.clock() - Time1) --> 0.2

In my game it takes 0.2 seconds for this function to run cuz I have a lot of BaseParts, but I have a question. I expect giving a White List would make the process faster since the engine should check only the parts inside the White List. I ran the function without the whitelist:

local Origin = CFrame.new(Vector3.new(-840, 0, -820))
local Size = Vector3.new(1000, 1000, 1000)

local Params = OverlapParams.new()
local Time1 = os.clock()
workspace:GetPartBoundsInBox(Origin, Size, Params)
print(os.clock() - Time1) --> 0.2

My guesses are that the engine scans the workspace completely and checks if they are in the white list. I don’t like it. Could you guys make it so it scans only the parts inside the white list please? I really need it for my game items. I want to get the nearest ones out of all of them. I would love to tag all my items and pass the table with all items to that function as white list. (Faster than checking for magnitude yourself).

6 Likes

This makes hitboxes infinitely easier to produce. and I love it.

1 Like

Wait these can be used as shapecasts…
omg it’s actual hitbox time

Getting parts in a radius directly is much better than finding parts in the Region3 and then seeing how far away they are from the center

Also is there a documentation for OverlapParams? How do I properly use them?

1 Like

As a long-time fan of :GetTouchingParts, but constantly frustrated at it’s terrible limitations, I’ve started using this wide-spread among my games within the past few days, and I’ve gotta say - Wow, not only is this comprehensive & useful, but it’s super intuitive. Just about any setup using Region3 or GetTouchingParts can be so eloquently converted to this new system, saving a few lines of code in the process, usually.

Top notch update, solving one of my oldest problems in Roblox development.

5 Likes

Can’t OverlapParams and RaycastParams be combined into one data type like QueryParams? I find it extremely inconvenient to have to use different data types as they are essentially identical.

Code sample:

local o_params=OverlapParams.new()
o_params.FilterType=Enum.RaycastFilterType.Blacklist
--Both use Enum.RaycastFilterType further proving they
--are identical data types
o_params.FilterDescendantsInstances={self.char,self.cam}
o_params.MaxParts=1

local r_params=RaycastParams.new()
r_params.FilterType=Enum.RaycastFilterType.Blacklist
r_params.FilterDescendantsInstances={self.char,self.cam}
2 Likes

Did WorldRoot:GetPartsInPart() change recently? I’m pretty sure it used to return Terrain if the part overlapped with terrain but I just noticed it does not return Terrain anymore. I’m 90% sure this used to return terrain.

2 Likes

Can we please get wiki documentation for these methods?

2 Likes

I hate to necropost, but is there any chance we’ll get events for this API? An event that fires when a new part overlaps the bounding box would be helpful. I can’t think of a more performant method for checking if a player is in a specific area. Constantly checking their position or their distance from a part seems wasteful, while relying on events like .Touched is janky.

4 Likes

Please extend (or rather reduce) this to Points? I am not sure why we can not have “parts that bound a point”, or, “if a point is within the part”.

2 Likes

Will this have performance benefits over Region3? I had to write my own spatial partitioning class for my own engine on Roblox due to performance issues.

1 Like

Region3 uses AABB, it’s not a true way of seeing if stuff overlaps.
In theory this would be faster than GetTouchingParts, but, Region3 is about the fastest you can get.

So, typically to check collisions fast with this you’d first use Region3 to figure out if the part’s might be touching in a very cheap way, and then you’d use one of the new functions if that first check succeeds.
New functions appear to automatically do this, and are extremely fast.

2 Likes

I’m wondering the same thing here.

I’m working on a character collision system using capsule colliders, and I can’t get collisions to register on terrain, only physical parts in the world. Unlike you, however, I am using GetPartBoundsInRadius though.

Are there plans to add terrain detection in this API?

2 Likes

but gettouchingparts doesnt return an empty table if cancollide is off

1 Like

From the developer API reference:

If the part itself has CanCollide set to false, then this function will return an empty table UNLESS it has a TouchInterest (AKA: Something is connected to its Touched event).

https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts

1 Like

ah explains it all, thank you man

1 Like