Fix crash in broad-phase after shape modification.

Fix #180 and #177
This commit is contained in:
Crozet Sébastien
2021-05-01 10:21:00 +02:00
parent 2dfbd9ae92
commit f350ac35d9
2 changed files with 6 additions and 1 deletions

View File

@@ -369,6 +369,7 @@ impl BroadPhase {
// We need to promote the proxy to the bigger layer. // We need to promote the proxy to the bigger layer.
layer_id = self.ensure_layer_exists(new_layer_depth); layer_id = self.ensure_layer_exists(new_layer_depth);
self.proxies[*proxy_index].layer_id = layer_id; self.proxies[*proxy_index].layer_id = layer_id;
self.proxies[*proxy_index].layer_depth = new_layer_depth;
} }
} }

View File

@@ -90,7 +90,11 @@ impl SAPRegion {
/// ///
/// Returns `true` if this region contained the proxy. Returns `false` otherwise. /// Returns `true` if this region contained the proxy. Returns `false` otherwise.
pub fn proper_proxy_moved_to_a_bigger_layer(&mut self, proxy_id: SAPProxyIndex) -> bool { pub fn proper_proxy_moved_to_a_bigger_layer(&mut self, proxy_id: SAPProxyIndex) -> bool {
if self.existing_proxies[proxy_id as usize] { if self.existing_proxies.get(proxy_id as usize) == Some(true) {
// NOTE: we are just registering the fact that that proxy isn't a
// subproper proxy anymore. But it is still part of this region
// so we must not set `self.existing_proxies[proxy_id] = false`
// nor delete its endpoints.
self.subproper_proxy_count -= 1; self.subproper_proxy_count -= 1;
true true
} else { } else {