diff options
| author | Sébastien Crozet <developer@crozet.re> | 2023-01-15 11:59:15 +0100 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2023-01-15 12:17:10 +0100 |
| commit | 9b5ccb95e74350d4fb3b4bc2c4c9fbf9fb4943a2 (patch) | |
| tree | 5ccfe3e37b2fb11ed1c99d97afe245460865afb3 | |
| parent | 56aa0f5e732a2f810b5c1d5834905791f542cf48 (diff) | |
| download | rapier-9b5ccb95e74350d4fb3b4bc2c4c9fbf9fb4943a2.tar.gz rapier-9b5ccb95e74350d4fb3b4bc2c4c9fbf9fb4943a2.tar.bz2 rapier-9b5ccb95e74350d4fb3b4bc2c4c9fbf9fb4943a2.zip | |
Update dependencies
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | crates/rapier2d-f64/Cargo.toml | 6 | ||||
| -rw-r--r-- | crates/rapier2d/Cargo.toml | 6 | ||||
| -rw-r--r-- | crates/rapier3d-f64/Cargo.toml | 6 | ||||
| -rw-r--r-- | crates/rapier3d/Cargo.toml | 6 | ||||
| -rw-r--r-- | crates/rapier_testbed2d-f64/Cargo.toml | 10 | ||||
| -rw-r--r-- | crates/rapier_testbed2d/Cargo.toml | 10 | ||||
| -rw-r--r-- | crates/rapier_testbed3d-f64/Cargo.toml | 10 | ||||
| -rw-r--r-- | crates/rapier_testbed3d/Cargo.toml | 16 | ||||
| -rw-r--r-- | src/dynamics/joint/multibody_joint/multibody.rs | 30 | ||||
| -rw-r--r-- | src/dynamics/joint/multibody_joint/multibody_joint.rs | 14 | ||||
| -rw-r--r-- | src/dynamics/solver/delta_vel.rs | 10 | ||||
| -rw-r--r-- | src/dynamics/solver/joint_constraint/joint_generic_velocity_constraint.rs | 26 | ||||
| -rw-r--r-- | src/lib.rs | 8 | ||||
| -rw-r--r-- | src_testbed/debug_render.rs | 11 | ||||
| -rw-r--r-- | src_testbed/lines/mod.rs | 3 | ||||
| -rw-r--r-- | src_testbed/lines/render_dim.rs | 2 | ||||
| -rw-r--r-- | src_testbed/objects/node.rs | 4 | ||||
| -rw-r--r-- | 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::<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/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); } @@ -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/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<Shader>, @@ -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<Shader>, 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<f32>, 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() |
