Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fullscreen fill-extrusion querying at low pitch #10315

Merged
merged 2 commits into from
Jan 25, 2021
Merged

Conversation

arindam1993
Copy link
Contributor

The way query geometry was being constructed for fill-extrusions was incorrect for bounds based queries in which the point underneath the camera would fall within the query volume.

This PR fixes it by considering all 4 possible cases

  1. The point underneath the camera is not behind the query bounds, in this case ignore it
  2. The point is exactly behind, in this case insert it between the last two points
  3. The point is behind and to the left, so replace the 4th point
  4. The point is behind and to the right, so replace the 3rd point.

I've added some ASCII art code comments to make it clearer.

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Fill fullscreen fill-extrusion querying at low pitch.</changelog>

@arindam1993 arindam1993 changed the title Fill fullscreen fill-extrusion querying at low pitch Fix fullscreen fill-extrusion querying at low pitch Jan 22, 2021
Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

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

Looks good to me!

The way bufferedCameraGeometry depends on the order of the polygonizeBounds return value seemed a bit fragile to me at first but I can't think of a better approach. And the polygonizeBounds documentation is very explicit about the order.

One small nit.

if (this.cameraPoint.y > max.y) {
//case 1: insert point in the middle
if (this.cameraPoint.x > min.x && this.cameraPoint.x < max.x) {
cameraPolygon.push(this.cameraPoint);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would cameraPolygon.splice(3, 0, this.cameraPoint) work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes derp, I keep forgetting splice can be usedlike that

@karimnaaji karimnaaji added this to the v2.1.0 milestone Jan 23, 2021
@mourner mourner merged commit 81978c8 into main Jan 25, 2021
@mourner mourner deleted the fullscreen-query branch January 25, 2021 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants