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/pipeline/physics_hooks.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/pipeline/physics_hooks.rs')
| -rw-r--r-- | src/pipeline/physics_hooks.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/pipeline/physics_hooks.rs b/src/pipeline/physics_hooks.rs index 11166b5..ed130c7 100644 --- a/src/pipeline/physics_hooks.rs +++ b/src/pipeline/physics_hooks.rs @@ -1,8 +1,11 @@ use crate::dynamics::{RigidBodyHandle, RigidBodySet}; use crate::geometry::{ColliderHandle, ColliderSet, ContactManifold, SolverContact, SolverFlags}; -use crate::math::{Real, Vector}; +use crate::math::*; use na::ComplexField; +#[cfg(feature = "bevy")] +use bevy::prelude::{Component, Reflect, ReflectComponent}; + /// Context given to custom collision filters to filter-out collisions. pub struct PairFilterContext<'a> { /// The set of rigid-bodies. @@ -38,7 +41,7 @@ pub struct ContactModificationContext<'a> { /// The solver contacts that can be modified. pub solver_contacts: &'a mut Vec<SolverContact>, /// The contact normal that can be modified. - pub normal: &'a mut Vector<Real>, + pub normal: &'a mut Vector, /// User-defined data attached to the manifold. // NOTE: we keep this a &'a mut u32 to emphasize the // fact that this can be modified. @@ -56,11 +59,7 @@ impl<'a> ContactModificationContext<'a> { /// `PhysicsHooks::modify_solver_contacts` method at each timestep, for each /// contact manifold involving a one-way platform. The `self.user_data` field /// must not be modified from the outside of this method. - pub fn update_as_oneway_platform( - &mut self, - allowed_local_n1: &Vector<Real>, - allowed_angle: Real, - ) { + pub fn update_as_oneway_platform(&mut self, allowed_local_n1: &Vector, allowed_angle: Real) { const CONTACT_CONFIGURATION_UNKNOWN: u32 = 0; const CONTACT_CURRENTLY_ALLOWED: u32 = 1; const CONTACT_CURRENTLY_FORBIDDEN: u32 = 2; @@ -69,7 +68,7 @@ impl<'a> ContactModificationContext<'a> { // Test the allowed normal with the local-space contact normal that // points towards the exterior of context.collider1. - let contact_is_ok = self.manifold.local_n1.dot(allowed_local_n1) >= cang; + let contact_is_ok = self.manifold.local_n1.dot(*allowed_local_n1) >= cang; match *self.user_data { CONTACT_CONFIGURATION_UNKNOWN => { @@ -118,6 +117,11 @@ impl<'a> ContactModificationContext<'a> { bitflags::bitflags! { #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] + #[cfg_attr( + feature = "bevy", + derive(Component, Reflect), + reflect(Component, Hash, PartialEq) + )] /// Flags affecting the behavior of the constraints solver for a given contact manifold. pub struct ActiveHooks: u32 { /// If set, Rapier will call `PhysicsHooks::filter_contact_pair` whenever relevant. |
