newton.geometry.BroadPhaseAllPairs#

class newton.geometry.BroadPhaseAllPairs[source]#

Bases: object

A broad phase collision detection class that performs N x N collision checks between all geometry pairs.

This class performs collision detection between all possible pairs of geometries by checking for axis-aligned bounding box (AABB) overlaps. It uses a lower triangular matrix approach to avoid checking each pair twice.

The collision checks take into account per-geometry cutoff distances and collision groups. Two geometries will only be considered as a candidate pair if: 1. Their AABBs overlap when expanded by their cutoff distances 2. Their collision groups allow interaction (determined by test_group_pair())

The class outputs an array of candidate collision pairs that need more detailed narrow phase collision checking.

__init__()#
launch(geom_lower, geom_upper, geom_cutoffs, geom_collision_groups, geom_count, candidate_pair, num_candidate_pair)#

Launch the N x N broad phase collision detection.

This method performs collision detection between all possible pairs of geometries by checking for axis-aligned bounding box (AABB) overlaps. It uses a lower triangular matrix approach to avoid checking each pair twice.

Parameters:
  • geom_lower (array(ndim=1, dtype=vec3f)) – Array of lower bounds for each geometry’s AABB

  • geom_upper (array(ndim=1, dtype=vec3f)) – Array of upper bounds for each geometry’s AABB

  • geom_cutoffs (array(ndim=1, dtype=float32)) – Array of cutoff distances for each geometry

  • geom_collision_groups (array(ndim=1, dtype=int32)) – Array of collision group IDs for each geometry. Positive values indicate groups that only collide with themselves (and with negative groups). Negative values indicate groups that collide with everything except their negative counterpart. Zero indicates no collisions.

  • geom_count (int) – Number of active bounding boxes to check

  • candidate_pair (array(ndim=1, dtype=vec2i)) – Output array to store overlapping geometry pairs

  • num_candidate_pair (array(ndim=1, dtype=int32)) – Output array to store number of overlapping pairs found

The method will populate candidate_pair with the indices of geometry pairs (i,j) where i < j whose AABBs overlap when expanded by their cutoff distances and whose collision groups allow interaction. The number of pairs found will be written to num_candidate_pair[0].