Page MenuHome

GPencil: Replace material name with material pointer for Modifiers filter
ClosedPublic

Authored by Antonio Vazquez (antoniov) on May 10 2020, 3:24 PM.

Details

Summary

Before, the material name was used to filter the effect of the stroke, but after the last changes in the ID code, now it's not working. The old design worked, but it was wrong.

After talking with @Julian Eisel (Severin), we agreed to replace the material name with a pointer. Also, this fix a design issue when the materials were linked and use the same name. This is also needed to support future override code.

Related to T76594

It would be important to put this fix in 2.83.

Note: To put in 2.83 requires a version bump and replace the if in versioning code to the last 2.83 version.

Diff Detail

Repository
rB Blender
Branch
temp-gpencil-materialid (branched from master)
Build Status
Buildable 7987
Build 7987: arc lint + arc unit

Event Timeline

Antonio Vazquez (antoniov) requested review of this revision.May 10 2020, 3:24 PM
Antonio Vazquez (antoniov) created this revision.

There is a problem when the material datablock is removed. Looking for a solution.

Antonio Vazquez (antoniov) planned changes to this revision.May 10 2020, 8:27 PM

@Julian Eisel (Severin) How can I clean the pointer in the modifiers when the material is removed from object materials? Now, if you remove a material and then try to update the prop, crash..also the prop value did not change when the material is removed and this is wrong.

I Have tested using row.prop(md, "material", text="") instead of row.prop_search(md, "material", gpd, "materials", text=""') and get the same crash (also prop has the problem it shows all materials, not only objet materials as prop_search does).

Fix segment fault when material is removed.

Set Error icon when material is not valid.

Bastien Montagne (mont29) requested changes to this revision.May 11 2020, 11:16 AM

There are at least two obvious huge things missing here: handling of those pointers in read code, and in lib_query.c

Also, any real reasons not to refcount them?

And unless that fix is really critical, I'd be wary putting it in 2.83 tbh.

source/blender/makesrna/intern/rna_gpencil_modifier.c
428

No idea why you need those setters? because you do not want to use ID refcounting? You should clear PROP_ID_REFCOUNT then instead.

This revision now requires changes to proceed.May 11 2020, 11:16 AM

As a note, I have a fix ready to make the search menu behave as before with string properties for ID names (which is discouraged because of possible name duplicates). That's a very simple one and can go into 2.83, so this at least behaves as before. I also have an alternative one to handle this better in the UI code (P1380), so that the data-name is set for string properties, not the UI name. But it's not save for 2.83.

For 2.90 we can then do this change here, addressing the remaining issue with linked materials.

There are at least two obvious huge things missing here: handling of those pointers in read code, and in lib_query.c

Scratch that, was obviously not well awake this morning, those are handled by the generic ID foreach callbacks... Others remarks remain valid though.

  • Remove RNA_set functions
  • Set correct Walk parameter to keep right user count

@Julian Eisel (Severin) If we all agree to not move this to 2.83, you could move the search fix to make it works now, and later I can move to 2.90 this fix and in this way we have time to check carefully all. I think is too risky add a change like this few days of release date.

Really, with your temp fix in prop_search, 99% of the problems will be solved, except linked materials, but this is not a big issue and always it's better that having this important bug open.

Thanks @Bastien Montagne (mont29) for your review...your help has saved me a lot of code.

Looks OK now, think indeed @Julian Eisel (Severin) 's simplest fix should be the only one to go in 2.83, this change should only go in master.

release/scripts/startup/bl_ui/properties_data_modifier.py
1860–1864

This can be done in a single line: return material in (slot.material for slot in ob.material_slots). You do not even need the helper function then... ;)

source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
74

same remark as above

This revision is now accepted and ready to land.May 11 2020, 3:33 PM

Committed in d63956d0e51c