[core] Account for overscaling in debug collision circles.
Fixes issue #11116. Port of GL JS issue $6041.
This commit is contained in:
Submodule mapbox-gl-js updated: de365184e1...063fdebeaf
@@ -110,6 +110,7 @@ class CollisionCircleProgram : public Program<
|
||||
gl::Uniforms<
|
||||
uniforms::u_matrix,
|
||||
uniforms::u_extrude_scale,
|
||||
uniforms::u_overscale_factor,
|
||||
uniforms::u_camera_to_center_distance>,
|
||||
style::Properties<>>
|
||||
{
|
||||
|
||||
@@ -55,6 +55,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_fadetexture);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_a);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_b);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, u_tile_units_to_pixels);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, u_overscale_factor);
|
||||
|
||||
} // namespace uniforms
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -268,9 +268,10 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
gl::DepthMode::disabled(),
|
||||
gl::StencilMode::disabled(),
|
||||
parameters.colorModeForRenderPass(),
|
||||
CollisionBoxProgram::UniformValues {
|
||||
CollisionCircleProgram::UniformValues {
|
||||
uniforms::u_matrix::Value{ tile.matrix },
|
||||
uniforms::u_extrude_scale::Value{ extrudeScale },
|
||||
uniforms::u_overscale_factor::Value{ float(tile.tile.id.overscaleFactor()) },
|
||||
uniforms::u_camera_to_center_distance::Value{ parameters.state.getCameraToCenterDistance() }
|
||||
},
|
||||
*bucket.collisionCircle.vertexBuffer,
|
||||
|
||||
@@ -26,7 +26,10 @@ varying vec2 v_extrude_scale;
|
||||
void main() {
|
||||
vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
highp float collision_perspective_ratio = 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance);
|
||||
highp float collision_perspective_ratio = clamp(
|
||||
0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),
|
||||
0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||
|
||||
@@ -43,6 +46,7 @@ void main() {
|
||||
|
||||
)MBGL_SHADER";
|
||||
const char* collision_circle::fragmentSource = R"MBGL_SHADER(
|
||||
uniform float u_overscale_factor;
|
||||
|
||||
varying float v_placed;
|
||||
varying float v_notUsed;
|
||||
@@ -68,7 +72,7 @@ void main() {
|
||||
|
||||
float extrude_scale_length = length(v_extrude_scale);
|
||||
float extrude_length = length(v_extrude) * extrude_scale_length;
|
||||
float stroke_width = 15.0 * extrude_scale_length;
|
||||
float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;
|
||||
float radius = v_radius * extrude_scale_length;
|
||||
|
||||
float distance_to_edge = abs(extrude_length - radius);
|
||||
|
||||
Reference in New Issue
Block a user