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:
authorPhilipp Oeser <info@graphics-engineer.com>2019-01-23 17:00:58 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2019-01-24 17:34:44 +0300
commit5fc4214adaaa8d13bc5f2d5d45ee9a814b672e04 (patch)
treefbe30013018102dff6121c61df5fea9f18df91fa /source/blender/editors
parent9eee2aa20c7b5d29e76f023771f9c27002292804 (diff)
Fix T60133: texture paint external editing not working
Operator relys on 3DView and was failing from Topbar and Properties Editor. Now tries to find the biggest 3DView and uses that. Reviewers: brecht Maniphest Tasks: T60133 Differential Revision: https://developer.blender.org/D4215
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 0a972e76c9a..c6584a01c17 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -79,6 +79,7 @@
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "BKE_texture.h"
#include "DEG_depsgraph.h"
@@ -5607,6 +5608,15 @@ void PAINT_OT_project_image(wmOperatorType *ot)
ot->prop = prop;
}
+static bool texture_paint_image_from_view_poll(bContext *C)
+{
+ if (BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) == NULL) {
+ CTX_wm_operator_poll_msg_set(C, "No 3D viewport found to create image from");
+ return false;
+ }
+ return true;
+}
+
static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
{
Image *image;
@@ -5617,13 +5627,24 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
int w = settings->imapaint.screen_grab_size[0];
int h = settings->imapaint.screen_grab_size[1];
int maxsize;
char err_out[256] = "unknown";
+ ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
+ if (!sa) {
+ BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from");
+ return OPERATOR_CANCELLED;
+ }
+ View3D *v3d = sa->spacedata.first;
+ ARegion *ar = BKE_area_find_region_active_win(sa);
+ if (!ar) {
+ BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from");
+ return OPERATOR_CANCELLED;
+ }
+ RegionView3D *rv3d = ar->regiondata;
+
RNA_string_get(op->ptr, "filepath", filename);
maxsize = GPU_max_texture_size();
@@ -5633,7 +5654,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ibuf = ED_view3d_draw_offscreen_imbuf(
depsgraph, scene, v3d->shading.type,
- v3d, CTX_wm_region(C),
+ v3d, ar,
w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, err_out);
if (!ibuf) {
@@ -5680,11 +5701,11 @@ void PAINT_OT_image_from_view(wmOperatorType *ot)
/* identifiers */
ot->name = "Image from View";
ot->idname = "PAINT_OT_image_from_view";
- ot->description = "Make an image from the current 3D view for re-projection";
+ ot->description = "Make an image from biggest 3D view for re-projection";
/* api callbacks */
ot->exec = texture_paint_image_from_view_exec;
- ot->poll = ED_operator_region_view3d_active;
+ ot->poll = texture_paint_image_from_view_poll;
/* flags */
ot->flag = OPTYPE_REGISTER;