UI: Automatic Blend Thumbnail Selection
Adds an "Auto" option to blend thumbnail types that will automatically use Screenshot if there is no camera and 3dview, or workbench render with shading settings from the largest 3dview. See D12407 for more details. Differential Revision: https://developer.blender.org/D12407 Reviewed by Campbell Barton
This commit is contained in:
parent
a1c65748c4
commit
4fa0bbb5ac
@ -231,7 +231,7 @@ const UserDef U_default = {
|
||||
.collection_instance_empty_size = 1.0f,
|
||||
|
||||
.statusbar_flag = STATUSBAR_SHOW_VERSION,
|
||||
.file_preview_type = USER_FILE_PREVIEW_CAMERA,
|
||||
.file_preview_type = USER_FILE_PREVIEW_AUTO,
|
||||
|
||||
.runtime =
|
||||
{
|
||||
|
@ -887,7 +887,7 @@ void blo_do_versions_userdef(UserDef *userdef)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(300, 21)) {
|
||||
/* Deprecated userdef->flag USER_SAVE_PREVIEWS */
|
||||
userdef->file_preview_type = (userdef->flag & USER_FLAG_UNUSED_5) ? USER_FILE_PREVIEW_CAMERA :
|
||||
userdef->file_preview_type = (userdef->flag & USER_FLAG_UNUSED_5) ? USER_FILE_PREVIEW_AUTO :
|
||||
USER_FILE_PREVIEW_NONE;
|
||||
/* Clear for reuse. */
|
||||
userdef->flag &= ~USER_FLAG_UNUSED_5;
|
||||
|
@ -1015,6 +1015,7 @@ typedef enum eUserPref_Flag {
|
||||
/** #UserDef.file_preview_type */
|
||||
typedef enum eUserpref_File_Preview_Type {
|
||||
USER_FILE_PREVIEW_NONE = 0,
|
||||
USER_FILE_PREVIEW_AUTO,
|
||||
USER_FILE_PREVIEW_SCREENSHOT,
|
||||
USER_FILE_PREVIEW_CAMERA,
|
||||
} eUserpref_File_Preview_Type;
|
||||
|
@ -6060,6 +6060,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
|
||||
|
||||
static const EnumPropertyItem preview_type_items[] = {
|
||||
{USER_FILE_PREVIEW_NONE, "NONE", 0, "None", "Do not create blend previews"},
|
||||
{USER_FILE_PREVIEW_AUTO, "AUTO", 0, "Auto", "Automatically select best preview type"},
|
||||
{USER_FILE_PREVIEW_SCREENSHOT, "SCREENSHOT", 0, "Screenshot", "Capture the entire window"},
|
||||
{USER_FILE_PREVIEW_CAMERA, "CAMERA", 0, "Camera View", "Workbench render of scene"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
|
@ -1602,10 +1602,9 @@ static ImBuf *blend_file_thumb_from_camera(const bContext *C,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((scene->camera == NULL) && (screen != NULL)) {
|
||||
if (screen != NULL) {
|
||||
area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0);
|
||||
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
||||
if (region) {
|
||||
if (area) {
|
||||
v3d = area->spacedata.first;
|
||||
}
|
||||
}
|
||||
@ -1624,12 +1623,13 @@ static ImBuf *blend_file_thumb_from_camera(const bContext *C,
|
||||
if (scene->camera) {
|
||||
ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
|
||||
scene,
|
||||
NULL,
|
||||
OB_SOLID,
|
||||
(v3d) ? &v3d->shading : NULL,
|
||||
(v3d) ? v3d->shading.type : OB_SOLID,
|
||||
scene->camera,
|
||||
PREVIEW_RENDER_LARGE_HEIGHT * 2,
|
||||
PREVIEW_RENDER_LARGE_HEIGHT * 2,
|
||||
IB_rect,
|
||||
(v3d) ? V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
|
||||
V3D_OFSDRAW_NONE,
|
||||
R_ALPHAPREMUL,
|
||||
NULL,
|
||||
@ -1766,12 +1766,28 @@ static bool wm_file_write(bContext *C,
|
||||
/* Main now can store a '.blend' thumbnail, useful for background mode
|
||||
* or thumbnail customization. */
|
||||
main_thumb = thumb = bmain->blen_thumb;
|
||||
if (BLI_thread_is_main()) {
|
||||
if (U.file_preview_type == USER_FILE_PREVIEW_SCREENSHOT) {
|
||||
ibuf_thumb = blend_file_thumb_from_screenshot(C, &thumb);
|
||||
if (BLI_thread_is_main() && U.file_preview_type != USER_FILE_PREVIEW_NONE) {
|
||||
|
||||
int file_preview_type = U.file_preview_type;
|
||||
|
||||
if (file_preview_type == USER_FILE_PREVIEW_AUTO) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bool do_render = (scene != NULL && scene->camera != NULL &&
|
||||
(BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) != NULL));
|
||||
file_preview_type = do_render ? USER_FILE_PREVIEW_CAMERA : USER_FILE_PREVIEW_SCREENSHOT;
|
||||
}
|
||||
else if (U.file_preview_type == USER_FILE_PREVIEW_CAMERA) {
|
||||
|
||||
switch (file_preview_type) {
|
||||
case USER_FILE_PREVIEW_SCREENSHOT: {
|
||||
ibuf_thumb = blend_file_thumb_from_screenshot(C, &thumb);
|
||||
break;
|
||||
}
|
||||
case USER_FILE_PREVIEW_CAMERA: {
|
||||
ibuf_thumb = blend_file_thumb_from_camera(C, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user