diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-03-26 18:16:27 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-03-26 18:16:27 +0100 |
| commit | 97157c9423f3360c5e941b4065377689221014ae (patch) | |
| tree | 707adf6e1feab0a9b7752d292baa161de790a8a1 /src/data | |
| parent | 326469a1df9d8502903d88fe8e47a67e9e7c9edd (diff) | |
| download | rapier-97157c9423f3360c5e941b4065377689221014ae.tar.gz rapier-97157c9423f3360c5e941b4065377689221014ae.tar.bz2 rapier-97157c9423f3360c5e941b4065377689221014ae.zip | |
First working version of non-linear CCD based on single-substep motion-clamping.
Diffstat (limited to 'src/data')
| -rw-r--r-- | src/data/coarena.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/data/coarena.rs b/src/data/coarena.rs index 78cbfa7..c25cc55 100644 --- a/src/data/coarena.rs +++ b/src/data/coarena.rs @@ -29,6 +29,20 @@ impl<T> Coarena<T> { .and_then(|(gg, t)| if g == *gg { Some(t) } else { None }) } + /// Inserts an element into this coarena. + pub fn insert(&mut self, a: Index, value: T) + where + T: Clone + Default, + { + let (i1, g1) = a.into_raw_parts(); + + if self.data.len() <= i1 { + self.data.resize(i1 + 1, (u32::MAX as u64, T::default())); + } + + self.data[i1] = (g1, value); + } + /// Ensure that elements at the two given indices exist in this coarena, and return their reference. /// /// Missing elements are created automatically and initialized with the `default` value. |
