Browse Source

geo & repr data update tweaks

Alexander Rose 4 years ago
parent
commit
2d0e8d4ca0

+ 1 - 1
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 {

+ 3 - 7
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 {

+ 2 - 2
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 {

+ 2 - 6
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 {

+ 2 - 2
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 {

+ 3 - 2
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 {

+ 1 - 1
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;

+ 3 - 2
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);

+ 1 - 0
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)) {