aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/rigid_body_components.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-04-19 18:57:40 +0200
committerSébastien Crozet <sebastien@crozet.re>2022-04-20 19:02:49 +0200
commit2b1374c596957ac8cabe085859be3b823a1ba0c6 (patch)
treea7f37ec29199a5a2c6198a6b001e665524fdab96 /src/dynamics/rigid_body_components.rs
parentee679427cda6363e4de94a59e293d01133a44d1f (diff)
downloadrapier-2b1374c596957ac8cabe085859be3b823a1ba0c6.tar.gz
rapier-2b1374c596957ac8cabe085859be3b823a1ba0c6.tar.bz2
rapier-2b1374c596957ac8cabe085859be3b823a1ba0c6.zip
First round deleting the component sets.
Diffstat (limited to 'src/dynamics/rigid_body_components.rs')
-rw-r--r--src/dynamics/rigid_body_components.rs39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs
index b8f88ef..c7655e0 100644
--- a/src/dynamics/rigid_body_components.rs
+++ b/src/dynamics/rigid_body_components.rs
@@ -1,8 +1,7 @@
-use crate::data::{BundleSet, ComponentSet, ComponentSetMut, ComponentSetOption};
use crate::dynamics::MassProperties;
use crate::geometry::{
ColliderChanges, ColliderHandle, ColliderMassProps, ColliderParent, ColliderPosition,
- ColliderShape,
+ ColliderSet, ColliderShape,
};
use crate::math::{
AngVector, AngularInertia, Isometry, Point, Real, Rotation, Translation, Vector,
@@ -295,16 +294,12 @@ impl RigidBodyMassProps {
}
/// Recompute the mass-properties of this rigid-bodies based on its currentely attached colliders.
- pub fn recompute_mass_properties_from_colliders<Colliders>(
+ pub fn recompute_mass_properties_from_colliders(
&mut self,
- colliders: &Colliders,
+ colliders: &ColliderSet,
attached_colliders: &RigidBodyColliders,
position: &Isometry<Real>,
- ) where
- Colliders: ComponentSetOption<ColliderParent>
- + ComponentSet<ColliderMassProps>
- + ComponentSet<ColliderShape>,
- {
+ ) {
self.local_mprops = self
.additional_local_mprops
.as_ref()
@@ -312,14 +307,14 @@ impl RigidBodyMassProps {
.unwrap_or_else(MassProperties::default);
for handle in &attached_colliders.0 {
- let co_parent: Option<&ColliderParent> = colliders.get(handle.0);
- if let Some(co_parent) = co_parent {
- let (co_mprops, co_shape): (&ColliderMassProps, &ColliderShape) =
- colliders.index_bundle(handle.0);
- let to_add = co_mprops
- .mass_properties(&**co_shape)
- .transform_by(&co_parent.pos_wrt_parent);
- self.local_mprops += to_add;
+ if let Some(co) = colliders.get(handle) {
+ if let Some(co_parent) = co.parent {
+ let to_add = co
+ .mprops
+ .mass_properties(&**co.shape)
+ .transform_by(&co_parent.pos_wrt_parent);
+ self.local_mprops += to_add;
+ }
}
}
@@ -892,16 +887,12 @@ impl RigidBodyColliders {
}
/// Update the positions of all the colliders attached to this rigid-body.
- pub fn update_positions<Colliders>(
+ pub fn update_positions(
&self,
- colliders: &mut Colliders,
+ colliders: &mut ColliderSet,
modified_colliders: &mut Vec<ColliderHandle>,
parent_pos: &Isometry<Real>,
- ) where
- Colliders: ComponentSetMut<ColliderPosition>
- + ComponentSetMut<ColliderChanges>
- + ComponentSetOption<ColliderParent>,
- {
+ ) {
for handle in &self.0 {
// NOTE: the ColliderParent component must exist if we enter this method.
let co_parent: &ColliderParent = colliders