Page MenuHome

UI: Drag and Drop Constraints, Layout Updates
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Apr 23 2020, 12:29 AM.

Details

Summary

This patch implements the list panel system D7490 for constraints. In this case the panels are still defined in Python.

I also updated the constraint layouts to be in line with UI guidelines established with 2.8. I think the benefits to readability and consistency are huge.

Examples:

Diff Detail

Repository
rB Blender
Branch
panel-list-patch-3 (branched from master)
Build Status
Buildable 8581
Build 8581: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Hans Goudey (HooglyBoogly) requested review of this revision.Apr 23 2020, 12:29 AM
source/blender/editors/object/object_constraint.c
1608

Note: This currently returns NULL because of an unset "constraint" context pointer. I'm not sure why though, because I set in the header and in python:
uiLayoutSetContextPointer(layout, "constraint", &ptr);
self.layout.context_pointer_set("constraint", con)
I'm happy to debug this further, but I figured I might be missing something and it would be worth asking.

The drag and drop works fine with a "return true" poll function.

This revision is now accepted and ready to land.Apr 23 2020, 8:07 AM

Updated to latest master

Aaron Carlisle (Blendify) added inline comments.
release/scripts/startup/bl_ui/properties_constraint.py
506–514

"Axis" is a better label, and is more consistent with other areas of Blender.

533

"Axis" is a better label, and is more consistent with other areas of Blender.

560–563

"Axis" is a better label, and is more consistent with other areas of Blender.

Hans Goudey (HooglyBoogly) marked 3 inline comments as done.

Change "Use" to "Axis"

Update to latest master

Merge changes from updates to patch 1 and 2
Move panel id from constraint type function to constraint.c

  • Change "For Transform" to "Affect Transform"
  • Merge branch 'master' into panel-list-patch-3
  • Remove a few unintentional changes
Julian Eisel (Severin) requested changes to this revision.Jun 8 2020, 12:23 PM

Just a few minor points, overall this seems mostly ready.

source/blender/editors/interface/interface_templates.c
1911

Why is this an enum, seems like this could be a bool? Or if this uses an enum, there should be proper enum item names.

1961

If constraint_panel_id() is just a wrapper for BKE_constraint_panelId(), why not call that directly here?
But if you decide to keep it that way, no need for the cast :)

source/blender/editors/object/object_constraint.c
1573

Would protect this a bit better against invalid values. What if either index or current_index is -1? I guess for the latter an assert would be sufficient.

1600

Try to explain the operators in different terms than the name uses. E.g. "Change the order of constraint so that...".

This revision now requires changes to proceed.Jun 8 2020, 12:23 PM
Hans Goudey (HooglyBoogly) marked 4 inline comments as done.
  • Small layout tweaks, use more columns to decrease empty space
  • Add a comment about enum values
  • Remove useless function
  • Rename BKE_constraint_panelId to BKE_constraint_panel_id
  • Add checks / asserts in constraint move to index
  • Improve description for move to index operator
  • Re-add constraint_panel_id function

It's actually necessary for its (void *) argument. I added a comment to mention that.

Hans Goudey (HooglyBoogly) planned changes to this revision.Jun 10 2020, 7:07 PM

Fix using the pinned object

source/blender/editors/interface/interface_templates.c
1911

Not quite sure, but it's from existing code in object_constraint.c:

prop = RNA_def_enum(
    ot->srna, "owner", constraint_owner_items, 0, "Owner", "The owner of this constraint");

I added a comment about the enum values here, which are local to the implementation.

1961

Oops! I'll make sure I do this change for the other patches so you don't have to comment it each time ; )

source/blender/editors/object/object_constraint.c
1600

How is this? I'll change the modifier op description too.

  • Small cleanup in constraint header template
  • Remove deprecated constraint UI (rigid_body_join)

I haven't been able to figure out the problem with pinned objects. I've applied the same
fix I used for modifiers, but it works in the C template code, but not in python.

The code for getting the active constraint list in python is exactly the same, so I'm sort of stumped here.

  • Merge branch 'master' into panel-list-patch-3
  • Correct order of mapping subpanel

