impl more traits for components
This commit is contained in:
committed by
Sébastien Crozet
parent
3b0d256464
commit
9233a855f0
@@ -1,7 +1,7 @@
|
|||||||
use crate::dynamics::SpringModel;
|
use crate::dynamics::SpringModel;
|
||||||
use crate::math::{Point, Real, Rotation, Vector};
|
use crate::math::{Point, Real, Rotation, Vector};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// A joint that removes all relative linear motion between a pair of points on two bodies.
|
/// A joint that removes all relative linear motion between a pair of points on two bodies.
|
||||||
pub struct BallJoint {
|
pub struct BallJoint {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::math::{Isometry, Real, SpacialVector};
|
use crate::math::{Isometry, Real, SpacialVector};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// A joint that prevents all relative movement between two bodies.
|
/// A joint that prevents all relative movement between two bodies.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::dynamics::{BallJoint, FixedJoint, PrismaticJoint, RevoluteJoint};
|
|||||||
use crate::math::{Isometry, Real, SpacialVector};
|
use crate::math::{Isometry, Real, SpacialVector};
|
||||||
use crate::na::{Rotation3, UnitQuaternion};
|
use crate::na::{Rotation3, UnitQuaternion};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// A joint that prevents all relative movement between two bodies.
|
/// A joint that prevents all relative movement between two bodies.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use crate::dynamics::RevoluteJoint;
|
use crate::dynamics::RevoluteJoint;
|
||||||
use crate::dynamics::{BallJoint, FixedJoint, JointHandle, PrismaticJoint, RigidBodyHandle};
|
use crate::dynamics::{BallJoint, FixedJoint, JointHandle, PrismaticJoint, RigidBodyHandle};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// An enum grouping all possible types of joints.
|
/// An enum grouping all possible types of joints.
|
||||||
pub enum JointParams {
|
pub enum JointParams {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use na::Vector2;
|
|||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
use na::Vector5;
|
use na::Vector5;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// A joint that removes all relative motion between two bodies, except for the translations along one axis.
|
/// A joint that removes all relative motion between two bodies, except for the translations along one axis.
|
||||||
pub struct PrismaticJoint {
|
pub struct PrismaticJoint {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::math::{Isometry, Point, Real, Vector};
|
|||||||
use crate::utils::WBasis;
|
use crate::utils::WBasis;
|
||||||
use na::{RealField, Unit, Vector5};
|
use na::{RealField, Unit, Vector5};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// A joint that removes all relative motion between two bodies, except for the rotations along one axis.
|
/// A joint that removes all relative motion between two bodies, except for the rotations along one axis.
|
||||||
pub struct RevoluteJoint {
|
pub struct RevoluteJoint {
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ impl Default for RigidBodyChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||||
/// The position of this rigid-body.
|
/// The position of this rigid-body.
|
||||||
pub struct RigidBodyPosition {
|
pub struct RigidBodyPosition {
|
||||||
/// The world-space position of the rigid-body.
|
/// The world-space position of the rigid-body.
|
||||||
@@ -199,9 +199,9 @@ bitflags::bitflags! {
|
|||||||
const TRANSLATION_LOCKED = 1 << 0;
|
const TRANSLATION_LOCKED = 1 << 0;
|
||||||
/// Flag indicating that the rigid-body cannot rotate along the `X` axis.
|
/// Flag indicating that the rigid-body cannot rotate along the `X` axis.
|
||||||
const ROTATION_LOCKED_X = 1 << 1;
|
const ROTATION_LOCKED_X = 1 << 1;
|
||||||
/// Flag indicating that the rigid-body cannot rotate along the `X` axis.
|
/// Flag indicating that the rigid-body cannot rotate along the `Y` axis.
|
||||||
const ROTATION_LOCKED_Y = 1 << 2;
|
const ROTATION_LOCKED_Y = 1 << 2;
|
||||||
/// Flag indicating that the rigid-body cannot rotate along the `X` axis.
|
/// Flag indicating that the rigid-body cannot rotate along the `Z` axis.
|
||||||
const ROTATION_LOCKED_Z = 1 << 3;
|
const ROTATION_LOCKED_Z = 1 << 3;
|
||||||
/// Combination of flags indicating that the rigid-body cannot rotate along any axis.
|
/// Combination of flags indicating that the rigid-body cannot rotate along any axis.
|
||||||
const ROTATION_LOCKED = Self::ROTATION_LOCKED_X.bits | Self::ROTATION_LOCKED_Y.bits | Self::ROTATION_LOCKED_Z.bits;
|
const ROTATION_LOCKED = Self::ROTATION_LOCKED_X.bits | Self::ROTATION_LOCKED_Y.bits | Self::ROTATION_LOCKED_Z.bits;
|
||||||
@@ -210,7 +210,7 @@ bitflags::bitflags! {
|
|||||||
|
|
||||||
// TODO: split this into "LocalMassProps" and `WorldMassProps"?
|
// TODO: split this into "LocalMassProps" and `WorldMassProps"?
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||||
/// The mass properties of this rigid-bodies.
|
/// The mass properties of this rigid-bodies.
|
||||||
pub struct RigidBodyMassProps {
|
pub struct RigidBodyMassProps {
|
||||||
/// Flags for locking rotation and translation.
|
/// Flags for locking rotation and translation.
|
||||||
@@ -326,7 +326,7 @@ impl RigidBodyMassProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||||
/// The velocities of this rigid-body.
|
/// The velocities of this rigid-body.
|
||||||
pub struct RigidBodyVelocity {
|
pub struct RigidBodyVelocity {
|
||||||
/// The linear velocity of the rigid-body.
|
/// The linear velocity of the rigid-body.
|
||||||
@@ -466,7 +466,7 @@ impl RigidBodyVelocity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||||
/// Damping factors to progressively slow down a rigid-body.
|
/// Damping factors to progressively slow down a rigid-body.
|
||||||
pub struct RigidBodyDamping {
|
pub struct RigidBodyDamping {
|
||||||
/// Damping factor for gradually slowing down the translational motion of the rigid-body.
|
/// Damping factor for gradually slowing down the translational motion of the rigid-body.
|
||||||
@@ -485,7 +485,7 @@ impl Default for RigidBodyDamping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||||
/// The user-defined external forces applied to this rigid-body.
|
/// The user-defined external forces applied to this rigid-body.
|
||||||
pub struct RigidBodyForces {
|
pub struct RigidBodyForces {
|
||||||
/// Accumulation of external forces (only for dynamic bodies).
|
/// Accumulation of external forces (only for dynamic bodies).
|
||||||
@@ -545,7 +545,7 @@ impl RigidBodyForces {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||||
/// Information used for Continuous-Collision-Detection.
|
/// Information used for Continuous-Collision-Detection.
|
||||||
pub struct RigidBodyCcd {
|
pub struct RigidBodyCcd {
|
||||||
/// The distance used by the CCD solver to decide if a movement would
|
/// The distance used by the CCD solver to decide if a movement would
|
||||||
@@ -617,7 +617,7 @@ impl RigidBodyCcd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash)]
|
||||||
/// Internal identifiers used by the physics engine.
|
/// Internal identifiers used by the physics engine.
|
||||||
pub struct RigidBodyIds {
|
pub struct RigidBodyIds {
|
||||||
pub(crate) active_island_id: usize,
|
pub(crate) active_island_id: usize,
|
||||||
@@ -638,7 +638,7 @@ impl Default for RigidBodyIds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
/// The set of colliders attached to this rigid-bodies.
|
/// The set of colliders attached to this rigid-bodies.
|
||||||
///
|
///
|
||||||
/// This should not be modified manually unless you really know what
|
/// This should not be modified manually unless you really know what
|
||||||
@@ -735,7 +735,7 @@ impl RigidBodyColliders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[derive(Clone, Debug, Copy)]
|
#[derive(Clone, Debug, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
/// The dominance groups of a rigid-body.
|
/// The dominance groups of a rigid-body.
|
||||||
pub struct RigidBodyDominance(pub i8);
|
pub struct RigidBodyDominance(pub i8);
|
||||||
|
|
||||||
@@ -746,7 +746,7 @@ impl Default for RigidBodyDominance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RigidBodyDominance {
|
impl RigidBodyDominance {
|
||||||
/// The actually dominance group of this rigid-body, after taking into account its type.
|
/// The actual dominance group of this rigid-body, after taking into account its type.
|
||||||
pub fn effective_group(&self, status: &RigidBodyType) -> i16 {
|
pub fn effective_group(&self, status: &RigidBodyType) -> i16 {
|
||||||
if status.is_dynamic() {
|
if status.is_dynamic() {
|
||||||
self.0 as i16
|
self.0 as i16
|
||||||
@@ -760,7 +760,7 @@ impl RigidBodyDominance {
|
|||||||
///
|
///
|
||||||
/// This controls whether a body is sleeping or not.
|
/// This controls whether a body is sleeping or not.
|
||||||
/// If the threshold is negative, the body never sleeps.
|
/// If the threshold is negative, the body never sleeps.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
pub struct RigidBodyActivation {
|
pub struct RigidBodyActivation {
|
||||||
/// The threshold pseudo-kinetic energy bellow which the body can fall asleep.
|
/// The threshold pseudo-kinetic energy bellow which the body can fall asleep.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::geometry::{InteractionGroups, SAPProxyIndex, Shape, SharedShape};
|
|||||||
use crate::math::{Isometry, Real};
|
use crate::math::{Isometry, Real};
|
||||||
use crate::parry::partitioning::IndexedData;
|
use crate::parry::partitioning::IndexedData;
|
||||||
use crate::pipeline::{ActiveEvents, ActiveHooks};
|
use crate::pipeline::{ActiveEvents, ActiveHooks};
|
||||||
use std::ops::Deref;
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
/// The unique identifier of a collider added to a collider set.
|
/// The unique identifier of a collider added to a collider set.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
@@ -97,7 +97,7 @@ impl ColliderType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// Data associated to a collider that takes part to a broad-phase algorithm.
|
/// Data associated to a collider that takes part to a broad-phase algorithm.
|
||||||
pub struct ColliderBroadPhaseData {
|
pub struct ColliderBroadPhaseData {
|
||||||
@@ -115,7 +115,7 @@ impl Default for ColliderBroadPhaseData {
|
|||||||
/// The shape of a collider.
|
/// The shape of a collider.
|
||||||
pub type ColliderShape = SharedShape;
|
pub type ColliderShape = SharedShape;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// The mass-properties of a collider.
|
/// The mass-properties of a collider.
|
||||||
pub enum ColliderMassProps {
|
pub enum ColliderMassProps {
|
||||||
@@ -155,7 +155,7 @@ impl ColliderMassProps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// Information about the rigid-body this collider is attached to.
|
/// Information about the rigid-body this collider is attached to.
|
||||||
pub struct ColliderParent {
|
pub struct ColliderParent {
|
||||||
@@ -165,7 +165,7 @@ pub struct ColliderParent {
|
|||||||
pub pos_wrt_parent: Isometry<Real>,
|
pub pos_wrt_parent: Isometry<Real>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// The position of a collider.
|
/// The position of a collider.
|
||||||
pub struct ColliderPosition(pub Isometry<Real>);
|
pub struct ColliderPosition(pub Isometry<Real>);
|
||||||
@@ -177,6 +177,12 @@ impl AsRef<Isometry<Real>> for ColliderPosition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsMut<Isometry<Real>> for ColliderPosition {
|
||||||
|
fn as_mut(&mut self) -> &mut Isometry<Real> {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Deref for ColliderPosition {
|
impl Deref for ColliderPosition {
|
||||||
type Target = Isometry<Real>;
|
type Target = Isometry<Real>;
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -185,6 +191,12 @@ impl Deref for ColliderPosition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DerefMut for ColliderPosition {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for ColliderPosition {
|
impl Default for ColliderPosition {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::identity()
|
Self::identity()
|
||||||
@@ -208,7 +220,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// The constraints solver-related properties of this collider (friction, restitution, etc.)
|
/// The constraints solver-related properties of this collider (friction, restitution, etc.)
|
||||||
pub struct ColliderMaterial {
|
pub struct ColliderMaterial {
|
||||||
@@ -329,7 +341,7 @@ impl Default for ActiveCollisionTypes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
/// A set of flags for controlling collision/intersection filtering, modification, and events.
|
/// A set of flags for controlling collision/intersection filtering, modification, and events.
|
||||||
pub struct ColliderFlags {
|
pub struct ColliderFlags {
|
||||||
|
|||||||
Reference in New Issue
Block a user