pub struct Joint { /* private fields */ }Expand description
A struct that can be used to connect physics bodies together.
Implementations§
Source§impl Joint
impl Joint
Sourcepub fn distance(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
anchor_a: &Vec2,
anchor_b: &Vec2,
frequency: f32,
damping: f32,
) -> Joint
pub fn distance( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, anchor_a: &Vec2, anchor_b: &Vec2, frequency: f32, damping: f32, ) -> Joint
Creates a distance joint between two physics bodies.
§Arguments
can_collide- Whether or not the physics body connected to joint will collide with each other.body_a- The first physics body to connect with the joint.body_b- The second physics body to connect with the joint.anchor_a- The position of the joint on the first physics body.anchor_b- The position of the joint on the second physics body.frequency- The frequency of the joint, in Hertz.damping- The damping ratio of the joint.
§Returns
Joint- The new distance joint.
Sourcepub fn friction(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
world_pos: &Vec2,
max_force: f32,
max_torque: f32,
) -> Joint
pub fn friction( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, world_pos: &Vec2, max_force: f32, max_torque: f32, ) -> Joint
Creates a friction joint between two physics bodies.
§Arguments
can_collide- Whether or not the physics body connected to joint will collide with each other.body_a- The first physics body to connect with the joint.body_b- The second physics body to connect with the joint.world_pos- The position of the joint in the game world.max_force- The maximum force that can be applied to the joint.max_torque- The maximum torque that can be applied to the joint.
§Returns
Joint- The new friction joint.
Sourcepub fn gear(
collision: bool,
joint_a: &dyn IJoint,
joint_b: &dyn IJoint,
ratio: f32,
) -> Joint
pub fn gear( collision: bool, joint_a: &dyn IJoint, joint_b: &dyn IJoint, ratio: f32, ) -> Joint
Creates a gear joint between two other joints.
§Arguments
can_collide- Whether or not the physics bodies connected to the joint can collide with each other.joint_a- The first joint to connect with the gear joint.joint_b- The second joint to connect with the gear joint.ratio- The gear ratio.
§Returns
Joint- The new gear joint.
Sourcepub fn spring(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
linear_offset: &Vec2,
angular_offset: f32,
max_force: f32,
max_torque: f32,
correction_factor: f32,
) -> Joint
pub fn spring( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, linear_offset: &Vec2, angular_offset: f32, max_force: f32, max_torque: f32, correction_factor: f32, ) -> Joint
Creates a new spring joint between the two specified bodies.
§Arguments
can_collide- Whether the connected bodies should collide with each other.body_a- The first body connected to the joint.body_b- The second body connected to the joint.linear_offset- Position of body-B minus the position of body-A, in body-A’s frame.angular_offset- Angle of body-B minus angle of body-A.max_force- The maximum force the joint can exert.max_torque- The maximum torque the joint can exert.correction_factor- Correction factor. 0.0 = no correction, 1.0 = full correction.
§Returns
Joint- The created joint.
Sourcepub fn move_target(
collision: bool,
body: &dyn IBody,
target_pos: &Vec2,
max_force: f32,
frequency: f32,
damping: f32,
) -> MoveJoint
pub fn move_target( collision: bool, body: &dyn IBody, target_pos: &Vec2, max_force: f32, frequency: f32, damping: f32, ) -> MoveJoint
Creates a new move joint for the specified body.
§Arguments
can_collide- Whether the body can collide with other bodies.body- The body that the joint is attached to.target_pos- The target position that the body should move towards.max_force- The maximum force the joint can exert.frequency- Frequency ratio.damping- Damping ratio.
§Returns
MoveJoint- The created move joint.
Sourcepub fn prismatic(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
world_pos: &Vec2,
axis_angle: f32,
lower_translation: f32,
upper_translation: f32,
max_motor_force: f32,
motor_speed: f32,
) -> MotorJoint
pub fn prismatic( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, world_pos: &Vec2, axis_angle: f32, lower_translation: f32, upper_translation: f32, max_motor_force: f32, motor_speed: f32, ) -> MotorJoint
Creates a new prismatic joint between the two specified bodies.
§Arguments
can_collide- Whether the connected bodies should collide with each other.body_a- The first body connected to the joint.body_b- The second body connected to the joint.world_pos- The world position of the joint.axis_angle- The axis angle of the joint.lower_translation- Lower translation limit.upper_translation- Upper translation limit.max_motor_force- Maximum motor force.motor_speed- Motor speed.
§Returns
MotorJoint- The created prismatic joint.
Sourcepub fn pulley(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
anchor_a: &Vec2,
anchor_b: &Vec2,
ground_anchor_a: &Vec2,
ground_anchor_b: &Vec2,
ratio: f32,
) -> Joint
pub fn pulley( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, anchor_a: &Vec2, anchor_b: &Vec2, ground_anchor_a: &Vec2, ground_anchor_b: &Vec2, ratio: f32, ) -> Joint
Creates a pulley joint between two physics bodies.
§Arguments
can_collide- Whether or not the connected bodies will collide with each other.body_a- The first physics body to connect.body_b- The second physics body to connect.anchor_a- The position of the anchor point on the first body.anchor_b- The position of the anchor point on the second body.ground_anchor_a- The position of the ground anchor point on the first body in world coordinates.ground_anchor_b- The position of the ground anchor point on the second body in world coordinates.ratio- The pulley ratio.
§Returns
Joint- The pulley joint.
Sourcepub fn revolute(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
world_pos: &Vec2,
lower_angle: f32,
upper_angle: f32,
max_motor_torque: f32,
motor_speed: f32,
) -> MotorJoint
pub fn revolute( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, world_pos: &Vec2, lower_angle: f32, upper_angle: f32, max_motor_torque: f32, motor_speed: f32, ) -> MotorJoint
Creates a revolute joint between two physics bodies.
§Arguments
can_collide- Whether or not the connected bodies will collide with each other.body_a- The first physics body to connect.body_b- The second physics body to connect.world_pos- The position in world coordinates where the joint will be created.lower_angle- The lower angle limit in radians.upper_angle- The upper angle limit in radians.max_motor_torque- The maximum torque that can be applied to the joint to achieve the target speed.motor_speed- The desired speed of the joint.
§Returns
MotorJoint- The revolute joint.
Sourcepub fn rope(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
anchor_a: &Vec2,
anchor_b: &Vec2,
max_length: f32,
) -> Joint
pub fn rope( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, anchor_a: &Vec2, anchor_b: &Vec2, max_length: f32, ) -> Joint
Creates a rope joint between two physics bodies.
§Arguments
can_collide- Whether or not the connected bodies will collide with each other.body_a- The first physics body to connect.body_b- The second physics body to connect.anchor_a- The position of the anchor point on the first body.anchor_b- The position of the anchor point on the second body.max_length- The maximum distance between the anchor points.
§Returns
Joint- The rope joint.
Sourcepub fn weld(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
world_pos: &Vec2,
frequency: f32,
damping: f32,
) -> Joint
pub fn weld( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, world_pos: &Vec2, frequency: f32, damping: f32, ) -> Joint
Creates a weld joint between two bodies.
§Arguments
can_collide- Whether or not the bodies connected to the joint can collide with each other.body_a- The first body to be connected by the joint.body_b- The second body to be connected by the joint.world_pos- The position in the world to connect the bodies together.frequency- The frequency at which the joint should be stiff.damping- The damping rate of the joint.
§Returns
Joint- The newly created weld joint.
Sourcepub fn wheel(
collision: bool,
body_a: &dyn IBody,
body_b: &dyn IBody,
world_pos: &Vec2,
axis_angle: f32,
max_motor_torque: f32,
motor_speed: f32,
frequency: f32,
damping: f32,
) -> MotorJoint
pub fn wheel( collision: bool, body_a: &dyn IBody, body_b: &dyn IBody, world_pos: &Vec2, axis_angle: f32, max_motor_torque: f32, motor_speed: f32, frequency: f32, damping: f32, ) -> MotorJoint
Creates a wheel joint between two bodies.
§Arguments
can_collide- Whether or not the bodies connected to the joint can collide with each other.body_a- The first body to be connected by the joint.body_b- The second body to be connected by the joint.world_pos- The position in the world to connect the bodies together.axis_angle- The angle of the joint axis in radians.max_motor_torque- The maximum torque the joint motor can exert.motor_speed- The target speed of the joint motor.frequency- The frequency at which the joint should be stiff.damping- The damping rate of the joint.
§Returns
MotorJoint- The newly created wheel joint.
Sourcepub fn new(def: &JointDef, item_dict: &Dictionary) -> Joint
pub fn new(def: &JointDef, item_dict: &Dictionary) -> Joint
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Joint
impl RefUnwindSafe for Joint
impl Send for Joint
impl Sync for Joint
impl Unpin for Joint
impl UnwindSafe for Joint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more