#14441 Keep annotation labels inside the view frustum - #14442
Draft
magnesj wants to merge 1 commit into
Draft
Conversation
The label is moved from the anchor point towards the camera to be drawn in front of other geometry. The offset was derived from the zoom level, and was not related to the distance between the camera and the anchor point. In a 3D view the offset is usually larger than this distance, moving the label behind the camera. Labels outside the view frustum are silently discarded by the text renderer. Limit the offset to the smaller of half the distance to the anchor point and the distance to the near plane. The limit is derived from the anchor point and not from the near plane, as the label parts are part of the scene and are used to compute the clipping planes. Reject anchor point candidates behind the camera. Coordinates behind the camera are mirrored into the viewport by the perspective divide in cvf::Camera::project(), and could be selected as the coordinate closest to the label position.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14441
The label for a surface intersection curve or band is moved from the anchor point towards the camera, to be drawn in front of other geometry. The offset was computed by
computeScalingFactorFromZoom()as 10 times the near plane diagonal, a zoom dependent length that is not related to the distance between the camera and the anchor point. In a 3D view the offset is usually several times larger than this distance, and the label ends up behind the camera.cvf::DrawableText::renderText()maps the projected depth to1 - 2 * zand clips anything outside[-1, 1], so a label outside the view frustum is silently discarded. As the relation between the offset and the camera distance differs per curve and changes when the camera is moved, labels appear and disappear.The flat 2D intersection view calls
addAnnotationLabels()withcomputeScalingFactor = false, giving a fixed offset of 1.0. This is why the labels are displayed as expected in that view.Changes
caf::Viewer::calculateNearFarPlanes(). A limit derived from the near plane would create a feedback loop between the label positions and the clipping planes.cvf::Camera::project()divides by the homogeneous w-coordinate, which is negative behind the camera, mirroring these coordinates into the viewport. Such a coordinate could be selected as the coordinate closest to the label position at 90% of the viewport width, placing the label behind the camera. The same check is added to theCOUNT_HINTandALLstrategies, and to the multiple label path used for measured depth labels along a well path.autoat namespace scope, they had external linkage.Verification
RivAnnotationTools-Test.cppadds two tests. Both fail without the fix:LabelIsInsideViewFrustum: the label projects to window z = 3.31, the frustum is 0 to 1AnchorPointsBehindCameraAreIgnored: the selected anchor point is 306 units behind the cameraThe complete unit test suite passes, 961 tests.
The change has not yet been verified visually in a 3D view.