[core] always commit placement to fix #11795
Since placements will be committed even if they do not need the full fade duration to fade features in, we need the new `fadeStartTime` to keep track of how long we still need to fade. This is important because if we fade too long we will trigger another placement and never stop rendering.
This commit is contained in:
committed by
Ansis Brammanis
parent
0a15be07ae
commit
58b6c42f5d
@@ -387,6 +387,8 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
|
||||
|
||||
bool placementChanged = false;
|
||||
if (!placement->stillRecent(parameters.timePoint)) {
|
||||
placementChanged = true;
|
||||
|
||||
auto newPlacement = std::make_unique<Placement>(parameters.state, parameters.mapMode);
|
||||
std::set<std::string> usedSymbolLayers;
|
||||
for (auto it = order.rbegin(); it != order.rend(); ++it) {
|
||||
@@ -396,13 +398,9 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
|
||||
}
|
||||
}
|
||||
|
||||
placementChanged = newPlacement->commit(*placement, parameters.timePoint);
|
||||
newPlacement->commit(*placement, parameters.timePoint);
|
||||
crossTileSymbolIndex.pruneUnusedLayers(usedSymbolLayers);
|
||||
if (placementChanged || symbolBucketsChanged) {
|
||||
placement = std::move(newPlacement);
|
||||
}
|
||||
|
||||
placement->setRecent(parameters.timePoint);
|
||||
placement = std::move(newPlacement);
|
||||
|
||||
updateFadingTiles();
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,6 @@ Placement::Placement(const TransformState& state_, MapMode mapMode_)
|
||||
: collisionIndex(state_)
|
||||
, state(state_)
|
||||
, mapMode(mapMode_)
|
||||
, recentUntil(TimePoint::min())
|
||||
{}
|
||||
|
||||
void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatrix, bool showCollisionBoxes) {
|
||||
@@ -188,7 +187,7 @@ void Placement::placeLayerBucket(
|
||||
bucket.justReloaded = false;
|
||||
}
|
||||
|
||||
bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
|
||||
void Placement::commit(const Placement& prevPlacement, TimePoint now) {
|
||||
commitTime = now;
|
||||
|
||||
bool placementChanged = false;
|
||||
@@ -222,7 +221,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
|
||||
}
|
||||
}
|
||||
|
||||
return placementChanged;
|
||||
fadeStartTime = placementChanged ? commitTime : prevPlacement.fadeStartTime;
|
||||
}
|
||||
|
||||
void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
|
||||
@@ -339,18 +338,15 @@ float Placement::symbolFadeChange(TimePoint now) const {
|
||||
}
|
||||
|
||||
bool Placement::hasTransitions(TimePoint now) const {
|
||||
return symbolFadeChange(now) < 1.0 || stale;
|
||||
if (mapMode == MapMode::Continuous) {
|
||||
return stale || std::chrono::duration<float>(now - fadeStartTime) < Duration(std::chrono::milliseconds(300));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Placement::stillRecent(TimePoint now) const {
|
||||
return mapMode == MapMode::Continuous && recentUntil > now;
|
||||
}
|
||||
void Placement::setRecent(TimePoint now) {
|
||||
stale = false;
|
||||
if (mapMode == MapMode::Continuous) {
|
||||
// Only set in continuous mode because "now" isn't defined in still mode
|
||||
recentUntil = now + Duration(std::chrono::milliseconds(300));
|
||||
}
|
||||
return mapMode == MapMode::Continuous && commitTime + Duration(std::chrono::milliseconds(300)) > now;
|
||||
}
|
||||
|
||||
void Placement::setStale() {
|
||||
|
||||
@@ -63,7 +63,7 @@ class Placement {
|
||||
public:
|
||||
Placement(const TransformState&, MapMode mapMode);
|
||||
void placeLayer(RenderSymbolLayer&, const mat4&, bool showCollisionBoxes);
|
||||
bool commit(const Placement& prevPlacement, TimePoint);
|
||||
void commit(const Placement& prevPlacement, TimePoint);
|
||||
void updateLayerOpacities(RenderSymbolLayer&);
|
||||
float symbolFadeChange(TimePoint now) const;
|
||||
bool hasTransitions(TimePoint now) const;
|
||||
@@ -94,12 +94,12 @@ private:
|
||||
|
||||
TransformState state;
|
||||
MapMode mapMode;
|
||||
TimePoint fadeStartTime;
|
||||
TimePoint commitTime;
|
||||
|
||||
std::unordered_map<uint32_t, JointPlacement> placements;
|
||||
std::unordered_map<uint32_t, JointOpacityState> opacities;
|
||||
|
||||
TimePoint recentUntil;
|
||||
bool stale = false;
|
||||
|
||||
std::unordered_map<uint32_t, RetainedQueryData> retainedQueryData;
|
||||
|
||||
Reference in New Issue
Block a user