forked from bartvdbraak/blender
Fix crash in project-from view without a brush or active object
This commit is contained in:
parent
7d9760d962
commit
229c2c14f7
@ -591,11 +591,12 @@ static Brush *image_paint_brush(bContext *C)
|
|||||||
|
|
||||||
static int image_paint_poll(bContext *C)
|
static int image_paint_poll(bContext *C)
|
||||||
{
|
{
|
||||||
Object *obact = CTX_data_active_object(C);
|
Object *obact;
|
||||||
|
|
||||||
if (!image_paint_brush(C))
|
if (!image_paint_brush(C))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
obact = CTX_data_active_object(C);
|
||||||
if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
|
if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -4541,7 +4541,8 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
|
|||||||
if (ps->tool == PAINT_TOOL_CLONE)
|
if (ps->tool == PAINT_TOOL_CLONE)
|
||||||
ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) ? 1 : 0;
|
ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) ? 1 : 0;
|
||||||
|
|
||||||
ps->do_stencil_brush = ps->brush->imagepaint_tool == PAINT_TOOL_MASK;
|
|
||||||
|
ps->do_stencil_brush = (ps->brush && ps->brush->imagepaint_tool == PAINT_TOOL_MASK);
|
||||||
/* deactivate stenciling for the stencil brush :) */
|
/* deactivate stenciling for the stencil brush :) */
|
||||||
ps->do_layer_stencil = ((settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_STENCIL) &&
|
ps->do_layer_stencil = ((settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_STENCIL) &&
|
||||||
!(ps->do_stencil_brush) && ps->stencil_ima);
|
!(ps->do_stencil_brush) && ps->stencil_ima);
|
||||||
@ -4660,15 +4661,15 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
|
|||||||
IDProperty *view_data = NULL;
|
IDProperty *view_data = NULL;
|
||||||
Object *ob = OBACT;
|
Object *ob = OBACT;
|
||||||
|
|
||||||
paint_proj_mesh_data_ensure(C, ob, op);
|
if (ob == NULL || ob->type != OB_MESH) {
|
||||||
|
|
||||||
project_state_init(C, ob, &ps, BRUSH_STROKE_NORMAL);
|
|
||||||
|
|
||||||
if (ps.ob == NULL || ps.ob->type != OB_MESH) {
|
|
||||||
BKE_report(op->reports, RPT_ERROR, "No active mesh object");
|
BKE_report(op->reports, RPT_ERROR, "No active mesh object");
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paint_proj_mesh_data_ensure(C, ob, op);
|
||||||
|
|
||||||
|
project_state_init(C, ob, &ps, BRUSH_STROKE_NORMAL);
|
||||||
|
|
||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
BKE_report(op->reports, RPT_ERROR, "Image could not be found");
|
BKE_report(op->reports, RPT_ERROR, "Image could not be found");
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
@ -4869,6 +4870,8 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
|
|||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Brush *br = BKE_paint_brush(&imapaint->paint);
|
Brush *br = BKE_paint_brush(&imapaint->paint);
|
||||||
|
|
||||||
|
BLI_assert(ob->type == OB_MESH);
|
||||||
|
|
||||||
/* no material, add one */
|
/* no material, add one */
|
||||||
if (ob->totcol == 0) {
|
if (ob->totcol == 0) {
|
||||||
Material *ma = BKE_material_add(CTX_data_main(C), "Material");
|
Material *ma = BKE_material_add(CTX_data_main(C), "Material");
|
||||||
|
Loading…
Reference in New Issue
Block a user