Browse Source

fixed bug in SortedArray.hashCode & possible bug in UnitsVisual.prepareUpdate

David Sehnal 6 years ago
parent
commit
47055f4ce0

+ 1 - 1
src/mol-data/int/impl/sorted-array.ts

@@ -32,7 +32,7 @@ export function hashCode(xs: Nums) {
     // hash of tuple (size, min, max, mid)
     const s = xs.length;
     if (!s) return 0;
-    if (s > 2) return hash4(s, xs[0], xs[s - 1], xs[s << 1]);
+    if (s > 2) return hash4(s, xs[0], xs[s - 1], xs[s >> 1]);
     return hash3(s, xs[0], xs[s - 1]);
 }
 

+ 7 - 0
src/mol-model/structure/structure/unit.ts

@@ -79,6 +79,13 @@ namespace Unit {
         }
     }
 
+    export namespace SymmetryGroup {
+        export function areInvariantElementsEqual(a: SymmetryGroup, b: SymmetryGroup) {
+            if (a.hashCode !== b.hashCode) return false;
+            return SortedArray.areEqual(a.elements, b.elements);
+        }
+    }
+
     export function conformationId (unit: Unit) {
         return Unit.isAtomic(unit) ? unit.model.atomicConformation.id : unit.model.coarseConformation.id
     }

+ 3 - 2
src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts

@@ -35,7 +35,8 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
 
     private createResVisualParams(s: Structure) {
         return StructureRepresentation3DHelpers.createParams(this.plugin, s, {
-            repr: BuiltInStructureRepresentations['ball-and-stick']
+            repr: BuiltInStructureRepresentations['ball-and-stick'],
+            size: [BuiltInSizeThemes.uniform, () => ({ value: 0.85 } )]
         });
     }
 
@@ -43,7 +44,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
         return StructureRepresentation3DHelpers.createParams(this.plugin, s, {
             repr: BuiltInStructureRepresentations['ball-and-stick'],
             color: [BuiltInColorThemes.uniform, () => ({ value: ColorNames.gray })],
-            size: [BuiltInSizeThemes.uniform, () => ({ value: 0.2} )]
+            size: [BuiltInSizeThemes.uniform, () => ({ value: 0.33 } )]
         });
     }
 

+ 1 - 1
src/mol-repr/structure/units-visual.ts

@@ -88,7 +88,7 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry
 
         if (!renderObject) {
             updateState.createNew = true
-        } else if (!currentStructureGroup || newStructureGroup.group.hashCode !== currentStructureGroup.group.hashCode) {
+        } else if (!currentStructureGroup || !Unit.SymmetryGroup.areInvariantElementsEqual(newStructureGroup.group, currentStructureGroup.group)) {
             updateState.createNew = true
         }