pub fn finalize_collider_attach_to_bodies(
    world: &mut World,
    modification_tracker: &mut ModificationTracker,
) {
    for (
        collider_entity,
        (
            mut co_changes,
            mut co_bf_data,
            mut co_pos,
            co_shape,
            co_mprops,
            co_parent,
            _added_colider_parent,
        ),
    ) in world
        .query::<(
            // Collider.
            &mut ColliderChanges,
            &mut ColliderBroadPhaseData,
            &mut ColliderPosition,
            &ColliderShape,
            &ColliderMassProps,
            &ColliderParent,
            Added<ColliderParent>,
        )>()
        .iter()
        .filter(|(_e, (_, _, _, _, _, _, added))| *added)
    {
        let mut body_query = world.query_one::<(
                // Rigid-bodies.
                &mut RigidBodyChanges,
                &mut RigidBodyCcd,
                &mut RigidBodyColliders,
                &mut RigidBodyMassProps,
                &RigidBodyPosition,
            )>(co_parent.handle.entity()).unwrap();
        if let Some((mut rb_changes, mut rb_ccd, mut rb_colliders, mut rb_mprops, rb_pos)) =
            body_query.get()
        {
            // Contract:
            // - Reset collider's references.
            // - Set collider's parent handle.
            // - Attach the collider to the body.

            // Update the modification tracker.
            // NOTE: this must be done before the `.attach_collider` because
            //       `.attach_collider` will set the `MODIFIED` flag.

            if !rb_changes.contains(RigidBodyChanges::MODIFIED) {
                modification_tracker.modified_bodies.push(co_parent.handle);
            }

            modification_tracker
                .body_colliders
                .entry(co_parent.handle)
                .or_insert_with(Vec::new)
                .push(collider_entity.handle());
            modification_tracker
                .colliders_parent
                .insert(collider_entity.handle(), co_parent.handle);

            *co_changes = ColliderChanges::default();
            *co_bf_data = ColliderBroadPhaseData::default();
            rb_colliders.attach_collider(
                &mut rb_changes,
                &mut rb_ccd,
                &mut rb_mprops,
                rb_pos,
                collider_entity.handle(),
                &mut co_pos,
                co_parent,
                co_shape,
                co_mprops,
            );
        }
    }
}
/// System responsible for creating a Rapier rigid-body and collider from their
/// builder resources.
System responsible for creating a Rapier rigid-body and collider from their
builder resources.
System responsible for creating a Rapier rigid - body and collider from their builder resources .
pub fn finalize_collider_attach_to_bodies(
    world: &mut World,
    modification_tracker: &mut ModificationTracker,
) {
    for (
        collider_entity,
        (
            mut co_changes,
            mut co_bf_data,
            mut co_pos,
            co_shape,
            co_mprops,
            co_parent,
            _added_colider_parent,
        ),
    ) in world
        .query::<(
            // Collider.
            &mut ColliderChanges,
            &mut ColliderBroadPhaseData,
            &mut ColliderPosition,
            &ColliderShape,
            &ColliderMassProps,
            &ColliderParent,
            Added<ColliderParent>,
        )>()
        .iter()
        .filter(|(_e, (_, _, _, _, _, _, added))| *added)
    {
        let mut body_query = world.query_one::<(
                // Rigid-bodies.
                &mut RigidBodyChanges,
                &mut RigidBodyCcd,
                &mut RigidBodyColliders,
                &mut RigidBodyMassProps,
                &RigidBodyPosition,
            )>(co_parent.handle.entity()).unwrap();
        if let Some((mut rb_changes, mut rb_ccd, mut rb_colliders, mut rb_mprops, rb_pos)) =
            body_query.get()
        {
            // Contract:
            // - Reset collider's references.
            // - Set collider's parent handle.
            // - Attach the collider to the body.
            // Update the modification tracker.
            // NOTE: this must be done before the `.attach_collider` because
            //       `.attach_collider` will set the `MODIFIED` flag.
            if !rb_changes.contains(RigidBodyChanges::MODIFIED) {
                modification_tracker.modified_bodies.push(co_parent.handle);
            }
            modification_tracker
                .body_colliders
                .entry(co_parent.handle)
                .or_insert_with(Vec::new)
                .push(collider_entity.handle());
            modification_tracker
                .colliders_parent
                .insert(collider_entity.handle(), co_parent.handle);
            *co_changes = ColliderChanges::default();
            *co_bf_data = ColliderBroadPhaseData::default();
            rb_colliders.attach_collider(
                &mut rb_changes,
                &mut rb_ccd,
                &mut rb_mprops,
                rb_pos,
                collider_entity.handle(),
                &mut co_pos,
                co_parent,
                co_shape,
                co_mprops,
            );
        }
    }
}
pub fn finalize_collider_attach_to_bodies ( world : & mut World , modification_tracker : & mut ModificationTracker , ) { for ( collider_entity , ( mut co_changes , mut co_bf_data , mut co_pos , co_shape , co_mprops , co_parent , _added_colider_parent , ) , ) in world . query :: < ( // Collider. & mut ColliderChanges , & mut ColliderBroadPhaseData , & mut ColliderPosition , & ColliderShape , & ColliderMassProps , & ColliderParent , Added < ColliderParent > , ) > ( ) . iter ( ) . filter ( | ( _e , ( _ , _ , _ , _ , _ , _ , added ) ) | * added ) { let mut body_query = world . query_one :: < ( // Rigid-bodies. & mut RigidBodyChanges , & mut RigidBodyCcd , & mut RigidBodyColliders , & mut RigidBodyMassProps , & RigidBodyPosition , ) > ( co_parent . handle . entity ( ) ) . unwrap ( ) ; if let Some ( ( mut rb_changes , mut rb_ccd , mut rb_colliders , mut rb_mprops , rb_pos ) ) = body_query . get ( ) { // Contract: // - Reset collider's references. // - Set collider's parent handle. // - Attach the collider to the body. // Update the modification tracker. // NOTE: this must be done before the `.attach_collider` because //       `.attach_collider` will set the `MODIFIED` flag. if ! rb_changes . contains ( RigidBodyChanges :: MODIFIED ) { modification_tracker . modified_bodies . push ( co_parent . handle ) ; } modification_tracker . body_colliders . entry ( co_parent . handle ) . or_insert_with ( Vec :: new ) . push ( collider_entity . handle ( ) ) ; modification_tracker . colliders_parent . insert ( collider_entity . handle ( ) , co_parent . handle ) ; * co_changes = ColliderChanges :: default ( ) ; * co_bf_data = ColliderBroadPhaseData :: default ( ) ; rb_colliders . attach_collider ( & mut rb_changes , & mut rb_ccd , & mut rb_mprops , rb_pos , collider_entity . handle ( ) , & mut co_pos , co_parent , co_shape , co_mprops , ) ; } } }
System responsible for creating a Rapier rigid-body and collider from their
builder resources.
System responsible for creating a Rapier rigid - body and collider from their builder resources .
world
&mut World
modification_tracker
&mut ModificationTracker
world
&mut World
modification_tracker
&mut ModificationTracker