Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions maplibre/src/sdf/collision_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ impl System for CollisionSystem {
let coords = view_tile.coords();
if let Some(component) = world.tiles.query::<&SymbolLayersDataComponent>(coords) {
for layer in &component.layers {
let mut feature_metadata = vec![
SDFShaderFeatureMetadata::default();
let metadata_count = if layer.features.is_empty() {
layer.new_buffer.buffer.vertices.len()
} else {
layer
.features
.last()
.map(|feature| feature.indices.end)
.unwrap_or_default()
];
};
let mut feature_metadata =
vec![SDFShaderFeatureMetadata { opacity: 1.0 }; metadata_count];

for feature in &layer.features {
// calculate where tile is
Expand Down Expand Up @@ -195,12 +198,12 @@ impl System for CollisionSystem {
);

for index in feature.indices.clone() {
let index = layer.buffer.buffer.indices[index] as usize;
let index = layer.new_buffer.buffer.indices[index] as usize;
feature_metadata[index].opacity = 1.0;
}
} else {
for index in feature.indices.clone() {
let index = layer.buffer.buffer.indices[index] as usize;
let index = layer.new_buffer.buffer.indices[index] as usize;
feature_metadata[index].opacity = 0.0;
}

Expand Down
20 changes: 12 additions & 8 deletions maplibre/src/sdf/upload_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ fn upload_symbol_layer(
continue;
};

// Assign every feature in the layer the color from the style
let feature_metadata = iter::repeat(SDFShaderFeatureMetadata { opacity: 0.0 })
.take(
features
.last()
.map(|feature| feature.indices.end)
.unwrap_or_default(),
)
// Per-vertex opacity metadata. Default to 1.0 (visible) so text renders
// even when collision detection features are not yet populated.
let metadata_count = if features.is_empty() {
buffer.buffer.vertices.len()
} else {
features
.last()
.map(|feature| feature.indices.end)
.unwrap_or_default()
};
let feature_metadata = iter::repeat(SDFShaderFeatureMetadata { opacity: 1.0 })
.take(metadata_count)
.collect::<Vec<_>>();

// FIXME avoid uploading empty indices
Expand Down
2 changes: 1 addition & 1 deletion maplibre/src/vector/process_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn process_vector_tile<T: VectorTransferables, C: Context>(
coords,
tessellator.quad_buffer.into(),
tessellator_new.quad_buffer.into(),
tessellator.features,
tessellator_new.features,
original_layer,
)?;
}
Expand Down
2 changes: 1 addition & 1 deletion maplibre/src/vector/transferables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl SymbolLayerTessellated for crate::vector::transferables::DefaultSymbolLayer
}

fn is_empty(&self) -> bool {
self.buffer.usable_indices == 0
self.new_buffer.usable_indices == 0
}

fn to_bucket(self) -> SymbolLayerData {
Expand Down
Loading
Loading