Mustard2 / MustardUI

Custom UI for Blender human models. It features automatic outfits switch, custom properties support, armature panel creation, and much more.
https://mustard3d.eu
MIT License
301 stars 30 forks source link

Library linked rig workflow #4

Open clembu opened 3 years ago

clembu commented 3 years ago

I have found that most if not all of the properties and operators in the UI are not library-overridable. Meaning, when one links the rig in another file, and makes either a proxy or a library override, this UI is simply disabled because the properties it controls are not editable.

meaning that this UI is only friendly to appending the rig. Which, in all regards, is functional and makes things work, but it also means a lot of data duplication.

Mustard2 commented 3 years ago

Yes this is how it works now. I'm planning a major revision of the code in order to solve this and a lot of other problems/limitations.

(I started this as a small first Blender script project, and since I'm dumb I started adding stuffs without rewriting it properly. In the end there were too many things in the UI for rewriting everything from scratch. But I'm aware of the issues, and planning to revisit everything soon.)

Mustard2 commented 3 years ago

5 I am working on this, it will be "fixed" in the new version. I am busy porting all old functionalities on the new code, so it won't be a fast process. :)

Mustard2 commented 3 years ago

I might need some help here.

I saw that there is a override = [‘LIBRARY_OVERRIDABLE’] option for all properties. Should this be enabled to all properties to achieve what you firstly asked in this issue?

Ref. https://docs.blender.org/api/current/bpy.props.html

clembu commented 3 years ago

I think all properties directly accessible via UI should be overridable. I haven't handled a linked MustardUI file in a while so i forgot exactly what was blocked ; i'll check when i have time, to jog my memory. But typically things like the debug mode or the advanced toggles, or the subdivision modifier checkboxes.

Mustard2 commented 3 years ago

Thank you! I'll try myself, if that's the solution it should be simple to implement it everywhere.

clembu commented 3 years ago

None of the controls seem to be active, actually. This is what the menu looks like when making a library overdrive from the Tifa collection. image

If it helps to understand, the debug info on the description tooltip for the outfit list (for example) gives me this image

To be fair, I just realized the Tifa i'm using right now is bundled with the 0.11.3 version of the script, so that's why the property is still outfits and not outfits_list, but still, i think the idea is that if there's a button to edit that property, it'll need to be overridable

Mustard2 commented 3 years ago

OK, thank you very much for the test. :)

I didn't change the options of the properties in version 0.20.0, so I expect the issue to be also there. I will try to set the override option and check if the problem is solved.

Mustard2 commented 2 years ago

Partial solution for this issue has been implemented in 0.21 and 0.22, enabling library override for custom properties.

Mr-Lux commented 2 years ago

Is there any update on the progress to make enums and bool locks properties library overridable within the script?

Mustard2 commented 2 years ago

