Skip to content

Commit aa36ec8

Browse files
committed
fix bug with segments with no property index
1 parent 9879495 commit aa36ec8

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

src/segmentation_display_state/property_map.ts

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,10 @@ export function shaderCodeWithPropertyPreprocessing(
13891389
}
13901390
}
13911391
for (const [i, property] of numericalProperties.entries()) {
1392-
code = code.replaceAll(`prop("${property.id}")`, `uSegmentNumericalProperty${i}`);
1392+
code = code.replaceAll(
1393+
`prop("${property.id}")`,
1394+
`uSegmentNumericalProperty${i}`,
1395+
);
13931396
}
13941397
return code;
13951398
}
@@ -1425,31 +1428,34 @@ export const setSegmentPropertyUniforms = (
14251428
id: bigint,
14261429
) => {
14271430
const index = segmentPropertyMap.getSegmentInlineIndex(id);
1431+
const {
1432+
labels,
1433+
tags: tagsProperty,
1434+
numericalProperties,
1435+
} = segmentPropertyMap;
1436+
labels; // TODO, support labels
14281437

1429-
if (index !== -1) {
1430-
const {
1431-
labels,
1432-
tags: tagsProperty,
1433-
numericalProperties,
1434-
} = segmentPropertyMap;
1435-
labels; // TODO, support labels
1438+
for (const [i, property] of numericalProperties.entries()) {
1439+
const value = index !== -1 ? property.values[index] : 0;
1440+
const uniformSetter = getShaderUniformValueSetter(gl, property.dataType);
1441+
uniformSetter.call(
1442+
gl,
1443+
shader.uniform(`uSegmentNumericalProperty${i}`),
1444+
value,
1445+
);
1446+
}
14361447

1437-
for (const [i, property] of numericalProperties.entries()) {
1438-
const value = property.values[index];
1439-
const uniformSetter = getShaderUniformValueSetter(gl, property.dataType);
1440-
uniformSetter.call(gl, shader.uniform(`uSegmentNumericalProperty${i}`), value);
1448+
if (tagsProperty !== undefined) {
1449+
const { values, tags } = tagsProperty;
1450+
for (let i = 0; i < tags.length; ++i) {
1451+
gl.uniform1ui(shader.uniform(`uSegmentTagProperty${i}`), 0);
14411452
}
1453+
const tagIndices = index !== -1 ? values[index] : "";
1454+
for (let i = 0, length = tagIndices.length; i < length; ++i) {
1455+
const tagIdx = tagIndices.charCodeAt(i);
14421456

1443-
if (tagsProperty !== undefined) {
1444-
const { values, tags } = tagsProperty;
1445-
const tagIndices = values[index];
1446-
for (let i = 0; i < tags.length; ++i) {
1447-
gl.uniform1ui(shader.uniform(`uSegmentTagProperty${i}`), 0);
1448-
}
1449-
for (let i = 0, length = tagIndices.length; i < length; ++i) {
1450-
const tagIdx = tagIndices.charCodeAt(i);
1451-
gl.uniform1ui(shader.uniform(`uSegmentTagProperty${tagIdx}`), 1);
1452-
}
1457+
console.log("enable tag property", tagIdx);
1458+
gl.uniform1ui(shader.uniform(`uSegmentTagProperty${tagIdx}`), 1);
14531459
}
14541460
}
14551461
};

src/sliceview/volume/segmentation_renderlayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ uint64_t getMappedObjectId(uint64_t value) {
339339
shader: ShaderProgram,
340340
parameters: ShaderParameters,
341341
) {
342-
console.log("initializing segmentation shader", parameters);
342+
// console.log("initializing segmentation shader", parameters);
343343
const { gl } = this;
344344
const { displayState, segmentationGroupState } = this;
345345
const { segmentSelectionState } = this.displayState;

0 commit comments

Comments
 (0)