pub unsafe extern "C" fn PxBroadPhaseRegions_addRegion_mut(
    self_: *mut PxBroadPhaseRegions,
    region: *const PxBroadPhaseRegion,
    populateRegion: bool,
    bounds: *const PxBounds3,
    distances: *const f32
) -> u32
Expand description

Adds a new broad-phase region.

The total number of regions is limited to PxBroadPhaseCaps::mMaxNbRegions. If that number is exceeded, the call is ignored.

The newly added region will be automatically populated with already existing objects that touch it, if the ‘populateRegion’ parameter is set to true. Otherwise the newly added region will be empty, and it will only be populated with objects when those objects are added to the simulation, or updated if they already exist.

Using ‘populateRegion=true’ has a cost, so it is best to avoid it if possible. In particular it is more efficient to create the empty regions first (with populateRegion=false) and then add the objects afterwards (rather than the opposite).

Objects automatically move from one region to another during their lifetime. The system keeps tracks of what regions a given object is in. It is legal for an object to be in an arbitrary number of regions. However if an object leaves all regions, or is created outside of all regions, several things happen:

  • collisions get disabled for this object
  • the object appears in the getOutOfBoundsObjects() array

If an out-of-bounds object, whose collisions are disabled, re-enters a valid broadphase region, then collisions are re-enabled for that object.

Handle for newly created region, or 0xffffffff in case of failure.