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:
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_fill.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 5637e755198..993ec15248f 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -48,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_paint.h"
+#include "BKE_report.h"
#include "ED_gpencil.h"
#include "ED_screen.h"
@@ -61,7 +62,6 @@
#include "IMB_imbuf_types.h"
#include "GPU_immediate.h"
-#include "GPU_draw.h"
#include "GPU_matrix.h"
#include "GPU_framebuffer.h"
#include "GPU_state.h"
@@ -1038,7 +1038,15 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
gps->flag |= GP_STROKE_CYCLIC;
gps->flag |= GP_STROKE_3DSPACE;
- gps->mat_nr = BKE_gpencil_object_material_ensure(tgpf->bmain, tgpf->ob, tgpf->mat);
+ gps->mat_nr = BKE_gpencil_object_material_get_index_from_brush(tgpf->ob, brush);
+ if (gps->mat_nr < 0) {
+ if (tgpf->ob->actcol - 1 < 0) {
+ gps->mat_nr = 0;
+ }
+ else {
+ gps->mat_nr = tgpf->ob->actcol - 1;
+ }
+ }
/* allocate memory for storage points */
gps->totpoints = tgpf->sbuffer_used;
@@ -1346,8 +1354,28 @@ static int gpencil_fill_init(bContext *C, wmOperator *op)
/* start of interactive part of operator */
static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ Object *ob = CTX_data_active_object(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
tGPDfill *tgpf = NULL;
+ /* Fill tool needs a material (cannot use default material) */
+ bool valid = true;
+ if ((brush) && (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)) {
+ if (brush->gpencil_settings->material == NULL) {
+ valid = false;
+ }
+ }
+ else {
+ if (give_current_material(ob, ob->actcol) == NULL) {
+ valid = false;
+ }
+ }
+ if (!valid) {
+ BKE_report(op->reports, RPT_ERROR, "Fill tool needs active material.");
+ return OPERATOR_CANCELLED;
+ }
+
/* try to initialize context data needed */
if (!gpencil_fill_init(C, op)) {
gpencil_fill_exit(C, op);
@@ -1366,7 +1394,7 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
tgpf->ar->type, gpencil_fill_draw_3d, tgpf, REGION_DRAW_POST_VIEW);
}
- WM_cursor_modal_set(CTX_wm_window(C), BC_PAINTBRUSHCURSOR);
+ WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_PAINT_BRUSH);
gpencil_fill_status_indicators(C, tgpf);