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

Property list changes are only notified when it did change in Curve #74927

Merged

Conversation

Rindbee
Copy link
Contributor

@Rindbee Rindbee commented Mar 15, 2023

Object::notify_property_list_changed() should only be called when the structure of the property has actually changed.

The structure of the property tree has not changed if the size of the array has not changed, and the only possibility is that the element value has changed.

Fix #74865.

@MewPurPur
Copy link
Contributor

MewPurPur commented Mar 15, 2023

It's nice that it fixes the most visible symptom of my issue, but the curve editor will still be reconstructed when adding or removing points, which isn't expected behavior.

For example in a WIP commit where I implemented a snap button in the curve editor, every time I add/remove a point, the snap button would get untoggled. Makes the whole thing dysfunctional. This helps with the re-construction issue but it's not a full fix IMO

`Object::notify_property_list_changed()` should only be called when
the structure of the property has actually changed.

The structure of the property tree has not changed if the size of the
array has not changed, and the only possibility is that the element
value has changed.
@Rindbee Rindbee force-pushed the notify_property_list_changed_when_it_did branch from 25ae932 to 69f488e Compare March 15, 2023 01:51
@Rindbee
Copy link
Contributor Author

Rindbee commented Mar 15, 2023

but the curve editor will still be reconstructed when adding or removing points, which isn't expected behavior.

Because when adding or removing array elements, the structure of the property tree does change. See Curve::_get_property_list().

Perhaps when the size of Array changes, we can try to use a new signal to specifically notify this change. Make these array properties behave like a sub-inspector (same as EditorPropertyResource) in the inspector.

@Rindbee
Copy link
Contributor Author

Rindbee commented Mar 15, 2023

And EditorInspector::update_tree() is not only a redraw process, but also a rebuild process. I think it is more appropriate to rename it to EditorInspector::rebuild_tree(). One reason the editor is not smooth is that it is called too often. Usually for the whole tree.

@Chaosus Chaosus added this to the 4.1 milestone Mar 15, 2023
@anvilfolk
Copy link
Contributor

Did a very quick look - the thought process and changes do seem to make sense. I like the discussion around making a sub-editor just for the points though, since that would allow changing points without resetting the rest of the editor. I think that would help @MewPurPur 's future efforts to add snapping!

Any chance that makes sense to add in this PR, or is that a future PR?

@YuriSizov
Copy link
Contributor

I don't see why we would need to redraw the entire tree when the structure of an array or a dictionary property changes. It's all handled by a single editor property control (from the POV of the inspector), we don't really need to update the entire tree.

@anvilfolk
Copy link
Contributor

@YuriSizov so the issue is that the points of the curve are individually exported as properties. The curve doesn't export the array of points:

void Curve2D::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < points.size(); i++) {
PropertyInfo pi = PropertyInfo(Variant::VECTOR2, vformat("point_%d/position", i));
pi.usage &= ~PROPERTY_USAGE_STORAGE;
p_list->push_back(pi);
if (i != 0) {
pi = PropertyInfo(Variant::VECTOR2, vformat("point_%d/in", i));
pi.usage &= ~PROPERTY_USAGE_STORAGE;
p_list->push_back(pi);
}
if (i != points.size() - 1) {
pi = PropertyInfo(Variant::VECTOR2, vformat("point_%d/out", i));
pi.usage &= ~PROPERTY_USAGE_STORAGE;
p_list->push_back(pi);
}
}
}

Whereas, for instance, GradientTexture2D directly exports the underlying packed arrays. This means that the property list doesn't change, and therefore the inspector tree isn't rebuilt (to display the "new" properties). For Curve, since the property list changed, the inspector is going to rebuild the tree in order to display all the properties.

Unfortunately, I believe it would be a compatibility-breaking change to directly export the underlying point & tangent arrays directly.

I think maybe the way to handle this is to follow up on the idea of having a subinspector just for the points, and that's what gets updated when the property list changes, leaving the rest untouched (particularly, the visual curve editor itself), which is at the origin of this bug. But I also don't fully understand UI and whether this is possible :)

@Rindbee
Copy link
Contributor Author

Rindbee commented Mar 15, 2023

The array here refers to using ADD_ARRAY/ADD_ARRAY_COUNT and _get_property_list() to organize the properties of the object into an array (like an array of structures).

Copy link
Contributor

@YuriSizov YuriSizov left a comment

Choose a reason for hiding this comment

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

Well, I guess it makes sense to make this change for now to speed things up a bit. Looks like a proper solution would require bigger changes to the way we work with the property list in the inspector.

@YuriSizov YuriSizov merged commit 0247a37 into godotengine:master Mar 15, 2023
@YuriSizov
Copy link
Contributor

Thanks!

@Rindbee Rindbee deleted the notify_property_list_changed_when_it_did branch March 15, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Curve Editor gets re-constructed after every operation.
5 participants