Struct CollisionWorld
A collection of rigid bodies wrapped by a bounding volume hierarchy. This allows to do collision queries such as raycasting, overlap testing, etc.
Inherited Members
Namespace: Unity.Physics
Assembly: Unity.Physics.dll
Syntax
public struct CollisionWorld : ICollidable, IAspectQueryable, IDisposable
Constructors
CollisionWorld(int, int)
Construct a collision world with the given number of uninitialized rigid bodies.
Declaration
public CollisionWorld(int numStaticBodies, int numDynamicBodies)
Parameters
Type | Name | Description |
---|---|---|
int | numStaticBodies | Number of static bodies. |
int | numDynamicBodies | Number of dynamic bodies. |
Fields
CollisionTolerance
Sets the collision tolerance.
Contacts are always created between rigid bodies if they are closer than this distance threshold. Default value is DefaultCollisionTolerance.
Declaration
public float CollisionTolerance
Field Value
Type | Description |
---|---|
float | The collision tolerance. |
DefaultCollisionTolerance
Default CollisionTolerance value.
Declaration
public const float DefaultCollisionTolerance = 0.01
Field Value
Type | Description |
---|---|
float |
Properties
Bodies
Gets the bodies.
Declaration
public NativeArray<RigidBody> Bodies { get; }
Property Value
Type | Description |
---|---|
NativeArray<RigidBody> | The bodies. |
DynamicBodies
Gets the dynamic bodies.
Declaration
public NativeArray<RigidBody> DynamicBodies { get; }
Property Value
Type | Description |
---|---|
NativeArray<RigidBody> | The dynamic bodies. |
NumBodies
Gets the number of bodies.
Declaration
public int NumBodies { get; }
Property Value
Type | Description |
---|---|
int | The total number of bodies. |
NumDynamicBodies
Gets the number of dynamic bodies.
Declaration
public int NumDynamicBodies { get; }
Property Value
Type | Description |
---|---|
int | The total number of dynamic bodies. |
NumStaticBodies
Gets the number of static bodies.
Declaration
public int NumStaticBodies { get; }
Property Value
Type | Description |
---|---|
int | The total number of static bodies. |
StaticBodies
Gets the static bodies.
Declaration
public NativeArray<RigidBody> StaticBodies { get; }
Property Value
Type | Description |
---|---|
NativeArray<RigidBody> | The static bodies. |
Methods
BoxCast(float3, quaternion, float3, float3, float, out ColliderCastHit, CollisionFilter, QueryInteraction)
Box cast.
Declaration
public bool BoxCast(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
ColliderCastHit | hitInfo | [out] Information describing the hit. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
BoxCast(float3, quaternion, float3, float3, float, CollisionFilter, QueryInteraction)
Box cast.
Declaration
public bool BoxCast(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
BoxCastAll(float3, quaternion, float3, float3, float, ref NativeList<ColliderCastHit>, CollisionFilter, QueryInteraction)
Box cast all.
Declaration
public bool BoxCastAll(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
NativeList<ColliderCastHit> | outHits | [in,out] The out hits. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
BoxCastCustom<T>(float3, quaternion, float3, float3, float, ref T, CollisionFilter, QueryInteraction)
Box cast custom.
Declaration
public bool BoxCastCustom<T>(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
T | collector | [in,out] The collector. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
BuildBroadphase(ref PhysicsWorld, float, float3, bool)
Build the broadphase based on the given world.
Declaration
public void BuildBroadphase(ref PhysicsWorld world, float timeStep, float3 gravity, bool buildStaticTree = true)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
bool | buildStaticTree | (Optional) True to build static tree. |
CalculateAabb()
Calculates the aabb.
Declaration
public Aabb CalculateAabb()
Returns
Type | Description |
---|---|
Aabb | The calculated aabb. |
CalculateDistance(in ColliderAspect, float, ref NativeList<DistanceHit>, QueryInteraction)
Calculates the distance from the collider aspect.
Declaration
public bool CalculateDistance(in ColliderAspect colliderAspect, float maxDistance, ref NativeList<DistanceHit> allHits, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float | maxDistance | The maximum distance. |
NativeList<DistanceHit> | allHits | [in,out] all hits. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(in ColliderAspect, float, out DistanceHit, QueryInteraction)
Calculates the distance from the collider aspect.
Declaration
public bool CalculateDistance(in ColliderAspect colliderAspect, float maxDistance, out DistanceHit closestHit, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float | maxDistance | The maximum distance. |
DistanceHit | closestHit | [out] The closest hit. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(in ColliderAspect, float, QueryInteraction)
Calculates the distance from the collider aspect.
Declaration
public bool CalculateDistance(in ColliderAspect colliderAspect, float maxDistance, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float | maxDistance | The maximum distance. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(ColliderDistanceInput)
Calculates the distance.
Declaration
public bool CalculateDistance(ColliderDistanceInput input)
Parameters
Type | Name | Description |
---|---|---|
ColliderDistanceInput | input | The input. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(ColliderDistanceInput, ref NativeList<DistanceHit>)
Calculates the distance.
Declaration
public bool CalculateDistance(ColliderDistanceInput input, ref NativeList<DistanceHit> allHits)
Parameters
Type | Name | Description |
---|---|---|
ColliderDistanceInput | input | The input. |
NativeList<DistanceHit> | allHits | [in,out] all hits. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(ColliderDistanceInput, out DistanceHit)
Calculates the distance.
Declaration
public bool CalculateDistance(ColliderDistanceInput input, out DistanceHit closestHit)
Parameters
Type | Name | Description |
---|---|---|
ColliderDistanceInput | input | The input. |
DistanceHit | closestHit | [out] The closest hit. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(PointDistanceInput)
Calculates the distance.
Declaration
public bool CalculateDistance(PointDistanceInput input)
Parameters
Type | Name | Description |
---|---|---|
PointDistanceInput | input | The input. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(PointDistanceInput, ref NativeList<DistanceHit>)
Calculates the distance.
Declaration
public bool CalculateDistance(PointDistanceInput input, ref NativeList<DistanceHit> allHits)
Parameters
Type | Name | Description |
---|---|---|
PointDistanceInput | input | The input. |
NativeList<DistanceHit> | allHits | [in,out] all hits. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance(PointDistanceInput, out DistanceHit)
Calculates the distance.
Declaration
public bool CalculateDistance(PointDistanceInput input, out DistanceHit closestHit)
Parameters
Type | Name | Description |
---|---|---|
PointDistanceInput | input | The input. |
DistanceHit | closestHit | [out] The closest hit. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CalculateDistance<T>(in ColliderAspect, float, ref T, QueryInteraction)
Calculates the distance from the collider aspect.
Declaration
public bool CalculateDistance<T>(in ColliderAspect colliderAspect, float maxDistance, ref T collector, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float | maxDistance | The maximum distance. |
T | collector | [in,out] The collector. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CalculateDistance<T>(ColliderDistanceInput, ref T)
Calculates the distance.
Declaration
public bool CalculateDistance<T>(ColliderDistanceInput input, ref T collector) where T : struct, ICollector<DistanceHit>
Parameters
Type | Name | Description |
---|---|---|
ColliderDistanceInput | input | The input. |
T | collector | [in,out] The collector. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CalculateDistance<T>(PointDistanceInput, ref T)
Calculates the distance.
Declaration
public bool CalculateDistance<T>(PointDistanceInput input, ref T collector) where T : struct, ICollector<DistanceHit>
Parameters
Type | Name | Description |
---|---|---|
PointDistanceInput | input | The input. |
T | collector | [in,out] The collector. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CapsuleCast(float3, float3, float, float3, float, out ColliderCastHit, CollisionFilter, QueryInteraction)
Capsule cast.
Declaration
public bool CapsuleCast(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
ColliderCastHit | hitInfo | [out] Information describing the hit. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CapsuleCast(float3, float3, float, float3, float, CollisionFilter, QueryInteraction)
Capsule cast.
Declaration
public bool CapsuleCast(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CapsuleCastAll(float3, float3, float, float3, float, ref NativeList<ColliderCastHit>, CollisionFilter, QueryInteraction)
Capsule cast all.
Declaration
public bool CapsuleCastAll(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
NativeList<ColliderCastHit> | outHits | [in,out] The out hits. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CapsuleCastCustom<T>(float3, float3, float, float3, float, ref T, CollisionFilter, QueryInteraction)
Capsule cast custom.
Declaration
public bool CapsuleCastCustom<T>(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
T | collector | [in,out] The collector. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CastCollider(in ColliderAspect, float3, float, ref NativeList<ColliderCastHit>, QueryInteraction)
Cast a collider aspect against this CollisionWorld.
Declaration
public bool CastCollider(in ColliderAspect colliderAspect, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> allHits, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float3 | direction | The direction of the aspect. |
float | maxDistance | The maximum distance. |
NativeList<ColliderCastHit> | allHits | [in,out] all hits. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastCollider(in ColliderAspect, float3, float, out ColliderCastHit, QueryInteraction)
Cast a collider aspect against this CollisionWorld.
Declaration
public bool CastCollider(in ColliderAspect colliderAspect, float3 direction, float maxDistance, out ColliderCastHit closestHit, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float3 | direction | The direction of the aspect. |
float | maxDistance | The maximum distance. |
ColliderCastHit | closestHit | [out] The closest hit. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastCollider(in ColliderAspect, float3, float, QueryInteraction)
Cast a collider aspect against this CollisionWorld.
Declaration
public bool CastCollider(in ColliderAspect colliderAspect, float3 direction, float maxDistance, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float3 | direction | The direction of the aspect. |
float | maxDistance | The maximum distance. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastCollider(ColliderCastInput)
Cast collider.
Declaration
public bool CastCollider(ColliderCastInput input)
Parameters
Type | Name | Description |
---|---|---|
ColliderCastInput | input | The input. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastCollider(ColliderCastInput, ref NativeList<ColliderCastHit>)
Cast collider.
Declaration
public bool CastCollider(ColliderCastInput input, ref NativeList<ColliderCastHit> allHits)
Parameters
Type | Name | Description |
---|---|---|
ColliderCastInput | input | The input. |
NativeList<ColliderCastHit> | allHits | [in,out] all hits. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastCollider(ColliderCastInput, out ColliderCastHit)
Cast collider.
Declaration
public bool CastCollider(ColliderCastInput input, out ColliderCastHit closestHit)
Parameters
Type | Name | Description |
---|---|---|
ColliderCastInput | input | The input. |
ColliderCastHit | closestHit | [out] The closest hit. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastCollider<T>(in ColliderAspect, float3, float, ref T, QueryInteraction)
Cast a collider aspect against this CollisionWorld.
Declaration
public bool CastCollider<T>(in ColliderAspect colliderAspect, float3 direction, float maxDistance, ref T collector, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
Parameters
Type | Name | Description |
---|---|---|
ColliderAspect | colliderAspect | The collider aspect. |
float3 | direction | The direction of the aspect. |
float | maxDistance | The maximum distance. |
T | collector | [in,out] The collector. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CastCollider<T>(ColliderCastInput, ref T)
Cast collider.
Declaration
public bool CastCollider<T>(ColliderCastInput input, ref T collector) where T : struct, ICollector<ColliderCastHit>
Parameters
Type | Name | Description |
---|---|---|
ColliderCastInput | input | The input. |
T | collector | [in,out] The collector. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CastRay(RaycastInput)
Cast ray.
Declaration
public bool CastRay(RaycastInput input)
Parameters
Type | Name | Description |
---|---|---|
RaycastInput | input | The input. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastRay(RaycastInput, ref NativeList<RaycastHit>)
Cast ray.
Declaration
public bool CastRay(RaycastInput input, ref NativeList<RaycastHit> allHits)
Parameters
Type | Name | Description |
---|---|---|
RaycastInput | input | The input. |
NativeList<RaycastHit> | allHits | [in,out] all hits. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastRay(RaycastInput, out RaycastHit)
Cast ray.
Declaration
public bool CastRay(RaycastInput input, out RaycastHit closestHit)
Parameters
Type | Name | Description |
---|---|---|
RaycastInput | input | The input. |
RaycastHit | closestHit | [out] The closest hit. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CastRay<T>(RaycastInput, ref T)
Cast ray.
Declaration
public bool CastRay<T>(RaycastInput input, ref T collector) where T : struct, ICollector<RaycastHit>
Parameters
Type | Name | Description |
---|---|---|
RaycastInput | input | The input. |
T | collector | [in,out] The collector. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
CheckBox(float3, quaternion, float3, CollisionFilter, QueryInteraction)
Check box.
Declaration
public bool CheckBox(float3 center, quaternion orientation, float3 halfExtents, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CheckCapsule(float3, float3, float, CollisionFilter, QueryInteraction)
Check capsule.
Declaration
public bool CheckCapsule(float3 point1, float3 point2, float radius, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
CheckSphere(float3, float, CollisionFilter, QueryInteraction)
Interfaces that represent queries that exist in the GameObjects world.
Declaration
public bool CheckSphere(float3 position, float radius, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | position | The position. |
float | radius | The radius. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Clone()
Clone the world.
The Broadphase is deep copied. All data in rigid bodies is deep copied, except for their colliders, which are shallow copied.
Declaration
public CollisionWorld Clone()
Returns
Type | Description |
---|---|
CollisionWorld | A copy of this object. |
Clone(bool, bool, NativeList<int>)
Clone the world.
The Broadphase is deep copied. All data in rigid bodies is deep copied, except for their colliders, which are optionally deep copied or shallow copied.
Declaration
public CollisionWorld Clone(bool deepCopyDynamicColliders, bool deepCopyStaticColliders = false, NativeList<int> deepCopyRigidBodyList = default)
Parameters
Type | Name | Description |
---|---|---|
bool | deepCopyDynamicColliders | Deep copy all dynamic colliders. |
bool | deepCopyStaticColliders | Deep copy all static colliders. |
NativeList<int> | deepCopyRigidBodyList | Deep copy colliders of the rigid bodies in the list, each specified
by its index.
Must not contain duplicate entries, and must not contain indices of rigid bodies whose
colliders will already be deep copied due to the values chosen for the
|
Returns
Type | Description |
---|---|
CollisionWorld | A copy of this object. |
Dispose()
Free internal memory.
Declaration
public void Dispose()
FindOverlaps(ref Writer, ref Writer)
Write all overlapping body pairs to the given streams, where at least one of the bodies is dynamic. The results are unsorted.
Declaration
public void FindOverlaps(ref NativeStream.Writer dynamicVsDynamicPairsWriter, ref NativeStream.Writer staticVsDynamicPairsWriter)
Parameters
Type | Name | Description |
---|---|---|
NativeStream.Writer | dynamicVsDynamicPairsWriter | [in,out] The dynamic vs dynamic pairs writer. |
NativeStream.Writer | staticVsDynamicPairsWriter | [in,out] The static vs dynamic pairs writer. |
GetRigidBodyIndex(Entity)
Gets the zero-based index of the rigid body.
Declaration
public int GetRigidBodyIndex(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity. |
Returns
Type | Description |
---|---|
int | The rigid body index. |
OverlapAabb(OverlapAabbInput, ref NativeList<int>)
Test input against the broadphase tree, filling allHits with the body indices of every overlap. Returns true if there was at least overlap.
Declaration
public bool OverlapAabb(OverlapAabbInput input, ref NativeList<int> allHits)
Parameters
Type | Name | Description |
---|---|---|
OverlapAabbInput | input | The input. |
NativeList<int> | allHits | [in,out] all hits. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
OverlapBox(float3, quaternion, float3, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)
Overlap box.
Declaration
public bool OverlapBox(float3 center, quaternion orientation, float3 halfExtents, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
NativeList<DistanceHit> | outHits | [in,out] The out hits. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
OverlapBoxCustom<T>(float3, quaternion, float3, ref T, CollisionFilter, QueryInteraction)
Overlap box custom.
Declaration
public bool OverlapBoxCustom<T>(float3 center, quaternion orientation, float3 halfExtents, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center. |
quaternion | orientation | The orientation. |
float3 | halfExtents | Half extents of the box. |
T | collector | [in,out] The collector. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
OverlapCapsule(float3, float3, float, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)
Overlap capsule.
Declaration
public bool OverlapCapsule(float3 point1, float3 point2, float radius, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
NativeList<DistanceHit> | outHits | [in,out] The out hits. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
OverlapCapsuleCustom<T>(float3, float3, float, ref T, CollisionFilter, QueryInteraction)
Overlap capsule custom.
Declaration
public bool OverlapCapsuleCustom<T>(float3 point1, float3 point2, float radius, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
Parameters
Type | Name | Description |
---|---|---|
float3 | point1 | The first point in capsule definition. |
float3 | point2 | The second point in capsule definition. |
float | radius | The radius. |
T | collector | [in,out] The collector. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
OverlapSphere(float3, float, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)
Overlap sphere.
Declaration
public bool OverlapSphere(float3 position, float radius, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | position | The position. |
float | radius | The radius. |
NativeList<DistanceHit> | outHits | [in,out] The out hits. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
OverlapSphereCustom<T>(float3, float, ref T, CollisionFilter, QueryInteraction)
Overlap sphere custom.
Declaration
public bool OverlapSphereCustom<T>(float3 position, float radius, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
Parameters
Type | Name | Description |
---|---|---|
float3 | position | The position. |
float | radius | The radius. |
T | collector | [in,out] The collector. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
Reset(int, int)
Resets this object.
Declaration
public void Reset(int numStaticBodies, int numDynamicBodies)
Parameters
Type | Name | Description |
---|---|---|
int | numStaticBodies | Number of static bodies. |
int | numDynamicBodies | Number of dynamic bodies. |
ScheduleBuildBroadphaseJobs(ref PhysicsWorld, float, float3, ReadOnly, JobHandle, bool)
Schedule a set of jobs to build the broadphase based on the given world.
Declaration
public JobHandle ScheduleBuildBroadphaseJobs(ref PhysicsWorld world, float timeStep, float3 gravity, NativeReference<int>.ReadOnly buildStaticTree, JobHandle inputDeps, bool multiThreaded = true)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
NativeReference<int>.ReadOnly | buildStaticTree | The build static tree. |
JobHandle | inputDeps | The input deps. |
bool | multiThreaded | (Optional) True if multi threaded. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
ScheduleFindOverlapsJobs(out NativeStream, out NativeStream, JobHandle, bool)
Schedule a set of jobs which will write all overlapping body pairs to the given steam, where at least one of the bodies is dynamic. The results are unsorted.
Declaration
public SimulationJobHandles ScheduleFindOverlapsJobs(out NativeStream dynamicVsDynamicPairsStream, out NativeStream staticVsDynamicPairsStream, JobHandle inputDeps, bool multiThreaded = true)
Parameters
Type | Name | Description |
---|---|---|
NativeStream | dynamicVsDynamicPairsStream | [out] The dynamic vs dynamic pairs stream. |
NativeStream | staticVsDynamicPairsStream | [out] The static vs dynamic pairs stream. |
JobHandle | inputDeps | The input deps. |
bool | multiThreaded | (Optional) True if multi threaded. |
Returns
Type | Description |
---|---|
SimulationJobHandles | The SimulationJobHandles. |
ScheduleUpdateDynamicTree(ref PhysicsWorld, float, float3, JobHandle, bool)
Schedule a set of jobs to synchronize the collision world with the dynamics world.
Declaration
public JobHandle ScheduleUpdateDynamicTree(ref PhysicsWorld world, float timeStep, float3 gravity, JobHandle inputDeps, bool multiThreaded = true)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
JobHandle | inputDeps | The input deps. |
bool | multiThreaded | (Optional) True if multi threaded. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
ScheduleUpdateStaticTree(ref PhysicsWorld, ReadOnly, JobHandle, bool)
Schedule a set of jobs to update the static collision world.
Declaration
public JobHandle ScheduleUpdateStaticTree(ref PhysicsWorld world, NativeReference<int>.ReadOnly buildStaticTree, JobHandle inputDeps, bool multiThreaded = true)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
NativeReference<int>.ReadOnly | buildStaticTree | The build static tree. |
JobHandle | inputDeps | The input deps. |
bool | multiThreaded | (Optional) True if multi threaded. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
SphereCast(float3, float, float3, float, out ColliderCastHit, CollisionFilter, QueryInteraction)
Sphere cast.
Declaration
public bool SphereCast(float3 origin, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | origin | The origin. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
ColliderCastHit | hitInfo | [out] Information describing the hit. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
SphereCast(float3, float, float3, float, CollisionFilter, QueryInteraction)
Sphere cast.
Declaration
public bool SphereCast(float3 origin, float radius, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | origin | The origin. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
SphereCastAll(float3, float, float3, float, ref NativeList<ColliderCastHit>, CollisionFilter, QueryInteraction)
Sphere cast all.
Declaration
public bool SphereCastAll(float3 origin, float radius, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
Parameters
Type | Name | Description |
---|---|---|
float3 | origin | The origin. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
NativeList<ColliderCastHit> | outHits | [in,out] The out hits. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
SphereCastCustom<T>(float3, float, float3, float, ref T, CollisionFilter, QueryInteraction)
Sphere cast custom.
Declaration
public bool SphereCastCustom<T>(float3 origin, float radius, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
Parameters
Type | Name | Description |
---|---|---|
float3 | origin | The origin. |
float | radius | The radius. |
float3 | direction | The direction. |
float | maxDistance | The maximum distance. |
T | collector | [in,out] The collector. |
CollisionFilter | filter | Specifies the filter. |
QueryInteraction | queryInteraction | (Optional) The query interaction. |
Returns
Type | Description |
---|---|
bool | True if there is a hit, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Generic type parameter. |
UpdateBodyIndexMap()
Updates the body index map.
Declaration
public void UpdateBodyIndexMap()
UpdateDynamicTree(ref PhysicsWorld, float, float3)
Synchronize the collision world with the dynamics world.
Declaration
public void UpdateDynamicTree(ref PhysicsWorld world, float timeStep, float3 gravity)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
UpdateStaticTree(ref PhysicsWorld)
Rebuild the static collision world.
Declaration
public void UpdateStaticTree(ref PhysicsWorld world)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |