diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index e47bfef5762..c1e30dd93c2 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -257,24 +257,26 @@ void ShaderMaterial::_get_property_list(List *p_list) const { groups[last_group][last_subgroup].push_back(info); } - // Sort groups alphabetically. - List props; + List group_names; for (HashMap>>::Iterator group = groups.begin(); group; ++group) { - for (HashMap>::Iterator subgroup = group->value.begin(); subgroup; ++subgroup) { - for (List::Element *item = subgroup->value.front(); item; item = item->next()) { - if (subgroup->key == "") { - props.push_back({ group->key, item->get() }); - } else { - props.push_back({ group->key + "::" + subgroup->key, item->get() }); - } + group_names.push_back(group->key); + } + group_names.sort(); + + for (const String &group_name : group_names) { + List subgroup_names; + HashMap> &subgroups = groups[group_name]; + for (HashMap>::Iterator subgroup = subgroups.begin(); subgroup; ++subgroup) { + subgroup_names.push_back(subgroup->key); + } + subgroup_names.sort(); + for (const String &subgroup_name : subgroup_names) { + List &prop_infos = subgroups[subgroup_name]; + for (List::Element *item = prop_infos.front(); item; item = item->next()) { + p_list->push_back(item->get()); } } } - props.sort_custom(); - - for (List::Element *E = props.front(); E; E = E->next()) { - p_list->push_back(E->get().info); - } } } diff --git a/scene/resources/material.h b/scene/resources/material.h index 6c81293ee30..dd9589c577e 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -84,17 +84,6 @@ class ShaderMaterial : public Material { HashMap param_cache; - struct UniformProp { - String str; - PropertyInfo info; - }; - - struct UniformPropComparator { - bool operator()(const UniformProp &p_a, const UniformProp &p_b) const { - return p_a.str.naturalnocasecmp_to(p_b.str) < 0; - } - }; - protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const;