Fix sorting of uniform items in the material properties
Co-authored-by: Chia-Hsiang Cheng <garychia@users.noreply.github.com>
This commit is contained in:
parent
95df3e7c88
commit
4f0e0f1650
2 changed files with 16 additions and 25 deletions
|
@ -257,24 +257,26 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
groups[last_group][last_subgroup].push_back(info);
|
||||
}
|
||||
|
||||
// Sort groups alphabetically.
|
||||
List<UniformProp> props;
|
||||
List<String> group_names;
|
||||
for (HashMap<String, HashMap<String, List<PropertyInfo>>>::Iterator group = groups.begin(); group; ++group) {
|
||||
for (HashMap<String, List<PropertyInfo>>::Iterator subgroup = group->value.begin(); subgroup; ++subgroup) {
|
||||
for (List<PropertyInfo>::Element *item = subgroup->value.front(); item; item = item->next()) {
|
||||
if (subgroup->key == "<None>") {
|
||||
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<String> subgroup_names;
|
||||
HashMap<String, List<PropertyInfo>> &subgroups = groups[group_name];
|
||||
for (HashMap<String, List<PropertyInfo>>::Iterator subgroup = subgroups.begin(); subgroup; ++subgroup) {
|
||||
subgroup_names.push_back(subgroup->key);
|
||||
}
|
||||
subgroup_names.sort();
|
||||
for (const String &subgroup_name : subgroup_names) {
|
||||
List<PropertyInfo> &prop_infos = subgroups[subgroup_name];
|
||||
for (List<PropertyInfo>::Element *item = prop_infos.front(); item; item = item->next()) {
|
||||
p_list->push_back(item->get());
|
||||
}
|
||||
}
|
||||
}
|
||||
props.sort_custom<UniformPropComparator>();
|
||||
|
||||
for (List<UniformProp>::Element *E = props.front(); E; E = E->next()) {
|
||||
p_list->push_back(E->get().info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,17 +84,6 @@ class ShaderMaterial : public Material {
|
|||
|
||||
HashMap<StringName, Variant> 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;
|
||||
|
|
Loading…
Reference in a new issue