17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 06:19:19 +02:00

perf(scenery): minimap semaphores matched against the named models of a group collected once, instead of a search through all nodes of the scenery for each semaphore

This commit is contained in:
2026-10-07 16:10:38 +02:00
parent 9d6aa24af4
commit 7b15b9a017

View File

@@ -107,6 +107,11 @@ node_groups::update_map()
for (auto const &pair : m_groupmap) {
auto const &group = pair.second;
// named models of the group, collected once the group turns out to hold a semaphore.
// nested groups are flattened, so a group can hold millions of nodes, most of them nameless scenery;
// going through all of them for each semaphore took minutes
std::vector<TAnimModel *> namedmodels;
bool namedmodelscollected = false;
for (basic_node *node : group.nodes) {
std::string postfix { "_sem_mem" };
@@ -128,10 +133,17 @@ node_groups::update_map()
}
}
for (basic_node *node : group.nodes)
if (auto *model = dynamic_cast<TAnimModel*>(node))
if (model->name().starts_with(sem_name))
sem_info->models.push_back(model);
if (false == namedmodelscollected) {
for (basic_node *groupnode : group.nodes)
if (false == groupnode->name().empty())
if (auto *model = dynamic_cast<TAnimModel*>(groupnode))
namedmodels.push_back(model);
namedmodelscollected = true;
}
for (auto *model : namedmodels)
if (model->name().starts_with(sem_name))
sem_info->models.push_back(model);
}
if (Global.map_manualswitchcontrol) {