Trait oxygengine_physics_2d::prelude::joint::JointConstraint
source · pub trait JointConstraint<N, Handle>: NonlinearConstraintGenerator<N, Handle> + Downcast + Send + Syncwhere
N: RealField + Copy,
Handle: BodyHandle,{
// Required methods
fn num_velocity_constraints(&self) -> usize;
fn anchors(&self) -> (BodyPartHandle<Handle>, BodyPartHandle<Handle>);
fn velocity_constraints(
&mut self,
parameters: &IntegrationParameters<N>,
bodies: &dyn BodySet<N, Handle = Handle>,
ext_vels: &Matrix<N, Dynamic, Const<1>, VecStorage<N, Dynamic, Const<1>>>,
ground_j_id: &mut usize,
j_id: &mut usize,
jacobians: &mut [N],
velocity_constraints: &mut LinearConstraints<N, usize>
);
fn cache_impulses(
&mut self,
constraints: &LinearConstraints<N, usize>,
inv_dt: N
);
// Provided methods
fn is_active(&self, bodies: &dyn BodySet<N, Handle = Handle>) -> bool { ... }
fn is_broken(&self) -> bool { ... }
}
Expand description
Trait implemented by joint that operate by generating constraints to restrict the relative motion of two body parts.
Required Methods§
sourcefn num_velocity_constraints(&self) -> usize
fn num_velocity_constraints(&self) -> usize
The maximum number of velocity constraints generated by this joint.
sourcefn anchors(&self) -> (BodyPartHandle<Handle>, BodyPartHandle<Handle>)
fn anchors(&self) -> (BodyPartHandle<Handle>, BodyPartHandle<Handle>)
The two body parts affected by this joint.
sourcefn velocity_constraints(
&mut self,
parameters: &IntegrationParameters<N>,
bodies: &dyn BodySet<N, Handle = Handle>,
ext_vels: &Matrix<N, Dynamic, Const<1>, VecStorage<N, Dynamic, Const<1>>>,
ground_j_id: &mut usize,
j_id: &mut usize,
jacobians: &mut [N],
velocity_constraints: &mut LinearConstraints<N, usize>
)
fn velocity_constraints( &mut self, parameters: &IntegrationParameters<N>, bodies: &dyn BodySet<N, Handle = Handle>, ext_vels: &Matrix<N, Dynamic, Const<1>, VecStorage<N, Dynamic, Const<1>>>, ground_j_id: &mut usize, j_id: &mut usize, jacobians: &mut [N], velocity_constraints: &mut LinearConstraints<N, usize> )
Initialize and retrieve all the constraints appied to the bodies attached to this joint.
sourcefn cache_impulses(
&mut self,
constraints: &LinearConstraints<N, usize>,
inv_dt: N
)
fn cache_impulses( &mut self, constraints: &LinearConstraints<N, usize>, inv_dt: N )
Called after velocity constraint resolution, allows the joint to keep a cache of impulses generated for each constraint.
Provided Methods§
Implementations§
source§impl<N, Handle> dyn JointConstraint<N, Handle>where
N: Any + 'static + RealField + Copy,
Handle: Any + 'static + BodyHandle,
impl<N, Handle> dyn JointConstraint<N, Handle>where N: Any + 'static + RealField + Copy, Handle: Any + 'static + BodyHandle,
sourcepub fn is<__T>(&self) -> boolwhere
__T: JointConstraint<N, Handle>,
pub fn is<__T>(&self) -> boolwhere __T: JointConstraint<N, Handle>,
Returns true if the trait object wraps an object of type __T
.
sourcepub fn downcast<__T>(
self: Box<dyn JointConstraint<N, Handle>, Global>
) -> Result<Box<__T, Global>, Box<dyn JointConstraint<N, Handle>, Global>>where
__T: JointConstraint<N, Handle>,
pub fn downcast<__T>( self: Box<dyn JointConstraint<N, Handle>, Global> ) -> Result<Box<__T, Global>, Box<dyn JointConstraint<N, Handle>, Global>>where __T: JointConstraint<N, Handle>,
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
sourcepub fn downcast_rc<__T>(
self: Rc<dyn JointConstraint<N, Handle>, Global>
) -> Result<Rc<__T, Global>, Rc<dyn JointConstraint<N, Handle>, Global>>where
__T: JointConstraint<N, Handle>,
pub fn downcast_rc<__T>( self: Rc<dyn JointConstraint<N, Handle>, Global> ) -> Result<Rc<__T, Global>, Rc<dyn JointConstraint<N, Handle>, Global>>where __T: JointConstraint<N, Handle>,
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
sourcepub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: JointConstraint<N, Handle>,
pub fn downcast_ref<__T>(&self) -> Option<&__T>where __T: JointConstraint<N, Handle>,
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
sourcepub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: JointConstraint<N, Handle>,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where __T: JointConstraint<N, Handle>,
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.