Make GetLargestCutoffDistance work with collision groups

Currently Roblox’s camera system uses http://wiki.roblox.com/index.php?title=API:Class/Camera/GetLargestCutoffDistance to determine how far out you can zoom before collidable objects gets in the way of what you see.
The problem with this method is that it only takes an ignorelist, and we can’t specify it to work on a given collision group / part’s collision group(s).
I’ve noticed that the GetLargestCutoffDistance method behaves differently than simply raycasting to find parts that may clash with the camera view, and running loop to add noncollidable parts to the ignore list used for GetLargestCutoffDistance didn’t seem to do the trick.

Current behavior, as GetLargestCutoffDistance doesn’t account for collision groups:

Behavior where GetLargestCutoffDistance accounts for collision groups:

Proposed solution:
Change

float GetLargestCutoffDistance (
    array<PVInstance> ignoreList
)

to

float GetLargestCutoffDistance (
    array<PVInstance> ignoreList,
    BasePart collidesWithPart = nil
)

So that passing the optional HumanoidRootPart as a second parameter would solve the above use case, given that the HRP can be part of multiple collision groups etc.

2 Likes

It’d be nicer if the ignoreList just accepted collision group ids that should be ignored.

1 Like

The only issue then is that you need to loop over the collision groups and check to see if they will be able to collide with the given part then.

Both solutions have ups and downs, and while my solution in OP is more targetted towards the use case of the camera, it has the downside of needing a part to be present.

But this is such a specific parameter and at a glance it doesn’t make sense what it does or how it’s any different from adding a part to the ignore list.

1 Like