Skip to content

Commit f4f59e7

Browse files
Fixes
1 parent 81372b5 commit f4f59e7

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/render/program/collision_program.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type CollisionUniformsType = {|
2323

2424
export type CollisionCircleUniformsType = {|
2525
'u_matrix': UniformMatrix4f,
26-
'u_invMatrix': UniformMatrix4f,
26+
'u_inv_matrix': UniformMatrix4f,
2727
'u_quads': Uniform4fv,
2828
'u_camera_to_center_distance': Uniform1f,
2929
'u_viewport_size': Uniform2f
@@ -39,7 +39,7 @@ const collisionUniforms = (context: Context, locations: UniformLocations): Colli
3939

4040
const collisionCircleUniforms = (context: Context, locations: UniformLocations): CollisionCircleUniformsType => ({
4141
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
42-
'u_invMatrix': new UniformMatrix4f(context, locations.u_invMatrix),
42+
'u_inv_matrix': new UniformMatrix4f(context, locations.u_inv_matrix),
4343
'u_quads': new Uniform4fv(context, locations.u_quads),
4444
'u_camera_to_center_distance': new Uniform1f(context, locations.u_camera_to_center_distance),
4545
'u_viewport_size': new Uniform2f(context, locations.u_viewport_size)
@@ -71,7 +71,7 @@ const collisionCircleUniformValues = (
7171
): UniformValues<CollisionCircleUniformsType> => {
7272
return {
7373
'u_matrix': matrix,
74-
'u_invMatrix': invMatrix,
74+
'u_inv_matrix': invMatrix,
7575
'u_quads': quads,
7676
'u_camera_to_center_distance': transform.cameraToCenterDistance,
7777
'u_viewport_size': [transform.width, transform.height]

src/shaders/collision_circle.vertex.glsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
attribute vec2 a_idx;
1919

2020
uniform mat4 u_matrix;
21-
uniform mat4 u_invMatrix;
21+
uniform mat4 u_inv_matrix;
2222
uniform vec2 u_viewport_size;
2323
uniform float u_camera_to_center_distance;
2424

@@ -37,8 +37,8 @@ varying float v_collision;
3737

3838
vec3 toTilePosition(vec2 screenPos) {
3939
// Shoot a ray towards the ground to reconstruct the depth-value
40-
vec4 rayStart = u_invMatrix * vec4(screenPos, -1.0, 1.0);
41-
vec4 rayEnd = u_invMatrix * vec4(screenPos, 1.0, 1.0);
40+
vec4 rayStart = u_inv_matrix * vec4(screenPos, -1.0, 1.0);
41+
vec4 rayEnd = u_inv_matrix * vec4(screenPos, 1.0, 1.0);
4242

4343
rayStart.xyz /= rayStart.w;
4444
rayEnd.xyz /= rayEnd.w;

src/symbol/collision_index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import PathInterpolator from './path_interpolator';
77
import * as intersectionTests from '../util/intersection_tests';
88
import Grid from './grid_index';
99
import {mat4} from 'gl-matrix';
10+
import ONE_EM from '../symbol/one_em';
1011

1112
import * as projection from '../symbol/projection';
1213

@@ -103,7 +104,7 @@ class CollisionIndex {
103104

104105
const perspectiveRatio = this.projectAnchor(posMatrix, symbol.anchorX, symbol.anchorY).perspectiveRatio;
105106
const labelPlaneFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio;
106-
const labelPlaneFontScale = labelPlaneFontSize / 24;
107+
const labelPlaneFontScale = labelPlaneFontSize / ONE_EM;
107108

108109
const tileUnitAnchorPoint = new Point(symbol.anchorX, symbol.anchorY);
109110
const labelPlaneAnchorPoint = projection.project(tileUnitAnchorPoint, labelPlaneMatrix).point;
@@ -139,7 +140,11 @@ class CollisionIndex {
139140
const first = firstAndLastGlyph.first;
140141
const last = firstAndLastGlyph.last;
141142

142-
let projectedPath = first.path.slice(1).reverse().concat(last.path.slice(1));
143+
let projectedPath = [];
144+
for (let i = first.path.length - 1; i >= 1; i--)
145+
projectedPath.push(first.path[i]);
146+
for (let i = 1; i < last.path.length; i++)
147+
projectedPath.push(last.path[i]);
143148

144149
// Tolerate a slightly longer distance than one diameter between two adjacent circles
145150
const circleDist = radius * 2.5;

src/symbol/path_interpolator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PathInterpolator {
3939

4040
t = clamp(t, 0, 1);
4141

42-
// Find the correct segment. Use a cached index value to start the search
42+
// Find the correct segment [p0, p1] where p0 <= x < p1
4343
let currentIndex = 1;
4444
let distOfCurrentIdx = this._distances[currentIndex];
4545
const distToTarget = t * this.paddedLength + this.padding;
@@ -48,7 +48,7 @@ class PathInterpolator {
4848
distOfCurrentIdx = this._distances[++currentIndex];
4949
}
5050

51-
// We've found a segment with two points p0 and p1 where p0 <= x < p1. Interpolate between these two points
51+
// Interpolate between the two points of the segment
5252
const idxOfPrevPoint = currentIndex - 1;
5353
const distOfPrevIdx = this._distances[idxOfPrevPoint];
5454
const segmentLength = distOfCurrentIdx - distOfPrevIdx;

0 commit comments

Comments
 (0)