You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: helpers.rs
    path of file: ./repos/Ambient/crates/physics/src
    
    the code of the file until where you have to start completion: use std::collections::HashSet;

use ambient_core::{
    transform::{get_world_position, rotation, translation},
    FIXED_SERVER_TICK_TIME,
};
use ambient_ecs::{query, ECSError, EntityId, World};
use anyhow::{bail, Context};
use glam::{vec3, Mat4, Vec3};
use itertools::Itertools;
use physxx::{
    AsPxActor, AsPxRigidActor, PxActor, PxActorRef, PxActorTypeFlag, PxBase, PxBoxGeometry,
    PxConvexMeshGeometry, PxForceMode, PxJoint, PxMeshScale, PxOverlapCallback, PxPhysicsRef,
    PxQueryFilterData, PxQueryFlag, PxRevoluteJointRef, PxRigidActor, PxRigidActorRef, PxRigidBody,
    PxRigidBodyFlag, PxRigidDynamicRef, PxRigidStaticRef, PxSceneRef, PxShape, PxSphereGeometry,
    PxTransform, PxTriangleMeshGeometry, PxUserData,
};

use crate::{
    collider::{collider_shapes_convex, collider_type, kinematic},
    main_physics_scene,
    physx::{
        physics, physics_controlled, physics_shape, revolute_joint, rigid_actor, rigid_dynamic,
        rigid_static,
    },
    unit_mass, unit_velocity, ColliderScene, PxActorUserData, PxShapeUserData,
};

pub fn convert_rigid_static_to_dynamic(world: &mut World, id: EntityId) {
    convert_rigid_static_dynamic(world, id, true);
}
pub fn convert_rigid_dynamic_to_static(world: &mut World, id: EntityId) {
    convert_rigid_static_dynamic(world, id, false);
}

pub fn convert_rigid_static_dynamic(world: &mut World, id: EntityId, to_dynamic: bool) {
    let old_actor = {
        if let Some(actor) = world
            .get_ref(id, physics_shape())
            .ok()
            .and_then(|shape| shape.get_actor()
    
pub fn unweld_two(world: &World, first: EntityId, second: EntityId) {
    let first_shape = world.get_ref(first, physics_shape()).unwrap().clone();
    let first_actor = first_shape.get_actor().unwrap();
    let second_shape = world.get_ref(second, physics_shape()).unwrap().clone();
    let second_actor = second_shape.get_actor().unwrap();
    let scene = second_actor.get_scene().unwrap();
    let physics = world.resource(physics());

    if first_actor != second_actor {
        return;
    }
    let second_shapes = first_actor
        .get_shapes()
        .into_iter()
        .filter(|shape| {
            if shape.get_user_data::<PxShapeUserData>().unwrap().entity == second {
                first_actor.detach_shape(shape, true);
                true
            } else {
                false
            }
        })
        .collect_vec();
    let second_actor = if first_actor.to_rigid_dynamic().is_some() {
        PxRigidDynamicRef::new(physics.physics, &first_actor.get_global_pose()).as_rigid_actor()
    } else {
        PxRigidStaticRef::new(physics.physics, &first_actor.get_global_pose()).as_rigid_actor()
    };
    second_actor
        .as_actor()
        .set_user_data(first_actor.as_actor().get_user_data::<PxActorUserData>());
    for shape in second_shapes {
        if !second_actor.attach_shape(&shape) {
            panic!("Failed to attach shape");
        }
    }
    scene.add_actor(&second_actor);

    if let Some(first) = first_actor.to_rigid_body() {
        let densities = first
            .get_shapes()
            .iter()
            .map(|shape| shape.get_user_data::<PxShapeUserData>().unwrap().density)
            .collect_vec();
        first.update_mass_and_inertia(densities, None, None);
    }

    if let Some(second) = second_actor.to_rigid_body() {
        let densities = second
            .get_shapes()
            .iter()
            .map(|shape| shape.get_user_data::<PxShapeUserData>().unwrap().density)
            .collect_vec();
        second.update_mass_and_inertia(densities, None, None);
    }
}