diff --git a/src/mol-geo/geometry/clipping-data.ts b/src/mol-geo/geometry/clipping-data.ts index 5c2209feda0c08ab2ce743fb86872f39bbc44a68..b54c01fead8701d9599c89862cdc8146c58a414d 100644 --- a/src/mol-geo/geometry/clipping-data.ts +++ b/src/mol-geo/geometry/clipping-data.ts @@ -34,7 +34,7 @@ export function createClipping(count: number, clippingData?: ClippingData): Clip if (clippingData) { ValueCell.update(clippingData.tClipping, clipping); ValueCell.update(clippingData.uClippingTexDim, Vec2.create(clipping.width, clipping.height)); - ValueCell.update(clippingData.dClipping, count > 0); + ValueCell.updateIfChanged(clippingData.dClipping, count > 0); return clippingData; } else { return { diff --git a/src/mol-geo/geometry/color-data.ts b/src/mol-geo/geometry/color-data.ts index 145c97da08806c0b055c5f07169950fa4d052ecc..5dc3ecdfa8c1a7f89e8856384a3d9c5c339681c2 100644 --- a/src/mol-geo/geometry/color-data.ts +++ b/src/mol-geo/geometry/color-data.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -34,9 +34,7 @@ export function createColors(locationIt: LocationIterator, colorTheme: ColorThem export function createValueColor(value: Color, colorData?: ColorData): ColorData { if (colorData) { ValueCell.update(colorData.uColor, Color.toVec3Normalized(colorData.uColor.ref.value, value)); - if (colorData.dColorType.ref.value !== 'uniform') { - ValueCell.update(colorData.dColorType, 'uniform'); - } + ValueCell.updateIfChanged(colorData.dColorType, 'uniform'); return colorData; } else { return { @@ -57,9 +55,7 @@ export function createTextureColor(colors: TextureImage<Uint8Array>, type: Color if (colorData) { ValueCell.update(colorData.tColor, colors); ValueCell.update(colorData.uColorTexDim, Vec2.create(colors.width, colors.height)); - if (colorData.dColorType.ref.value !== type) { - ValueCell.update(colorData.dColorType, type); - } + ValueCell.updateIfChanged(colorData.dColorType, type); return colorData; } else { return { diff --git a/src/mol-geo/geometry/overpaint-data.ts b/src/mol-geo/geometry/overpaint-data.ts index 583ed1c4c230e8ccf6f0514e22392c624fa1d07a..7df9bf453b6a4abe3e9ba46a293de27dc6b3ab37 100644 --- a/src/mol-geo/geometry/overpaint-data.ts +++ b/src/mol-geo/geometry/overpaint-data.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -33,7 +33,7 @@ export function createOverpaint(count: number, overpaintData?: OverpaintData): O if (overpaintData) { ValueCell.update(overpaintData.tOverpaint, overpaint); ValueCell.update(overpaintData.uOverpaintTexDim, Vec2.create(overpaint.width, overpaint.height)); - ValueCell.update(overpaintData.dOverpaint, count > 0); + ValueCell.updateIfChanged(overpaintData.dOverpaint, count > 0); return overpaintData; } else { return { diff --git a/src/mol-geo/geometry/size-data.ts b/src/mol-geo/geometry/size-data.ts index a3eb3bf50e282cde34f4263072336aaecf35de24..1aca592f246d7c1596c3bfaf51ac077b7342b666 100644 --- a/src/mol-geo/geometry/size-data.ts +++ b/src/mol-geo/geometry/size-data.ts @@ -64,9 +64,7 @@ function createEmptySizeTexture() { export function createValueSize(value: number, sizeData?: SizeData): SizeData { if (sizeData) { ValueCell.update(sizeData.uSize, value); - if (sizeData.dSizeType.ref.value !== 'uniform') { - ValueCell.update(sizeData.dSizeType, 'uniform'); - } + ValueCell.updateIfChanged(sizeData.dSizeType, 'uniform'); return sizeData; } else { return { @@ -86,9 +84,7 @@ export function createTextureSize(sizes: TextureImage<Uint8Array>, type: SizeTyp if (sizeData) { ValueCell.update(sizeData.tSize, sizes); ValueCell.update(sizeData.uSizeTexDim, Vec2.create(sizes.width, sizes.height)); - if (sizeData.dSizeType.ref.value !== type) { - ValueCell.update(sizeData.dSizeType, type); - } + ValueCell.updateIfChanged(sizeData.dSizeType, type); return sizeData; } else { return { diff --git a/src/mol-geo/geometry/transparency-data.ts b/src/mol-geo/geometry/transparency-data.ts index 6491f15889adfb460857064cd62c1e80fb3ff361..22879551be9ae5d7999ff0439e4a2de61174a029 100644 --- a/src/mol-geo/geometry/transparency-data.ts +++ b/src/mol-geo/geometry/transparency-data.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -31,7 +31,7 @@ export function createTransparency(count: number, transparencyData?: Transparenc if (transparencyData) { ValueCell.update(transparencyData.tTransparency, transparency); ValueCell.update(transparencyData.uTransparencyTexDim, Vec2.create(transparency.width, transparency.height)); - ValueCell.update(transparencyData.dTransparency, count > 0); + ValueCell.updateIfChanged(transparencyData.dTransparency, count > 0); return transparencyData; } else { return { diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 3b18512b5145bdf649d39ccba435b21546e26c73..c8f77ec2a72886f05eb1093bdf1f2e32f685d04d 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -21,13 +21,14 @@ import { Task } from '../../../mol-task'; import { IndexPairBonds } from '../../../mol-model-formats/structure/property/bonds/index-pair'; import { createModels } from '../../../mol-model-formats/structure/basic/parser'; import { MmcifFormat } from '../../../mol-model-formats/structure/mmcif'; -import { ChainIndex } from './indexing'; +import { ChainIndex, ElementIndex } from './indexing'; import { SymmetryOperator } from '../../../mol-math/geometry'; import { ModelSymmetry } from '../../../mol-model-formats/structure/property/symmetry'; import { Column } from '../../../mol-data/db'; import { CustomModelProperty } from '../../../mol-model-props/common/custom-model-property'; import { Trajectory, ArrayTrajectory } from '../trajectory'; import { Unit } from '../structure'; +import SortedArray from '../../../mol-data/int/sorted-array'; /** * Interface to the "source data" of the molecule. @@ -206,7 +207,7 @@ export namespace Model { const CoordinatesHistoryProp = '__CoordinatesHistory__'; export type CoordinatesHistory = { - areEqual(unit: Unit, model: Model): boolean + areEqual(elements: SortedArray<ElementIndex>, kind: Unit.Kind, model: Model): boolean } export const CoordinatesHistory = { get(model: Model): CoordinatesHistory | undefined { diff --git a/src/mol-model/structure/structure/unit.ts b/src/mol-model/structure/structure/unit.ts index d1c37ba416ffc04b683e688ab15285fd78dd993f..3f31ff23bcc27ee39e31756bf84dae65252d52be 100644 --- a/src/mol-model/structure/structure/unit.ts +++ b/src/mol-model/structure/structure/unit.ts @@ -496,7 +496,7 @@ namespace Unit { export function isSameConformation(u: Unit, model: Model) { const coordsHistory = Model.CoordinatesHistory.get(Model.getRoot(model)); - if (coordsHistory?.areEqual(u, model)) return true; + if (coordsHistory) return coordsHistory.areEqual(u.elements, u.kind, model); const xs = u.elements; const { x: xa, y: ya, z: za } = u.conformation.coordinates; diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 9bcabd9141ed423908ce1eefdab653b78c6aae8c..83958df6764c20c7033de6b0ad619f216ea7c23e 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -98,7 +98,7 @@ export function ComplexVisual<G extends Geometry, P extends StructureParams & Ge setUpdateState(updateState, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure); - if (Structure.conformationHash(newStructure) !== Structure.conformationHash(currentStructure)) { + if (!Structure.areHierarchiesEqual(newStructure, currentStructure)) { updateState.updateTransform = true; updateState.createGeometry = true; } @@ -113,6 +113,7 @@ export function ComplexVisual<G extends Geometry, P extends StructureParams & Ge if (updateState.createGeometry) { updateState.updateColor = true; + updateState.updateSize = true; } } @@ -241,7 +242,7 @@ export function ComplexMeshVisual<P extends ComplexMeshParams>(builder: ComplexM ...builder, setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => { builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure); - if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true; + if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true; }, geometryUtils: Mesh.Utils }, materialId); diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index 41e9b62ac89875e67d7a762278a8d12306ac792a..e83c3b443487546250b16ba9d7a1ce6ccd84f197 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -111,6 +111,7 @@ export function UnitsVisual<G extends Geometry, P extends StructureParams & Geom // console.log('new hierarchy'); updateState.updateTransform = true; updateState.updateColor = true; + updateState.updateSize = true; } if (!ColorTheme.areEqual(newTheme.color, currentTheme.color)) {