pub fn update_as_oneway_platform(
        &mut self,
        allowed_local_n1: &Vector<Real>,
        allowed_angle: Real,
    ) {
        const CONTACT_CONFIGURATION_UNKNOWN: u32 = 0;
        const CONTACT_CURRENTLY_ALLOWED: u32 = 1;
        const CONTACT_CURRENTLY_FORBIDDEN: u32 = 2;

        let cang = ComplexField::cos(allowed_angle);

        // 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;

        match *self.user_data {
            CONTACT_CONFIGURATION_UNKNOWN => {
                if contact_is_ok {
                    // The contact is close enough to the allowed normal.
                    *self.user_data = CONTACT_CURRENTLY_ALLOWED;
                } else {
                    // The contact normal isn't close enough to the allowed
                    // normal, so remove all the contacts and mark further contacts
                    // as forbidden.
                    self.solver_contacts.clear();

                    // NOTE: in some very rare cases `local_n1` will be
                    // zero if the objects are exactly touching at one point.
                    // So in this case we can't really conclude.
                    // If the norm is non-zero, then we can tell we need to forbid
                    // further contacts. Otherwise we have to wait for the next frame.
                    if self.manifold.local_n1.norm_squared() > 0.1 {
                        *self.user_data = CONTACT_CURRENTLY_FORBIDDEN;
                    }
                }
            }
            CONTACT_CURRENTLY_FORBIDDEN => {
                // Contacts are forbidden so we need to continue forbidding contacts
                // until all the contacts are non-penetrating again. In that case, if
                // the contacts are OK wrt. the contact normal, then we can mark them as allowed.
                if contact_is_ok && self.solver_contacts.iter().all(|c| c.dist > 0.0) {
                    *self.user_data = CONTACT_CURRENTLY_ALLOWED;
                } else {
                    // Discard all the contacts.
                    self.solver_contacts.clear();
                }
            }
            CONTACT_CURRENTLY_ALLOWED => {
                // We allow all the contacts right now. The configuration becomes
                // uncertain again when the contact manifold no longer contains any contact.
                if self.solver_contacts.is_empty() {
                    *self.user_data = CONTACT_CONFIGURATION_UNKNOWN;
                }
            }
            _ => unreachable!(),
        }
    }
/// Helper function to update `self` to emulate a oneway-platform.
///
/// The "oneway" behavior will only allow contacts between two colliders
/// if the local contact normal of the first collider involved in the contact
/// is almost aligned with the provided `allowed_local_n1` direction.
///
/// To make this method work properly it must be called as part of the
/// `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.
Helper function to update `self` to emulate a oneway-platform.
The "oneway" behavior will only allow contacts between two colliders
if the local contact normal of the first collider involved in the contact
is almost aligned with the provided `allowed_local_n1` direction.

To make this method work properly it must be called as part of the
`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.
Helper function to update ` self ` to emulate a oneway - platform . The " oneway " behavior will only allow contacts between two colliders if the local contact normal of the first collider involved in the contact is almost aligned with the provided ` allowed_local_n1 ` direction . To make this method work properly it must be called as part of the ` 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,
    ) {
        const CONTACT_CONFIGURATION_UNKNOWN: u32 = 0;
        const CONTACT_CURRENTLY_ALLOWED: u32 = 1;
        const CONTACT_CURRENTLY_FORBIDDEN: u32 = 2;
        let cang = ComplexField::cos(allowed_angle);
        // 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;
        match *self.user_data {
            CONTACT_CONFIGURATION_UNKNOWN => {
                if contact_is_ok {
                    // The contact is close enough to the allowed normal.
                    *self.user_data = CONTACT_CURRENTLY_ALLOWED;
                } else {
                    // The contact normal isn't close enough to the allowed
                    // normal, so remove all the contacts and mark further contacts
                    // as forbidden.
                    self.solver_contacts.clear();
                    // NOTE: in some very rare cases `local_n1` will be
                    // zero if the objects are exactly touching at one point.
                    // So in this case we can't really conclude.
                    // If the norm is non-zero, then we can tell we need to forbid
                    // further contacts. Otherwise we have to wait for the next frame.
                    if self.manifold.local_n1.norm_squared() > 0.1 {
                        *self.user_data = CONTACT_CURRENTLY_FORBIDDEN;
                    }
                }
            }
            CONTACT_CURRENTLY_FORBIDDEN => {
                // Contacts are forbidden so we need to continue forbidding contacts
                // until all the contacts are non-penetrating again. In that case, if
                // the contacts are OK wrt. the contact normal, then we can mark them as allowed.
                if contact_is_ok && self.solver_contacts.iter().all(|c| c.dist > 0.0) {
                    *self.user_data = CONTACT_CURRENTLY_ALLOWED;
                } else {
                    // Discard all the contacts.
                    self.solver_contacts.clear();
                }
            }
            CONTACT_CURRENTLY_ALLOWED => {
                // We allow all the contacts right now. The configuration becomes
                // uncertain again when the contact manifold no longer contains any contact.
                if self.solver_contacts.is_empty() {
                    *self.user_data = CONTACT_CONFIGURATION_UNKNOWN;
                }
            }
            _ => unreachable!(),
        }
    }
pub fn update_as_oneway_platform ( & mut self , allowed_local_n1 : & Vector < Real > , allowed_angle : Real , ) { const CONTACT_CONFIGURATION_UNKNOWN : u32 = 0 ; const CONTACT_CURRENTLY_ALLOWED : u32 = 1 ; const CONTACT_CURRENTLY_FORBIDDEN : u32 = 2 ; let cang = ComplexField :: cos ( allowed_angle ) ; // 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 ; match * self . user_data { CONTACT_CONFIGURATION_UNKNOWN => { if contact_is_ok { // The contact is close enough to the allowed normal. * self . user_data = CONTACT_CURRENTLY_ALLOWED ; } else { // The contact normal isn't close enough to the allowed // normal, so remove all the contacts and mark further contacts // as forbidden. self . solver_contacts . clear ( ) ; // NOTE: in some very rare cases `local_n1` will be // zero if the objects are exactly touching at one point. // So in this case we can't really conclude. // If the norm is non-zero, then we can tell we need to forbid // further contacts. Otherwise we have to wait for the next frame. if self . manifold . local_n1 . norm_squared ( ) > 0.1 { * self . user_data = CONTACT_CURRENTLY_FORBIDDEN ; } } } CONTACT_CURRENTLY_FORBIDDEN => { // Contacts are forbidden so we need to continue forbidding contacts // until all the contacts are non-penetrating again. In that case, if // the contacts are OK wrt. the contact normal, then we can mark them as allowed. if contact_is_ok && self . solver_contacts . iter ( ) . all ( | c | c . dist > 0.0 ) { * self . user_data = CONTACT_CURRENTLY_ALLOWED ; } else { // Discard all the contacts. self . solver_contacts . clear ( ) ; } } CONTACT_CURRENTLY_ALLOWED => { // We allow all the contacts right now. The configuration becomes // uncertain again when the contact manifold no longer contains any contact. if self . solver_contacts . is_empty ( ) { * self . user_data = CONTACT_CONFIGURATION_UNKNOWN ; } } _ => unreachable ! ( ) , } }
Helper function to update `self` to emulate a oneway-platform.
Helper function to update ` self ` to emulate a oneway - platform .
&mut self
allowed_local_n1
&Vector<Real>
allowed_angle
Real