diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-04-19 18:57:40 +0200 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2022-04-20 19:02:49 +0200 |
| commit | 2b1374c596957ac8cabe085859be3b823a1ba0c6 (patch) | |
| tree | a7f37ec29199a5a2c6198a6b001e665524fdab96 /src/dynamics/rigid_body_set.rs | |
| parent | ee679427cda6363e4de94a59e293d01133a44d1f (diff) | |
| download | rapier-2b1374c596957ac8cabe085859be3b823a1ba0c6.tar.gz rapier-2b1374c596957ac8cabe085859be3b823a1ba0c6.tar.bz2 rapier-2b1374c596957ac8cabe085859be3b823a1ba0c6.zip | |
First round deleting the component sets.
Diffstat (limited to 'src/dynamics/rigid_body_set.rs')
| -rw-r--r-- | src/dynamics/rigid_body_set.rs | 68 |
1 files changed, 7 insertions, 61 deletions
diff --git a/src/dynamics/rigid_body_set.rs b/src/dynamics/rigid_body_set.rs index a75d96d..62a6a54 100644 --- a/src/dynamics/rigid_body_set.rs +++ b/src/dynamics/rigid_body_set.rs @@ -1,11 +1,6 @@ -use crate::data::{Arena, ComponentSet, ComponentSetMut, ComponentSetOption}; +use crate::data::Arena; use crate::dynamics::{ - ImpulseJointSet, RigidBody, RigidBodyCcd, RigidBodyChanges, RigidBodyDamping, RigidBodyForces, - RigidBodyIds, RigidBodyMassProps, RigidBodyPosition, RigidBodyVelocity, -}; -use crate::dynamics::{ - IslandManager, MultibodyJointSet, RigidBodyActivation, RigidBodyColliders, RigidBodyDominance, - RigidBodyHandle, RigidBodyType, + ImpulseJointSet, IslandManager, MultibodyJointSet, RigidBody, RigidBodyChanges, RigidBodyHandle, }; use crate::geometry::ColliderSet; use std::ops::{Index, IndexMut}; @@ -39,59 +34,6 @@ pub struct RigidBodySet { pub(crate) modified_bodies: Vec<RigidBodyHandle>, } -macro_rules! impl_field_component_set( - ($T: ty, $field: ident) => { - impl ComponentSetOption<$T> for RigidBodySet { - fn get(&self, handle: crate::data::Index) -> Option<&$T> { - self.get(RigidBodyHandle(handle)).map(|b| &b.$field) - } - } - - impl ComponentSet<$T> for RigidBodySet { - fn size_hint(&self) -> usize { - self.len() - } - - #[inline(always)] - fn for_each(&self, mut f: impl FnMut(crate::data::Index, &$T)) { - for (handle, body) in self.bodies.iter() { - f(handle, &body.$field) - } - } - } - - impl ComponentSetMut<$T> for RigidBodySet { - fn set_internal(&mut self, handle: crate::data::Index, val: $T) { - if let Some(rb) = self.get_mut_internal(RigidBodyHandle(handle)) { - rb.$field = val; - } - } - - #[inline(always)] - fn map_mut_internal<Result>( - &mut self, - handle: crate::data::Index, - f: impl FnOnce(&mut $T) -> Result, - ) -> Option<Result> { - self.get_mut_internal(RigidBodyHandle(handle)).map(|rb| f(&mut rb.$field)) - } - } - } -); - -impl_field_component_set!(RigidBodyPosition, rb_pos); -impl_field_component_set!(RigidBodyMassProps, rb_mprops); -impl_field_component_set!(RigidBodyVelocity, rb_vels); -impl_field_component_set!(RigidBodyDamping, rb_damping); -impl_field_component_set!(RigidBodyForces, rb_forces); -impl_field_component_set!(RigidBodyCcd, rb_ccd); -impl_field_component_set!(RigidBodyIds, rb_ids); -impl_field_component_set!(RigidBodyType, rb_type); -impl_field_component_set!(RigidBodyActivation, rb_activation); -impl_field_component_set!(RigidBodyColliders, rb_colliders); -impl_field_component_set!(RigidBodyDominance, rb_dominance); -impl_field_component_set!(RigidBodyChanges, changes); - impl RigidBodySet { /// Create a new empty set of rigid bodies. pub fn new() -> Self { @@ -147,7 +89,7 @@ impl RigidBodySet { /* * Update active sets. */ - islands.rigid_body_removed(handle, &rb.rb_ids, self); + islands.rigid_body_removed(handle, &rb.ids, self); /* * Remove colliders attached to this rigid-body. @@ -233,6 +175,10 @@ impl RigidBodySet { self.bodies.get_mut(handle.0) } + pub(crate) fn index_mut_internal(&mut self, handle: RigidBodyHandle) -> &mut RigidBody { + &mut self.bodies[handle.0] + } + // Just a very long name instead of `.get_mut` to make sure // this is really the method we wanted to use instead of `get_mut_internal`. pub(crate) fn get_mut_internal_with_modification_tracking( |
