Class DynamicTree
Represents a dynamic AABB tree for broadphase collision detection.
public class DynamicTree
- Inheritance
-
DynamicTree
- Inherited Members
Remarks
Uses a bounding volume hierarchy with Surface Area Heuristic (SAH) for efficient insertion and query operations. Supports incremental updates for moving objects.
Complexity: O(log n) for insertion/removal, O(n) worst-case for overlap queries.
Constructors
DynamicTree(Func<IDynamicTreeProxy, IDynamicTreeProxy, bool>)
Initializes a new instance of the DynamicTree class.
public DynamicTree(Func<IDynamicTreeProxy, IDynamicTreeProxy, bool> filter)
Parameters
filterFunc<IDynamicTreeProxy, IDynamicTreeProxy, bool>A collision filter function, used in Jitter to exclude collisions between Shapes belonging to the same body. The collision is filtered out if the function returns false.
Fields
ExpandEps
Specifies a small additional expansion of the bounding box which is constant.
public const float ExpandEps = 0.1
Field Value
ExpandFactor
Specifies the factor by which the bounding box in the dynamic tree structure is expanded. The expansion is calculated as Velocity * ExpandFactor * (1 + alpha), where alpha is a pseudo-random number in the range [0, 1).
public const float ExpandFactor = 0.1
Field Value
InitialSize
Initial capacity of the internal node array.
public const int InitialSize = 1024
Field Value
NullNode
Sentinel value indicating a null/invalid node index.
public const int NullNode = -1
Field Value
PruningFraction
Fraction of the potential pairs hash set to scan per update for pruning invalid entries. A value of 128 means 1/128th of the hash set is scanned each update.
public const int PruningFraction = 128
Field Value
Properties
DebugTimings
Contains timings for the stages of the last call to Update(bool, float).
Values are in milliseconds. Index using (int)Timings.XYZ.
public ReadOnlySpan<double> DebugTimings { get; }
Property Value
Filter
Gets or sets the filter function used to exclude proxy pairs from collision detection.
public Func<IDynamicTreeProxy, IDynamicTreeProxy, bool> Filter { get; set; }
Property Value
Remarks
The filter is called during overlap enumeration. Return false to exclude a pair.
In Jitter, this is typically used to exclude shapes belonging to the same rigid body.
Exceptions
- ArgumentNullException
Thrown when the value is null.
HashSetInfo
Retrieve information of the size and filling of the internal hash set used to store potential overlaps.
public (int TotalSize, int Count) HashSetInfo { get; }
Property Value
- (int solver, int relaxation)
Nodes
Read-only view of the internal tree nodes for debugging or visualization. Do not cache the returned span across tree operations.
public ReadOnlySpan<DynamicTree.Node> Nodes { get; }
Property Value
Proxies
Gets a read-only view of all proxies registered with this tree.
public ReadOnlyPartitionedSet<IDynamicTreeProxy> Proxies { get; }
Property Value
Root
Gets the index of the root node, or NullNode if the tree is empty.
public int Root { get; }
Property Value
UpdatedProxyCount
Gets the number of updated proxies during the last call to Update(bool, float).
public int UpdatedProxyCount { get; }
Property Value
Methods
ActivateProxy<T>(T)
Marks a proxy as active, causing it to be tracked for movement during updates.
public void ActivateProxy<T>(T proxy) where T : class, IDynamicTreeProxy
Parameters
proxyTThe proxy to activate.
Type Parameters
TThe proxy type.
AddProxy<T>(T, bool)
Adds a proxy to the tree.
public void AddProxy<T>(T proxy, bool active = true) where T : class, IDynamicTreeProxy
Parameters
proxyTThe proxy to add.
activeboolIf
true, the proxy is tracked for movement each update.
Type Parameters
TThe proxy type.
Exceptions
- InvalidOperationException
Thrown if the proxy is already in this tree.
CalculateCost()
Calculates the SAH cost of the tree (sum of all node surface areas).
public double CalculateCost()
Returns
- double
The total cost. Lower values indicate a more balanced tree.
DeactivateProxy<T>(T)
Marks a proxy as inactive, assuming it will not move outside its expanded bounding box.
public void DeactivateProxy<T>(T proxy) where T : class, IDynamicTreeProxy
Parameters
proxyTThe proxy to deactivate.
Type Parameters
TThe proxy type.
EnumerateOverlaps(Action<IDynamicTreeProxy, IDynamicTreeProxy>, bool)
Enumerates all potential collision pairs and invokes the specified action for each.
public void EnumerateOverlaps(Action<IDynamicTreeProxy, IDynamicTreeProxy> action, bool multiThread = false)
Parameters
actionAction<IDynamicTreeProxy, IDynamicTreeProxy>The action to invoke for each overlapping pair.
multiThreadboolIf
true, uses multithreading for enumeration.
EnumerateTreeBoxes(Action<TreeBox, int>)
Enumerates all axis-aligned bounding boxes in the tree.
public void EnumerateTreeBoxes(Action<TreeBox, int> action)
Parameters
FindNearestPoint(in JVector, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of FindNearest<T>(in T, in JQuaternion, in JVector, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that queries with a SupportPrimitives.Point.
public bool FindNearestPoint(in JVector position, DynamicTree.FindNearestFilterPre? pre, DynamicTree.FindNearestFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float distance)
Parameters
positionJVectorpreDynamicTree.FindNearestFilterPrepostDynamicTree.FindNearestFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectordistancefloat
Returns
FindNearestPoint(in JVector, float, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of FindNearest<T>(in T, in JQuaternion, in JVector, float, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that queries with a SupportPrimitives.Point.
public bool FindNearestPoint(in JVector position, float maxDistance, DynamicTree.FindNearestFilterPre? pre, DynamicTree.FindNearestFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float distance)
Parameters
positionJVectormaxDistancefloatpreDynamicTree.FindNearestFilterPrepostDynamicTree.FindNearestFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectordistancefloat
Returns
FindNearestSphere(float, in JVector, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of FindNearest<T>(in T, in JQuaternion, in JVector, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that queries with a SupportPrimitives.Sphere.
public bool FindNearestSphere(float radius, in JVector position, DynamicTree.FindNearestFilterPre? pre, DynamicTree.FindNearestFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float distance)
Parameters
radiusfloatThe sphere radius.
positionJVectorpreDynamicTree.FindNearestFilterPrepostDynamicTree.FindNearestFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectordistancefloat
Returns
FindNearestSphere(float, in JVector, float, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of FindNearest<T>(in T, in JQuaternion, in JVector, float, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that queries with a SupportPrimitives.Sphere.
public bool FindNearestSphere(float radius, in JVector position, float maxDistance, DynamicTree.FindNearestFilterPre? pre, DynamicTree.FindNearestFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float distance)
Parameters
radiusfloatThe sphere radius.
positionJVectormaxDistancefloatpreDynamicTree.FindNearestFilterPrepostDynamicTree.FindNearestFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectordistancefloat
Returns
FindNearest<T>(in T, in JQuaternion, in JVector, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Finds the closest IDistanceTestable proxy in the tree to the query shape and returns the exact closest points.
public bool FindNearest<T>(in T support, in JQuaternion orientation, in JVector position, DynamicTree.FindNearestFilterPre? pre, DynamicTree.FindNearestFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float distance) where T : ISupportMappable
Parameters
supportTThe query shape.
orientationJQuaternionThe query shape orientation in world space.
positionJVectorThe query shape position in world space.
preDynamicTree.FindNearestFilterPreOptional pre-filter that can skip candidate proxies before the exact distance test.
postDynamicTree.FindNearestFilterPostOptional post-filter that can reject exact results and continue the search.
proxyIDynamicTreeProxyThe nearest accepted proxy, or
nullif no proxy is found.pointAJVectorClosest point on the query shape in world space. Undefined when the shapes overlap.
pointBJVectorClosest point on the found proxy in world space. Undefined when the shapes overlap.
normalJVectorUnit direction from the query shape toward the found proxy, or Zero when the shapes overlap.
distancefloatSeparation distance between the query shape and the found proxy. Zero when they overlap.
Returns
- bool
trueif an accepted proxy is found. This includes the overlapping case, wheredistanceis zero.falseif no accepted proxy is found, in which caseproxyisnull.
Type Parameters
T
Remarks
This overload is unbounded and considers all IDistanceTestable proxies in the tree.
To skip overlapping proxies and continue searching for separated ones, use a post
filter that returns false for results with distance == 0.
FindNearest<T>(in T, in JQuaternion, in JVector, float, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Bounded variant of FindNearest<T>(in T, in JQuaternion, in JVector, FindNearestFilterPre?, FindNearestFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
that limits the search to maxDistance.
public bool FindNearest<T>(in T support, in JQuaternion orientation, in JVector position, float maxDistance, DynamicTree.FindNearestFilterPre? pre, DynamicTree.FindNearestFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float distance) where T : ISupportMappable
Parameters
supportTorientationJQuaternionpositionJVectormaxDistancefloatMaximum separation distance to consider. Proxies farther than this are ignored.
preDynamicTree.FindNearestFilterPrepostDynamicTree.FindNearestFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectordistancefloat
Returns
Type Parameters
T
IsActive<T>(T)
Checks whether the specified proxy is currently active.
public bool IsActive<T>(T proxy) where T : class, IDynamicTreeProxy
Parameters
proxyTThe proxy to check.
Returns
- bool
trueif the proxy is active; otherwise,false.
Type Parameters
TThe proxy type.
Optimize(Func<double>, int, float, bool)
Optimizes the tree structure by randomly reinserting proxies.
public void Optimize(Func<double> getNextRandom, int sweeps, float chance, bool incremental)
Parameters
getNextRandomFunc<double>A function returning random values in [0, 1).
sweepsintNumber of optimization passes. Must be greater than zero.
chancefloatProbability of reinserting each proxy per sweep. Range: [0, 1].
incrementalboolIf
false, all proxies are reinserted in random order on the first sweep.
Optimize(int, float, bool)
Optimizes the tree structure by randomly reinserting proxies.
public void Optimize(int sweeps = 100, float chance = 0.01, bool incremental = false)
Parameters
sweepsintNumber of optimization passes. Must be greater than zero.
chancefloatProbability of reinserting each proxy per sweep. Range: [0, 1].
incrementalboolIf
false, all proxies are reinserted in random order on the first sweep.
Query<T>(T, in JBoundingBox)
Queries the tree for proxies overlapping an axis-aligned bounding box.
public void Query<T>(T hits, in JBoundingBox box) where T : class, ICollection<IDynamicTreeProxy>
Parameters
hitsTCollection to store overlapping proxies.
boxJBoundingBoxThe bounding box to query.
Type Parameters
TThe collection type.
Query<T>(T, in JVector, in JVector)
Queries the tree for proxies intersecting a ray.
public void Query<T>(T hits, in JVector rayOrigin, in JVector rayDirection) where T : class, ICollection<IDynamicTreeProxy>
Parameters
hitsTCollection to store intersected proxies.
rayOriginJVectorThe origin of the ray.
rayDirectionJVectorThe direction of the ray.
Type Parameters
TThe collection type.
Query<TSink>(ref TSink, in JBoundingBox)
Queries the tree for proxies overlapping an axis-aligned bounding box and appends all hits to the specified sink.
public void Query<TSink>(ref TSink hits, in JBoundingBox box) where TSink : ISink<IDynamicTreeProxy>
Parameters
hitsTSinkThe sink receiving all overlapping proxies.
boxJBoundingBoxThe bounding box to query.
Type Parameters
TSinkThe sink type receiving all overlapping proxies.
Query<TSink>(ref TSink, in JVector, in JVector)
Queries the tree for proxies intersecting a ray and appends all hits to the specified sink.
public void Query<TSink>(ref TSink hits, in JVector rayOrigin, in JVector rayDirection) where TSink : ISink<IDynamicTreeProxy>
Parameters
hitsTSinkThe sink receiving all intersected proxies.
rayOriginJVectorThe origin of the ray.
rayDirectionJVectorThe direction of the ray.
Type Parameters
TSinkThe sink type receiving all intersected proxies.
RayCast(JVector, JVector, RayCastFilterPre?, RayCastFilterPost?, out IDynamicTreeProxy?, out JVector, out float)
Ray cast against the world.
public bool RayCast(JVector origin, JVector direction, DynamicTree.RayCastFilterPre? pre, DynamicTree.RayCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector normal, out float lambda)
Parameters
originJVectorOrigin of the ray.
directionJVectorDirection of the ray. Does not have to be normalized.
preDynamicTree.RayCastFilterPreOptional pre-filter which allows to skip shapes in the detection.
postDynamicTree.RayCastFilterPostOptional post-filter which allows to skip detections.
proxyIDynamicTreeProxyThe shape which was hit.
normalJVectorThe surface normal at the hit point. Zero if the ray does not hit, or if the ray origin is inside the hit shape. Use the return value to determine whether a hit occurred; do not rely on this being non-zero as a hit indicator.
lambdafloatDistance from the origin to the hit point in units of the ray direction. Zero if the origin is inside the hit shape.
Returns
- bool
True if the ray hits, false otherwise.
RayCast(JVector, JVector, float, RayCastFilterPre?, RayCastFilterPost?, out IDynamicTreeProxy?, out JVector, out float)
Ray cast against the world.
public bool RayCast(JVector origin, JVector direction, float maxLambda, DynamicTree.RayCastFilterPre? pre, DynamicTree.RayCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector normal, out float lambda)
Parameters
originJVectorOrigin of the ray.
directionJVectorDirection of the ray. Does not have to be normalized.
maxLambdafloatMaximum lambda of the ray's length to consider for intersections.
preDynamicTree.RayCastFilterPreOptional pre-filter which allows to skip shapes in the detection.
postDynamicTree.RayCastFilterPostOptional post-filter which allows to skip detections.
proxyIDynamicTreeProxyThe shape which was hit.
normalJVectorThe surface normal at the hit point. Zero if the ray does not hit, or if the ray origin is inside the hit shape. Use the return value to determine whether a hit occurred; do not rely on this being non-zero as a hit indicator.
lambdafloatDistance from the origin to the hit point in units of the ray direction. Zero if the origin is inside the hit shape.
Returns
- bool
True if the ray hits, false otherwise.
RemoveProxy(IDynamicTreeProxy)
Removes a proxy from the tree.
public void RemoveProxy(IDynamicTreeProxy proxy)
Parameters
proxyIDynamicTreeProxyThe proxy to remove.
Exceptions
- InvalidOperationException
Thrown if the proxy is not in this tree.
SweepCastBox(in JVector, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Box.
public bool SweepCastBox(in JVector halfExtents, in JQuaternion orientation, in JVector position, in JVector direction, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
halfExtentsJVectorThe half extents of the box.
orientationJQuaternionpositionJVectordirectionJVectorpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastBox(in JVector, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Box.
public bool SweepCastBox(in JVector halfExtents, in JQuaternion orientation, in JVector position, in JVector direction, float maxLambda, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
halfExtentsJVectorThe half extents of the box.
orientationJQuaternionpositionJVectordirectionJVectormaxLambdafloatpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastCapsule(float, float, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Capsule.
public bool SweepCastCapsule(float radius, float halfLength, in JQuaternion orientation, in JVector position, in JVector direction, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
radiusfloatThe capsule radius.
halfLengthfloatHalf the cylindrical section length of the capsule.
orientationJQuaternionpositionJVectordirectionJVectorpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastCapsule(float, float, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Capsule.
public bool SweepCastCapsule(float radius, float halfLength, in JQuaternion orientation, in JVector position, in JVector direction, float maxLambda, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
radiusfloatThe capsule radius.
halfLengthfloatHalf the cylindrical section length of the capsule.
orientationJQuaternionpositionJVectordirectionJVectormaxLambdafloatpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastCylinder(float, float, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Cylinder.
public bool SweepCastCylinder(float radius, float halfHeight, in JQuaternion orientation, in JVector position, in JVector direction, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
radiusfloatThe cylinder radius.
halfHeightfloatHalf the cylinder height.
orientationJQuaternionpositionJVectordirectionJVectorpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastCylinder(float, float, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Cylinder.
public bool SweepCastCylinder(float radius, float halfHeight, in JQuaternion orientation, in JVector position, in JVector direction, float maxLambda, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
radiusfloatThe cylinder radius.
halfHeightfloatHalf the cylinder height.
orientationJQuaternionpositionJVectordirectionJVectormaxLambdafloatpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastSphere(float, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Sphere.
public bool SweepCastSphere(float radius, in JVector position, in JVector direction, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
radiusfloatThe sphere radius.
positionJVectordirectionJVectorpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCastSphere(float, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Convenience overload of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float) that sweeps a SupportPrimitives.Sphere.
public bool SweepCastSphere(float radius, in JVector position, in JVector direction, float maxLambda, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda)
Parameters
radiusfloatThe sphere radius.
positionJVectordirectionJVectormaxLambdafloatpreDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Sweeps a support-mapped query shape against all ISweepTestable proxies in the tree and returns the closest exact hit.
public bool SweepCast<T>(in T support, in JQuaternion orientation, in JVector position, in JVector direction, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda) where T : ISupportMappable
Parameters
supportTThe query shape.
orientationJQuaternionThe query shape orientation in world space.
positionJVectorThe query shape position in world space at the start of the sweep.
directionJVectorThe sweep direction vector in world space.
preDynamicTree.SweepCastFilterPreOptional pre-filter that can skip candidate proxies before the exact sweep test.
postDynamicTree.SweepCastFilterPostOptional post-filter that can reject exact results and continue the search.
proxyIDynamicTreeProxyThe closest accepted hit proxy, or
nullif no hit is found.pointAJVectorCollision point on the query shape in world space at the sweep origin. Undefined when the shapes already overlap.
pointBJVectorCollision point on the hit proxy in world space at the sweep origin. Undefined when the shapes already overlap.
normalJVectorCollision normal in world space, or Zero when the shapes already overlap.
lambdafloatTime of impact in units of
direction. Zero when the shapes already overlap.
Returns
- bool
trueif an accepted hit is found. This includes the overlapping case, wherelambdais zero.falseif no accepted hit is found, in which caseproxyisnull.
Type Parameters
T
SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, float, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
Bounded variant of SweepCast<T>(in T, in JQuaternion, in JVector, in JVector, SweepCastFilterPre?, SweepCastFilterPost?, out IDynamicTreeProxy?, out JVector, out JVector, out JVector, out float)
that limits the sweep to maxLambda.
public bool SweepCast<T>(in T support, in JQuaternion orientation, in JVector position, in JVector direction, float maxLambda, DynamicTree.SweepCastFilterPre? pre, DynamicTree.SweepCastFilterPost? post, out IDynamicTreeProxy? proxy, out JVector pointA, out JVector pointB, out JVector normal, out float lambda) where T : ISupportMappable
Parameters
supportTorientationJQuaternionpositionJVectordirectionJVectormaxLambdafloatMaximum sweep parameter to consider along
direction.preDynamicTree.SweepCastFilterPrepostDynamicTree.SweepCastFilterPostproxyIDynamicTreeProxypointAJVectorpointBJVectornormalJVectorlambdafloat
Returns
Type Parameters
T
Update(bool, float)
Updates all active proxies in the tree.
public void Update(bool multiThread, float dt)
Parameters
multiThreadboolIf
true, uses multithreading for the update.dtfloatThe timestep in seconds, used for velocity-based bounding box expansion.
Update<T>(T)
Forces an immediate update of a single proxy in the tree.
public void Update<T>(T proxy) where T : class, IDynamicTreeProxy
Parameters
proxyTThe proxy to update.
Type Parameters
TThe proxy type.