Skip to content

Commit afb357b

Browse files
ibesoragithub-actions[bot]
authored andcommitted
Fix
GitOrigin-RevId: e36781d548f3d2986da2dae9345d3538f0311502
1 parent fa6e4b1 commit afb357b

6 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/style/pauseable_placement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class LayerPlacement {
5757

5858
while (this._currentPartIndex < bucketParts.length) {
5959
const bucketPart = bucketParts[this._currentPartIndex];
60-
placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes, bucketPart.symbolInstanceStart === 0, scaleFactor);
60+
placement.placeLayerBucketPart(bucketPart, this._seenCrossTileIDs, showCollisionBoxes, scaleFactor);
6161
this._currentPartIndex++;
6262
if (shouldPausePlacement()) {
6363
return true;

src/style/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4722,7 +4722,7 @@ class Style extends Evented<MapEvents> {
47224722
if (styleLayer.type !== 'symbol') continue;
47234723
if (styleLayer.visibility === 'none') continue;
47244724
const checkAgainstClipLayer = this.isLayerClipped(styleLayer);
4725-
this.placement.updateLayerOpacities(styleLayer, layerTiles[makeFQID(styleLayer.source, styleLayer.scope)], i, checkAgainstClipLayer ? replacementSource : null);
4725+
this.placement.updateLayerOpacities(styleLayer, layerTiles[makeFQID(styleLayer.source, styleLayer.scope)], i, checkAgainstClipLayer ? replacementSource : null, showCollisionBoxes, this.map.painter.scaleFactor);
47264726
}
47274727
}
47284728

src/symbol/placement.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ export class Placement {
437437
}
438438
}
439439

440-
placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: Set<number>, showCollisionBoxes: boolean, updateCollisionBoxIfNecessary: boolean, scaleFactor: number = 1) {
441-
this.algorithm.placeLayerBucketPart(this, bucketPart, seenCrossTileIDs, showCollisionBoxes, updateCollisionBoxIfNecessary, scaleFactor);
440+
placeLayerBucketPart(bucketPart: BucketPart, seenCrossTileIDs: Set<number>, showCollisionBoxes: boolean, scaleFactor: number = 1) {
441+
this.algorithm.placeLayerBucketPart(this, bucketPart, seenCrossTileIDs, showCollisionBoxes, scaleFactor);
442442
}
443443

444444
commit(now: number): void {
@@ -504,7 +504,7 @@ export class Placement {
504504
}
505505
}
506506

507-
updateLayerOpacities(styleLayer: TypedStyleLayer, tiles: Array<Tile>, layerIndex: number, replacementSource?: ReplacementSource | null) {
507+
updateLayerOpacities(styleLayer: TypedStyleLayer, tiles: Array<Tile>, layerIndex: number, replacementSource?: ReplacementSource | null, showCollisionBoxes: boolean = false, scaleFactor: number = 1) {
508508
if (replacementSource) {
509509
this.lastReplacementSourceUpdateTime = replacementSource.updateTime;
510510
}
@@ -521,6 +521,18 @@ export class Placement {
521521
symbolBucket.hdExt.updateRoadElevation(symbolBucket, tile.tileID.canonical);
522522
}
523523
symbolBucket.updateZOffset();
524+
525+
// Collision debug boxes encode elevation directly in their vertex data, so they must be
526+
// rebuilt here (after zOffset is refreshed above) rather than during placement, otherwise
527+
// they'd render one placement cycle behind the actual symbol quads whenever elevation changes.
528+
if (showCollisionBoxes && tile.collisionBoxArray) {
529+
const layout = symbolBucket.layers[0].layout;
530+
const [textSizeScaleRangeMin, textSizeScaleRangeMax] = layout.get('text-size-scale-range');
531+
const [iconSizeScaleRangeMin, iconSizeScaleRangeMax] = layout.get('icon-size-scale-range');
532+
const textScaleFactor = clamp(scaleFactor, textSizeScaleRangeMin, textSizeScaleRangeMax);
533+
const iconScaleFactor = clamp(scaleFactor, iconSizeScaleRangeMin, iconSizeScaleRangeMax);
534+
symbolBucket.updateCollisionDebugBuffers(this.transform.zoom, tile.collisionBoxArray, textScaleFactor, iconScaleFactor);
535+
}
524536
}
525537
}
526538
}

src/symbol/placement_algorithm.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export interface PlacementAlgorithm {
105105
bucketPart: BucketPart,
106106
seenCrossTileIDs: Set<number>,
107107
showCollisionBoxes: boolean,
108-
updateCollisionBoxIfNecessary: boolean,
109108
scaleFactor: number,
110109
) => void;
111110

src/symbol/placement_algorithms/default.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Point from '@mapbox/point-geometry';
22
import assert from '../../style-spec/util/assert';
33
import {mat4, vec4} from 'gl-matrix';
4-
import {clamp, warnOnce} from '../../util/util';
4+
import {warnOnce} from '../../util/util';
55
import CollisionIndex from '../collision_index';
66
import ONE_EM from '../one_em';
77
import {WritingMode} from '../shaping';
@@ -48,7 +48,6 @@ export class DefaultPlacementAlgorithm implements PlacementAlgorithm {
4848
bucketPart: BucketPart,
4949
seenCrossTileIDs: Set<number>,
5050
showCollisionBoxes: boolean,
51-
updateCollisionBoxIfNecessary: boolean,
5251
scaleFactor: number = 1,
5352
): void {
5453
const {
@@ -80,10 +79,6 @@ export class DefaultPlacementAlgorithm implements PlacementAlgorithm {
8079
const symbolZOffset = paint.get('symbol-z-offset');
8180
const elevationFromSea = layout.get('symbol-elevation-reference') === 'sea';
8281
const symbolPlacement = layout.get('symbol-placement');
83-
const [textSizeScaleRangeMin, textSizeScaleRangeMax] = layout.get('text-size-scale-range');
84-
const [iconSizeScaleRangeMin, iconSizeScaleRangeMax] = layout.get('icon-size-scale-range');
85-
const textScaleFactor = clamp(scaleFactor, textSizeScaleRangeMin, textSizeScaleRangeMax);
86-
const iconScaleFactor = clamp(scaleFactor, iconSizeScaleRangeMin, iconSizeScaleRangeMax);
8782
const textVariableAnchor = layout.get('text-variable-anchor');
8883

8984
const isTextPlacedAlongLine = textRotateWithMap && symbolPlacement !== 'point';
@@ -106,10 +101,6 @@ export class DefaultPlacementAlgorithm implements PlacementAlgorithm {
106101
bucket.deserializeCollisionBoxes(collisionBoxArray);
107102
}
108103

109-
if (showCollisionBoxes && updateCollisionBoxIfNecessary) {
110-
bucket.updateCollisionDebugBuffers(placement.transform.zoom, collisionBoxArray, textScaleFactor, iconScaleFactor);
111-
}
112-
113104
const placeSymbol = (symbolInstance: SymbolInstance, boxIndex: number, collisionArrays: CollisionArrays) => {
114105
const {crossTileID, numVerticalGlyphVertices} = symbolInstance;
115106

test/integration/render-tests/symbol-elevation/z-elevation-with-sort-by-viewport-y-and-collision-boxes/style.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
],
1111
"image-threshold": [
1212
{"platform-tag-contains": "", "threshold": 0.0035}
13-
],
14-
"skip-test": [
15-
{"platform-tag-contains": "web", "reason": "Flaky symbol placement"}
1613
]
1714
}
1815
},

0 commit comments

Comments
 (0)