Skip to content
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 23 commits into from
Mar 20, 2022
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
30b709f
Testbed: add a constructor that calls a custom closure with bevy’s App
sebcrozet Jan 24, 2022
154c35b
Rename JointHandle -> ImpulseJointHandle
sebcrozet Jan 25, 2022
563030b
Minor island solver simplification
sebcrozet Jan 29, 2022
4737b06
Joint API and joint motors improvements
sebcrozet Feb 20, 2022
71a7023
Start fixing the parallel version.
sebcrozet Feb 20, 2022
3e91db6
Allow removing a rigid-body without auto-removing attached colliders
sebcrozet Feb 20, 2022
20a3191
Second round to fix the parallel solver.
sebcrozet Feb 27, 2022
d741e56
Complete the parallel solver fix
sebcrozet Mar 6, 2022
6cf1b9b
Rebase on master branch
sebcrozet Mar 6, 2022
b27b708
Rename the 3D debug-deserialize example
sebcrozet Mar 6, 2022
a4e816c
Don’t track the state.bin file.
sebcrozet Mar 6, 2022
2cbcc8f
Add a max penetration correction integration parameter
sebcrozet Mar 13, 2022
f13838e
Rigid-body: don’t clear forces at end of timestep + don’t wake-up a r…
sebcrozet Mar 13, 2022
231a135
Add 2-axes coupling for angular joint limits
sebcrozet Mar 19, 2022
f482f27
Add a method to propagate collider transforms with the RigidBodySet
sebcrozet Mar 19, 2022
d6ce0c2
Fix warnings and add comments.
sebcrozet Mar 19, 2022
c2dc653
Rename rigid-body `static` to `fixed`
sebcrozet Mar 19, 2022
cc0604a
Combine contact events and intersection events into a single event ty…
sebcrozet Mar 19, 2022
9646d2a
Emit collision stopped events after a collider is removed.
sebcrozet Mar 20, 2022
6fb959e
Update changelog.
sebcrozet Mar 20, 2022
654a9f3
Cargo fmt
sebcrozet Mar 20, 2022
af520b8
Type fix
sebcrozet Mar 20, 2022
30cf322
Update tests
sebcrozet Mar 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rust-analyzer.cargo.features": [
"simd-stable"
]
}
184 changes: 177 additions & 7 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -2,9 +2,14 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"options": {
"env": {
"RUST_BACKTRACE": "1"
}
},
"tasks": [
{
"label": "run 3d (no-simd - release) ",
"label": "🚀 run 3d",
"type": "shell",
"command": "cargo",
"args": [
@@ -20,7 +25,23 @@
"group": "build"
},
{
"label": "run 3d (simd - release) ",
"label": "🚀 run 3d − 💌 deterministic",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_examples3",
"--release",
"--features",
"enhanced-determinism",
"--",
"--pause"
],
"group": "build"
},
{
"label": "🚀 run 3d − 🌈 simd",
"type": "shell",
"command": "cargo",
"args": [
@@ -36,7 +57,7 @@
"group": "build"
},
{
"label": "run 3d (simd - parallel - release) ",
"label": "🚀 run 3d − 🌈 simd 🪢 parallel",
"type": "shell",
"command": "cargo",
"args": [
@@ -52,7 +73,7 @@
"group": "build"
},
{
"label": "run 2d (no-simd - release) ",
"label": "🚀 run 2d",
"type": "shell",
"command": "cargo",
"args": [
@@ -68,7 +89,7 @@
"group": "build"
},
{
"label": "run 2d (simd - release) ",
"label": "🚀 run 2d − 🌈 simd",
"type": "shell",
"command": "cargo",
"args": [
@@ -84,7 +105,7 @@
"group": "build"
},
{
"label": "run 2d (simd - parallel - release) ",
"label": "🚀 run 2d − 🌈 simd 🪢 parallel",
"type": "shell",
"command": "cargo",
"args": [
@@ -98,6 +119,155 @@
"--pause"
],
"group": "build"
}
},
{
"label": "⏱ bench 3d",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_benchmarks3",
"--release",
"--features",
"other-backends",
"--",
"--pause"
],
"group": "build"
},
{
"label": "⏱ bench 3d − 🌈 simd",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_benchmarks3",
"--release",
"--features",
"simd-stable,other-backends",
"--",
"--pause"
],
"group": "build"
},
{
"label": "⏱ bench 3d − 🌈 simd 🪢 parallel",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_benchmarks3",
"--release",
"--features",
"simd-stable,other-backends,parallel",
"--",
"--pause"
],
"group": "build"
},
{
"label": "⏱ bench 2d",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_benchmarks2",
"--release",
"--features",
"other-backends",
"--",
"--pause"
],
"group": "build"
},
{
"label": "⏱ bench 2d − 🌈 simd",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_benchmarks2",
"--release",
"--features",
"simd-stable,other-backends",
"--",
"--pause"
],
"group": "build"
},
{
"label": "⏱ bench 2d − 🌈 simd 🪢 parallel",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_benchmarks2",
"--release",
"--features",
"simd-stable,other-backends,parallel",
"--",
"--pause"
],
"group": "build"
},
{
"label": "🪲 debug 3d",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_examples3",
"--",
"--pause"
],
"group": "build"
},
{
"label": "🪲 debug 3d − 🌈 simd",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_examples3",
"--features",
"simd-stable",
"--",
"--pause"
],
"group": "build"
},
{
"label": "🪲 debug 3d − 🌈 simd 🪢 parallel",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--bin",
"all_examples3",
"--features",
"simd-stable,parallel",
"--",
"--pause"
],
"group": "build"
},
{
"label": "🛠 tests",
"type": "shell",
"command": "cargo",
"args": [
"test"
],
"group": "build"
},
]
]
}
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@

