Introducing OverlapParams - New Spatial Query API

This is already possible, you simply need to put the parts outside of the workspace inside of a WorldModel, and you will be able to raycast and region query against them on the WorldModel the same way you would against parts in the Workspace by calling those functions on the Workspace.

Returning a mixture of parts from different physical spaces doesn’t make a ton of sense, but creating a separate physical space for parts to exist in via a WorldModel already works.

5 Likes

The post talks about baseparts, but I’m curios if this would work on anything else. Notably, meshes and terrain?

Meshes and Terrain are technically BaseParts as they inherit from that class so the answer is, probably yes.

Are there any plans to have this support terrain? This would save me a lot of time programming and probably resources too if done because my solution now is to use raycasting to get terrain.

1 Like

This is perfect for my dynamic destruction script!

Support in what way? Terrain is voxel based, so you can naturally query whether cells are full / empty using the GetCell / GetCells ReadVoxels API

1 Like

Terrain::GetCell is deprecated, and Terrain::GetCells dosen’t exist.
Use Terrain::ReadVoxels instead.

3 Likes

My bad, thought I remembered the API off the top of my head but I should have looked it up. My brain is still thinking in 2014.

9 Likes

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