rust/hwphysics/src/grid.rs
changeset 15263 24828281c9c5
parent 15262 d8c4fd911b37
child 15273 bfd185ad03e7
equal deleted inserted replaced
15262:d8c4fd911b37 15263:24828281c9c5
   112         }
   112         }
   113     }
   113     }
   114 
   114 
   115     pub fn check_collisions(&self, collisions: &mut DetectedCollisions) {
   115     pub fn check_collisions(&self, collisions: &mut DetectedCollisions) {
   116         for bin in &self.bins {
   116         for bin in &self.bins {
   117             for bounds in &bin.dynamic_entries {
   117             for (index, bounds) in bin.dynamic_entries.iter().enumerate() {
   118                 for other in &bin.dynamic_entries {
   118                 for (other_index, other) in bin.dynamic_entries.iter().enumerate().skip(index + 1) {
   119                     if bounds.intersects(other) && bounds != other {
   119                     if bounds.intersects(other) && bounds != other {
   120                         collisions.push(0, 0, &bounds.center)
   120                         collisions.push(
       
   121                             bin.dynamic_refs[index],
       
   122                             Some(bin.dynamic_refs[other_index]),
       
   123                             &bounds.center,
       
   124                         )
   121                     }
   125                     }
   122                 }
   126                 }
   123 
   127 
   124                 for other in &bin.static_entries {
   128                 for (other_index, other) in bin.static_entries.iter().enumerate() {
   125                     if bounds.intersects(other) {
   129                     if bounds.intersects(other) {
   126                         collisions.push(0, 0, &bounds.center)
   130                         collisions.push(
       
   131                             bin.dynamic_refs[index],
       
   132                             Some(bin.static_refs[other_index]),
       
   133                             &bounds.center,
       
   134                         )
   127                     }
   135                     }
   128                 }
   136                 }
   129             }
   137             }
   130         }
   138         }
   131     }
   139     }