diff -r d8c4fd911b37 -r 24828281c9c5 rust/hwphysics/src/grid.rs --- a/rust/hwphysics/src/grid.rs Wed Jul 24 23:37:58 2019 +0300 +++ b/rust/hwphysics/src/grid.rs Thu Jul 25 00:05:30 2019 +0300 @@ -114,16 +114,24 @@ pub fn check_collisions(&self, collisions: &mut DetectedCollisions) { for bin in &self.bins { - for bounds in &bin.dynamic_entries { - for other in &bin.dynamic_entries { + for (index, bounds) in bin.dynamic_entries.iter().enumerate() { + for (other_index, other) in bin.dynamic_entries.iter().enumerate().skip(index + 1) { if bounds.intersects(other) && bounds != other { - collisions.push(0, 0, &bounds.center) + collisions.push( + bin.dynamic_refs[index], + Some(bin.dynamic_refs[other_index]), + &bounds.center, + ) } } - for other in &bin.static_entries { + for (other_index, other) in bin.static_entries.iter().enumerate() { if bounds.intersects(other) { - collisions.push(0, 0, &bounds.center) + collisions.push( + bin.dynamic_refs[index], + Some(bin.static_refs[other_index]), + &bounds.center, + ) } } }