From ceab604a6f7d9c656ba6ad757b51c8027931fb1f Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Tue, 20 Nov 2018 12:04:40 -0800 Subject: [PATCH] fixed geometry bounding sphere update --- .../geometry/direct-volume/direct-volume.ts | 2 +- src/mol-geo/geometry/lines/lines.ts | 6 +++--- src/mol-geo/geometry/mesh/mesh.ts | 4 ++-- src/mol-geo/geometry/points/points.ts | 4 ++-- src/mol-gl/scene.ts | 20 ------------------- src/mol-plugin/state.ts | 1 - src/mol-repr/structure/complex-visual.ts | 4 ++-- src/mol-repr/structure/units-visual.ts | 4 ++-- src/mol-repr/volume/representation.ts | 4 ++-- 9 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/mol-geo/geometry/direct-volume/direct-volume.ts b/src/mol-geo/geometry/direct-volume/direct-volume.ts index af49e2124..4bc8f20ee 100644 --- a/src/mol-geo/geometry/direct-volume/direct-volume.ts +++ b/src/mol-geo/geometry/direct-volume/direct-volume.ts @@ -124,7 +124,7 @@ export namespace DirectVolume { } } - export function updateValues(values: DirectVolumeValues, props: PD.Values<Params>) { + export function updateValues(values: DirectVolumeValues, directVolume: DirectVolume, props: PD.Values<Params>) { const vertices = new Float32Array(values.aPosition.ref.value) transformPositionArray(values.uTransform.ref.value, vertices, 0, vertices.length / 3) const boundingSphere = calculateBoundingSphere( diff --git a/src/mol-geo/geometry/lines/lines.ts b/src/mol-geo/geometry/lines/lines.ts index 5e2764ce4..9f56f34b7 100644 --- a/src/mol-geo/geometry/lines/lines.ts +++ b/src/mol-geo/geometry/lines/lines.ts @@ -137,14 +137,14 @@ export namespace Lines { } } - export function updateValues(values: LinesValues, props: PD.Values<Params>) { + export function updateValues(values: LinesValues, lines: Lines, props: PD.Values<Params>) { const boundingSphere = Sphere3D.addSphere( calculateBoundingSphere( - values.aStart.ref.value, Math.floor(values.aStart.ref.value.length / 3), + values.aStart.ref.value, lines.lineCount, values.aTransform.ref.value, values.instanceCount.ref.value ), calculateBoundingSphere( - values.aEnd.ref.value, Math.floor(values.aEnd.ref.value.length / 3), + values.aEnd.ref.value, lines.lineCount, values.aTransform.ref.value, values.instanceCount.ref.value ), ) diff --git a/src/mol-geo/geometry/mesh/mesh.ts b/src/mol-geo/geometry/mesh/mesh.ts index 6d4b450d4..1b2f29df6 100644 --- a/src/mol-geo/geometry/mesh/mesh.ts +++ b/src/mol-geo/geometry/mesh/mesh.ts @@ -408,9 +408,9 @@ export namespace Mesh { } } - export function updateValues(values: MeshValues, props: PD.Values<Params>) { + export function updateValues(values: MeshValues, mesh: Mesh, props: PD.Values<Params>) { const boundingSphere = calculateBoundingSphere( - values.aPosition.ref.value, Math.floor(values.aPosition.ref.value.length / 3), + values.aPosition.ref.value, mesh.vertexCount, values.aTransform.ref.value, values.instanceCount.ref.value ) if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { diff --git a/src/mol-geo/geometry/points/points.ts b/src/mol-geo/geometry/points/points.ts index 4d443427c..d6c28569a 100644 --- a/src/mol-geo/geometry/points/points.ts +++ b/src/mol-geo/geometry/points/points.ts @@ -92,9 +92,9 @@ export namespace Points { } } - export function updateValues(values: PointsValues, props: PD.Values<Params>) { + export function updateValues(values: PointsValues, points: Points, props: PD.Values<Params>) { const boundingSphere = calculateBoundingSphere( - values.aPosition.ref.value, Math.floor(values.aPosition.ref.value.length / 3), + values.aPosition.ref.value, points.pointCount, values.aTransform.ref.value, values.instanceCount.ref.value ) if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { diff --git a/src/mol-gl/scene.ts b/src/mol-gl/scene.ts index a8278c282..199965f8a 100644 --- a/src/mol-gl/scene.ts +++ b/src/mol-gl/scene.ts @@ -13,26 +13,6 @@ import { Sphere3D } from 'mol-math/geometry'; import { Vec3 } from 'mol-math/linear-algebra'; function calculateBoundingSphere(renderableMap: Map<RenderObject, Renderable<RenderableValues & BaseValues>>, boundingSphere: Sphere3D): Sphere3D { - // let count = 0 - // const center = Vec3.set(boundingSphere.center, 0, 0, 0) - // renderableMap.forEach(r => { - // if (r.boundingSphere.radius) { - // Vec3.add(center, center, r.boundingSphere.center) - // ++count - // } - // }) - // if (count > 0) { - // Vec3.scale(center, center, 1 / count) - // } - - // let radius = 0 - // renderableMap.forEach(r => { - // if (r.boundingSphere.radius) { - // radius = Math.max(radius, Vec3.distance(center, r.boundingSphere.center) + r.boundingSphere.radius) - // } - // }) - // boundingSphere.radius = radius - const spheres: Sphere3D[] = []; renderableMap.forEach(r => { if (!r.state.visible || !r.boundingSphere.radius) return; diff --git a/src/mol-plugin/state.ts b/src/mol-plugin/state.ts index db6cf78e9..e120f86bc 100644 --- a/src/mol-plugin/state.ts +++ b/src/mol-plugin/state.ts @@ -12,7 +12,6 @@ import { CameraSnapshotManager } from './state/camera'; import { PluginStateSnapshotManager } from './state/snapshots'; import { RxEventHelper } from 'mol-util/rx-event-helper'; import { Canvas3DParams } from 'mol-canvas3d/canvas3d'; -import { ParamDefinition } from 'mol-util/param-definition'; import { PluginCommands } from './command'; export { PluginState } diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 4e39ce449..1574648d2 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -48,7 +48,7 @@ interface ComplexVisualBuilder<P extends ComplexParams, G extends Geometry> { interface ComplexVisualGeometryBuilder<P extends ComplexParams, G extends Geometry> extends ComplexVisualBuilder<P, G> { createEmptyGeometry(geometry?: G): G createRenderObject(ctx: VisualContext, structure: Structure, geometry: Geometry, locationIt: LocationIterator, theme: Theme, currentProps: PD.Values<P>): Promise<ComplexRenderObject> - updateValues(values: RenderableValues, newProps: PD.Values<P>): void + updateValues(values: RenderableValues, geometry: Geometry, newProps: PD.Values<P>): void } export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeometryBuilder<P, Geometry>): ComplexVisual<P> { @@ -113,7 +113,7 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo await createColors(ctx.runtime, locationIt, theme.color, renderObject.values) } - updateValues(renderObject.values, newProps) + updateValues(renderObject.values, geometry, newProps) updateRenderableState(renderObject.state, newProps) currentProps = newProps diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index e0f4ba605..f89364eb9 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -55,7 +55,7 @@ interface UnitsVisualBuilder<P extends UnitsParams, G extends Geometry> { interface UnitsVisualGeometryBuilder<P extends UnitsParams, G extends Geometry> extends UnitsVisualBuilder<P, G> { createEmptyGeometry(geometry?: G): G createRenderObject(ctx: VisualContext, group: Unit.SymmetryGroup, geometry: Geometry, locationIt: LocationIterator, theme: Theme, currentProps: PD.Values<P>): Promise<UnitsRenderObject> - updateValues(values: RenderableValues, newProps: PD.Values<P>): void + updateValues(values: RenderableValues, geometry: Geometry, newProps: PD.Values<P>): void } export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryBuilder<P, Geometry>): UnitsVisual<P> { @@ -138,7 +138,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB await createColors(ctx.runtime, locationIt, theme.color, renderObject.values) } - updateValues(renderObject.values, newProps) + updateValues(renderObject.values, geometry, newProps) updateRenderableState(renderObject.state, newProps) currentProps = newProps diff --git a/src/mol-repr/volume/representation.ts b/src/mol-repr/volume/representation.ts index 85a467af2..9c2e642ec 100644 --- a/src/mol-repr/volume/representation.ts +++ b/src/mol-repr/volume/representation.ts @@ -36,7 +36,7 @@ interface VolumeVisualBuilder<P extends VolumeParams, G extends Geometry> { interface VolumeVisualGeometryBuilder<P extends VolumeParams, G extends Geometry> extends VolumeVisualBuilder<P, G> { createRenderObject(ctx: VisualContext, geometry: G, locationIt: LocationIterator, theme: Theme, currentProps: PD.Values<P>): Promise<VolumeRenderObject> - updateValues(values: RenderableValues, newProps: PD.Values<P>): void + updateValues(values: RenderableValues, geometry: G, newProps: PD.Values<P>): void } export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeometryBuilder<P, Geometry>): VolumeVisual<P> { @@ -69,7 +69,7 @@ export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeomet ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(geometry)) } - updateValues(renderObject.values, newProps) + updateValues(renderObject.values, geometry, newProps) updateRenderableState(renderObject.state, newProps) currentProps = newProps -- GitLab