For node groups there is no good default preview generation (also see rBb63f375775b4: Assets: disable automatic preview generation for node groups).
Nevertheless, it would be useful to generate a preview image for a node group by rendering an object in some cases.
This patch adds a new operator that allows updating the preview image for the active asset by rendering the active object (note, the operator can also be used for other asset types, not just node groups).
Details
Diff Detail
- Repository
- rB Blender
Event Timeline
This looks like a nice workflow. Just a couple inline comments. I don't have a strong opinion about where to put the button, but I'm not sure I would align it with the refresh button. Maybe Julian has a stronger opinion here.
| source/blender/editors/include/UI_interface_icons.h | ||
|---|---|---|
| 102 | I think the convention is to use an r_ prefix here. | |
| source/blender/editors/interface/interface_icons.c | ||
| 1959 | I don't have much experience with this code, but it feels wrong that this function can accept a null preview_image argument when its main job is to fill a preview with data. Unless there's a good reason not to, I think the null check should be moved to the operator. | |
I think this approach is quite okay. I suggested to have the UI like in the current version, since it doesn't hide everything in a menu, but there is at least the somewhat descriptive refresh icon and a visually clear way to access more options.
I'd remove the object icon from the menu item. It's reusing an icon for a different purpose, which we should avoid. In this case it's not adding much other than visual noise. It's well established that such icon use causes problems with no substantive benefit. (@Yevgeny Makarov (jenkm) made a nice writeup about such things on devtalk).
| source/blender/editors/util/ed_util_ops.cc | ||
|---|---|---|
| 179–181 | Bonus points if you add a disabled hint via CTX_wm_operator_poll_msg_set() ;) | |
I think the menu entry communicates well without the need of an icon, especially since there is no other entries in the menu yet. If the menu becomes long then the render icon can be used but even then, the label is clear enough.
One small note perhaps a change in the tooltip "Create a preview for the selected data-block by rendering the active object", replace "data-block" with "asset"? From the user's point of view they are rendering a preview for an asset, the fact that it's a data-block is irrelevant. Also we can shorten the tooltip by using "this" since it's always in the context of the current/active/selected asset.
So it'd become: "Create a preview for this asset by rendering the active object".
| source/blender/editors/util/ed_util_ops.cc | ||
|---|---|---|
| 195–196 | BKE_previewimg_id_ensure() returns the preview-image, no need to call the getter again. | |
