Browse Source

better handle single-element units in Structure.eachUnitPair

Alexander Rose 2 years ago
parent
commit
42239c305f
2 changed files with 3 additions and 1 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 1
      src/mol-model/structure/structure/structure.ts

+ 2 - 0
CHANGELOG.md

@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
 
 ## [Unreleased]
 
+- Fix edge-case in `Structure.eachUnitPair` with single-element units
+
 ## [v3.25.0] - 2022-11-16
 
 - Fix handling of gzipped assets (reverts #615)

+ 1 - 1
src/mol-model/structure/structure/structure.ts

@@ -1224,7 +1224,7 @@ namespace Structure {
             const closeUnits = lookup.findUnitIndices(imageCenter[0], imageCenter[1], imageCenter[2], bs.radius + maxRadius);
             for (let i = 0; i < closeUnits.count; i++) {
                 const other = structure.units[closeUnits.indices[i]];
-                if (!Box3D.overlaps(bbox, other.boundary.box)) continue;
+                if (other.elements.length > 3 && !Box3D.overlaps(bbox, other.boundary.box)) continue;
                 if (!validUnit(other) || unit.id >= other.id || !validUnitPair(unit, other)) continue;
 
                 if (other.elements.length >= unit.elements.length) callback(unit, other);