Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show revert button for MeshInstance3D blendshape values #82984

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scene/3d/mesh_instance_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,23 @@ void MeshInstance3D::create_debug_tangents() {
}
}

bool MeshInstance3D::_property_can_revert(const StringName &p_name) const {
HashMap<StringName, int>::ConstIterator E = blend_shape_properties.find(p_name);
if (E) {
return true;
}
return false;
Comment on lines +497 to +501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, can you confirm that this doesn't break the revertability of other, non blend shape properties of MeshInstance3D?

Copy link
Contributor Author

@smix8 smix8 Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that I can still revert all the Node3D/GeometryInstance3D inspector properties that seem to be the only class in the inherit chain that uses the same functions. Everything else about that function shenanigan and how it does its thing under the hood no idea, I am just monkey-copy-pasting from other nodes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false means fallback to default behavior, like with other similar methods.

}

bool MeshInstance3D::_property_get_revert(const StringName &p_name, Variant &r_property) const {
HashMap<StringName, int>::ConstIterator E = blend_shape_properties.find(p_name);
if (E) {
r_property = 0.0f;
return true;
}
return false;
}

void MeshInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance3D::set_mesh);
ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance3D::get_mesh);
Expand Down
3 changes: 3 additions & 0 deletions scene/3d/mesh_instance_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class MeshInstance3D : public GeometryInstance3D {
void _notification(int p_what);
static void _bind_methods();

bool _property_can_revert(const StringName &p_name) const;
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;

public:
void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
Expand Down
Loading