Page MenuHome

UI: Add color attribute create to canvas selector
ClosedPublic

Authored by Ethan Hall (Ethan1080) on Apr 22 2022, 8:45 AM.

Details

Summary

The purpose of this patch is to add the option to create a color
attribute paint slot from the canvas selector when in material mode.

See the discussion here: T97346


Add Image Paint SlotAdd Color Attribute Paint Slot

Diff Detail

Repository
rB Blender
Branch
canvas_ui (branched from master)
Build Status
Buildable 21770
Build 21770: arc lint + arc unit

Event Timeline

Ethan Hall (Ethan1080) requested review of this revision.Apr 22 2022, 8:45 AM
Ethan Hall (Ethan1080) created this revision.
  • Implement color attribute fill.
  • Cleanup Code.
Ethan Hall (Ethan1080) edited the summary of this revision. (Show Details)
  • Sync color fill changes with D14743
  • Replace accidentally removed comment.
  • Simplify RNA names

Small tweaks

  • Use expanded buttons consistent with D14785.
  • De-duplicate one line of code.
  • Tweak tooltips.
  • Make includes explicit

Only for includes relevant to this patch (a cleanup can fix others.)

Ethan Hall (Ethan1080) edited the summary of this revision. (Show Details)Apr 28 2022, 2:40 AM

For creating new attributes or image textures this works fine. I couldn't test it much further because of regular crashes in Eevee. The crash seems to happen in general when using the experimental textture painting in sculpt mode though. I'll investigate that first

  • Rebase and fix switch statement
This revision is now accepted and ready to land.May 3 2022, 6:43 AM
Hans Goudey (HooglyBoogly) requested changes to this revision.May 3 2022, 9:50 AM

Thanks for looking into this. In my review I'm mainly looking at cleanup, but also, unless I'm missing something, it looks like there's a fair amount of non-functional refactoring that should be included separately from this change.

source/blender/editors/sculpt_paint/paint_image_proj.c
6412–6420

const looks misplaced here.

Really, this sort of cleanup shouldn't be in a patch with functional changes though. If you split out things like this and add me as a reviewer, I'd be happy to take a look. but including it in patches like this makes it harder to find the real changes and do a proper review.

6423–6430

These translation markers shouldn't be necessary-- any enum exposed to RNA is meant to be scanned by the translation system already.

Either way, it shouldn't be included in this patch, since it's a separate concern.

6444–6451

It doesn't look like there's any need to reorder these, is there?

6676

It's not clear to me why this handling of materials is changing, I thought this patch was just meant to add something to this popover.

It actually looks like there are a fair amount of non-functional changes to the handling of materials elsewhere in this patch too.

6788–6798

These enum arrays shouldn't be duplicated again-- should be possible to reuse their definitions (maybe that's in another patch?

6814–6838

Please avoid doing cleanup in a patch with functional changes wherever possible. For example, the order of "color" property definition doesn't have to change here.

This revision now requires changes to proceed.May 3 2022, 9:50 AM
  • Revert any refactoring not necessary for patch
Ethan Hall (Ethan1080) marked 4 inline comments as done.May 3 2022, 11:48 AM
Ethan Hall (Ethan1080) added inline comments.
source/blender/editors/sculpt_paint/paint_image_proj.c
6676

I will make the changes to material handling in a separate patch.

When testing, I noticed that the invoke method creates a material. This was done to patch a bug, but creating a new material in the invoke method is not the ideal solution as the material is added even if the operation is canceled before execution. So, I fixed the bug in a different way. Also, creating the material and setting the default color in invoke makes the calls to get_or_create_current_material and proj_paint_default_color in exec redundant.

6788–6798

I saw that was a part of D14733.

6814–6838

I reordered "color" since it is a property shared by image paint slots and color attribute paint slots. Either it has to move, or I have to revert the comments that describe the three sections of the properties.

6820

I rename the text from "Type" to "Material Layer Type" since the new "slot_type" property introduces ambiguity. Since I changed the label, I also fix the description since it was obviously a copy paste error.

Thanks for splitting out the refactoring, the patch is much clearer now.

source/blender/editors/sculpt_paint/paint_image_proj.c
6788–6798

I just committed that change separately so we can move on from that :)

This revision is now accepted and ready to land.May 3 2022, 12:26 PM
source/blender/editors/sculpt_paint/paint_image_proj.c
6676

Yeah, it probably makes more sense for the exec method to create a material. IIRC generally "invoke" just meant to set up an operator based on user input, not actually do anything.