diff options
| author | Robert Hrusecky <robert.hrusecky@utexas.edu> | 2020-10-05 23:20:03 -0500 |
|---|---|---|
| committer | Robert Hrusecky <robert.hrusecky@utexas.edu> | 2020-10-05 23:20:03 -0500 |
| commit | c25c5c5192d843d96d300aa3c4d711a43f709c54 (patch) | |
| tree | 9f4c9e03742b28d4485e5519ca8a1bc459ca1c8e /src | |
| parent | d7ff0826d2b1f0243aa1b54589796c66775f4f0c (diff) | |
| download | rapier-c25c5c5192d843d96d300aa3c4d711a43f709c54.tar.gz rapier-c25c5c5192d843d96d300aa3c4d711a43f709c54.tar.bz2 rapier-c25c5c5192d843d96d300aa3c4d711a43f709c54.zip | |
Bug fix: newly empty regions not updating
SAPRegions which became empty in the last frame need to be updated one
more time in order to remove the last proxy.
Diffstat (limited to 'src')
| -rw-r--r-- | src/geometry/broad_phase_multi_sap.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/geometry/broad_phase_multi_sap.rs b/src/geometry/broad_phase_multi_sap.rs index db588cf..84e05d9 100644 --- a/src/geometry/broad_phase_multi_sap.rs +++ b/src/geometry/broad_phase_multi_sap.rs @@ -303,7 +303,7 @@ struct SAPRegion { existing_proxies: BitVec, #[cfg_attr(feature = "serde-serialize", serde(skip))] to_insert: Vec<usize>, // Workspace - need_update: bool, + update_count: usize, proxy_count: usize, } @@ -319,7 +319,7 @@ impl SAPRegion { axii, existing_proxies: BitVec::new(), to_insert: Vec::new(), - need_update: false, + update_count: 0, proxy_count: 0, } } @@ -328,7 +328,7 @@ impl SAPRegion { // We keep the proxy_id as argument for uniformity with the "preupdate" // method. However we don't actually need it because the deletion will be // handled transparently during the next update. - self.need_update = true; + self.update_count = 1; } pub fn preupdate_proxy(&mut self, proxy_id: usize) -> bool { @@ -343,13 +343,16 @@ impl SAPRegion { self.proxy_count += 1; false } else { - self.need_update = true; + // Here we need a second update if all proxies exit this region. In this case, we need + // to delete the final proxy, but the region may not have AABBs overlapping it, so it + // wouldn't get an update otherwise. + self.update_count = 2; true } } pub fn update(&mut self, proxies: &Proxies, reporting: &mut HashMap<(u32, u32), bool>) { - if self.need_update { + if self.update_count > 0 { // Update endpoints. let mut deleted = 0; for dim in 0..DIM { @@ -364,7 +367,7 @@ impl SAPRegion { } } - self.need_update = false; + self.update_count -= 1; } if !self.to_insert.is_empty() { |
