pub struct Joint { /* private fields */ }
Expand description
Joint component. A joint connects two dynamic, or one static and one dynamic, entity physically. It doesn’t have to be a component of one of the entities it connects, but that can be convenient at times.
There are many different kinds of joints. A Joint
can represent all standard joint types except D6,
which we have D6Joint
for.
If you don’t set a second_entity
, the joint will be to kind of a static invisible global frame - not super
realistic, but often useful.
Usually accessed through entity.joint
().
Most of the time, you’ll be better served by a D6Joint
. Joint
represent PhysX
’s legacy joint types. They
can be easier to use for simpler applications but D6Joint
has all the capabilities and are more flexible.
Implementations
sourceimpl Joint
impl Joint
sourcepub fn joint_type(&self) -> ValueAccessorReadWrite<JointType>
pub fn joint_type(&self) -> ValueAccessorReadWrite<JointType>
Returns a ValueAccessor
for the joint type of the entity.
Used to set/get the mesh style.
sourcepub fn first_entity(&self) -> ValueAccessorReadWrite<Entity>
pub fn first_entity(&self) -> ValueAccessorReadWrite<Entity>
The first entity of the joint.
sourcepub fn second_entity(&self) -> ValueAccessorReadWrite<Entity>
pub fn second_entity(&self) -> ValueAccessorReadWrite<Entity>
The second entity of the joint.
sourcepub fn first_offset(&self) -> ValueAccessorReadWrite<Vec3>
pub fn first_offset(&self) -> ValueAccessorReadWrite<Vec3>
The location on the first entity that the joint is attached to.
sourcepub fn second_offset(&self) -> ValueAccessorReadWrite<Vec3>
pub fn second_offset(&self) -> ValueAccessorReadWrite<Vec3>
The location on the second entity that the joint is attached to.
sourcepub fn first_orientation(&self) -> ValueAccessorReadWrite<Quat>
pub fn first_orientation(&self) -> ValueAccessorReadWrite<Quat>
The orientation of the joint on the second entity that the joint is attached to. For hinge joints, the default is the exact X axis, rotated by this orientation.
sourcepub fn second_orientation(&self) -> ValueAccessorReadWrite<Quat>
pub fn second_orientation(&self) -> ValueAccessorReadWrite<Quat>
The orientation of the joint on the second entity that the joint is attached to. For hinge joints, the default is the exact X axis, rotated by this orientation.
sourcepub fn limits(&self) -> ValueAccessorReadWrite<Vec2>
pub fn limits(&self) -> ValueAccessorReadWrite<Vec2>
The limit bounds of a joint. x is min, y is max, what exactly it limits depends on the joint type:
- Ball joint: x is the y angle limit of the cone (around the x axis), while y sets the z angle limit.
- Hinge: x is the lower angle limit, y is the upper angle limit.
- Slider: x is the lower position limit, y is the upper position limit.
- Distance: x is the minimum distance, y is the maximum distance.
sourcepub fn limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
pub fn limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
The limit type of a joint.
sourcepub fn velocity(&self) -> ValueAccessorRead<f32>
pub fn velocity(&self) -> ValueAccessorRead<f32>
The joint velocity (angular for hinge joints, linear for linear joints). Can only be retrieved for now, need to use forces to change it.
sourcepub fn drive_enable(&self) -> ValueAccessorReadWriteAnimate<bool>
pub fn drive_enable(&self) -> ValueAccessorReadWriteAnimate<bool>
Turns on joint drive. Currently only works with Hinge joints. D6Joint
has more flexible drive capabilities, though.
sourcepub fn drive_velocity(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn drive_velocity(&self) -> ValueAccessorReadWriteAnimate<f32>
The drive velocity. Does nothing unless drive_enable
is set to true.
sourcepub fn drive_force_limit(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn drive_force_limit(&self) -> ValueAccessorReadWriteAnimate<f32>
Sets the maximum force the joint drive can exercise.
sourcepub fn drive_gear_ratio(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn drive_gear_ratio(&self) -> ValueAccessorReadWriteAnimate<f32>
Sets the gear ratio of the joint drive.
sourcepub fn drive_freespin(&self) -> ValueAccessorReadWriteAnimate<bool>
pub fn drive_freespin(&self) -> ValueAccessorReadWriteAnimate<bool>
Enables freespin on the joint drive (it’ll continue to spin by inertia if you turn off the drive).
sourcepub fn break_force(&self) -> ValueAccessorReadWrite<f32>
pub fn break_force(&self) -> ValueAccessorReadWrite<f32>
Sets the force threshold for breaking the joint. Default is std::f32::MAX (effectively unbreakable).
sourcepub fn break_torque(&self) -> ValueAccessorReadWrite<f32>
pub fn break_torque(&self) -> ValueAccessorReadWrite<f32>
Sets the torque threshold for breaking the joint. Default is std::f32::MAX (effectively unbreakable).
sourcepub fn is_broken(&self) -> ValueAccessorRead<bool>
pub fn is_broken(&self) -> ValueAccessorRead<bool>
Lets you check whether the joint is broken. Cannot be modified.
sourcepub fn angle_or_position(&self) -> ValueAccessorRead<Vec3>
pub fn angle_or_position(&self) -> ValueAccessorRead<Vec3>
Lets you check the angles or position of the joint. Interpreted differently depending on the joint type:
- Hinge: x means the angle. You can use
hinge_angle
instead. - Ball: y means the y-angle, z means the z-angle. You can use
ball_swing_angles
instead. - Linear: x means the position along the joint. You can use
linear_position
instead.
sourcepub fn hinge_angle(&self) -> f32
pub fn hinge_angle(&self) -> f32
Utility function for angle_or_position
: If the joint is a hinge, returns the angle directly.
sourcepub fn linear_position(&self) -> f32
pub fn linear_position(&self) -> f32
Utility function: If the joint is linear, returns the position along the line directly.
sourcepub fn ball_swing_angles(&self) -> Vec2
pub fn ball_swing_angles(&self) -> Vec2
Utility function: If the joint is a ball joint, return the swing angles.
Trait Implementations
sourceimpl ComponentTrait for Joint
impl ComponentTrait for Joint
sourcefn get_type() -> ComponentType
fn get_type() -> ComponentType
The type of the component, as a ComponentType
enum.
sourcefn from_entity(handle: Entity) -> Self
fn from_entity(handle: Entity) -> Self
Adopt an Entity
, wrap in a component struct.
Auto Trait Implementations
impl RefUnwindSafe for Joint
impl Send for Joint
impl Sync for Joint
impl Unpin for Joint
impl UnwindSafe for Joint
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more