Skip to content

fix: Correct picking formulas#142

Open
afonsobspinto wants to merge 1 commit intomasterfrom
feature/picking
Open

fix: Correct picking formulas#142
afonsobspinto wants to merge 1 commit intomasterfrom
feature/picking

Conversation

@afonsobspinto
Copy link
Copy Markdown
Member

Cherry picks the fix for picking from the feature/edit-mode. See https://metacell.atlassian.net/browse/NA-629 for details.

Closes https://metacell.atlassian.net/browse/NA-629

}
}
}
export {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To change - We can avoid the re-export, neuroglancer doesn't guarantee a stable API

element.clientLeft;
const mouseY =
((clientY - bounds.top) / bounds.height) * element.offsetHeight +
((clientY - bounds.top) / bounds.height) * element.offsetHeight -
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for PR - definite problem - the border around the panels is accidentally getting added to mouse position. Result would be a 4 pixel off selection in Y, and moreso if the border size is expanded.

const y = startY + relativeY;
if (x < 0 || y < 0 || x >= viewportWidth || y >= viewportHeight) {
buffer[
baseOffset + (relativeY * pickDiameter + relativeX) * stride
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definite problem, the buffer clearing was not using the relative index into the buffer, but instead using x and y window locations. Probably never really came up because picking there happens very rarely

}
const { renderViewport } = this;
const glWindowX =
const glWindowX = Math.floor(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for when we make PR - Problem, without rounding to int (floor makes sense) it is possible we could end up with a floating point value here. This immediately goes into readPixels which is expecting an int, and how our float is handled is likely implementation dependent. It is also used in clearOutOfBoundsPickData, but with our other fix to use relative X and Y that could handle fractional data so it's less of a problem there.


This change is related to the change to add 0.5 to the pick because now we're flooring and using the 0.5 to use the center. But I think we can remove the 0.5 add and land at the pixel edge instead of the pixel centre. In neuroglancer, the origin of a voxel is the lower corner anyway, not the centre. I've noted this bit elsewhere

}
}

export function getCenteredPickWindowCoordinate(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need this due to the origin of a voxel in neuroglancer not being its centre. Think we could remove this fn and revert the places where it is called to the old in place

return glWindowCoordinate + relativeCoordinate - pickRadius + 0.5;
}

export function resolveNearestPanelPickSample(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could use a js doc comment explaining it. Even the description of the params would help a lot

Comment thread src/sliceview/panel.ts
};
for (let i = 0; i < numOffsets; ++i) {
const offset = pickOffsetSequence[i];
const pickId = data[4 * i];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definite problem. This explains why we had trouble picking the nodes in polylines in 2D. The 3D code was doing this correctly, but specifically in 2D it was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants