Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-04-18 00:51:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-18 00:51:11 +0400
commitfdea14acb4b79b59da44ec45149d94129e1e8a8c (patch)
tree4e1dec274c45e9ab0bb084d186079d3764f19c4c /source/blender/windowmanager
parent149c52859b798230335f9316893891af057191aa (diff)
save thumbnail from the 3D view if no camera is present.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 9ffea0e290b..e50fbaa624e 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -80,6 +80,7 @@
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_sound.h"
+#include "BKE_screen.h"
#include "BKE_texture.h"
@@ -662,23 +663,47 @@ static void write_history(void)
}
}
-static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
+/* screen can be NULL */
+static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt)
{
/* will be scaled down, but gives some nice oversampling */
ImBuf *ibuf;
int *thumb;
char err_out[256] = "unknown";
+ /* screen if no camera found */
+ ScrArea *sa = NULL;
+ ARegion *ar = NULL;
+ View3D *v3d = NULL;
+
*thumb_pt = NULL;
/* scene can be NULL if running a script at startup and calling the save operator */
- if (G.background || scene == NULL || scene->camera == NULL)
+ if (G.background || scene == NULL)
+ return NULL;
+
+ if ((scene->camera == NULL) && (screen != NULL)) {
+ sa = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0);
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (ar) {
+ v3d = sa->spacedata.first;
+ }
+ }
+
+ if (scene->camera == NULL && v3d == NULL) {
return NULL;
+ }
/* gets scaled to BLEN_THUMB_SIZE */
- ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera,
- BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
- IB_rect, OB_SOLID, FALSE, err_out);
+ if (scene->camera) {
+ ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera,
+ BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
+ IB_rect, OB_SOLID, FALSE, err_out);
+ }
+ else {
+ ibuf = ED_view3d_draw_offscreen_imbuf(scene, v3d, ar, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
+ IB_rect, FALSE, err_out);
+ }
if (ibuf) {
float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
@@ -763,7 +788,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* blend file thumbnail */
/* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
if (U.flag & USER_SAVE_PREVIEWS) {
- ibuf_thumb = blend_file_thumb(CTX_data_scene(C), &thumb);
+ ibuf_thumb = blend_file_thumb(CTX_data_scene(C), CTX_wm_screen(C), &thumb);
}
BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE);