Merge pull request #99231 from fire/sort-blendshapes-by-id

Sort blend shapes in the inspector by ID instead of alphabetically
This commit is contained in:
Thaddeus Crews 2024-11-19 15:20:11 -06:00
commit 1680edb2cd
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84

View File

@ -87,17 +87,9 @@ bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
} }
void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const { void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
List<String> ls; for (uint32_t i = 0; i < blend_shape_tracks.size(); i++) {
for (const KeyValue<StringName, int> &E : blend_shape_properties) { p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("blend_shapes/%s", String(mesh->get_blend_shape_name(i))), PROPERTY_HINT_RANGE, "-1,1,0.00001"));
ls.push_back(E.key);
} }
ls.sort();
for (const String &E : ls) {
p_list->push_back(PropertyInfo(Variant::FLOAT, E, PROPERTY_HINT_RANGE, "-1,1,0.00001"));
}
if (mesh.is_valid()) { if (mesh.is_valid()) {
for (int i = 0; i < mesh->get_surface_count(); i++) { for (int i = 0; i < mesh->get_surface_count(); i++) {
p_list->push_back(PropertyInfo(Variant::OBJECT, vformat("%s/%d", PNAME("surface_material_override"), i), PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial", PROPERTY_USAGE_DEFAULT)); p_list->push_back(PropertyInfo(Variant::OBJECT, vformat("%s/%d", PNAME("surface_material_override"), i), PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial", PROPERTY_USAGE_DEFAULT));
@ -142,6 +134,7 @@ int MeshInstance3D::get_blend_shape_count() const {
} }
return mesh->get_blend_shape_count(); return mesh->get_blend_shape_count();
} }
int MeshInstance3D::find_blend_shape_by_name(const StringName &p_name) { int MeshInstance3D::find_blend_shape_by_name(const StringName &p_name) {
if (mesh.is_null()) { if (mesh.is_null()) {
return -1; return -1;
@ -153,11 +146,13 @@ int MeshInstance3D::find_blend_shape_by_name(const StringName &p_name) {
} }
return -1; return -1;
} }
float MeshInstance3D::get_blend_shape_value(int p_blend_shape) const { float MeshInstance3D::get_blend_shape_value(int p_blend_shape) const {
ERR_FAIL_COND_V(mesh.is_null(), 0.0); ERR_FAIL_COND_V(mesh.is_null(), 0.0);
ERR_FAIL_INDEX_V(p_blend_shape, (int)blend_shape_tracks.size(), 0); ERR_FAIL_INDEX_V(p_blend_shape, (int)blend_shape_tracks.size(), 0);
return blend_shape_tracks[p_blend_shape]; return blend_shape_tracks[p_blend_shape];
} }
void MeshInstance3D::set_blend_shape_value(int p_blend_shape, float p_value) { void MeshInstance3D::set_blend_shape_value(int p_blend_shape, float p_value) {
ERR_FAIL_COND(mesh.is_null()); ERR_FAIL_COND(mesh.is_null());
ERR_FAIL_INDEX(p_blend_shape, (int)blend_shape_tracks.size()); ERR_FAIL_INDEX(p_blend_shape, (int)blend_shape_tracks.size());