pub fn create_joints(
    world: &mut World,
    joints: &mut JointSet,
    joints_entity_map: &mut JointsEntityMap,
) {
    let mut changes = Vec::new();

    for (entity, joint) in world.query::<&JointBuilderComponent>().iter() {
        // Make sure the rigid-bodies the joint it attached to exist.
        if world.get::<RigidBodyIds>(joint.entity1).is_err()
            || world.get::<RigidBodyIds>(joint.entity2).is_err()
        {
            continue;
        }

        let handle = joints.insert(joint.entity1.handle(), joint.entity2.handle(), joint.params);
        changes.push((handle, entity, (joint.entity1, joint.entity2)));
    }

    for (handle, entity, joint_entity) in changes.drain(..) {
        world
            .insert_one(
                entity,
                JointHandleComponent::new(handle, joint_entity.0, joint_entity.1),
            )
            .unwrap();
        world.remove_one::<JointBuilderComponent>(entity).unwrap();
        joints_entity_map.0.insert(entity, handle);
    }
}
/// System responsible for creating Rapier joints from their builder resources.
System responsible for creating Rapier joints from their builder resources.
System responsible for creating Rapier joints from their builder resources .
pub fn create_joints(
    world: &mut World,
    joints: &mut JointSet,
    joints_entity_map: &mut JointsEntityMap,
) {
    let mut changes = Vec::new();
    for (entity, joint) in world.query::<&JointBuilderComponent>().iter() {
        // Make sure the rigid-bodies the joint it attached to exist.
        if world.get::<RigidBodyIds>(joint.entity1).is_err()
            || world.get::<RigidBodyIds>(joint.entity2).is_err()
        {
            continue;
        }
        let handle = joints.insert(joint.entity1.handle(), joint.entity2.handle(), joint.params);
        changes.push((handle, entity, (joint.entity1, joint.entity2)));
    }
    for (handle, entity, joint_entity) in changes.drain(..) {
        world
            .insert_one(
                entity,
                JointHandleComponent::new(handle, joint_entity.0, joint_entity.1),
            )
            .unwrap();
        world.remove_one::<JointBuilderComponent>(entity).unwrap();
        joints_entity_map.0.insert(entity, handle);
    }
}
pub fn create_joints ( world : & mut World , joints : & mut JointSet , joints_entity_map : & mut JointsEntityMap , ) { let mut changes = Vec :: new ( ) ; for ( entity , joint ) in world . query :: < & JointBuilderComponent > ( ) . iter ( ) { // Make sure the rigid-bodies the joint it attached to exist. if world . get :: < RigidBodyIds > ( joint . entity1 ) . is_err ( ) || world . get :: < RigidBodyIds > ( joint . entity2 ) . is_err ( ) { continue ; } let handle = joints . insert ( joint . entity1 . handle ( ) , joint . entity2 . handle ( ) , joint . params ) ; changes . push ( ( handle , entity , ( joint . entity1 , joint . entity2 ) ) ) ; } for ( handle , entity , joint_entity ) in changes . drain ( .. ) { world . insert_one ( entity , JointHandleComponent :: new ( handle , joint_entity . 0 , joint_entity . 1 ) , ) . unwrap ( ) ; world . remove_one :: < JointBuilderComponent > ( entity ) . unwrap ( ) ; joints_entity_map . 0 . insert ( entity , handle ) ; } }
System responsible for creating Rapier joints from their builder resources.
System responsible for creating Rapier joints from their builder resources .
world
&mut World
joints
&mut JointSet
joints_entity_map
&mut JointsEntityMap
world
&mut World
joints
&mut JointSet
joints_entity_map
&mut JointsEntityMap