Plans: Cache whether any plans are currently visible

This commit is contained in:
Jonathan G Rennison
2024-01-17 19:03:10 +00:00
parent 1159224d6f
commit 3d87cfeca5
9 changed files with 65 additions and 5 deletions

View File

@@ -17,6 +17,9 @@ INSTANTIATE_POOL_METHODS(Plan)
Plan *_current_plan = nullptr;
Plan *_new_plan = nullptr;
uint64_t _plan_update_counter = 0;
uint64_t _last_plan_visibility_check = 0;
bool _last_plan_visibility_check_result = false;
void PlanLine::UpdateVisualExtents()
{
@@ -63,3 +66,25 @@ bool Plan::ValidateNewLine()
}
return ret;
}
void UpdateAreAnyPlansVisible()
{
_last_plan_visibility_check = _plan_update_counter;
if (_current_plan && _current_plan->temp_line->tiles.size() > 1) {
_last_plan_visibility_check_result = true;
return;
}
for (const Plan *p : Plan::Iterate()) {
if (!p->IsVisible()) continue;
for (const PlanLine *pl : p->lines) {
if (pl->visible) {
_last_plan_visibility_check_result = true;
return;
}
}
}
_last_plan_visibility_check_result = false;
}