Struct BroadPhaseRayBatcher<TRayTester>
- Namespace
- BepuPhysics.CollisionDetection
- Assembly
- BepuPhysics.dll
Helps test the broad phase's active and static trees with a custom leaf tester.
public struct BroadPhaseRayBatcher<TRayTester> : IDisposable where TRayTester : struct, IBroadPhaseBatchedRayTester
Type Parameters
TRayTester
Type used to test rays against leaves.
- Implements
- Inherited Members
Constructors
BroadPhaseRayBatcher(BufferPool, BroadPhase, TRayTester, int)
Constructs a ray batcher for the broad phase and initializes its backing resources.
public BroadPhaseRayBatcher(BufferPool pool, BroadPhase broadPhase, TRayTester rayTester, int batcherRayCapacity = 2048)
Parameters
pool
BufferPoolPool to pull resources from.
broadPhase
BroadPhaseBroad phase to be tested.
rayTester
TRayTesterRay tester used to test leaves found by the broad phase tree traversals.
batcherRayCapacity
intMaximum number of rays to execute in each traversal. This should typically be chosen as the highest value which avoids spilling data out of L2 cache.
Methods
Add(ref Vector3, ref Vector3, float, int)
Adds a ray to the batcher to test against the broad phase trees. If the underlying ray batcher hits its maximum capacity, all the accumulated rays will be tested against the broad phase trees and the accumulator will be reset.
public void Add(ref Vector3 origin, ref Vector3 direction, float maximumT, int id = 0)
Parameters
origin
Vector3Origin of the ray to test against the tree.
direction
Vector3Direction of the ray to test against the tree.
maximumT
floatMaximum distance that the ray will travel in units of the ray's length.
id
intIdentifier value for the ray. Leaf tests will have access to the id.
Dispose()
Disposes the underlying batcher resources.
public void Dispose()
Flush()
Tests any accumulated rays against the broad phase trees and then resets the batcher.
public void Flush()