Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

PhysicsDestructor.Fragment

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static LowLevelPhysics2D.PhysicsDestructor.FragmentResult Fragment(LowLevelPhysics2D.PhysicsDestructor.FragmentGeometry target, ReadOnlySpan<Vector2> fragmentPoints, Unity.Collections.Allocator allocator);

Parameters

Parameter Description
target The target geometry to fragment. There must be at least a single geometry element. Any target polygons with a non-zero radius will be ignored.
fragmentPoints The world-space fragment points used to define fragment regions. The number of fragment points must be greater than 1.
allocator The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

FragmentResult The fragment results. These results must be disposed of after use otherwise leaks will occur.

Description

Fragment the specified target geometry using the specified fragment points. The fragment points define areas where polygon fragments will be produced from the target geometry. If the resulting polygon fragments have more polygon vertices than can fit into a single PolygonGeometry then the fragment will be split into multiple polygon fragments. The maximum number of vertices a single polygon fragment can have is defined by PhysicsConstants.MaxPolygonVertices. If even a single fragment point overlaps the target geometry then all results will be returned in PhysicsDestructor.FragmentResult.brokenGeometry. If none of the fragment points overlap the target geometry then all the results will be returned in PhysicsDestructor.FragmentResult.unbrokenGeometry. See FragmentResult.


Parameters

Parameter Description
target The target geometry to fragment. There must be at least a single geometry element. Any target polygons with a non-zero radius will be ignored.
mask The mask geomety that will be used to clip the target geometry. There must be at least a single geometry element. Any mask polygons with a non-zero radius will be ignored.
fragmentPoints The world-space fragment points used to define fragment regions. The number of fragment points must be greater than 1.
allocator The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

FragmentResult The fragment results. The transform returned here is the one provided in the target geometry. These results must be disposed of after use otherwise leaks will occur.

Description

Fragment the specified mask geometry geometry using the specified fragment points, after the target geometry has the mask (carving) geometry removed from it.

The target geometry is first clipped with the mask geometry using a PhysicsComposer.Operation.NOT operation. The resulting target geometry is returned in PhysicsDestructor.FragmentResult.unbrokenGeometry. The mask geometry is then clipped with the original target geometry using an PhysicsComposer.Operation.AND operation. If the clipped mask produces no geometry then no results are returned in PhysicsDestructor.FragmentResult.brokenGeometry. The fragment points define areas where polygon fragments will be produced from the clipped masked geometry. The resulting polygon fragments are returned in PhysicsDestructor.FragmentResult.brokenGeometry. If the resulting polygon fragments have more polygon vertices than can fit into a single PolygonGeometry then the fragment will be split into multiple polygon fragments. The maximum number of vertices a single polygon fragment can have is defined by PhysicsConstants.MaxPolygonVertices. See FragmentResult.