Tested just now, I'm noticing some big but maybe easy to fix issues with bones:

  • In Pose Mode, Object Constraints are not visible
  • When attempting to add bone constraints, it seems to try to add it as an object constraint instead, not sure what's going on exactly but it fails to draw:

  • Existing bone constraints don't show up anywhere.

Tested just now, I'm noticing some big but maybe easy to fix issues with bones:

Thanks for testing! That's what I was referring to in my previous comment about being stumped. But you may have given me a good clue to solve it.

  • List panel system: Check for NULL data listbase
  • Fix bone constraints by duplicating panels, but sharing drawing code
  • Update UI for all IK, spline IK constraints
  • Add some comments

So, @Demeter Dzadik (Mets), it looks like what you reported did lead to the solution.

Unfortunately if was about as far from a quick fix as I could have imagined.
The problem was that there are two contexts these UIs are in, bone_constraint and constraint.
Because of the limitations of the panel system there needs to be separate panel types for each context.
So I duplicated the panels for bones and objects, but made the drawing code common between the two.

I also finally updated the spline IK and IK constraint UI.

Awesome, glad to be of use! More pain awaits!

  • Source panel seems to have the constraint header thingie on it, and fails to draw, error in console:



This only happens on bone constraint, while it works correctly on the object constraint.

  • On Limit Distance, the Reset Distance button is aligned with the Distance slider:


There is a similar layout on the Stretch To constraint, but there it looks correct.

Reproducible Crash 1

  • Add single bone, enter pose mode
  • Add pose constraint
  • Add object constraint
  • Delete pose constraint
  • Switch to object constraint tab
  • Crash


Reproducible Crash 2

  • Add single bone
  • Enter pose mode
  • Add object constraint
  • Crash


Not so reproducible crash 3
One time I set my undo steps to 2 since that was something I remembered causing some crashes in the past, and then furiously clicked adding and moving and deleting constraints. This time I got a segfault when deleting a bone constraint:



I couldn't reproduce this again, and I don't know if the undo steps thing was relevant. I didn't look at the stack trace, but I'm just hoping the root cause for all of these is the same. Also, sorry about the bad filenames, this post was originally in quite a different order while I was still figuring out the reproduction steps >.>.

  • Fix layout issues
  • Fix object / bone constraint confusion in code

@Demeter Dzadik (Mets) Thank you very much for the detailed crash descriptions, they made debugging this very quick!
I should have noticed the issues earlier, the panel code was still trying to find constraints based on whether you were in pose mode rather than the type of panel.

Great work! With all of that out of the way, I have a suggestion that's more subjective and design related, but I feel quite strongly about it.

I think use_property_decorate=True is a bad idea here. I'm guessing it's being used to follow some sort of UI guidelines, but I think surely we should ask ourselves how often certain properties get animated before making the ability to do so take up space in the UI.

The purpose of the dots is to let users know that these properties can in fact, be animated, which is a noble goal of course. My issue is, users don't care, because there is no use case for keyframing 99% of these values (Influence makes up the 1%). In exchange for this discoverability, the dots add a lot of noise and distraction to an area of Blender that is already very intimidating. So for this reason I think it's a bad tradeoff, and I advocate for use_property_decorate=False, and only setting it to True where it can be sufficiently justified.

Great work! With all of that out of the way, I have a suggestion that's more subjective and design related, but I feel quite strongly about it.

I think use_property_decorate=True is a bad idea here. I'm guessing it's being used to follow some sort of UI guidelines, but I think surely we should ask ourselves how often certain properties get animated before making the ability to do so take up space in the UI.

The purpose of the dots is to let users know that these properties can in fact, be animated, which is a noble goal of course. My issue is, users don't care, because there is no use case for keyframing 99% of these values (Influence makes up the 1%). In exchange for this discoverability, the dots add a lot of noise and distraction to an area of Blender that is already very intimidating. So for this reason I think it's a bad tradeoff, and I advocate for use_property_decorate=False, and only setting it to True where it can be sufficiently justified.

