Table of Contents

Class CollisionUtil

Namespace
Hi.Collision
Assembly
HiCbtr.dll

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

treeA CubeTree

treeA

treeB TriTree

treeB

matAB mat4d_t

relative transform matrix to take B to the position relative to A. The mat is Inv(matA)*matB.

safeDistance double

safe distance for the flag judgement

cap int

Returns

CollisionFlag

CollisionFlag

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

collidableA ICollidable

collidable A

collidableB ICollidable

collidable B

matAB mat4d_t

relative transform matrix to take B to the position relative to A. The mat is Inv(matA)*matB. If one of collidableA and collidableB is null, return OUTSIDE_SAFE_DISTANCE.

safeDistance double

safe distance for the flag judgement

cap int

Returns

CollisionFlag

CollisionFlag

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

treeA TriTree

treeA

treeB TriTree

treeB

matAB mat4d_t

relative transform matrix to take B to the position relative to A. The mat is Inv(matA)*matB.

safeDistance double

safe distance for the flag judgement

cap int

Returns

CollisionFlag

CollisionFlag

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

asmbId long

The topology id of the assembly the anchor map walks (the equipment's).

rootId long

The topology id of the root anchor the poses are relative to (the chain's root); live.

collidables IReadOnlyList<ICollidable>

The distinct collidables of the call, in the order the records index them.

pairs CollisionPairRecord[]

One record per pair, in list order.

answers CollisionPairAnswer[]

One answer per pair, written on status 0; at least as many as pairs.

collidableFlags int[]

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.

primary CollisionFlag

The primary flag: the minimum over the reached pairs, OUTSIDE_SAFE_DISTANCE when none was reached and on any status other than 0.

cap int

The 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.