diff options
| author | Sébastien Crozet <sebcrozet@dimforge.com> | 2024-03-17 21:20:18 +0100 |
|---|---|---|
| committer | Sébastien Crozet <sebcrozet@dimforge.com> | 2024-03-17 21:24:28 +0100 |
| commit | ecd308338b189ab569816a38a03e3f8b89669dde (patch) | |
| tree | fa612abff2f23ea6a5ff04c64c07296d9fb065c8 /src/geometry/mod.rs | |
| parent | da92e5c2837b27433286cf0dd9d887fd44dda254 (diff) | |
| download | rapier-bevy-glam.tar.gz rapier-bevy-glam.tar.bz2 rapier-bevy-glam.zip | |
feat: start experimenting with a glam/bevy versionbevy-glam
Diffstat (limited to 'src/geometry/mod.rs')
| -rw-r--r-- | src/geometry/mod.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index 1525211..02f019a 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -21,7 +21,7 @@ pub use parry::bounding_volume::BoundingVolume; pub use parry::query::{PointQuery, PointQueryWithLocation, RayCast, TrackedContact}; pub use parry::shape::SharedShape; -use crate::math::{Real, Vector}; +use crate::math::*; /// A contact between two colliders. pub type Contact = parry::query::TrackedContact<ContactData>; @@ -70,6 +70,7 @@ bitflags::bitflags! { } #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "bevy", derive(bevy::prelude::Event))] #[derive(Copy, Clone, Hash, Debug)] /// Events occurring when two colliders start or stop colliding pub enum CollisionEvent { @@ -123,7 +124,8 @@ impl CollisionEvent { } } -#[derive(Copy, Clone, PartialEq, Debug, Default)] +#[cfg_attr(feature = "bevy", derive(bevy::prelude::Event))] +#[derive(Copy, Clone, PartialEq, Debug)] /// Event occurring when the sum of the magnitudes of the contact forces /// between two colliders exceed a threshold. pub struct ContactForceEvent { @@ -132,7 +134,7 @@ pub struct ContactForceEvent { /// The second collider involved in the contact. pub collider2: ColliderHandle, /// The sum of all the forces between the two colliders. - pub total_force: Vector<Real>, + pub total_force: Vector, /// The sum of the magnitudes of each force between the two colliders. /// /// Note that this is **not** the same as the magnitude of `self.total_force`. @@ -140,11 +142,25 @@ pub struct ContactForceEvent { /// the magnitude of their sum. pub total_force_magnitude: Real, /// The world-space (unit) direction of the force with strongest magnitude. - pub max_force_direction: Vector<Real>, + pub max_force_direction: Vector, /// The magnitude of the largest force at a contact point of this contact pair. pub max_force_magnitude: Real, } +impl Default for ContactForceEvent { + #[inline] + fn default() -> Self { + Self { + collider1: ColliderHandle::PLACEHOLDER, + collider2: ColliderHandle::PLACEHOLDER, + total_force: Default::default(), + total_force_magnitude: Default::default(), + max_force_direction: Default::default(), + max_force_magnitude: Default::default(), + } + } +} + impl ContactForceEvent { /// Init a contact force event from a contact pair. pub fn from_contact_pair(dt: Real, pair: &ContactPair, total_force_magnitude: Real) -> Self { |
