Skip to content
Snippets Groups Projects
Commit 47055f4c authored by David Sehnal's avatar David Sehnal
Browse files

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

parent 102c64cd
No related branches found
No related tags found
No related merge requests found
......@@ -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]);
}
......
......@@ -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
}
......
......@@ -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 } )]
});
}
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment