Skip to content

Commit

Permalink
fix: handle clip bounds; add skipDequantization flag
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshh committed May 4, 2023
1 parent 3680244 commit 23a25a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/neuroglancer/datasource/graphene/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { SharedWatchableValue } from 'neuroglancer/shared_watchable_value';
import { DisplayDimensionRenderInfo } from 'neuroglancer/navigation_state';
import { forEachVisibleSegment } from 'neuroglancer/segmentation_display_state/base';
import { computeChunkBounds } from 'neuroglancer/sliceview/volume/backend';
import { verifyObject } from 'src/neuroglancer/util/json';
import { verifyObject } from 'neuroglancer/util/json';

function getVerifiedFragmentPromise(
credentialsProvider: SpecialProtocolCredentialsProvider,
Expand Down Expand Up @@ -142,12 +142,12 @@ function decodeMultiscaleManifestChunk(chunk: GrapheneMultiscaleManifestChunk, r
verifyObject(response);
chunk.manifest = {
chunkShape: vec3.clone(response.chunkShape),
chunkGridSpatialOrigin: vec3.create(),
chunkGridSpatialOrigin: vec3.clone(response.chunkGridSpatialOrigin),
lodScales: new Float32Array(response.lodScales),
octree: new Uint32Array(response.octree),
vertexOffsets: new Float32Array(response.lodScales.length * 3),
clipLowerBound: vec3.create(),
clipUpperBound: vec3.create(),
clipLowerBound: vec3.clone(response.clipLowerBound),
clipUpperBound: vec3.clone(response.clipUpperBound),
}
chunk.fragmentIds = response.fragments;
}
Expand All @@ -157,7 +157,7 @@ async function decodeMultiscaleFragmentChunk(
const {lod} = chunk;
const source = chunk.manifestChunk!.source! as GrapheneMultiscaleMeshSource;
const m = await import(/* webpackChunkName: "draco" */ 'neuroglancer/mesh/draco');
const rawMesh = await m.decodeDracoPartitioned(new Uint8Array(response), 0, lod !== 0);
const rawMesh = await m.decodeDracoPartitioned(new Uint8Array(response), 0, lod !== 0, false);
assignMultiscaleMeshFragmentData(chunk, rawMesh, source.format.vertexPositionFormat);
}

Expand Down
2 changes: 1 addition & 1 deletion src/neuroglancer/datasource/precomputed/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ async function decodeMultiscaleFragmentChunk(
const source = chunk.manifestChunk!.source! as PrecomputedMultiscaleMeshSource;
const m = await import(/* webpackChunkName: "draco" */ 'neuroglancer/mesh/draco');
const rawMesh = await m.decodeDracoPartitioned(
new Uint8Array(response), source.parameters.metadata.vertexQuantizationBits, lod !== 0);
new Uint8Array(response), source.parameters.metadata.vertexQuantizationBits, lod !== 0, true);
assignMultiscaleMeshFragmentData(chunk, rawMesh, source.format.vertexPositionFormat);
}

Expand Down
4 changes: 2 additions & 2 deletions src/neuroglancer/mesh/draco/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ const dracoModulePromise = (async () => {

export async function decodeDracoPartitioned(
buffer: Uint8Array, vertexQuantizationBits: number,
partition: boolean): Promise<RawPartitionedMeshData> {
partition: boolean, skipDequantization: boolean): Promise<RawPartitionedMeshData> {
const m = await dracoModulePromise;
const offset = (m.instance.exports.malloc as Function)(buffer.byteLength);
const heap = new Uint8Array((m.instance.exports.memory as WebAssembly.Memory).buffer);
heap.set(buffer, offset);
numPartitions = partition ? 8 : 1;
const code = (m.instance.exports.neuroglancer_draco_decode as Function)(
offset, buffer.byteLength, partition, vertexQuantizationBits, false);
offset, buffer.byteLength, partition, vertexQuantizationBits, skipDequantization);
if (code === 0) {
const r = decodeResult;
decodeResult = undefined;
Expand Down

0 comments on commit 23a25a6

Please sign in to comment.