Joint

Struct Joint 

Source
pub struct Joint { /* private fields */ }
Expand description

A struct that can be used to connect physics bodies together.

Implementations§

Source§

impl Joint

Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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.
Source

pub fn new(def: &JointDef, item_dict: &Dictionary) -> Joint

Creates a joint instance based on the given joint definition and item dictionary containing physics bodies to be connected by joint.

§Arguments
  • def - The joint definition.
  • item_dict - The dictionary containing all the bodies and other required items.
§Returns
  • Joint - The newly created joint.
Source§

impl Joint

Source

pub fn cast(obj: &dyn IObject) -> Option<Joint>

Casts the object to a joint.

§Arguments
  • obj - The object to cast.
§Returns
  • Option<Joint> - The joint if the object is a joint, None otherwise.

Trait Implementations§

Source§

impl Clone for Joint

Source§

fn clone(&self) -> Joint

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Joint

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl IJoint for Joint

Source§

fn get_world(&self) -> PhysicsWorld

Gets the physics world that the joint belongs to.
Source§

fn destroy(&mut self)

Destroys the joint and removes it from the physics simulation.
Source§

impl IObject for Joint

Source§

fn raw(&self) -> i64

Source§

fn obj(&self) -> &dyn IObject

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_id(&self) -> i32

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.