aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--crates/rapier2d-f64/Cargo.toml8
-rw-r--r--crates/rapier2d/Cargo.toml8
-rw-r--r--crates/rapier3d-f64/Cargo.toml8
-rw-r--r--crates/rapier3d/Cargo.toml8
-rw-r--r--crates/rapier_testbed2d-f64/Cargo.toml14
-rw-r--r--crates/rapier_testbed2d/Cargo.toml14
-rw-r--r--crates/rapier_testbed3d-f64/Cargo.toml14
-rw-r--r--crates/rapier_testbed3d/Cargo.toml20
-rw-r--r--src/dynamics/joint/multibody_joint/multibody.rs30
-rw-r--r--src/dynamics/joint/multibody_joint/multibody_joint.rs14
-rw-r--r--src/dynamics/rigid_body.rs10
-rw-r--r--src/dynamics/rigid_body_components.rs2
-rw-r--r--src/dynamics/solver/delta_vel.rs10
-rw-r--r--src/dynamics/solver/joint_constraint/joint_generic_velocity_constraint.rs26
-rw-r--r--src/lib.rs8
-rw-r--r--src_testbed/debug_render.rs11
-rw-r--r--src_testbed/lines/mod.rs3
-rw-r--r--src_testbed/lines/render_dim.rs2
-rw-r--r--src_testbed/objects/node.rs4
-rw-r--r--src_testbed/testbed.rs43
21 files changed, 139 insertions, 122 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2a0acf..97b97f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,5 @@
-## Unreleased
+## v0.17.0 (15 Jan. 2022)
### Added
- Add `RigidBody::set_enabled`, `RigidBody::is_enabled`, `RigidBodyBuilder::enabled` to enable/disable a rigid-body
without having to delete it. Disabling a rigid-body attached to a multibody joint isn’t supported yet.
@@ -11,6 +11,7 @@
a port of the vehicle controller from Bullet physics).
- Add `RigidBody::user_force` and `RigidBody::user_torque` to read the forces or torques added by the user to a
dynamic rigid-body.
+- Add `RigidBody::locked_axes` to get the rigid-body axes that were locked by the user.
### Modified
- Add the `QueryPipeline` as an optional argument to `PhysicsPipeline::step` and `CollisionPipeline::step`. If this
@@ -18,6 +19,7 @@
these other pipelines. In that case, calling `QueryPipeline::update` a `PhysicsPipeline::step` isn’t needed.
- `RigidBody::set_body_type` now takes an extra boolean argument indicating if the rigid-body should be woken-up
(if it becomes dynamic).
+- `RigidBody::mass_properties` now also returns the world-space mass-properties of the rigid-body.
### Fix
- Fix bug resulting in rigid-bodies being awakened after they are created, even if they are created sleeping.
diff --git a/crates/rapier2d-f64/Cargo.toml b/crates/rapier2d-f64/Cargo.toml
index 60ea169..035bef7 100644
--- a/crates/rapier2d-f64/Cargo.toml
+++ b/crates/rapier2d-f64/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier2d-f64"
-version = "0.16.1"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "2-dimensional physics engine in Rust."
documentation = "http://docs.rs/rapier2d"
@@ -51,9 +51,9 @@ required-features = [ "dim2", "f64" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ], optional = true }
num-traits = "0.2"
-nalgebra = "0.31"
-parry2d-f64 = "0.12"
-simba = "0.7"
+nalgebra = "0.32"
+parry2d-f64 = "0.13"
+simba = "0.8"
approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
diff --git a/crates/rapier2d/Cargo.toml b/crates/rapier2d/Cargo.toml
index 115069c..cd4f651 100644
--- a/crates/rapier2d/Cargo.toml
+++ b/crates/rapier2d/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier2d"
-version = "0.16.1"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "2-dimensional physics engine in Rust."
documentation = "http://docs.rs/rapier2d"
@@ -51,9 +51,9 @@ required-features = [ "dim2", "f32" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ], optional = true }
num-traits = "0.2"
-nalgebra = "0.31"
-parry2d = "0.12"
-simba = "0.7"
+nalgebra = "0.32"
+parry2d = "0.13"
+simba = "0.8"
approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
diff --git a/crates/rapier3d-f64/Cargo.toml b/crates/rapier3d-f64/Cargo.toml
index 79c2783..cbd6e50 100644
--- a/crates/rapier3d-f64/Cargo.toml
+++ b/crates/rapier3d-f64/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier3d-f64"
-version = "0.16.1"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "3-dimensional physics engine in Rust."
documentation = "http://docs.rs/rapier3d"
@@ -51,9 +51,9 @@ required-features = [ "dim3", "f64" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ], optional = true }
num-traits = "0.2"
-nalgebra = "0.31"
-parry3d-f64 = "0.12"
-simba = "0.7"
+nalgebra = "0.32"
+parry3d-f64 = "0.13"
+simba = "0.8"
approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
diff --git a/crates/rapier3d/Cargo.toml b/crates/rapier3d/Cargo.toml
index 88c5281..982bfe1 100644
--- a/crates/rapier3d/Cargo.toml
+++ b/crates/rapier3d/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier3d"
-version = "0.16.1"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "3-dimensional physics engine in Rust."
documentation = "http://docs.rs/rapier3d"
@@ -51,9 +51,9 @@ required-features = [ "dim3", "f32" ]
vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = [ "now" ], optional = true }
num-traits = "0.2"
-nalgebra = "0.31"
-parry3d = "0.12"
-simba = "0.7"
+nalgebra = "0.32"
+parry3d = "0.13"
+simba = "0.8"
approx = "0.5"
rayon = { version = "1", optional = true }
crossbeam = "0.8"
diff --git a/crates/rapier_testbed2d-f64/Cargo.toml b/crates/rapier_testbed2d-f64/Cargo.toml
index 9ce9bcd..85a0a82 100644
--- a/crates/rapier_testbed2d-f64/Cargo.toml
+++ b/crates/rapier_testbed2d-f64/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier_testbed2d-f64"
-version = "0.16.0"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "Testbed for the Rapier 2-dimensional physics engine in Rust."
homepage = "http://rapier.org"
@@ -28,7 +28,7 @@ other-backends = [ "wrapped2d" ]
features = ["parallel", "other-backends"]
[dependencies]
-nalgebra = { version = "0.31", features = [ "rand" ] }
+nalgebra = { version = "0.32", features = [ "rand" ] }
rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
@@ -40,21 +40,21 @@ bincode = "1"
Inflector = "0.11"
md5 = "0.7"
-bevy_egui = "0.16"
-bevy_ecs = "0.8"
+bevy_egui = "0.18"
+bevy_ecs = "0.9"
#bevy_prototype_debug_lines = "0.7"
# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"
[dependencies.rapier]
package = "rapier2d-f64"
path = "../rapier2d-f64"
-version = "0.16.0"
+version = "0.17.0"
features = [ "serde-serialize", "debug-render", "profiler" ]
diff --git a/crates/rapier_testbed2d/Cargo.toml b/crates/rapier_testbed2d/Cargo.toml
index a1d8141..776edae 100644
--- a/crates/rapier_testbed2d/Cargo.toml
+++ b/crates/rapier_testbed2d/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier_testbed2d"
-version = "0.16.0"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "Testbed for the Rapier 2-dimensional physics engine in Rust."
homepage = "http://rapier.org"
@@ -28,7 +28,7 @@ other-backends = [ "wrapped2d" ]
features = ["parallel", "other-backends"]
[dependencies]
-nalgebra = { version = "0.31", features = [ "rand" ] }
+nalgebra = { version = "0.32", features = [ "rand" ] }
rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
@@ -40,21 +40,21 @@ bincode = "1"
Inflector = "0.11"
md5 = "0.7"
-bevy_egui = "0.16"
-bevy_ecs = "0.8"
+bevy_egui = "0.18"
+bevy_ecs = "0.9"
#bevy_prototype_debug_lines = "0.7"
# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"
[dependencies.rapier]
package = "rapier2d"
path = "../rapier2d"
-version = "0.16.0"
+version = "0.17.0"
features = [ "serde-serialize", "debug-render", "profiler" ]
diff --git a/crates/rapier_testbed3d-f64/Cargo.toml b/crates/rapier_testbed3d-f64/Cargo.toml
index d5760a2..17b29b4 100644
--- a/crates/rapier_testbed3d-f64/Cargo.toml
+++ b/crates/rapier_testbed3d-f64/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier_testbed3d-f64"
-version = "0.16.0"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "Testbed for the Rapier 3-dimensional physics engine in Rust."
homepage = "http://rapier.org"
@@ -27,7 +27,7 @@ parallel = [ "rapier/parallel", "num_cpus" ]
features = ["parallel"]
[dependencies]
-nalgebra = { version = "0.31", features = [ "rand" ] }
+nalgebra = { version = "0.32", features = [ "rand" ] }
rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
@@ -39,21 +39,21 @@ md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }
-bevy_egui = "0.16"
-bevy_ecs = "0.8"
+bevy_egui = "0.18"
+bevy_ecs = "0.9"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"
[dependencies.rapier]
package = "rapier3d-f64"
path = "../rapier3d-f64"
-version = "0.16.0"
+version = "0.17.0"
features = [ "serde-serialize", "debug-render", "profiler" ]
diff --git a/crates/rapier_testbed3d/Cargo.toml b/crates/rapier_testbed3d/Cargo.toml
index 62d5dd1..1f1005f 100644
--- a/crates/rapier_testbed3d/Cargo.toml
+++ b/crates/rapier_testbed3d/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rapier_testbed3d"
-version = "0.16.0"
+version = "0.17.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
description = "Testbed for the Rapier 3-dimensional physics engine in Rust."
homepage = "http://rapier.org"
@@ -28,36 +28,36 @@ other-backends = [ "physx", "physx-sys", "glam" ]
features = ["parallel", "other-backends"]
[dependencies]
-nalgebra = { version = "0.31", features = [ "rand" ] }
+nalgebra = { version = "0.32", features = [ "rand" ] }
rand = "0.8"
rand_pcg = "0.3"
instant = { version = "0.1", features = [ "web-sys", "now" ]}
bitflags = "1"
-glam = { version = "0.12", optional = true }
+glam = { version = "0.20", optional = true } # For Physx
num_cpus = { version = "1", optional = true }
-physx = { version = "0.12", features = [ "glam" ], optional = true }
-physx-sys = { version = "0.4", optional = true }
+physx = { version = "0.16", features = [ "glam" ], optional = true }
+physx-sys = { version = "0.8", optional = true }
crossbeam = "0.8"
bincode = "1"
md5 = "0.7"
Inflector = "0.11"
serde = { version = "1", features = [ "derive" ] }
-bevy_egui = "0.16"
-bevy_ecs = "0.8"
+bevy_egui = "0.18"
+bevy_ecs = "0.9"
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
# Dependencies for native only.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render", "x11"]}
# Dependencies for WASM only.
[target.'cfg(target_arch = "wasm32")'.dependencies]
-bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
+bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "render"]}
#bevy_webgl2 = "0.5"
[dependencies.rapier]
package = "rapier3d"
path = "../rapier3d"
-version = "0.16.0"
+version = "0.17.0"
features = [ "serde-serialize", "debug-render", "profiler" ]
diff --git a/src/dynamics/joint/multibody_joint/multibody.rs b/src/dynamics/joint/multibody_joint/multibody.rs
index 2eb90eb..63e87e2 100644
--- a/src/dynamics/joint/multibody_joint/multibody.rs
+++ b/src/dynamics/joint/multibody_joint/multibody.rs
@@ -11,9 +11,7 @@ use crate::math::{
};
use crate::prelude::MultibodyJoint;
use crate::utils::{IndexMut2, WAngularInertia, WCross, WCrossMatrix};
-use na::{
- self, DMatrix, DVector, DVectorSlice, DVectorSliceMut, Dynamic, OMatrix, SMatrix, SVector, LU,
-};
+use na::{self, DMatrix, DVector, DVectorView, DVectorViewMut, Dyn, OMatrix, SMatrix, SVector, LU};
#[repr(C)]
#[derive(Copy, Clone, Debug, Default)]
@@ -54,7 +52,7 @@ fn concat_rb_mass_matrix(
result[(1, 1)] = mass.y;
result[(2, 2)] = mass.z;
result
- .fixed_slice_mut::<ANG_DIM, ANG_DIM>(DIM, DIM)
+ .fixed_view_mut::<ANG_DIM, ANG_DIM>(DIM, DIM)
.copy_from(&inertia);
result
}
@@ -72,10 +70,10 @@ pub struct Multibody {
body_jacobians: Vec<Jacobian<Real>>,
// TODO: use sparse matrices?
augmented_mass: DMatrix<Real>,
- inv_augmented_mass: LU<Real, Dynamic, Dynamic>,
+ inv_augmented_mass: LU<Real, Dyn, Dyn>,
acc_augmented_mass: DMatrix<Real>,
- acc_inv_augmented_mass: LU<Real, Dynamic, Dynamic>,
+ acc_inv_augmented_mass: LU<Real, Dyn, Dyn>,
ndofs: usize,
pub(crate) root_is_dynamic: bool,
@@ -85,8 +83,8 @@ pub struct Multibody {
* Workspaces.
*/
workspace: MultibodyWorkspace,
- coriolis_v: Vec<OMatrix<Real, Dim, Dynamic>>,
- coriolis_w: Vec<OMatrix<Real, AngDim, Dynamic>>,
+ coriolis_v: Vec<OMatrix<Real, Dim, Dyn>>,
+ coriolis_w: Vec<OMatrix<Real, AngDim, Dyn>>,
i_coriolis_dt: Jacobian<Real>,
}
impl Default for Multibody {
@@ -234,7 +232,7 @@ impl Multibody {
}
/// The inverse augmented mass matrix of this multibody.
- pub fn inv_augmented_mass(&self) -> &LU<Real, Dynamic, Dynamic> {
+ pub fn inv_augmented_mass(&self) -> &LU<Real, Dyn, Dyn> {
&self.inv_augmented_mass
}
@@ -547,11 +545,11 @@ impl Multibody {
if self.coriolis_v.len() != self.links.len() {
self.coriolis_v.resize(
self.links.len(),
- OMatrix::<Real, Dim, Dynamic>::zeros(self.ndofs),
+ OMatrix::<Real, Dim, Dyn>::zeros(self.ndofs),
);
self.coriolis_w.resize(
self.links.len(),
- OMatrix::<Real, AngDim, Dynamic>::zeros(self.ndofs),
+ OMatrix::<Real, AngDim, Dyn>::zeros(self.ndofs),
);
self.i_coriolis_dt = Jacobian::zeros(self.ndofs);
}
@@ -730,9 +728,9 @@ impl Multibody {
/// The generalized velocity at the multibody_joint of the given link.
#[inline]
- pub(crate) fn joint_velocity(&self, link: &MultibodyLink) -> DVectorSlice<Real> {
+ pub(crate) fn joint_velocity(&self, link: &MultibodyLink) -> DVectorView<Real> {
let ndofs = link.joint().ndofs();
- DVectorSlice::from_slice(
+ DVectorView::from_slice(
&self.velocities.as_slice()[link.assembly_id..link.assembly_id + ndofs],
ndofs,
)
@@ -740,19 +738,19 @@ impl Multibody {
/// The generalized accelerations of this multibodies.
#[inline]
- pub fn generalized_acceleration(&self) -> DVectorSlice<Real> {
+ pub fn generalized_acceleration(&self) -> DVectorView<Real> {
self.accelerations.rows(0, self.ndofs)
}
/// The generalized velocities of this multibodies.
#[inline]
- pub fn generalized_velocity(&self) -> DVectorSlice<Real> {
+ pub fn generalized_velocity(&self) -> DVectorView<Real> {
self.velocities.rows(0, self.ndofs)
}
/// The mutable generalized velocities of this multibodies.
#[inline]
- pub fn generalized_velocity_mut(&mut self) -> DVectorSliceMut<Real> {
+ pub fn generalized_velocity_mut(&mut self) -> DVectorViewMut<Real> {
self.velocities.rows_mut(0, self.ndofs)
}
diff --git a/src/dynamics/joint/multibody_joint/multibody_joint.rs b/src/dynamics/joint/multibody_joint/multibody_joint.rs
index c4d9adb..da650e6 100644
--- a/src/dynamics/joint/multibody_joint/multibody_joint.rs
+++ b/src/dynamics/joint/multibody_joint/multibody_joint.rs
@@ -4,10 +4,10 @@ use crate::dynamics::{
RigidBodyVelocity,
};
use crate::math::{
- Isometry, JacobianSliceMut, Real, Rotation, SpacialVector, Translation, Vector, ANG_DIM, DIM,
+ Isometry, JacobianViewMut, Real, Rotation, SpacialVector, Translation, Vector, ANG_DIM, DIM,
SPATIAL_DIM,
};
-use na::{DVector, DVectorSliceMut};
+use na::{DVector, DVectorViewMut};
#[cfg(feature = "dim3")]
use na::{UnitQuaternion, Vector3};
@@ -126,14 +126,14 @@ impl MultibodyJoint {
}
/// Sets in `out` the non-zero entries of the multibody_joint jacobian transformed by `transform`.
- pub fn jacobian(&self, transform: &Rotation<Real>, out: &mut JacobianSliceMut<Real>) {
+ pub fn jacobian(&self, transform: &Rotation<Real>, out: &mut JacobianViewMut<Real>) {
let locked_bits = self.data.locked_axes.bits();
let mut curr_free_dof = 0;
for i in 0..DIM {
if (locked_bits & (1 << i)) == 0 {
let transformed_axis = transform * Vector::ith(i, 1.0);
- out.fixed_slice_mut::<DIM, 1>(0, curr_free_dof)
+ out.fixed_view_mut::<DIM, 1>(0, curr_free_dof)
.copy_from(&transformed_axis);
curr_free_dof += 1;
}
@@ -153,7 +153,7 @@ impl MultibodyJoint {
{
let dof_id = (!locked_ang_bits).trailing_zeros() as usize;
let rotmat = transform.to_rotation_matrix().into_inner();
- out.fixed_slice_mut::<ANG_DIM, 1>(DIM, curr_free_dof)
+ out.fixed_view_mut::<ANG_DIM, 1>(DIM, curr_free_dof)
.copy_from(&rotmat.column(dof_id));
}
}
@@ -163,7 +163,7 @@ impl MultibodyJoint {
#[cfg(feature = "dim3")]
3 => {
let rotmat = transform.to_rotation_matrix();
- out.fixed_slice_mut::<3, 3>(3, curr_free_dof)
+ out.fixed_view_mut::<3, 3>(3, curr_free_dof)
.copy_from(rotmat.matrix());
}
_ => unreachable!(),
@@ -213,7 +213,7 @@ impl MultibodyJoint {
}
/// Fill `out` with the non-zero entries of a damping that can be applied by default to ensure a good stability of the multibody_joint.
- pub fn default_damping(&self, out: &mut DVectorSliceMut<Real>) {
+ pub fn default_damping(&self, out: &mut DVectorViewMut<Real>) {
let locked_bits = self.data.locked_axes.bits();
let mut curr_free_dof = self.num_free_lin_dofs();
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index 78132b2..cd1a0dc 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -158,8 +158,8 @@ impl RigidBody {
/// The mass-properties of this rigid-body.
#[inline]
- pub fn mass_properties(&self) -> &MassProperties {
- &self.mprops.local_mprops
+ pub fn mass_properties(&self) -> &RigidBodyMassProps {
+ &self.mprops
}
/// The dominance group of this rigid-body.
@@ -184,6 +184,12 @@ impl RigidBody {
}
}
+ /// The axes along which this rigid-body cannot translate or rotate.
+ #[inline]
+ pub fn locked_axes(&self) -> LockedAxes {
+ self.mprops.flags
+ }
+
#[inline]
/// Locks or unlocks all the rotations of this rigid-body.
pub fn lock_rotations(&mut self, locked: bool, wake_up: bool) {
diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs
index eb94c6b..89f6020 100644
--- a/src/dynamics/rigid_body_components.rs
+++ b/src/dynamics/rigid_body_components.rs
@@ -245,7 +245,7 @@ impl Default for RigidBodyAdditionalMassProps {
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
-/// The mass properties of this rigid-bodies.
+/// The mass properties of a rigid-body.
pub struct RigidBodyMassProps {
/// Flags for locking rotation and translation.
pub flags: LockedAxes,
diff --git a/src/dynamics/solver/delta_vel.rs b/src/dynamics/solver/delta_vel.rs
index cfdb791..2fc92f0 100644
--- a/src/dynamics/solver/delta_vel.rs
+++ b/src/dynamics/solver/delta_vel.rs
@@ -1,6 +1,6 @@
use crate::math::{AngVector, Vector, SPATIAL_DIM};
use crate::utils::WReal;
-use na::{DVectorSlice, DVectorSliceMut, Scalar};
+use na::{DVectorView, DVectorViewMut, Scalar};
use std::ops::{AddAssign, Sub};
#[derive(Copy, Clone, Debug, Default)]
@@ -20,12 +20,12 @@ impl<N: Scalar + Copy> DeltaVel<N> {
unsafe { std::mem::transmute(self) }
}
- pub fn as_vector_slice(&self) -> DVectorSlice<N> {
- DVectorSlice::from_slice(&self.as_slice()[..], SPATIAL_DIM)
+ pub fn as_vector_slice(&self) -> DVectorView<N> {
+ DVectorView::from_slice(&self.as_slice()[..], SPATIAL_DIM)
}
- pub fn as_vector_slice_mut(&mut self) -> DVectorSliceMut<N> {
- DVectorSliceMut::from_slice(&mut self.as_mut_slice()[..], SPATIAL_DIM)
+ pub fn as_vector_slice_mut(&mut self) -> DVectorViewMut<N> {
+ DVectorViewMut::from_slice(&mut self.as_mut_slice()[..], SPATIAL_DIM)
}
}
diff --git a/src/dynamics/solver/joint_constraint/joint_generic_velocity_constraint.rs b/src/dynamics/solver/joint_constraint/joint_generic_velocity_constraint.rs
index 4f26a73..8c83f58 100644
--- a/src/dynamics/solver/joint_constraint/joint_generic_velocity_constraint.rs
+++ b/src/dynamics/solver/joint_constraint/joint_generic_velocity_constraint.rs
@@ -4,7 +4,7 @@ use crate::dynamics::solver::DeltaVel;
use crate::dynamics::{GenericJoint, IntegrationParameters, JointGraphEdge, JointIndex, Multibody};
use crate::math::{Isometry, Real, DIM};
use crate::prelude::SPATIAL_DIM;
-use na::{DVector, DVectorSlice, DVectorSliceMut};
+use na::{DVector, DVectorView, DVectorViewMut};
#[derive(Debug, Copy, Clone)]
pub struct JointGenericVelocityConstraint {
@@ -222,7 +222,7 @@ impl JointGenericVelocityConstraint {
&self,
mj_lambdas: &'a [DeltaVel<Real>],
generic_mj_lambdas: &'a DVector<Real>,
- ) -> DVectorSlice<'a, Real> {
+ ) -> DVectorView<'a, Real> {
if self.is_rigid_body1 {
mj_lambdas[self.mj_lambda1].as_vector_slice()
} else {
@@ -234,7 +234,7 @@ impl JointGenericVelocityConstraint {
&self,
mj_lambdas: &'a mut [DeltaVel<Real>],
generic_mj_lambdas: &'a mut DVector<Real>,
- ) -> DVectorSliceMut<'a, Real> {
+ ) -> DVectorViewMut<'a, Real> {
if self.is_rigid_body1 {
mj_lambdas[self.mj_lambda1].as_vector_slice_mut()
} else {
@@ -246,7 +246,7 @@ impl JointGenericVelocityConstraint {
&self,
mj_lambdas: &'a [DeltaVel<Real>],
generic_mj_lambdas: &'a DVector<Real>,
- ) -> DVectorSlice<'a, Real> {
+ ) -> DVectorView<'a, Real> {
if self.is_rigid_body2 {
mj_lambdas[self.mj_lambda2].as_vector_slice()
} else {
@@ -258,7 +258,7 @@ impl JointGenericVelocityConstraint {
&self,
mj_lambdas: &'a mut [DeltaVel<Real>],
generic_mj_lambdas: &'a mut DVector<Real>,
- ) -> DVectorSliceMut<'a, Real> {
+ ) -> DVectorViewMut<'a, Real> {
if self.is_rigid_body2 {
mj_lambdas[self.mj_lambda2].as_vector_slice_mut()
} else {
@@ -275,11 +275,11 @@ impl JointGenericVelocityConstraint {
let jacobians = jacobians.as_slice();
let mj_lambda1 = self.mj_lambda1(mj_lambdas, generic_mj_lambdas);
- let j1 = DVectorSlice::from_slice(&jacobians[self.j_id1..], self.ndofs1);
+ let j1 = DVectorView::from_slice(&jacobians[self.j_id1..], self.ndofs1);
let vel1 = j1.dot(&mj_lambda1);
let mj_lambda2 = self.mj_lambda2(mj_lambdas, generic_mj_lambdas);
- let j2 = DVectorSlice::from_slice(&jacobians[self.j_id2..], self.ndofs2);
+ let j2 = DVectorView::from_slice(&jacobians[self.j_id2..], self.ndofs2);
let vel2 = j2.dot(&mj_lambda2);
let dvel = self.rhs + (vel2 - vel1);
@@ -292,11 +292,11 @@ impl JointGenericVelocityConstraint {
self.impulse = total_impulse;
let mut mj_lambda1 = self.mj_lambda1_mut(mj_lambdas, generic_mj_lambdas);
- let wj1 = DVectorSlice::from_slice(&jacobians[self.wj_id1()..], self.ndofs1);
+ let wj1 = DVectorView::from_slice(&jacobians[self.wj_id1()..], self.ndofs1);
mj_lambda1.axpy(delta_impulse, &wj1, 1.0);
let mut mj_lambda2 = self.mj_lambda2_mut(mj_lambdas, generic_mj_lambdas);
- let wj2 = DVectorSlice::from_slice(&jacobians[self.wj_id2()..], self.ndofs2);
+ let wj2 = DVectorView::from_slice(&jacobians[self.wj_id2()..], self.ndofs2);
mj_lambda2.axpy(-delta_impulse, &wj2, 1.0);
}
@@ -506,7 +506,7 @@ impl JointGenericVelocityGroundConstraint {
&self,
_mj_lambdas: &'a [DeltaVel<Real>],
generic_mj_lambdas: &'a DVector<Real>,
- ) -> DVectorSlice<'a, Real> {
+ ) -> DVectorView<'a, Real> {
generic_mj_lambdas.rows(self.mj_lambda2, self.ndofs2)
}
@@ -514,7 +514,7 @@ impl JointGenericVelocityGroundConstraint {
&self,
_mj_lambdas: &'a mut [DeltaVel<Real>],
generic_mj_lambdas: &'a mut DVector<Real>,
- ) -> DVectorSliceMut<'a, Real> {
+ ) -> DVectorViewMut<'a, Real> {
generic_mj_lambdas.rows_mut(self.mj_lambda2, self.ndofs2)
}
@@ -527,7 +527,7 @@ impl JointGenericVelocityGroundConstraint {
let jacobians = jacobians.as_slice();
let mj_lambda2 = self.mj_lambda2(mj_lambdas, generic_mj_lambdas);
- let j2 = DVectorSlice::from_slice(&jacobians[self.j_id2..], self.ndofs2);
+ let j2 = DVectorView::from_slice(&jacobians[self.j_id2..], self.ndofs2);
let vel2 = j2.dot(&mj_lambda2);
let dvel = self.rhs + vel2;
@@ -540,7 +540,7 @@ impl JointGenericVelocityGroundConstraint {
self.impulse = total_impulse;
let mut mj_lambda2 = self.mj_lambda2_mut(mj_lambdas, generic_mj_lambdas);
- let wj2 = DVectorSlice::from_slice(&jacobians[self.wj_id2()..], self.ndofs2);
+ let wj2 = DVectorView::from_slice(&jacobians[self.wj_id2()..], self.ndofs2);
mj_lambda2.axpy(-delta_impulse, &wj2, 1.0);
}
diff --git a/src/lib.rs b/src/lib.rs
index 0c640c7..b863807 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -157,11 +157,11 @@ pub mod math {
/// The type of a slice of the constraint Jacobian in twist coordinates.
#[cfg(feature = "dim2")]
- pub type JacobianSlice<'a, N> = na::MatrixSlice3xX<'a, N>;
+ pub type JacobianView<'a, N> = na::MatrixView3xX<'a, N>;
/// The type of a mutable slice of the constraint Jacobian in twist coordinates.
#[cfg(feature = "dim2")]
- pub type JacobianSliceMut<'a, N> = na::MatrixSliceMut3xX<'a, N>;
+ pub type JacobianViewMut<'a, N> = na::MatrixViewMut3xX<'a, N>;
/// The maximum number of possible rotations and translations of a rigid body.
#[cfg(feature = "dim2")]
@@ -186,11 +186,11 @@ pub mod math {
/// The type of a slice of the constraint Jacobian in twist coordinates.
#[cfg(feature = "dim3")]
- pub type JacobianSlice<'a, N> = na::MatrixSlice6xX<'a, N>;
+ pub type JacobianView<'a, N> = na::MatrixView6xX<'a, N>;
/// The type of a mutable slice of the constraint Jacobian in twist coordinates.
#[cfg(feature = "dim3")]
- pub type JacobianSliceMut<'a, N> = na::MatrixSliceMut6xX<'a, N>;
+ pub type JacobianViewMut<'a, N> = na::MatrixViewMut6xX<'a, N>;
/// The maximum number of possible rotations and translations of a rigid body.
#[cfg(feature = "dim3")]
diff --git a/src_testbed/debug_render.rs b/src_testbed/debug_render.rs
index 047793d..928b8ba 100644
--- a/src_testbed/debug_render.rs
+++ b/src_testbed/debug_render.rs
@@ -6,6 +6,9 @@ use rapier::pipeline::{
DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline,
};
+#[derive(Resource)]
+pub struct DebugRenderPipelineResource(pub DebugRenderPipeline);
+
pub struct RapierDebugRenderPlugin {
depth_test: bool,
}
@@ -23,10 +26,10 @@ impl Plugin for RapierDebugRenderPlugin {
app.add_plugin(crate::lines::DebugLinesPlugin::with_depth_test(
self.depth_test,
))
- .insert_resource(DebugRenderPipeline::new(
+ .insert_resource(DebugRenderPipelineResource(DebugRenderPipeline::new(
Default::default(),
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
- ))
+ )))
.add_system_to_stage(CoreStage::Update, debug_render_scene);
}
}
@@ -57,12 +60,12 @@ impl<'a> DebugRenderBackend for BevyLinesRenderBackend<'a> {
}
fn debug_render_scene(
- mut pipeline: ResMut<DebugRenderPipeline>,
+ mut pipeline: ResMut<DebugRenderPipelineResource>,
harness: NonSend<Harness>,
mut lines: ResMut<DebugLines>,
) {
let mut backend = BevyLinesRenderBackend { lines: &mut *lines };
- pipeline.render(
+ pipeline.0.render(
&mut backend,
&harness.physics.bodies,
&harness.physics.colliders,
diff --git a/src_testbed/lines/mod.rs b/src_testbed/lines/mod.rs
index 3c68110..60d8098 100644
--- a/src_testbed/lines/mod.rs
+++ b/src_testbed/lines/mod.rs
@@ -73,6 +73,7 @@ mod dim {
pub(crate) const DEBUG_LINES_SHADER_HANDLE: HandleUntyped =
HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 17477439189930443325);
+#[derive(Resource)]
pub(crate) struct DebugLinesConfig {
depth_test: bool,
}
@@ -275,7 +276,7 @@ pub(crate) struct RenderDebugLinesMesh;
/// );
/// }
/// ```
-#[derive(Default)]
+#[derive(Default, Resource)]
pub struct DebugLines {
pub positions: Vec<[f32; 3]>,
//pub colors: Vec<[f32; 4]>,
diff --git a/src_testbed/lines/render_dim.rs b/src_testbed/lines/render_dim.rs
index be23321..718cce0 100644
--- a/