Update dependencies
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
## Unreleased
|
## v0.17.0 (15 Jan. 2022)
|
||||||
### Added
|
### Added
|
||||||
- Add `RigidBody::set_enabled`, `RigidBody::is_enabled`, `RigidBodyBuilder::enabled` to enable/disable a rigid-body
|
- 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.
|
without having to delete it. Disabling a rigid-body attached to a multibody joint isn’t supported yet.
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ required-features = [ "dim2", "f64" ]
|
|||||||
vec_map = { version = "0.8", optional = true }
|
vec_map = { version = "0.8", optional = true }
|
||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.32"
|
||||||
parry2d-f64 = "0.12"
|
parry2d-f64 = "0.13"
|
||||||
simba = "0.7"
|
simba = "0.8"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
crossbeam = "0.8"
|
crossbeam = "0.8"
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ required-features = [ "dim2", "f32" ]
|
|||||||
vec_map = { version = "0.8", optional = true }
|
vec_map = { version = "0.8", optional = true }
|
||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.32"
|
||||||
parry2d = "0.12"
|
parry2d = "0.13"
|
||||||
simba = "0.7"
|
simba = "0.8"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
crossbeam = "0.8"
|
crossbeam = "0.8"
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ required-features = [ "dim3", "f64" ]
|
|||||||
vec_map = { version = "0.8", optional = true }
|
vec_map = { version = "0.8", optional = true }
|
||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.32"
|
||||||
parry3d-f64 = "0.12"
|
parry3d-f64 = "0.13"
|
||||||
simba = "0.7"
|
simba = "0.8"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
crossbeam = "0.8"
|
crossbeam = "0.8"
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ required-features = [ "dim3", "f32" ]
|
|||||||
vec_map = { version = "0.8", optional = true }
|
vec_map = { version = "0.8", optional = true }
|
||||||
instant = { version = "0.1", features = [ "now" ], optional = true }
|
instant = { version = "0.1", features = [ "now" ], optional = true }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
nalgebra = "0.31"
|
nalgebra = "0.32"
|
||||||
parry3d = "0.12"
|
parry3d = "0.13"
|
||||||
simba = "0.7"
|
simba = "0.8"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rayon = { version = "1", optional = true }
|
rayon = { version = "1", optional = true }
|
||||||
crossbeam = "0.8"
|
crossbeam = "0.8"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ other-backends = [ "wrapped2d" ]
|
|||||||
features = ["parallel", "other-backends"]
|
features = ["parallel", "other-backends"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = { version = "0.31", features = [ "rand" ] }
|
nalgebra = { version = "0.32", features = [ "rand" ] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_pcg = "0.3"
|
rand_pcg = "0.3"
|
||||||
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
||||||
@@ -40,17 +40,17 @@ bincode = "1"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
md5 = "0.7"
|
md5 = "0.7"
|
||||||
|
|
||||||
bevy_egui = "0.16"
|
bevy_egui = "0.18"
|
||||||
bevy_ecs = "0.8"
|
bevy_ecs = "0.9"
|
||||||
#bevy_prototype_debug_lines = "0.7"
|
#bevy_prototype_debug_lines = "0.7"
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[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.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[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"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ other-backends = [ "wrapped2d" ]
|
|||||||
features = ["parallel", "other-backends"]
|
features = ["parallel", "other-backends"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = { version = "0.31", features = [ "rand" ] }
|
nalgebra = { version = "0.32", features = [ "rand" ] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_pcg = "0.3"
|
rand_pcg = "0.3"
|
||||||
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
||||||
@@ -40,17 +40,17 @@ bincode = "1"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
md5 = "0.7"
|
md5 = "0.7"
|
||||||
|
|
||||||
bevy_egui = "0.16"
|
bevy_egui = "0.18"
|
||||||
bevy_ecs = "0.8"
|
bevy_ecs = "0.9"
|
||||||
#bevy_prototype_debug_lines = "0.7"
|
#bevy_prototype_debug_lines = "0.7"
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[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.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[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"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ parallel = [ "rapier/parallel", "num_cpus" ]
|
|||||||
features = ["parallel"]
|
features = ["parallel"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = { version = "0.31", features = [ "rand" ] }
|
nalgebra = { version = "0.32", features = [ "rand" ] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_pcg = "0.3"
|
rand_pcg = "0.3"
|
||||||
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
||||||
@@ -39,17 +39,17 @@ md5 = "0.7"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
serde = { version = "1", features = [ "derive" ] }
|
serde = { version = "1", features = [ "derive" ] }
|
||||||
|
|
||||||
bevy_egui = "0.16"
|
bevy_egui = "0.18"
|
||||||
bevy_ecs = "0.8"
|
bevy_ecs = "0.9"
|
||||||
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[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.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[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"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -28,32 +28,32 @@ other-backends = [ "physx", "physx-sys", "glam" ]
|
|||||||
features = ["parallel", "other-backends"]
|
features = ["parallel", "other-backends"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = { version = "0.31", features = [ "rand" ] }
|
nalgebra = { version = "0.32", features = [ "rand" ] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_pcg = "0.3"
|
rand_pcg = "0.3"
|
||||||
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
instant = { version = "0.1", features = [ "web-sys", "now" ]}
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
glam = { version = "0.12", optional = true }
|
glam = { version = "0.20", optional = true } # For Physx
|
||||||
num_cpus = { version = "1", optional = true }
|
num_cpus = { version = "1", optional = true }
|
||||||
physx = { version = "0.12", features = [ "glam" ], optional = true }
|
physx = { version = "0.16", features = [ "glam" ], optional = true }
|
||||||
physx-sys = { version = "0.4", optional = true }
|
physx-sys = { version = "0.8", optional = true }
|
||||||
crossbeam = "0.8"
|
crossbeam = "0.8"
|
||||||
bincode = "1"
|
bincode = "1"
|
||||||
md5 = "0.7"
|
md5 = "0.7"
|
||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
serde = { version = "1", features = [ "derive" ] }
|
serde = { version = "1", features = [ "derive" ] }
|
||||||
|
|
||||||
bevy_egui = "0.16"
|
bevy_egui = "0.18"
|
||||||
bevy_ecs = "0.8"
|
bevy_ecs = "0.9"
|
||||||
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[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.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[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"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ use crate::math::{
|
|||||||
};
|
};
|
||||||
use crate::prelude::MultibodyJoint;
|
use crate::prelude::MultibodyJoint;
|
||||||
use crate::utils::{IndexMut2, WAngularInertia, WCross, WCrossMatrix};
|
use crate::utils::{IndexMut2, WAngularInertia, WCross, WCrossMatrix};
|
||||||
use na::{
|
use na::{self, DMatrix, DVector, DVectorView, DVectorViewMut, Dyn, OMatrix, SMatrix, SVector, LU};
|
||||||
self, DMatrix, DVector, DVectorSlice, DVectorSliceMut, Dynamic, OMatrix, SMatrix, SVector, LU,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
@@ -54,7 +52,7 @@ fn concat_rb_mass_matrix(
|
|||||||
result[(1, 1)] = mass.y;
|
result[(1, 1)] = mass.y;
|
||||||
result[(2, 2)] = mass.z;
|
result[(2, 2)] = mass.z;
|
||||||
result
|
result
|
||||||
.fixed_slice_mut::<ANG_DIM, ANG_DIM>(DIM, DIM)
|
.fixed_view_mut::<ANG_DIM, ANG_DIM>(DIM, DIM)
|
||||||
.copy_from(&inertia);
|
.copy_from(&inertia);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
@@ -72,10 +70,10 @@ pub struct Multibody {
|
|||||||
body_jacobians: Vec<Jacobian<Real>>,
|
body_jacobians: Vec<Jacobian<Real>>,
|
||||||
// TODO: use sparse matrices?
|
// TODO: use sparse matrices?
|
||||||
augmented_mass: DMatrix<Real>,
|
augmented_mass: DMatrix<Real>,
|
||||||
inv_augmented_mass: LU<Real, Dynamic, Dynamic>,
|
inv_augmented_mass: LU<Real, Dyn, Dyn>,
|
||||||
|
|
||||||
acc_augmented_mass: DMatrix<Real>,
|
acc_augmented_mass: DMatrix<Real>,
|
||||||
acc_inv_augmented_mass: LU<Real, Dynamic, Dynamic>,
|
acc_inv_augmented_mass: LU<Real, Dyn, Dyn>,
|
||||||
|
|
||||||
ndofs: usize,
|
ndofs: usize,
|
||||||
pub(crate) root_is_dynamic: bool,
|
pub(crate) root_is_dynamic: bool,
|
||||||
@@ -85,8 +83,8 @@ pub struct Multibody {
|
|||||||
* Workspaces.
|
* Workspaces.
|
||||||
*/
|
*/
|
||||||
workspace: MultibodyWorkspace,
|
workspace: MultibodyWorkspace,
|
||||||
coriolis_v: Vec<OMatrix<Real, Dim, Dynamic>>,
|
coriolis_v: Vec<OMatrix<Real, Dim, Dyn>>,
|
||||||
coriolis_w: Vec<OMatrix<Real, AngDim, Dynamic>>,
|
coriolis_w: Vec<OMatrix<Real, AngDim, Dyn>>,
|
||||||
i_coriolis_dt: Jacobian<Real>,
|
i_coriolis_dt: Jacobian<Real>,
|
||||||
}
|
}
|
||||||
impl Default for Multibody {
|
impl Default for Multibody {
|
||||||
@@ -234,7 +232,7 @@ impl Multibody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The inverse augmented mass matrix of this 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
|
&self.inv_augmented_mass
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,11 +545,11 @@ impl Multibody {
|
|||||||
if self.coriolis_v.len() != self.links.len() {
|
if self.coriolis_v.len() != self.links.len() {
|
||||||
self.coriolis_v.resize(
|
self.coriolis_v.resize(
|
||||||
self.links.len(),
|
self.links.len(),
|
||||||
OMatrix::<Real, Dim, Dynamic>::zeros(self.ndofs),
|
OMatrix::<Real, Dim, Dyn>::zeros(self.ndofs),
|
||||||
);
|
);
|
||||||
self.coriolis_w.resize(
|
self.coriolis_w.resize(
|
||||||
self.links.len(),
|
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);
|
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.
|
/// The generalized velocity at the multibody_joint of the given link.
|
||||||
#[inline]
|
#[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();
|
let ndofs = link.joint().ndofs();
|
||||||
DVectorSlice::from_slice(
|
DVectorView::from_slice(
|
||||||
&self.velocities.as_slice()[link.assembly_id..link.assembly_id + ndofs],
|
&self.velocities.as_slice()[link.assembly_id..link.assembly_id + ndofs],
|
||||||
ndofs,
|
ndofs,
|
||||||
)
|
)
|
||||||
@@ -740,19 +738,19 @@ impl Multibody {
|
|||||||
|
|
||||||
/// The generalized accelerations of this multibodies.
|
/// The generalized accelerations of this multibodies.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn generalized_acceleration(&self) -> DVectorSlice<Real> {
|
pub fn generalized_acceleration(&self) -> DVectorView<Real> {
|
||||||
self.accelerations.rows(0, self.ndofs)
|
self.accelerations.rows(0, self.ndofs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The generalized velocities of this multibodies.
|
/// The generalized velocities of this multibodies.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn generalized_velocity(&self) -> DVectorSlice<Real> {
|
pub fn generalized_velocity(&self) -> DVectorView<Real> {
|
||||||
self.velocities.rows(0, self.ndofs)
|
self.velocities.rows(0, self.ndofs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The mutable generalized velocities of this multibodies.
|
/// The mutable generalized velocities of this multibodies.
|
||||||
#[inline]
|
#[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)
|
self.velocities.rows_mut(0, self.ndofs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ use crate::dynamics::{
|
|||||||
RigidBodyVelocity,
|
RigidBodyVelocity,
|
||||||
};
|
};
|
||||||
use crate::math::{
|
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,
|
SPATIAL_DIM,
|
||||||
};
|
};
|
||||||
use na::{DVector, DVectorSliceMut};
|
use na::{DVector, DVectorViewMut};
|
||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
use na::{UnitQuaternion, Vector3};
|
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`.
|
/// 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 locked_bits = self.data.locked_axes.bits();
|
||||||
let mut curr_free_dof = 0;
|
let mut curr_free_dof = 0;
|
||||||
|
|
||||||
for i in 0..DIM {
|
for i in 0..DIM {
|
||||||
if (locked_bits & (1 << i)) == 0 {
|
if (locked_bits & (1 << i)) == 0 {
|
||||||
let transformed_axis = transform * Vector::ith(i, 1.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);
|
.copy_from(&transformed_axis);
|
||||||
curr_free_dof += 1;
|
curr_free_dof += 1;
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ impl MultibodyJoint {
|
|||||||
{
|
{
|
||||||
let dof_id = (!locked_ang_bits).trailing_zeros() as usize;
|
let dof_id = (!locked_ang_bits).trailing_zeros() as usize;
|
||||||
let rotmat = transform.to_rotation_matrix().into_inner();
|
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));
|
.copy_from(&rotmat.column(dof_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ impl MultibodyJoint {
|
|||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
3 => {
|
3 => {
|
||||||
let rotmat = transform.to_rotation_matrix();
|
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());
|
.copy_from(rotmat.matrix());
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => 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.
|
/// 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 locked_bits = self.data.locked_axes.bits();
|
||||||
let mut curr_free_dof = self.num_free_lin_dofs();
|
let mut curr_free_dof = self.num_free_lin_dofs();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::math::{AngVector, Vector, SPATIAL_DIM};
|
use crate::math::{AngVector, Vector, SPATIAL_DIM};
|
||||||
use crate::utils::WReal;
|
use crate::utils::WReal;
|
||||||
use na::{DVectorSlice, DVectorSliceMut, Scalar};
|
use na::{DVectorView, DVectorViewMut, Scalar};
|
||||||
use std::ops::{AddAssign, Sub};
|
use std::ops::{AddAssign, Sub};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
@@ -20,12 +20,12 @@ impl<N: Scalar + Copy> DeltaVel<N> {
|
|||||||
unsafe { std::mem::transmute(self) }
|
unsafe { std::mem::transmute(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_vector_slice(&self) -> DVectorSlice<N> {
|
pub fn as_vector_slice(&self) -> DVectorView<N> {
|
||||||
DVectorSlice::from_slice(&self.as_slice()[..], SPATIAL_DIM)
|
DVectorView::from_slice(&self.as_slice()[..], SPATIAL_DIM)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_vector_slice_mut(&mut self) -> DVectorSliceMut<N> {
|
pub fn as_vector_slice_mut(&mut self) -> DVectorViewMut<N> {
|
||||||
DVectorSliceMut::from_slice(&mut self.as_mut_slice()[..], SPATIAL_DIM)
|
DVectorViewMut::from_slice(&mut self.as_mut_slice()[..], SPATIAL_DIM)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::dynamics::solver::DeltaVel;
|
|||||||
use crate::dynamics::{GenericJoint, IntegrationParameters, JointGraphEdge, JointIndex, Multibody};
|
use crate::dynamics::{GenericJoint, IntegrationParameters, JointGraphEdge, JointIndex, Multibody};
|
||||||
use crate::math::{Isometry, Real, DIM};
|
use crate::math::{Isometry, Real, DIM};
|
||||||
use crate::prelude::SPATIAL_DIM;
|
use crate::prelude::SPATIAL_DIM;
|
||||||
use na::{DVector, DVectorSlice, DVectorSliceMut};
|
use na::{DVector, DVectorView, DVectorViewMut};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct JointGenericVelocityConstraint {
|
pub struct JointGenericVelocityConstraint {
|
||||||
@@ -222,7 +222,7 @@ impl JointGenericVelocityConstraint {
|
|||||||
&self,
|
&self,
|
||||||
mj_lambdas: &'a [DeltaVel<Real>],
|
mj_lambdas: &'a [DeltaVel<Real>],
|
||||||
generic_mj_lambdas: &'a DVector<Real>,
|
generic_mj_lambdas: &'a DVector<Real>,
|
||||||
) -> DVectorSlice<'a, Real> {
|
) -> DVectorView<'a, Real> {
|
||||||
if self.is_rigid_body1 {
|
if self.is_rigid_body1 {
|
||||||
mj_lambdas[self.mj_lambda1].as_vector_slice()
|
mj_lambdas[self.mj_lambda1].as_vector_slice()
|
||||||
} else {
|
} else {
|
||||||
@@ -234,7 +234,7 @@ impl JointGenericVelocityConstraint {
|
|||||||
&self,
|
&self,
|
||||||
mj_lambdas: &'a mut [DeltaVel<Real>],
|
mj_lambdas: &'a mut [DeltaVel<Real>],
|
||||||
generic_mj_lambdas: &'a mut DVector<Real>,
|
generic_mj_lambdas: &'a mut DVector<Real>,
|
||||||
) -> DVectorSliceMut<'a, Real> {
|
) -> DVectorViewMut<'a, Real> {
|
||||||
if self.is_rigid_body1 {
|
if self.is_rigid_body1 {
|
||||||
mj_lambdas[self.mj_lambda1].as_vector_slice_mut()
|
mj_lambdas[self.mj_lambda1].as_vector_slice_mut()
|
||||||
} else {
|
} else {
|
||||||
@@ -246,7 +246,7 @@ impl JointGenericVelocityConstraint {
|
|||||||
&self,
|
&self,
|
||||||
mj_lambdas: &'a [DeltaVel<Real>],
|
mj_lambdas: &'a [DeltaVel<Real>],
|
||||||
generic_mj_lambdas: &'a DVector<Real>,
|
generic_mj_lambdas: &'a DVector<Real>,
|
||||||
) -> DVectorSlice<'a, Real> {
|
) -> DVectorView<'a, Real> {
|
||||||
if self.is_rigid_body2 {
|
if self.is_rigid_body2 {
|
||||||
mj_lambdas[self.mj_lambda2].as_vector_slice()
|
mj_lambdas[self.mj_lambda2].as_vector_slice()
|
||||||
} else {
|
} else {
|
||||||
@@ -258,7 +258,7 @@ impl JointGenericVelocityConstraint {
|
|||||||
&self,
|
&self,
|
||||||
mj_lambdas: &'a mut [DeltaVel<Real>],
|
mj_lambdas: &'a mut [DeltaVel<Real>],
|
||||||
generic_mj_lambdas: &'a mut DVector<Real>,
|
generic_mj_lambdas: &'a mut DVector<Real>,
|
||||||
) -> DVectorSliceMut<'a, Real> {
|
) -> DVectorViewMut<'a, Real> {
|
||||||
if self.is_rigid_body2 {
|
if self.is_rigid_body2 {
|
||||||
mj_lambdas[self.mj_lambda2].as_vector_slice_mut()
|
mj_lambdas[self.mj_lambda2].as_vector_slice_mut()
|
||||||
} else {
|
} else {
|
||||||
@@ -275,11 +275,11 @@ impl JointGenericVelocityConstraint {
|
|||||||
let jacobians = jacobians.as_slice();
|
let jacobians = jacobians.as_slice();
|
||||||
|
|
||||||
let mj_lambda1 = self.mj_lambda1(mj_lambdas, generic_mj_lambdas);
|
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 vel1 = j1.dot(&mj_lambda1);
|
||||||
|
|
||||||
let mj_lambda2 = self.mj_lambda2(mj_lambdas, generic_mj_lambdas);
|
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 vel2 = j2.dot(&mj_lambda2);
|
||||||
|
|
||||||
let dvel = self.rhs + (vel2 - vel1);
|
let dvel = self.rhs + (vel2 - vel1);
|
||||||
@@ -292,11 +292,11 @@ impl JointGenericVelocityConstraint {
|
|||||||
self.impulse = total_impulse;
|
self.impulse = total_impulse;
|
||||||
|
|
||||||
let mut mj_lambda1 = self.mj_lambda1_mut(mj_lambdas, generic_mj_lambdas);
|
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);
|
mj_lambda1.axpy(delta_impulse, &wj1, 1.0);
|
||||||
|
|
||||||
let mut mj_lambda2 = self.mj_lambda2_mut(mj_lambdas, generic_mj_lambdas);
|
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);
|
mj_lambda2.axpy(-delta_impulse, &wj2, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ impl JointGenericVelocityGroundConstraint {
|
|||||||
&self,
|
&self,
|
||||||
_mj_lambdas: &'a [DeltaVel<Real>],
|
_mj_lambdas: &'a [DeltaVel<Real>],
|
||||||
generic_mj_lambdas: &'a DVector<Real>,
|
generic_mj_lambdas: &'a DVector<Real>,
|
||||||
) -> DVectorSlice<'a, Real> {
|
) -> DVectorView<'a, Real> {
|
||||||
generic_mj_lambdas.rows(self.mj_lambda2, self.ndofs2)
|
generic_mj_lambdas.rows(self.mj_lambda2, self.ndofs2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,7 +514,7 @@ impl JointGenericVelocityGroundConstraint {
|
|||||||
&self,
|
&self,
|
||||||
_mj_lambdas: &'a mut [DeltaVel<Real>],
|
_mj_lambdas: &'a mut [DeltaVel<Real>],
|
||||||
generic_mj_lambdas: &'a mut DVector<Real>,
|
generic_mj_lambdas: &'a mut DVector<Real>,
|
||||||
) -> DVectorSliceMut<'a, Real> {
|
) -> DVectorViewMut<'a, Real> {
|
||||||
generic_mj_lambdas.rows_mut(self.mj_lambda2, self.ndofs2)
|
generic_mj_lambdas.rows_mut(self.mj_lambda2, self.ndofs2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,7 +527,7 @@ impl JointGenericVelocityGroundConstraint {
|
|||||||
let jacobians = jacobians.as_slice();
|
let jacobians = jacobians.as_slice();
|
||||||
|
|
||||||
let mj_lambda2 = self.mj_lambda2(mj_lambdas, generic_mj_lambdas);
|
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 vel2 = j2.dot(&mj_lambda2);
|
||||||
|
|
||||||
let dvel = self.rhs + vel2;
|
let dvel = self.rhs + vel2;
|
||||||
@@ -540,7 +540,7 @@ impl JointGenericVelocityGroundConstraint {
|
|||||||
self.impulse = total_impulse;
|
self.impulse = total_impulse;
|
||||||
|
|
||||||
let mut mj_lambda2 = self.mj_lambda2_mut(mj_lambdas, generic_mj_lambdas);
|
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);
|
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.
|
/// The type of a slice of the constraint Jacobian in twist coordinates.
|
||||||
#[cfg(feature = "dim2")]
|
#[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.
|
/// The type of a mutable slice of the constraint Jacobian in twist coordinates.
|
||||||
#[cfg(feature = "dim2")]
|
#[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.
|
/// The maximum number of possible rotations and translations of a rigid body.
|
||||||
#[cfg(feature = "dim2")]
|
#[cfg(feature = "dim2")]
|
||||||
@@ -186,11 +186,11 @@ pub mod math {
|
|||||||
|
|
||||||
/// The type of a slice of the constraint Jacobian in twist coordinates.
|
/// The type of a slice of the constraint Jacobian in twist coordinates.
|
||||||
#[cfg(feature = "dim3")]
|
#[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.
|
/// The type of a mutable slice of the constraint Jacobian in twist coordinates.
|
||||||
#[cfg(feature = "dim3")]
|
#[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.
|
/// The maximum number of possible rotations and translations of a rigid body.
|
||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ use rapier::pipeline::{
|
|||||||
DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline,
|
DebugRenderBackend, DebugRenderMode, DebugRenderObject, DebugRenderPipeline,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct DebugRenderPipelineResource(pub DebugRenderPipeline);
|
||||||
|
|
||||||
pub struct RapierDebugRenderPlugin {
|
pub struct RapierDebugRenderPlugin {
|
||||||
depth_test: bool,
|
depth_test: bool,
|
||||||
}
|
}
|
||||||
@@ -23,10 +26,10 @@ impl Plugin for RapierDebugRenderPlugin {
|
|||||||
app.add_plugin(crate::lines::DebugLinesPlugin::with_depth_test(
|
app.add_plugin(crate::lines::DebugLinesPlugin::with_depth_test(
|
||||||
self.depth_test,
|
self.depth_test,
|
||||||
))
|
))
|
||||||
.insert_resource(DebugRenderPipeline::new(
|
.insert_resource(DebugRenderPipelineResource(DebugRenderPipeline::new(
|
||||||
Default::default(),
|
Default::default(),
|
||||||
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
|
!DebugRenderMode::RIGID_BODY_AXES & !DebugRenderMode::COLLIDER_AABBS,
|
||||||
))
|
)))
|
||||||
.add_system_to_stage(CoreStage::Update, debug_render_scene);
|
.add_system_to_stage(CoreStage::Update, debug_render_scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,12 +60,12 @@ impl<'a> DebugRenderBackend for BevyLinesRenderBackend<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn debug_render_scene(
|
fn debug_render_scene(
|
||||||
mut pipeline: ResMut<DebugRenderPipeline>,
|
mut pipeline: ResMut<DebugRenderPipelineResource>,
|
||||||
harness: NonSend<Harness>,
|
harness: NonSend<Harness>,
|
||||||
mut lines: ResMut<DebugLines>,
|
mut lines: ResMut<DebugLines>,
|
||||||
) {
|
) {
|
||||||
let mut backend = BevyLinesRenderBackend { lines: &mut *lines };
|
let mut backend = BevyLinesRenderBackend { lines: &mut *lines };
|
||||||
pipeline.render(
|
pipeline.0.render(
|
||||||
&mut backend,
|
&mut backend,
|
||||||
&harness.physics.bodies,
|
&harness.physics.bodies,
|
||||||
&harness.physics.colliders,
|
&harness.physics.colliders,
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ mod dim {
|
|||||||
pub(crate) const DEBUG_LINES_SHADER_HANDLE: HandleUntyped =
|
pub(crate) const DEBUG_LINES_SHADER_HANDLE: HandleUntyped =
|
||||||
HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 17477439189930443325);
|
HandleUntyped::weak_from_u64(Shader::TYPE_UUID, 17477439189930443325);
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
pub(crate) struct DebugLinesConfig {
|
pub(crate) struct DebugLinesConfig {
|
||||||
depth_test: bool,
|
depth_test: bool,
|
||||||
}
|
}
|
||||||
@@ -275,7 +276,7 @@ pub(crate) struct RenderDebugLinesMesh;
|
|||||||
/// );
|
/// );
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Default)]
|
#[derive(Default, Resource)]
|
||||||
pub struct DebugLines {
|
pub struct DebugLines {
|
||||||
pub positions: Vec<[f32; 3]>,
|
pub positions: Vec<[f32; 3]>,
|
||||||
//pub colors: Vec<[f32; 4]>,
|
//pub colors: Vec<[f32; 4]>,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub mod r3d {
|
|||||||
|
|
||||||
use crate::lines::{DebugLinesConfig, RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE};
|
use crate::lines::{DebugLinesConfig, RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE};
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
pub(crate) struct DebugLinePipeline {
|
pub(crate) struct DebugLinePipeline {
|
||||||
mesh_pipeline: MeshPipeline,
|
mesh_pipeline: MeshPipeline,
|
||||||
shader: Handle<Shader>,
|
shader: Handle<Shader>,
|
||||||
@@ -208,6 +209,7 @@ pub mod r2d {
|
|||||||
|
|
||||||
use crate::lines::{RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE};
|
use crate::lines::{RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE};
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
pub(crate) struct DebugLinePipeline {
|
pub(crate) struct DebugLinePipeline {
|
||||||
mesh_pipeline: Mesh2dPipeline,
|
mesh_pipeline: Mesh2dPipeline,
|
||||||
shader: Handle<Shader>,
|
shader: Handle<Shader>,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ impl EntityWithGraphics {
|
|||||||
color: Point3<f32>,
|
color: Point3<f32>,
|
||||||
sensor: bool,
|
sensor: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let entity = commands.spawn().id();
|
let entity = commands.spawn_empty().id();
|
||||||
|
|
||||||
let scale = collider_mesh_scale(shape);
|
let scale = collider_mesh_scale(shape);
|
||||||
let mesh = prefab_meshs
|
let mesh = prefab_meshs
|
||||||
@@ -108,7 +108,7 @@ impl EntityWithGraphics {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut entity_commands = commands.entity(entity);
|
let mut entity_commands = commands.entity(entity);
|
||||||
entity_commands.insert_bundle(bundle);
|
entity_commands.insert(bundle);
|
||||||
|
|
||||||
if sensor {
|
if sensor {
|
||||||
entity_commands.insert(Wireframe);
|
entity_commands.insert(Wireframe);
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ bitflags! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
pub struct TestbedState {
|
pub struct TestbedState {
|
||||||
pub running: RunMode,
|
pub running: RunMode,
|
||||||
pub draw_colls: bool,
|
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.
|
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))>);
|
struct SceneBuilders(Vec<(&'static str, fn(&mut Testbed))>);
|
||||||
|
|
||||||
#[cfg(feature = "other-backends")]
|
#[cfg(feature = "other-backends")]
|
||||||
@@ -369,23 +371,26 @@ impl TestbedApp {
|
|||||||
"Rapier: 3D demos".to_string()
|
"Rapier: 3D demos".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut app = App::new();
|
let window_plugin = WindowPlugin {
|
||||||
|
window: WindowDescriptor {
|
||||||
|
title,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
app.insert_resource(WindowDescriptor {
|
let mut app = App::new();
|
||||||
title,
|
app.insert_resource(ClearColor(Color::rgb(0.15, 0.15, 0.15)))
|
||||||
..Default::default()
|
.insert_resource(Msaa { samples: 4 })
|
||||||
})
|
.insert_resource(AmbientLight {
|
||||||
.insert_resource(ClearColor(Color::rgb(0.15, 0.15, 0.15)))
|
brightness: 0.3,
|
||||||
.insert_resource(Msaa { samples: 4 })
|
..Default::default()
|
||||||
.insert_resource(AmbientLight {
|
})
|
||||||
brightness: 0.3,
|
.add_plugins(DefaultPlugins.set(window_plugin))
|
||||||
..Default::default()
|
.add_plugin(OrbitCameraPlugin)
|
||||||
})
|
.add_plugin(WireframePlugin)
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugin(bevy_egui::EguiPlugin)
|
||||||
.add_plugin(OrbitCameraPlugin)
|
.add_plugin(debug_render::RapierDebugRenderPlugin::default());
|
||||||
.add_plugin(WireframePlugin)
|
|
||||||
.add_plugin(bevy_egui::EguiPlugin)
|
|
||||||
.add_plugin(debug_render::RapierDebugRenderPlugin::default());
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
app.add_plugin(bevy_webgl2::WebGL2Plugin);
|
app.add_plugin(bevy_webgl2::WebGL2Plugin);
|
||||||
@@ -995,7 +1000,7 @@ fn draw_contacts(_nf: &NarrowPhase, _colliders: &ColliderSet) {
|
|||||||
fn setup_graphics_environment(mut commands: Commands) {
|
fn setup_graphics_environment(mut commands: Commands) {
|
||||||
const HALF_SIZE: f32 = 100.0;
|
const HALF_SIZE: f32 = 100.0;
|
||||||
|
|
||||||
commands.spawn_bundle(DirectionalLightBundle {
|
commands.spawn(DirectionalLightBundle {
|
||||||
directional_light: DirectionalLight {
|
directional_light: DirectionalLight {
|
||||||
illuminance: 10000.0,
|
illuminance: 10000.0,
|
||||||
// Configure the projection to better fit the scene
|
// Configure the projection to better fit the scene
|
||||||
@@ -1020,7 +1025,7 @@ fn setup_graphics_environment(mut commands: Commands) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(Camera3dBundle {
|
.spawn(Camera3dBundle {
|
||||||
transform: Transform::from_matrix(
|
transform: Transform::from_matrix(
|
||||||
Mat4::look_at_rh(
|
Mat4::look_at_rh(
|
||||||
Vec3::new(-30.0, 30.0, 100.0),
|
Vec3::new(-30.0, 30.0, 100.0),
|
||||||
@@ -1053,7 +1058,7 @@ fn setup_graphics_environment(mut commands: Commands) {
|
|||||||
// ..Default::default()
|
// ..Default::default()
|
||||||
// });
|
// });
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(Camera2dBundle {
|
.spawn(Camera2dBundle {
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
translation: Vec3::new(0.0, 0.0, 0.0),
|
translation: Vec3::new(0.0, 0.0, 0.0),
|
||||||
rotation: Quat::IDENTITY,
|
rotation: Quat::IDENTITY,
|
||||||
|
|||||||
Reference in New Issue
Block a user