diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-01-23 08:56:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-23 08:56:27 -0800 |
| commit | 1608a1323ed76cdf33644cfea599cea715acf7a9 (patch) | |
| tree | 07b975a2b22b31f74a5efcbaa3d2a30aea31ae47 /src_testbed/objects/node.rs | |
| parent | ca635674fc72071d7ff546a749ac22766579b280 (diff) | |
| parent | b3b675d2de64d4437748ad46e41cca90c691de1a (diff) | |
| download | rapier-1608a1323ed76cdf33644cfea599cea715acf7a9.tar.gz rapier-1608a1323ed76cdf33644cfea599cea715acf7a9.tar.bz2 rapier-1608a1323ed76cdf33644cfea599cea715acf7a9.zip | |
Merge pull request #282 from dimforge/critical-damping
Improve the CFM implementation
Diffstat (limited to 'src_testbed/objects/node.rs')
| -rw-r--r-- | src_testbed/objects/node.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src_testbed/objects/node.rs b/src_testbed/objects/node.rs index 45a77db..6a4807f 100644 --- a/src_testbed/objects/node.rs +++ b/src_testbed/objects/node.rs @@ -10,7 +10,7 @@ use bevy::render::render_resource::PrimitiveTopology; use rapier::geometry::{ColliderHandle, ColliderSet, Shape, ShapeType}; #[cfg(feature = "dim3")] use rapier::geometry::{Cone, Cylinder}; -use rapier::math::{Isometry, Real}; +use rapier::math::{Isometry, Real, Vector}; use crate::graphics::BevyMaterial; #[cfg(feature = "dim2")] @@ -168,15 +168,20 @@ impl EntityWithGraphics { self.base_color = color; } - pub fn update(&mut self, colliders: &ColliderSet, components: &mut Query<(&mut Transform,)>) { + pub fn update( + &mut self, + colliders: &ColliderSet, + components: &mut Query<(&mut Transform,)>, + gfx_shift: &Vector<Real>, + ) { if let Some(Some(co)) = self.collider.map(|c| colliders.get(c)) { if let Ok(mut pos) = components.get_component_mut::<Transform>(self.entity) { let co_pos = co.position() * self.delta; - pos.translation.x = co_pos.translation.vector.x as f32; - pos.translation.y = co_pos.translation.vector.y as f32; + pos.translation.x = (co_pos.translation.vector.x + gfx_shift.x) as f32; + pos.translation.y = (co_pos.translation.vector.y + gfx_shift.y) as f32; #[cfg(feature = "dim3")] { - pos.translation.z = co_pos.translation.vector.z as f32; + pos.translation.z = (co_pos.translation.vector.z + gfx_shift.z) as f32; pos.rotation = Quat::from_xyzw( co_pos.rotation.i as f32, co_pos.rotation.j as f32, |
