Class CollisionUtil
Utility of tree grid related structure.
public static class CollisionUtil
- Inheritance
-
CollisionUtil
- Inherited Members
Methods
Detect(CubeTree, TriTree, mat4d_t, double, int)
Get CollisionFlag between treeA and treeB*matAB.
public static CollisionFlag Detect(this CubeTree treeA, TriTree treeB, mat4d_t matAB, double safeDistance, int cap = 1024)
Parameters
treeACubeTreetreeA
treeBTriTreetreeB
matABmat4d_trelative transform matrix to take B to the position relative to A. The mat is matB * Inv(matA) (row vectors: a point of B times matAB is that point in A's frame).
safeDistancedoublesafe distance for the flag judgement
capintthe initial bucket count of the set of triangle pairs already checked, not a limit
Returns
Detect(ICollidable, ICollidable, mat4d_t, double, int)
Get CollisionFlag
between collidableA and
collidableB*matAB.
public static CollisionFlag Detect(this ICollidable collidableA, ICollidable collidableB, mat4d_t matAB, double safeDistance = 0, int cap = 1024)
Parameters
collidableAICollidablecollidable A
collidableBICollidablecollidable B
matABmat4d_trelative transform matrix to take B to the position relative to A. The mat is matB * Inv(matA) (row vectors: a point of B times matAB is that point in A's frame). If one of
collidableAandcollidableBis null, return OUTSIDE_SAFE_DISTANCE.safeDistancedoublesafe distance for the flag judgement
capintthe initial bucket count of the set of triangle pairs already checked, not a limit
Returns
Detect(TriTree, TriTree, mat4d_t, double, int)
Get CollisionFlag between treeA and treeB*matAB.
public static CollisionFlag Detect(this TriTree treeA, TriTree treeB, mat4d_t matAB, double safeDistance, int cap = 1024)
Parameters
treeATriTreetreeA
treeBTriTreetreeB
matABmat4d_trelative transform matrix to take B to the position relative to A. The mat is matB * Inv(matA) (row vectors: a point of B times matAB is that point in A's frame).
safeDistancedoublesafe distance for the flag judgement
capintthe initial bucket count of the set of triangle pairs already checked, not a limit
Returns
Remarks
The check compares the two parts' bounding boxes before it walks the trees: B's box, taken into A's frame
by matAB, against A's box. When both boxes are finite, safeDistance is
a number that is not negative and the two boxes lie farther apart than it on some axis, the answer is
OUTSIDE_SAFE_DISTANCE without walking the trees; every other call walks them as
before. A clear pair whose gap is small against the trees' cells, which the walk alone answers
MAY_INSIDE_SAFE_DISTANCE, therefore reads OUTSIDE_SAFE_DISTANCE; a
Collision answer is never changed. To be told of parts that come near, give a
positive safeDistance: a pair whose boxes lie within it is walked. The batch check of a
step's collision pairs answers its tri-tree pairs the same way.
DetectPairs(long, long, IReadOnlyList<ICollidable>, CollisionPairRecord[], CollisionPairAnswer[], int[], out CollisionFlag, int)
Internal Use Only. One collision__detect_pairs call over the resolved records (play-core
migration P12): the licence pass, the anchor map of asmbId from
rootId, the relative poses, the memo, the dispatch into the native tree checks and
the fold run natively in one crossing where Detect(ICollidable, ICollidable, mat4d_t, double, int)
crossed once per pair. This method resolves what only the managed side knows – the collidee and the
native handle of every distinct collidable – and holds the trees for the call. The collidees are
asked for in the order the per-pair dispatch asks them (D6: A's for every pair whose two collidables
resolved, B's only when A's is a TriTree or a CubeTree; each collidable
once per call), so a collidable never asked is kind 0, as no dispatch reaches its tree. The collidees
of every pair whose two collidables resolved are asked for whether or not the pair's anchors are in
the map: a pair the loop will not reach – an unbound anchor, an anchor off the chain – is asked as
well, where the managed loop never asks for such a pair; the same flags, poses, dictionary and
primary either way, only a lazy tree build may happen earlier. Then the
TriTreePtrLock of every distinct TriTree is entered in ascending
Hi.Collision.TriTree.LockOrder, the one CubeTree's gate is entered, the handles are
read under them (0 for a disposed tree or a refused gate), the export runs, and everything is
released in reverse. Hi.Cbtr.CubeTree.EnterTree() is one frame per thread across instances, so a
call whose collidees hold two or more distinct cube trees is not batched: -1 is answered before any
lock and the caller runs the per-pair loop (D5).
public static int DetectPairs(long asmbId, long rootId, IReadOnlyList<ICollidable> collidables, CollisionPairRecord[] pairs, CollisionPairAnswer[] answers, int[] collidableFlags, out CollisionFlag primary, int cap = 1024)
Parameters
asmbIdlongThe topology id of the assembly the anchor map walks (the equipment's).
rootIdlongThe topology id of the root anchor the poses are relative to (the chain's root); live.
collidablesIReadOnlyList<ICollidable>The distinct collidables of the call, in the order the records index them.
pairsCollisionPairRecord[]One record per pair, in list order.
answersCollisionPairAnswer[]One answer per pair, written on status 0; at least as many as
pairs.collidableFlagsint[]The minimum flag of each collidable over the reached pairs, -1 when no reached pair names it; written on status 0; at least as many as
collidables.primaryCollisionFlagThe primary flag: the minimum over the reached pairs, OUTSIDE_SAFE_DISTANCE when none was reached and on any status other than 0.
capintThe per-check pair cap handed to the tree checks (a hash reserve, not a limit).
Returns
- int
0 ok; 1 unauthorized, and any higher status the export may answer later: nothing written, the caller answers no result; -1 the batch refused (two or more distinct cube trees): nothing written, the caller runs the managed loop.