Skip to content

PointPlacemark labels should be on depth buffer if clipHorizon is false #282

@smartalex32

Description

@smartalex32

Description

When using PointPlacemark, back in about 2017, there was the clipToHorizon member variable and accessors added. This would allow the Placemark object to be clipped at horizon line or overriden to not clip at the horizon line. The problem is that if the user says to NOT clip at the horizon, then the labels are not added to the depth buffer, and so they render in front of the globe when the PointPlacemark moves behind the globe.

In the forum post below they list different solutions to handle rendering the label, but it appears to just move the label to the bottom left of the screen permanently instead of keeping it in the default position based on screen location of the placemark. When I include code to keep close to the placemark, their solution still has the label rendering in front of the globe.

https://forum.worldwindcentral.com/forum/world-wind-java-forums/development-help/16581-how-to-prevent-clipping-of-objects-beyond-the-horizon

In PointPlacemark.java in the drawLabel() method at line 1200 there is code that disables the depth.

1199 // Do not depth buffer the label. (Placemarks beyond the horizon are culled above.)
1200 gl.glDisable(GL.GL_DEPTH_TEST);
1201 gl.glDepthMask(false);

The comment states that it is disabling depth test because "Placemarks beyond the horizon are culled above." but if the user sets the clipToHorizon to false, then they won't be clipped.

I feel like since the ability to override the default behavior was exposed, the other base renderables should have their default behavior change depending on the flag.

Steps to Reproduce

Assumes a basic application with globe and a layer already created

  1. Create a PointPlacemark and setClipToHorizon(false)
  2. SetDrawLabel(true) on PointPlacemarkAttributes and setLabelText() to a test label on the PointPlacemark
  3. Spin the globe until the placemark is behind the globe
    *Note: the Placemark disappears, but the label is seen through the globe.

Expected behavior:
The label should disappear behind the globe like the placemark if clipToHorizon is false.

Actual behavior:
The label is seen through the globe when clipToHorizon is false.

Reproduces how often:
Every time.

Operating System and Version

Windows, Java 11, and WorldWind 2.2.1

Additional Information

I've tried creating a wrapped PointPlacemark, and overriding the drawLabel() method so that I can set the GL_DEPTH_TEST enabled and keep all the same code, and it did not work. I'm not an expert at OpenGL so there may be a simple fix, but I believe this is a behavior issue that I wouldn't expect to happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions