[Bf-blender-cvs] [5fc4214adaa] master: Fix T60133: texture paint external editing not working

Philipp Oeser noreply at git.blender.org
Thu Jan 24 15:40:21 CET 2019


Commit: 5fc4214adaaa8d13bc5f2d5d45ee9a814b672e04
Author: Philipp Oeser
Date:   Wed Jan 23 15:00:58 2019 +0100
Branches: master
https://developer.blender.org/rB5fc4214adaaa8d13bc5f2d5d45ee9a814b672e04

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

===================================================================

M	source/blender/editors/sculpt_paint/paint_image_proj.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list