code: def _reorder_rigid_ids(self):
          
          max_rigid = self.max_rigid_id
          unique_rigid_ids = sorted(
              set([p.rigid_id for p in self.rigid_particles()]))
          n_unique_rigid = len(unique_rigid_ids)
          if max_rigid and n_unique_rigid != max_rigid + 1:
              missing_rigid_id = (
                  unique_rigid_ids[-1] * (unique_rigid_ids[-1] + 1)) / 2 - sum(unique_rigid_ids)
              for successor in self.successors():
                  if successor.rigid_id is not None:
                      if successor.rigid_id > missing_rigid_id:
                          successor.rigid_id -= 1
              if self.rigid_id:
                  if self.rigid_id > missing_rigid_id:
                      self.rigid_id -= 1
docs: Reorder rigid body IDs ensuring consecutiveness.
  
          Primarily used internally to ensure consecutive rigid_ids following
          removal of a Compound.