From 47055f4ce0115d3f48275138bf5b24005fc6c90f Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Sun, 3 Mar 2019 15:47:49 +0100 Subject: [PATCH] fixed bug in SortedArray.hashCode & possible bug in UnitsVisual.prepareUpdate --- src/mol-data/int/impl/sorted-array.ts | 2 +- src/mol-model/structure/structure/unit.ts | 7 +++++++ .../selection/structure-representation-interaction.ts | 5 +++-- src/mol-repr/structure/units-visual.ts | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mol-data/int/impl/sorted-array.ts b/src/mol-data/int/impl/sorted-array.ts index 6fff1aa00..0e6336af2 100644 --- a/src/mol-data/int/impl/sorted-array.ts +++ b/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]); } diff --git a/src/mol-model/structure/structure/unit.ts b/src/mol-model/structure/structure/unit.ts index 725862657..258141272 100644 --- a/src/mol-model/structure/structure/unit.ts +++ b/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 } diff --git a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts b/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts index 365d51eb6..a73b2f2d3 100644 --- a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts +++ b/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 } )] }); } diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index f7ed2da1b..074597241 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/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 } -- GitLab