## Unreleased
### Fixed
- Fix the simulation when the `parallel` feature is enabled.
- Fix bug where damping would not be applied properly to some bodies.
- Fix panics caused by various situations (contact or joints) involving rigid-bodies with locked translations/rotations.


### Modified
- Rename `JointHandle` to `ImpulseJointHandle`.
- Rename `RigidBodyMassPropsFlags` to `LockedAxes`.
- Rename `RigidBody::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 end
of the timestep.
- Rename `RigidBodyType::Static` to `RigidBodyType::Fixed` to avoid confusion with the `static` keyword.
- All method referring to `static` rigid-bodies now use `fixed` instead of `static`.
- Rename `RigidBodyBuilder::new_static, new_kinematic_velocity_based, new_kinematic_velocity_based` to
`RigidBodyBuilder::fixed, kinematic_velocity_based, kinematic_velocity_based`.
- The `ContactEvent` and `IntersectionEvent` have been replaced by a single enum `CollisionEvent` in order
to simplify the user’s event handling.
- The `ActiveEvents::CONTACT_EVENTS` and `ActiveEvents::INTERSECTION_EVENTS` flags have been replaced by a single
flag `ActiveEvents::COLLISION_EVENTS`.
- Joint motors no longer have a `VelocityBased` model. The new choices are `AccelerationBased` and `ForceBased`
which are more stable.
- Calling the `.build()` function from builders (`RigidBodyBuilder`, `ColliderBuilder`, etc.) is no longer necessary
whan 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` and `RigidBody::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.
- Don’t automatically clear forces at the end of a timestep.
- Don’t reset the velocity of kinematic bodies to zero at the end of the timestep.
- Events `CollisionEvent::Stopped` are now generated after a collider is removed.

### Added
- Significantly improve the API of joints by adding:
* Builders based on the builder pattern.
* Getters and setters for all joints.
* Method to convert a `GenericJoint` to one of the more specific joint type.
- Improve stability of joint motors.
- Adds a `bool` argument to `RigidBodySet::remove`. If set to `false`, the colliders attached to the rigid-body
won’t be automatically deleted (they will only be detached from the deleted rigid-body instead).
- Add `RigidBody::reset_forces` and `RigidBody::reset_torques` to reset all the forces and torques added to the
rigid-bodiy by the user.

## v0.12.0-alpha.0 (2 Jan. 2022)
### Fixed
- Fixed `RigidBody::restrict_rotations` to properly take into account the axes to lock.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -24,9 +24,11 @@ resolver = "2"
[profile.release]
#debug = true
#codegen-units = 1
#opt-level = 1
#lto = true

[profile.dev]
opt-level = 1


#[profile.dev.package.rapier3d]
#opt-level = 3
8 changes: 3 additions & 5 deletions benchmarks2d/balls2.rs
Original file line number Diff line number Diff line change
@@ -42,17 +42,15 @@ pub fn init_world(testbed: &mut Testbed) {
let y = j as f32 * shifty + centery;

let status = if j == 0 {
RigidBodyType::Static
RigidBodyType::Fixed
} else {
RigidBodyType::Dynamic
};

// Build the rigid body.
let rigid_body = RigidBodyBuilder::new(status)
.translation(vector![x, y])
.build();
let rigid_body = RigidBodyBuilder::new(status).translation(vector![x, y]);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::ball(rad).build();
let collider = ColliderBuilder::ball(rad);
colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
24 changes: 10 additions & 14 deletions benchmarks2d/boxes2.rs
Original file line number Diff line number Diff line change
@@ -15,25 +15,23 @@ pub fn init_world(testbed: &mut Testbed) {
*/
let ground_size = 25.0;

let rigid_body = RigidBodyBuilder::new_static().build();
let rigid_body = RigidBodyBuilder::fixed();
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, 1.2).build();
let collider = ColliderBuilder::cuboid(ground_size, 1.2);
colliders.insert_with_parent(collider, handle, &mut bodies);

let rigid_body = RigidBodyBuilder::new_static()
let rigid_body = RigidBodyBuilder::fixed()
.rotation(std::f32::consts::FRAC_PI_2)
.translation(vector![ground_size, ground_size * 2.0])
.build();
.translation(vector![ground_size, ground_size * 2.0]);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2).build();
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
colliders.insert_with_parent(collider, handle, &mut bodies);

let rigid_body = RigidBodyBuilder::new_static()
let rigid_body = RigidBodyBuilder::fixed()
.rotation(std::f32::consts::FRAC_PI_2)
.translation(vector![-ground_size, ground_size * 2.0])
.build();
.translation(vector![-ground_size, ground_size * 2.0]);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2).build();
let collider = ColliderBuilder::cuboid(ground_size * 2.0, 1.2);
colliders.insert_with_parent(collider, handle, &mut bodies);

/*
@@ -52,11 +50,9 @@ pub fn init_world(testbed: &mut Testbed) {
let y = j as f32 * shift + centery + 2.0;

// Build the rigid body.
let rigid_body = RigidBodyBuilder::new_dynamic()
.translation(vector![x, y])
.build();
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(rad, rad).build();
let collider = ColliderBuilder::cuboid(rad, rad);
colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
Loading