-
-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api improvements and fixes #304
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…igid-body if the modified property is equal to the old value.
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a combination of several pieces of work I needed to land before releasing the next non-alpha version. The diff is quite large because it involves several semi-automatic small modifications after some API changes (like removing the need to call
.build()
on all the builders).In particular this:
parallel
version of Rapier (fix Panic when using "parallel" feature #289).In addition, this introduces a few semantic modifications that result from recurrent user feedbacks. In particular:
Simplified event handling
The contact/intersection event system has been simplified. The difference between contact events and intersection events (for sensor colliders) was often an unnecessary source of confusion for newcomers. Even our
ContactEvent
andIntersectionEvent
structs where mostly identical. There is now a single event typeCollisionEvent
that can be triggered by sensor and non-sensor colliders.In addition, removing a collider did not trigger any
ContactEvent::Stopped
before. This made it very difficult for users to implement event handler based on, e.g., counters that is incremented/decremented when an event happens. This PR allows Rapier to generate events for colliders that have been removed before the current simulation step (fix #299).Don’t clear external forces
Currently, forces applied to a rigid-body are automatically cleared at the end of each timestep. This would cause various unexpected behavior (fix #278), and would make writing a custom substepping strategy (manually calling
PhysicsPipeline::step
multiple times during one frame) quite difficult because the forces wouldn’t persist between substeps.Therefore forces are no longer cleared automatically and a
RigidBody::reset_forces
method have been added to clear manually all the forces applied to a rigid-body.This change also deepens the contrast between applying forces and applying impulses. Impulses are instantaneous velocity changes whereas forces are now continuous forces that persist in time. This also makes sleeping easier to manage: as long as you don’t modify forces there is no reason to manually wake-up the rigid-body. So calling
.add_force(force, true)
only when forces changes allows waking the rigid-body only when it is needed.Don’t reset the velocity of kinematic bodies
Currently, the velocity of kinematic bodies are automatically reset at the end of each timestep. This means that the velocity of a velocity-based kinematic body has to be set at each frame, even if that velocity remains constant. Like forces auto-clearing, this makes custom sub-stepping strategies very difficult to implement.
With this PR, kinematic bodies velocities won’t be cleared automatically any more.
This also means that the velocity of kinematic bodies (including the velocity we automatically compute for position-based kinematic bodies) can now be read after the call to
PhysicsPipeline::step
, which can be useful for writing some user logic based on that velocity (fix dimforge/bevy_rapier#127).Changelog
Fixed
parallel
feature is enabled.Modified
JointHandle
toImpulseJointHandle
.RigidBodyMassPropsFlags
toLockedAxes
.RigidsBody::apply_force
,::apply_torque
,::apply_force_at_point
to::add_force
,::add_torque
, and::add_force_at_point
to better reflect the fact that they are not cleared at the endof the timestep.
RigidBodyType::Static
toRigidBodyType::Fixed
to avoid confusion with thestatic
keyword.static
rigid-bodies now usefixed
instead ofstatic
.RigidBodyBuilder::new_static, new_kinematic_velocity_based, new_kinematic_velocity_based
toRigidBodyBuilder::fixed, kinematic_velocity_based, kinematic_velocity_based
.ContactEvent
andIntersectionEvent
have been replaced by a single enumCollisionEvent
in orderto simplify the user’s event handling.
ActiveEvents::CONTACT_EVENTS
andActiveEvents::INTERSECTION_EVENTS
flags have been replaced by a singleflag
ActiveEvents::COLLISION_EVENTS
.VelocityBased
model. The new choices areAccelerationBased
andForceBased
which are more stable.
.build()
function from builders (RigidBodyBuilder
,ColliderBuilder
, etc.) is no longer necessarywhan adding them to sets. It is automatically called thanks to
Into<_>
implementations.Semantic modifications
These are changes in the behavior of the physics engine that are not necessarily
reflected by an API change:
RigidBody::set_linvel
andRigidBody::set_angvel
no longer modify the velocity of static bodies.RigidBody::set_body_type
will reset the velocity of a rigid-body to zero if it is static.CollisionEvent::Stopped
are now generated after a collider is removed.