nextr3d / Character-UI

Blender add-on for creating simple yet functional UIs for your characters.
Apache License 2.0
61 stars 4 forks source link

Override Linked Properties #30

Open Mr-Lux opened 2 years ago

Mr-Lux commented 2 years ago

the Problem

One workflow for animations and scene set up in blender is to link the collection containing the character from one blend file to another, and then create a Library Override that allows posing and use of most of the data.

Blender Documentation on the subject here

Normally, any custom properties must be marked as Library Overridable in it's settings to be accessible and modifiable in a linked overrided data block.

It's not a problem for custom properties user defined, because it's just a toggle. As seen here.

override_prop_example

However, in the state of the add-on the enums and bools for the outfits and locks that are generated in the scripts are not set to be overridable and thus are unusable when the character is linked.

The solution

I was able to make them overridable by adding in their generation the following line

override={"LIBRARY_OVERRIDABLE"} as a option.

following this documentation bool Property doc

in the shorthands to create toggles and enums

def ui_setup_toggle(self, property_name, update_function, name='Name', description='Empty description', default=False):
        "method for easier creation of toggles (buttons)"

        props = CharacterUIUtils.get_props_from_character()
        props[property_name] = default

        prop = BoolProperty(
            name=name,
            description=description,
            update=update_function,
            default=default,
           override={"LIBRARY_OVERRIDABLE"} #here
        )
        setattr(self, property_name, prop)

But, there was a side effect that I don't understand. Once overridable and the rig linked and overrided, when selecting a outfit, locking a piece or any other operations, it would revert back to the original value as if an update function resetted the property.

I could not find why.

So, is there a way to integrate a linked override compatible version for the CharacterUI script ?

nextr3d commented 2 years ago

This issue is an interesting one and I've wanted to delve into it many times but I think it's going to be a massive task.

There are multiple problem which I think will need to be solved.

  1. I think the add-on should let the user choose which properties can be overridden
  2. The ui script should recognize other scripts and if the users chooses the newest script in the scene should take care of everything (currently each character has one script with locked id so duplicated characters don't work)
  3. I've started using drivers for as many things as possible because it's a great native way of controlling the model and I don't know how drivers work with library overrides

I'm going to be honest, I've never used library overrides so I've never studied the inner workings of the whole system so I have a lot to learn but it would be nice to come up with a plan how it's going to be implemented and it would be really amazing if you wanted to tackle some of the things this problem introduces.

The last part is probably because the toggle itself is library overriddeable but the driver is not and the outfit pieces driver reads the value of the toggle and depending on the active outfit, the locked status, its parent and its parent's locked statues it either shows or hides the object.