diff options
| author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2024-09-16 21:45:14 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-16 16:45:14 +0200 |
| commit | e7e196d9f949a03ef997f0adc629344c3696b1ff (patch) | |
| tree | ca94d10a0a789e2cd1a2007a016a72339c9f247b /src/dynamics | |
| parent | c714ff81f2be61f433d0521bc56ba44ce0e71298 (diff) | |
| download | rapier-e7e196d9f949a03ef997f0adc629344c3696b1ff.tar.gz rapier-e7e196d9f949a03ef997f0adc629344c3696b1ff.tar.bz2 rapier-e7e196d9f949a03ef997f0adc629344c3696b1ff.zip | |
Improve capacity handling for `ColliderSet`, `RigidBodySet`. (#726)
These allow an application to reduce the cost of reallocation when
they know that a large number of colliders or rigid bodies will
be created.
Diffstat (limited to 'src/dynamics')
| -rw-r--r-- | src/dynamics/rigid_body_set.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body_set.rs b/src/dynamics/rigid_body_set.rs index 2ef91be..3145300 100644 --- a/src/dynamics/rigid_body_set.rs +++ b/src/dynamics/rigid_body_set.rs @@ -43,6 +43,14 @@ impl RigidBodySet { } } + /// Create a new set of rigid bodies, with an initial capacity. + pub fn with_capacity(capacity: usize) -> Self { + RigidBodySet { + bodies: Arena::with_capacity(capacity), + modified_bodies: Vec::with_capacity(capacity), + } + } + pub(crate) fn take_modified(&mut self) -> Vec<RigidBodyHandle> { std::mem::take(&mut self.modified_bodies) } |
