You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnmain(){App::build().add_plugins(DefaultPlugins).add_plugin(RapierPhysicsPlugin::<NoUserData>::default()).add_startup_system(setup_physics.system()).run();}structMyPhysicsHooks;implPhysicsHooksWithQuery<NoUserData<'_>>forMyPhysicsHooks{fnmodify_solver_contacts(&self,context:ContactModificationContextView,_user_data:&Query<NoUserData>){// This is a silly example of contact modifier that does silly things// for illustration purpose:// - Flip all the contact normals.// - Delete the first contact.// - Set the friction coefficients to 0.3// - Set the restitution coefficients to 0.4// - Set the tangent velocities to X * 10.0*context.normal = -*context.normal;if !context.solver_contacts.is_empty(){
context.solver_contacts.swap_remove(0);}for solver_contact in&mut*context.solver_contacts{
solver_contact.friction = 0.3;
solver_contact.restitution = 0.4;
solver_contact.tangent_velocity.x = 10.0;}// Use the persistent user-data to count the number of times// contact modification was called for this contact manifold// since its creation.*context.user_data += 1;println!("Contact manifold has been modified {} times since its creation.", *context.user_data);}}fnsetup_physics(mutcommands:Commands){// Register our physics hooks.
commands.insert_resource(PhysicsHooksWithQueryObject(Box::new(MyPhysicsHooks{})));// Add colliders with a `CustomFilterTag` component. Only colliders// with the same `CustomFilterTag` variant will collider thanks to// our custom physics hooks:
commands.spawn().insert(Collider::ball(0.5)).insert(ActiveHooks::MODIFY_SOLVER_CONTACTS);// TODO: add other colliders in a similar way.}
This is out of date in multiple ways. PhysicsHooksWithQueryObject has been renamed to PhysicsHooksWithQueryResource. Also, NoUserData<'_> no longer takes a type parameter. Additionally, ContactModificationContextView has no normal or solver_contacts fields
I'd make a PR and the first two are pretty easy to fix, but the last one requires going from context.normal to context.raw.manifold.data.normal, but that causes an error on the *context.normal = -*context.normal; line:
cannot apply unary operator `-` to type `bevy_rapier3d::nalgebra::coordinates::XYZ<f32>`
The text was updated successfully, but these errors were encountered:
Now PhysicsHooksWithQueryResource has been renamed again to BevyPhysicsHooks in dimforge/bevy_rapier#323 and it's usage is significantly different (still figuring it out myself).
I wasn't sure if I should open a new issue since it looks like this one did get addressed for the old changes but was never closed.
Thank you for the amazing library, and the amazing docs! There was just one thing I noticed.
There's this code block on the website:
This is out of date in multiple ways.
PhysicsHooksWithQueryObject
has been renamed toPhysicsHooksWithQueryResource
. Also,NoUserData<'_>
no longer takes a type parameter. Additionally,ContactModificationContextView
has nonormal
orsolver_contacts
fieldsI'd make a PR and the first two are pretty easy to fix, but the last one requires going from
context.normal
tocontext.raw.manifold.data.normal
, but that causes an error on the*context.normal = -*context.normal;
line:The text was updated successfully, but these errors were encountered: