From 9b5ccb95e74350d4fb3b4bc2c4c9fbf9fb4943a2 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 15 Jan 2023 11:59:15 +0100 Subject: Update dependencies --- CHANGELOG.md | 2 +- crates/rapier2d-f64/Cargo.toml | 6 +-- crates/rapier2d/Cargo.toml | 6 +-- crates/rapier3d-f64/Cargo.toml | 6 +-- crates/rapier3d/Cargo.toml | 6 +-- crates/rapier_testbed2d-f64/Cargo.toml | 10 ++--- crates/rapier_testbed2d/Cargo.toml | 10 ++--- crates/rapier_testbed3d-f64/Cargo.toml | 10 ++--- crates/rapier_testbed3d/Cargo.toml | 16 ++++---- src/dynamics/joint/multibody_joint/multibody.rs | 30 +++++++-------- .../joint/multibody_joint/multibody_joint.rs | 14 +++---- src/dynamics/solver/delta_vel.rs | 10 ++--- .../joint_generic_velocity_constraint.rs | 26 ++++++------- src/lib.rs | 8 ++-- src_testbed/debug_render.rs | 11 ++++-- src_testbed/lines/mod.rs | 3 +- src_testbed/lines/render_dim.rs | 2 + src_testbed/objects/node.rs | 4 +- src_testbed/testbed.rs | 43 ++++++++++++---------- 19 files changed, 116 insertions(+), 107 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a0acf..1597045 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. diff --git a/crates/rapier2d-f64/Cargo.toml b/crates/rapier2d-f64/Cargo.toml index 60ea169..049c295 100644 --- a/crates/rapier2d-f64/Cargo.toml +++ b/crates/rapier2d-f64/Cargo.toml @@ -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..53a0eb6 100644 --- a/crates/rapier2d/Cargo.toml +++ b/crates/rapier2d/Cargo.toml @@ -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..785a8ee 100644 --- a/crates/rapier3d-f64/Cargo.toml +++ b/crates/rapier3d-f64/Cargo.toml @@ -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..f178c48 100644 --- a/crates/rapier3d/Cargo.toml +++ b/crates/rapier3d/Cargo.toml @@ -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..0d71341 100644 --- a/crates/rapier_testbed2d-f64/Cargo.toml +++ b/crates/rapier_testbed2d-f64/Cargo.toml @@ -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,17 +40,17 @@ 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] diff --git a/crates/rapier_testbed2d/Cargo.toml b/crates/rapier_testbed2d/Cargo.toml index a1d8141..fd30fcc 100644 --- a/crates/rapier_testbed2d/Cargo.toml +++ b/crates/rapier_testbed2d/Cargo.toml @@ -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,17 +40,17 @@ 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] diff --git a/crates/rapier_testbed3d-f64/Cargo.toml b/crates/rapier_testbed3d-f64/Cargo.toml index d5760a2..56941e6 100644 --- a/crates/rapier_testbed3d-f64/Cargo.toml +++ b/crates/rapier_testbed3d-f64/Cargo.toml @@ -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,17 +39,17 @@ 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] diff --git a/crates/rapier_testbed3d/Cargo.toml b/crates/rapier_testbed3d/Cargo.toml index 62d5dd1..2c25a42 100644 --- a/crates/rapier_testbed3d/Cargo.toml +++ b/crates/rapier_testbed3d/Cargo.toml @@ -28,32 +28,32 @@ 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] 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::(DIM, DIM) + .fixed_view_mut::(DIM, DIM) .copy_from(&inertia); result } @@ -72,10 +70,10 @@ pub struct Multibody { body_jacobians: Vec>, // TODO: use sparse matrices? augmented_mass: DMatrix, - inv_augmented_mass: LU, + inv_augmented_mass: LU, acc_augmented_mass: DMatrix, - acc_inv_augmented_mass: LU, + acc_inv_augmented_mass: LU, ndofs: usize, pub(crate) root_is_dynamic: bool, @@ -85,8 +83,8 @@ pub struct Multibody { * Workspaces. */ workspace: MultibodyWorkspace, - coriolis_v: Vec>, - coriolis_w: Vec>, + coriolis_v: Vec>, + coriolis_w: Vec>, i_coriolis_dt: Jacobian, } 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 { + pub fn inv_augmented_mass(&self) -> &LU { &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::::zeros(self.ndofs), + OMatrix::::zeros(self.ndofs), ); self.coriolis_w.resize( self.links.len(), - OMatrix::::zeros(self.ndofs), + OMatrix::::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 { + pub(crate) fn joint_velocity(&self, link: &MultibodyLink) -> DVectorView { 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 { + pub fn generalized_acceleration(&self) -> DVectorView { self.accelerations.rows(0, self.ndofs) } /// The generalized velocities of this multibodies. #[inline] - pub fn generalized_velocity(&self) -> DVectorSlice { + pub fn generalized_velocity(&self) -> DVectorView { self.velocities.rows(0, self.ndofs) } /// The mutable generalized velocities of this multibodies. #[inline] - pub fn generalized_velocity_mut(&mut self) -> DVectorSliceMut { + pub fn generalized_velocity_mut(&mut self) -> DVectorViewMut { 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, out: &mut JacobianSliceMut) { + pub fn jacobian(&self, transform: &Rotation, out: &mut JacobianViewMut) { 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::(0, curr_free_dof) + out.fixed_view_mut::(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::(DIM, curr_free_dof) + out.fixed_view_mut::(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) { + pub fn default_damping(&self, out: &mut DVectorViewMut) { let locked_bits = self.data.locked_axes.bits(); let mut curr_free_dof = self.num_free_lin_dofs(); 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 DeltaVel { unsafe { std::mem::transmute(self) } } - pub fn as_vector_slice(&self) -> DVectorSlice { - DVectorSlice::from_slice(&self.as_slice()[..], SPATIAL_DIM) + pub fn as_vector_slice(&self) -> DVectorView { + DVectorView::from_slice(&self.as_slice()[..], SPATIAL_DIM) } - pub fn as_vector_slice_mut(&mut self) -> DVectorSliceMut { - DVectorSliceMut::from_slice(&mut self.as_mut_slice()[..], SPATIAL_DIM) + pub fn as_vector_slice_mut(&mut self) -> DVectorViewMut { + 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], generic_mj_lambdas: &'a DVector, - ) -> 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], generic_mj_lambdas: &'a mut DVector, - ) -> 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], generic_mj_lambdas: &'a DVector, - ) -> 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], generic_mj_lambdas: &'a mut DVector, - ) -> 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], generic_mj_lambdas: &'a DVector, - ) -> 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], generic_mj_lambdas: &'a mut DVector, - ) -> 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, + mut pipeline: ResMut, harness: NonSend, mut lines: ResMut, ) { 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/src_testbed/lines/render_dim.rs +++ b/src_testbed/lines/render_dim.rs @@ -26,6 +26,7 @@ pub mod r3d { use crate::lines::{DebugLinesConfig, RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE}; + #[derive(Resource)] pub(crate) struct DebugLinePipeline { mesh_pipeline: MeshPipeline, shader: Handle, @@ -208,6 +209,7 @@ pub mod r2d { use crate::lines::{RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE}; + #[derive(Resource)] pub(crate) struct DebugLinePipeline { mesh_pipeline: Mesh2dPipeline, shader: Handle, diff --git a/src_testbed/objects/node.rs b/src_testbed/objects/node.rs index ba7a2aa..f4b9015 100644 --- a/src_testbed/objects/node.rs +++ b/src_testbed/objects/node.rs @@ -44,7 +44,7 @@ impl EntityWithGraphics { color: Point3, sensor: bool, ) -> Self { - let entity = commands.spawn().id(); + let entity = commands.spawn_empty().id(); let scale = collider_mesh_scale(shape); let mesh = prefab_meshs @@ -108,7 +108,7 @@ impl EntityWithGraphics { }; let mut entity_commands = commands.entity(entity); - entity_commands.insert_bundle(bundle); + entity_commands.insert(bundle); if sensor { entity_commands.insert(Wireframe); diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs index 1052c55..775175d 100644 --- a/src_testbed/testbed.rs +++ b/src_testbed/testbed.rs @@ -97,6 +97,7 @@ bitflags! { } } +#[derive(Resource)] pub struct TestbedState { pub running: RunMode, pub draw_colls: bool, @@ -122,6 +123,7 @@ pub struct TestbedState { camera_locked: bool, // Used so that the camera can remain the same before and after we change backend or press the restart button. } +#[derive(Resource)] struct SceneBuilders(Vec<(&'static str, fn(&mut Testbed))>); #[cfg(feature = "other-backends")] @@ -369,23 +371,26 @@ impl TestbedApp { "Rapier: 3D demos".to_string() }; - let mut app = App::new(); - - app.insert_resource(WindowDescriptor { - title, - ..Default::default() - }) - .insert_resource(ClearColor(Color::rgb(0.15, 0.15, 0.15))) - .insert_resource(Msaa { samples: 4 }) - .insert_resource(AmbientLight { - brightness: 0.3, + let window_plugin = WindowPlugin { + window: WindowDescriptor { + title, + ..Default::default() + }, ..Default::default() - }) - .add_plugins(DefaultPlugins) - .add_plugin(OrbitCameraPlugin) - .add_plugin(WireframePlugin) - .add_plugin(bevy_egui::EguiPlugin) - .add_plugin(debug_render::RapierDebugRenderPlugin::default()); + }; + + let mut app = App::new(); + app.insert_resource(ClearColor(Color::rgb(0.15, 0.15, 0.15))) + .insert_resource(Msaa { samples: 4 }) + .insert_resource(AmbientLight { + brightness: 0.3, + ..Default::default() + }) + .add_plugins(DefaultPlugins.set(window_plugin)) + .add_plugin(OrbitCameraPlugin) + .add_plugin(WireframePlugin) + .add_plugin(bevy_egui::EguiPlugin) + .add_plugin(debug_render::RapierDebugRenderPlugin::default()); #[cfg(target_arch = "wasm32")] app.add_plugin(bevy_webgl2::WebGL2Plugin); @@ -995,7 +1000,7 @@ fn draw_contacts(_nf: &NarrowPhase, _colliders: &ColliderSet) { fn setup_graphics_environment(mut commands: Commands) { const HALF_SIZE: f32 = 100.0; - commands.spawn_bundle(DirectionalLightBundle { + commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { illuminance: 10000.0, // Configure the projection to better fit the scene @@ -1020,7 +1025,7 @@ fn setup_graphics_environment(mut commands: Commands) { }); commands - .spawn_bundle(Camera3dBundle { + .spawn(Camera3dBundle { transform: Transform::from_matrix( Mat4::look_at_rh( Vec3::new(-30.0, 30.0, 100.0), @@ -1053,7 +1058,7 @@ fn setup_graphics_environment(mut commands: Commands) { // ..Default::default() // }); commands - .spawn_bundle(Camera2dBundle { + .spawn(Camera2dBundle { transform: Transform { translation: Vec3::new(0.0, 0.0, 0.0), rotation: Quat::IDENTITY, -- cgit From d2ebb25c227e239aa283b989cf560bf3739a1c39 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 15 Jan 2023 12:23:32 +0100 Subject: Add accessor to get the locked axes of a rigid-body --- src/dynamics/rigid_body.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 78132b2..b850f66 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -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) { -- cgit From 89fc31f996b43a274337b1632673e6142e1fe621 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 15 Jan 2023 12:23:16 +0100 Subject: Give access to the world-space mass properties of rigid-bodies --- src/dynamics/rigid_body.rs | 4 ++-- src/dynamics/rigid_body_components.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index b850f66..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. 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, -- cgit From 3f5c0335e45a75ba435ef7dee3d203b11ec072d0 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 15 Jan 2023 12:16:58 +0100 Subject: Release v0.17.0 --- CHANGELOG.md | 2 ++ crates/rapier2d-f64/Cargo.toml | 2 +- crates/rapier2d/Cargo.toml | 2 +- crates/rapier3d-f64/Cargo.toml | 2 +- crates/rapier3d/Cargo.toml | 2 +- crates/rapier_testbed2d-f64/Cargo.toml | 4 ++-- crates/rapier_testbed2d/Cargo.toml | 4 ++-- crates/rapier_testbed3d-f64/Cargo.toml | 4 ++-- crates/rapier_testbed3d/Cargo.toml | 4 ++-- 9 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1597045..97b97f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 049c295..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 " ] description = "2-dimensional physics engine in Rust." documentation = "http://docs.rs/rapier2d" diff --git a/crates/rapier2d/Cargo.toml b/crates/rapier2d/Cargo.toml index 53a0eb6..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 " ] description = "2-dimensional physics engine in Rust." documentation = "http://docs.rs/rapier2d" diff --git a/crates/rapier3d-f64/Cargo.toml b/crates/rapier3d-f64/Cargo.toml index 785a8ee..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 " ] description = "3-dimensional physics engine in Rust." documentation = "http://docs.rs/rapier3d" diff --git a/crates/rapier3d/Cargo.toml b/crates/rapier3d/Cargo.toml index f178c48..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 " ] description = "3-dimensional physics engine in Rust." documentation = "http://docs.rs/rapier3d" diff --git a/crates/rapier_testbed2d-f64/Cargo.toml b/crates/rapier_testbed2d-f64/Cargo.toml index 0d71341..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 " ] description = "Testbed for the Rapier 2-dimensional physics engine in Rust." homepage = "http://rapier.org" @@ -56,5 +56,5 @@ bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "re [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 fd30fcc..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 " ] description = "Testbed for the Rapier 2-dimensional physics engine in Rust." homepage = "http://rapier.org" @@ -56,5 +56,5 @@ bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "re [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 56941e6..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 " ] description = "Testbed for the Rapier 3-dimensional physics engine in Rust." homepage = "http://rapier.org" @@ -55,5 +55,5 @@ bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "re [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 2c25a42..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 " ] description = "Testbed for the Rapier 3-dimensional physics engine in Rust." homepage = "http://rapier.org" @@ -59,5 +59,5 @@ bevy = {version = "0.9", default-features = false, features = ["bevy_winit", "re [dependencies.rapier] package = "rapier3d" path = "../rapier3d" -version = "0.16.0" +version = "0.17.0" features = [ "serde-serialize", "debug-render", "profiler" ] -- cgit