aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorBruce Mitchener <bruce.mitchener@gmail.com>2024-09-16 21:45:14 +0700
committerGitHub <noreply@github.com>2024-09-16 16:45:14 +0200
commite7e196d9f949a03ef997f0adc629344c3696b1ff (patch)
treeca94d10a0a789e2cd1a2007a016a72339c9f247b /src/geometry
parentc714ff81f2be61f433d0521bc56ba44ce0e71298 (diff)
downloadrapier-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/geometry')
-rw-r--r--src/geometry/collider_set.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/geometry/collider_set.rs b/src/geometry/collider_set.rs
index 3934472..7a2b6aa 100644
--- a/src/geometry/collider_set.rs
+++ b/src/geometry/collider_set.rs
@@ -23,6 +23,17 @@ impl ColliderSet {
}
}
+ /// Create a new set of colliders, with an initial capacity
+ /// for the set of colliders as well as the tracking of
+ /// modified colliders.
+ pub fn with_capacity(capacity: usize) -> Self {
+ ColliderSet {
+ colliders: Arena::with_capacity(capacity),
+ modified_colliders: Vec::with_capacity(capacity),
+ removed_colliders: Vec::new(),
+ }
+ }
+
pub(crate) fn take_modified(&mut self) -> Vec<ColliderHandle> {
std::mem::take(&mut self.modified_colliders)
}