Heh.. Yeah, it's mainly consistency. If we don't have them here, then why do we have them somewhere else, etc.
I like consistency-- I don't really know why constraints should be different than other areas of Blender. For example, we just added them to materials in properties editor.
That said, I don't have a strong feeling about their value here, so I'll page @William Reynish (billreynish) for his opinion here.

I used to not like them too but they have grown on me as I got used to the change.

Thanks again for the review!

(Edit: Removed my question, I misread your comment)

This seems fine code wise, I won't speak for the design. Neither did I review the layout changes in detail, if there are issues they can be fixed in master.

Only asking for one minor change.

source/blender/editors/object/object_constraint.c
1600

Would replace "index" with "position", otherwise fine with me.

Also, there's a double-space in the current one :)

This revision is now accepted and ready to land.Jun 18 2020, 6:17 PM

I'm pretty sure pinning doesn't work yet, Hans might be aware of this but I'll post my findings anyways, maybe it will be useful.

Repro steps for funky object constraint pinning:

  • Add 3 unique object constraints; Copy Loc/Rot/Scale.
  • Duplicate object
  • Enable pinning in the Properties Editor
  • Delete top-most constraint (Copy Loc)
  • Select the other object
  • It's now displaying the constraints of the active object instead of the pinned one, but only displays as many of them as there are on the pinned object. So it displays the first two; Copy Loc and Copy Rot. So, whatever value it's using to figure out how many constraints to display is correct. It's just the object whose constraints are being displayed is wrong.

Bone Constraints seem to have a different problem. It just always shows the constraints of the active bone, regardless of having pinned another. However, the armature and bone names at the top of the Properties Editor do display the pinned object and bone's names correctly.

I think we clearly should include the decorators. The purpose it to communicate the state of the controls (keyframed, animated, driven, overridden, etc) and almost all these properties can have these states. We only disable decorators for sections where those things don't work.

Hmmm, I tried. And I may return to this topic in the future, outside this patch, since it affects the modifier panel too.

But, I think at least you'll agree these keyframing buttons are in the way or confusing:

  • On Stretch To, the Volume Min/Max rows, the keyframing button keyframes the checkbox instead of the float value that's actually next to it. It's confusing, but I'm not sure how best to handle. It's nice that the checkbox is next to the float value, so it'd be a shame to lose that just because of this. I hope it's possible to simply make the keyframing button affect the slider instead of the checkbox. But if not, ohwell, it's the smallest of the problems.
  • IK constraint, might be still a TODO, I'm not sure, but seems a bit messy atm, in no small part thanks to the 3 keyframing dots in the middle of it.
  • On Copy Loc/Rot/Scale/Transforms, if an armature is selected as the target so the bone selector and head/tail slider show up, the head/tail slider has an ugly keyframing button in between properties:
    It would also make sense to put the toggle button to the left of the slider, and gray out the slider when it's off. Then the slider can have its keyframing button in the usual place, and the toggle button can live without a keyframing button.
This revision was automatically updated to reflect the committed changes.
Hans Goudey (HooglyBoogly) marked an inline comment as done.

Before committing I went through and dealt with all the problematic decorators. I also did a small pass for consistency on all the layouts and fixed the things @Demeter Dzadik (Mets) mentioned.

@Hans Goudey (HooglyBoogly) sorry for being late to the party, but I have some bad news. It seems to me like any subpanel of any constraint is just empty with this patch. The options in the Transform Constraint are also completely gone (also in the code as far as I can see).

release/scripts/startup/bl_ui/properties_constraint.py
786

It seems like the content of the transform constraint isn't implemented...

1190

typo in comment

@Hans Goudey (HooglyBoogly) sorry for being late to the party, but I have some bad news. It seems to me like any subpanel of any constraint is just empty with this patch. The options in the Transform Constraint are also completely gone (also in the code as far as I can see).

No worries, crisis averted! rBa089286d7b96

Thanks

Yes seems fixed. Good work. (Now I also figured out how those subsections are filled, so nevermind my inline comment on the transform constraint 😅)

release/scripts/startup/bl_ui/properties_constraint.py
1342

typo in comment