I have to find the time to go through all the properties and set the override. :(

If this is a priority, I can do this before other things.

Mr-Lux commented 2 years ago

It's a priority for me, but I don't how much is a requested feature. I just know that it's a well used way of building projects for animators when there are a lot of parts. So if you could that would be great, meanwhile I have my workarounds.

Mustard2 commented 2 years ago

@Mr-Lux Can you check if this is working for you? I only changed the override of some body and global outfit properties.

mustard_ui.zip

Mr-Lux commented 2 years ago

I tried on my side and it doesn't changed anything. I did not find a sure way to have a console line to check if said properties really are locked, but it should involve

https://docs.blender.org/api/current/bpy.types.bpy_struct.html#bpy.types.bpy_struct.is_property_overridable_library

However for now it seems it does not recognize (or more likely I don't know the proper syntax) the call for outfit or a lock.

Maybe related, a custom property added does not appear on a linked collection overrided. In my example it was the color value of a material. It does appear if maintenance tool are enabled though.

Mustard2 commented 2 years ago

So I'm actually confused, because I thought the only way to make it library overridable was to add the line override = {‘LIBRARY_OVERRIDABLE’} but it doesn't seem to work. So at the moment I don't have any clue of what might be wrong to be honest. Maybe properties in classes can not be overridden (atm I define properties inside a class to make everything cleaner)? Or do you need to use a flag also for property classes?

As for the other issues, I found that too. But is the color property you added library overridable, or also that is locked?

Mustard2 commented 2 years ago

Btw I guess the operator you are mentioning works for custom properties only. As you can see at least the custom properties in the UI (like the ones in the cogwheel of the outfits) are all library overridable. This is why I was asking if the color was working, because according also to this operator result, it should be.

tifa5_v1_2

But still no clue about standard properties defined in the script directly.

Mr-Lux commented 2 years ago

So I tried the new script and it did not work. I went deeper and tried changing the library override via console command using this, an operator present for any type of property.

https://docs.blender.org/api/current/bpy.types.bpy_struct.html#bpy.types.bpy_struct.property_overridable_library_set

But it got weird as a property defined in a property group that is set to override via that function (and confirmed via the "is_property_overridable_library" still gets blocked on a linked rig. I'm kinda lost to be honest. My knowledge is lacking, but maybe the mustard script reset those properties making any console command useless.

On another problem, when overriding a collection (which is the way to get the Armature and mesh in the same import), it just puts on override the main armature, making any mesh data block and material not overridable and so locks and material properties are not by default accessible, even if set to overridable.

For that one must go into the outliner, and in Overrides libraries (a filter in the same location than to acces Blend data or View Layers) and set each block as Overridable Editable. It seems from the blend devs that the option to do that for the whole hierarchy will be availablle in the next build (it's available for now in 3.3 alpha).

On my part, before using your script or another type of character ui script, I put every custom property into a property bone in my main armature. So even if linked, as every part was driven by those custom properties I had access to those. It was just tedious work and not dynamic as your script.

Mustard2 commented 2 years ago

For the first problem, we must distinguish two types of properties:

Not sure if I understand the second problem, but if you right click on the linked collection there is a way to hierarchically override all childrens: https://docs.blender.org/manual/en/latest/files/linked_libraries/library_overrides.html#creating-an-override

IamTirion commented 1 year ago

Hello, is there any update to this issue?

IamTirion commented 12 months ago

Although I can't be of any help in terms of coding, one thing I'd like to point out is that there's somewhat of a workaround, that may be a hint towards a proper solution. If you make the armature of a linked character local, you can use the MustardUI. The problem with this workaround is that the armature alone takes up a lot of data, thus still making the scene big.

Edit: By armature, I mean the green icon that contains all the bones in the Outliner, which is contained in the orange icon, which is what people usually call the armature. There is probably a proper name for this but I don't know what it is. Hopefully I didn't confuse you.

Mustard2 commented 11 months ago

Hi @IamTirion,

sorry for the late reply.

In fact the whole issue is on the armature data (the "green icon" one) and not the Object itself, which does not contain any UI data. If you make the first local, everything is fixed because the whole data structure is then accessible directly on the scene.

There are still a couple of things that I don't understand unfortunately, but the main thing is why there is no way to allow for linked properties to work if they are flagged as override = {‘LIBRARY_OVERRIDABLE’}. I don't think it might be it, I will try again with the current version 0.30 adding this option and see if the culprit was indeed the fact I was using a script instead of an addon. Long shot, but I'm honestly out of ideas on this issue at the moment. :(

IamTirion commented 11 months ago

Hi @IamTirion,

sorry for the late reply.

In fact the whole issue is on the armature data (the "green icon" one) and not the Object itself, which does not contain any UI data. If you make the first local, everything is fixed because the whole data structure is then accessible directly on the scene.

There are still a couple of things that I don't understand unfortunately, but the main thing is why there is no way to allow for linked properties to work if they are flagged as override = {‘LIBRARY_OVERRIDABLE’}. I don't think it might be it, I will try again with the current version 0.30 adding this option and see if the culprit was indeed the fact I was using a script instead of an addon. Long shot, but I'm honestly out of ideas on this issue at the moment. :(

Oh please don't apologise. I cannot be grateful enough for your script/addon. It brings so many functions that makes Blender much closer to Daz3d. In fact, you have unique functions like Simplify that even Daz3d doesn't have. It's a game-changer honestly. It's impossible to pose accurately without the smooth framerate from using Simplify.

I think it's not so surprising that some data cannot be overriden. The whole Library Override thing was made because the previous Proxy feature only allowed very limited types of data to be overridden. I think you could only override the location, rotation and scale on a Proxy. So, Library Override was made to open up more types of data that can be overriden, but still a lot of data is still not overrideable. It may just be a limitation of Blender, but it also makes sense in a way. Because if you could override anything, then what's the difference between making an exact copy (Append), and Linking an object?

There are a number of updates to Library Override in Blender 4 as written here: https://wiki.blender.org/wiki/Reference/Release_Notes/4.0/Core

However, I don't think any of those might help in this situation. But who knows? This is really out of my league :P.

And this is the roadmap for Library Override: https://projects.blender.org/blender/blender/issues/73318

You can see that they are still planning to add more type of data that can be overridden.

Well, I also have discovered something that might be related. If you use a Rigify, which works by a python script like yours, a custom property will be created for it. But you can't make it Library Overrideable by ticking the checkbox like the other custom properties.

IamTirion commented 11 months ago

@Mustard2 https://youtu.be/LcQkk7NbOoY?t=344

I wonder if this would help, Mustard? Data-block can be a custom property now and thus should be overrideable.

IamTirion commented 11 months ago

By the way, I have tried overriding the green icon armature in Blender 4.0 with your new addon. It still doesn't work. Guess that wasn't it :(.

Mustard2 commented 11 months ago

I have to be honest, I still have to try this in Blender 4.0 Might be a good candidate for the next update, if I figure out how to solve this :D

IamTirion commented 11 months ago

@Mustard2 By the way, have you tried asking for help on https://devtalk.blender.org/ or https://blenderartists.org/? I think you will get much more help from those places than here.

jdfleming commented 11 months ago

According to P2Design (YouTube), the non-saving behavior of overrides is by design : /

I had some success registering PropertyGroups with bpy.props.Object and keyframing the character custom properties into an Action then pushing that down to the NLA. I don't entirely hate this.

Blender reverts each override value the first time each value is manipulated resulting in 2-3 clicks to set each initial value. I entirely hate this.

While somewhat irritating, this NLA approach does allow linked character property overrides to persist.

Mustard2 commented 11 months ago

@IamTirion I think I can try, yes. Maybe someone has better understanding about what's happening

@jdfleming This is not great news :(

I see that they're planning some changes in Blender 4.1? Not sure if it's worth waiting a bit before trying this solution, which seems a workaround :(

IamTirion commented 7 months ago

I have a little question. I have heard many people using LLMs to write code, or find bugs, or to optimise their code. Have you tried asking a LLM about this situation, Mustard?

GeneralShan commented 7 months ago

I have a little question. I have heard many people using LLMs to write code, or find bugs, or to optimise their code. Have you tried asking a LLM about this situation, Mustard?

Usefulness of LLM for code is highly overstated. They are most helpful to beginners learning, or for saving time do basic things automatically. Specifically for a problem like this, highly unlikely LLM can do anything useful. This problem is depending on implementation details of Blender.

IamTirion commented 7 months ago

I have a little question. I have heard many people using LLMs to write code, or find bugs, or to optimise their code. Have you tried asking a LLM about this situation, Mustard?

Usefulness of LLM for code is highly overstated. They are most helpful to beginners learning, or for saving time do basic things automatically. Specifically for a problem like this, highly unlikely LLM can do anything useful. This problem is depending on implementation details of Blender.

I see. Thank you.

IamTirion commented 7 months ago

Hi, I have the opportunity to ask Dr. Sybren, the lead animation developer of Blender about this addon. May I ask which properties are edited with the "Simplify" button? Or is there a way I can find that out so I can list them out for him?

IamTirion commented 7 months ago

@Mustard2 Hi Mustard, in my recent conversation with Dr. Sybren, he gave some suggestions to fix this issue. You can see the conversation here: https://blender.chat/channel/animation, but it is a chat room, so the conversation is going to be lost to time. I'll crop the entire conversation into images so it can be saved here for reference. Meanwhile, I'll post the things that I think may help resolve this issue. I know you have already tried making some properties overrideable, but maybe it wasn't done correctly? Well, if this helps, that's great. If not, at least we tried.

The property that he thinks should be marked as "editable via library overrides": bpy.data.armatures["rig"]

Ways to override different properties: About the screenshot you posted in https://github.com/Mustard2/MustardUI/issues/4#issuecomment-1171100948 : please don't post screenshots of code, as you make it impossible for others to copy-paste it. Check https://stuvel.eu/post/2021-07-11-code-in-markdown/ for better ways to do this.

For Custom Properties defined via the Blender UI you have the 'Library Overridable' property. That has to be checked.

For properties added via Python with something like bpy.types.Armature.my_custom_prop = bpy.props.BoolProperty(...), there you can use …BoolProperty(name="xxx", override={"LIBRARY_OVERRIDABLE"})

IamTirion commented 7 months ago

Here is the entire conversation: image image image image