當前位置: 首頁>>代碼示例>>C++>>正文


C++ BKE_paint_get_active_from_context函數代碼示例

本文整理匯總了C++中BKE_paint_get_active_from_context函數的典型用法代碼示例。如果您正苦於以下問題:C++ BKE_paint_get_active_from_context函數的具體用法?C++ BKE_paint_get_active_from_context怎麽用?C++ BKE_paint_get_active_from_context使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BKE_paint_get_active_from_context函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: paint_curve_poll

bool paint_curve_poll(bContext *C)
{
  Object *ob = CTX_data_active_object(C);
  Paint *p;
  RegionView3D *rv3d = CTX_wm_region_view3d(C);
  SpaceImage *sima;

  if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0))) {
    return false;
  }

  sima = CTX_wm_space_image(C);

  if (sima && sima->mode != SI_MODE_PAINT) {
    return false;
  }

  p = BKE_paint_get_active_from_context(C);

  if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
    return true;
  }

  return false;
}
開發者ID:dfelinto,項目名稱:blender,代碼行數:25,代碼來源:paint_curve.c

示例2: paintcurve_delete_point_exec

static int paintcurve_delete_point_exec(bContext *C, wmOperator *op)
{
	Paint *p = BKE_paint_get_active_from_context(C);
	Brush *br = p->brush;
	PaintCurve *pc;
	PaintCurvePoint *pcp;
	wmWindow *window = CTX_wm_window(C);
	ARegion *ar = CTX_wm_region(C);
	int i;
	int tot_del = 0;
	pc = br->paint_curve;

	if (!pc || pc->tot_points == 0) {
		return OPERATOR_CANCELLED;
	}

	ED_paintcurve_undo_push(C, op, pc);

#define DELETE_TAG 2

	for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) {
		if (BEZT_ISSEL_ANY(&pcp->bez)) {
			pcp->bez.f2 |= DELETE_TAG;
			tot_del++;
		}
	}

	if (tot_del > 0) {
		int j = 0;
		int new_tot = pc->tot_points - tot_del;
		PaintCurvePoint *points_new = NULL;
		if (new_tot > 0)
			points_new = MEM_mallocN(new_tot * sizeof(PaintCurvePoint), "PaintCurvePoint");

		for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) {
			if (!(pcp->bez.f2 & DELETE_TAG)) {
				points_new[j] = pc->points[i];

				if ((i + 1) == pc->add_index) {
					BKE_paint_curve_clamp_endpoint_add_index(pc, j);
				}
				j++;
			}
			else if ((i + 1) == pc->add_index) {
				/* prefer previous point */
				pc->add_index = j;
			}
		}
		MEM_freeN(pc->points);

		pc->points = points_new;
		pc->tot_points = new_tot;
	}

#undef DELETE_TAG

	WM_paint_cursor_tag_redraw(window, ar);

	return OPERATOR_FINISHED;
}
開發者ID:mgschwan,項目名稱:blensor,代碼行數:60,代碼來源:paint_curve.c

示例3: paint_draw_smooth_cursor

/*** Cursors ***/
static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata)
{
  Paint *paint = BKE_paint_get_active_from_context(C);
  Brush *brush = BKE_paint_brush(paint);
  PaintStroke *stroke = customdata;

  if (stroke && brush) {
    GPU_line_smooth(true);
    GPU_blend(true);

    ARegion *ar = stroke->vc.ar;

    uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
    immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
    immUniformColor4ubv(paint->paint_cursor_col);

    immBegin(GPU_PRIM_LINES, 2);
    immVertex2f(pos, x, y);
    immVertex2f(pos,
                stroke->last_mouse_position[0] + ar->winrct.xmin,
                stroke->last_mouse_position[1] + ar->winrct.ymin);

    immEnd();

    immUnbindProgram();

    GPU_blend(false);
    GPU_line_smooth(false);
  }
}
開發者ID:dfelinto,項目名稱:blender,代碼行數:31,代碼來源:paint_stroke.c

示例4: paintcurve_point_add

static void paintcurve_point_add(bContext *C,  wmOperator *op, const int loc[2])
{
	Paint *p = BKE_paint_get_active_from_context(C);
	Brush *br = p->brush;
	Main *bmain = CTX_data_main(C);
	PaintCurve *pc;
	PaintCurvePoint *pcp;
	wmWindow *window = CTX_wm_window(C);
	ARegion *ar = CTX_wm_region(C);
	float vec[3] = {loc[0], loc[1], 0.0};
	int add_index;
	int i;

	pc = br->paint_curve;
	if (!pc) {
		br->paint_curve = pc = BKE_paint_curve_add(bmain, "PaintCurve");
	}

	ED_paintcurve_undo_push_begin(op->type->name);

	pcp = MEM_mallocN((pc->tot_points + 1) * sizeof(PaintCurvePoint), "PaintCurvePoint");
	add_index = pc->add_index;

	if (pc->points) {
		if (add_index > 0)
			memcpy(pcp, pc->points, add_index * sizeof(PaintCurvePoint));
		if (add_index < pc->tot_points)
			memcpy(pcp + add_index + 1, pc->points + add_index, (pc->tot_points - add_index) * sizeof(PaintCurvePoint));

		MEM_freeN(pc->points);
	}
	pc->points = pcp;
	pc->tot_points++;

	/* initialize new point */
	memset(&pcp[add_index], 0, sizeof(PaintCurvePoint));
	copy_v3_v3(pcp[add_index].bez.vec[0], vec);
	copy_v3_v3(pcp[add_index].bez.vec[1], vec);
	copy_v3_v3(pcp[add_index].bez.vec[2], vec);

	/* last step, clear selection from all bezier handles expect the next */
	for (i = 0; i < pc->tot_points; i++) {
		pcp[i].bez.f1 = pcp[i].bez.f2 = pcp[i].bez.f3 = 0;
	}

	BKE_paint_curve_clamp_endpoint_add_index(pc, add_index);

	if (pc->add_index != 0) {
		pcp[add_index].bez.f3 = SELECT;
		pcp[add_index].bez.h2 = HD_ALIGN;
	}
	else {
		pcp[add_index].bez.f1 = SELECT;
		pcp[add_index].bez.h1 = HD_ALIGN;
	}

	ED_paintcurve_undo_push_end();

	WM_paint_cursor_tag_redraw(window, ar);
}
開發者ID:wchargin,項目名稱:blender,代碼行數:60,代碼來源:paint_curve.c

示例5: paintcurve_slide_invoke

static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
  Paint *p = BKE_paint_get_active_from_context(C);
  const float loc_fl[2] = {UNPACK2(event->mval)};
  char select;
  int i;
  bool do_select = RNA_boolean_get(op->ptr, "select");
  bool align = RNA_boolean_get(op->ptr, "align");
  Brush *br = p->brush;
  PaintCurve *pc = br->paint_curve;
  PaintCurvePoint *pcp;

  if (!pc) {
    return OPERATOR_PASS_THROUGH;
  }

  if (do_select) {
    pcp = paintcurve_point_get_closest(pc, loc_fl, align, PAINT_CURVE_SELECT_THRESHOLD, &select);
  }
  else {
    pcp = NULL;
    /* just find first selected point */
    for (i = 0; i < pc->tot_points; i++) {
      if ((select = paintcurve_point_side_index(&pc->points[i].bez, i == 0, SEL_F3))) {
        pcp = &pc->points[i];
        break;
      }
    }
  }

  if (pcp) {
    ARegion *ar = CTX_wm_region(C);
    wmWindow *window = CTX_wm_window(C);
    PointSlideData *psd = MEM_mallocN(sizeof(PointSlideData), "PointSlideData");
    copy_v2_v2_int(psd->initial_loc, event->mval);
    psd->event = event->type;
    psd->pcp = pcp;
    psd->select = paintcurve_point_co_index(select);
    for (i = 0; i < 3; i++) {
      copy_v2_v2(psd->point_initial_loc[i], pcp->bez.vec[i]);
    }
    psd->align = align;
    op->customdata = psd;

    /* first, clear all selection from points */
    for (i = 0; i < pc->tot_points; i++) {
      pc->points[i].bez.f1 = pc->points[i].bez.f3 = pc->points[i].bez.f2 = 0;
    }

    /* only select the active point */
    PAINT_CURVE_POINT_SELECT(pcp, psd->select);
    BKE_paint_curve_clamp_endpoint_add_index(pc, pcp - pc->points);

    WM_event_add_modal_handler(C, op);
    WM_paint_cursor_tag_redraw(window, ar);
    return OPERATOR_RUNNING_MODAL;
  }

  return OPERATOR_PASS_THROUGH;
}
開發者ID:dfelinto,項目名稱:blender,代碼行數:60,代碼來源:paint_curve.c

示例6: palette_poll

static int palette_poll(bContext *C)
{
	Paint *paint = BKE_paint_get_active_from_context(C);

	if (paint && paint->palette != NULL)
		return true;

	return false;
}
開發者ID:Moguri,項目名稱:blender,代碼行數:9,代碼來源:paint_ops.c

示例7: paintcurve_new_exec

static int paintcurve_new_exec(bContext *C, wmOperator *UNUSED(op))
{
	Paint *p = BKE_paint_get_active_from_context(C);
	Main *bmain = CTX_data_main(C);

	if (p && p->brush) {
		p->brush->paint_curve = BKE_paint_curve_add(bmain, "PaintCurve");
	}

	return OPERATOR_FINISHED;
}
開發者ID:mgschwan,項目名稱:blensor,代碼行數:11,代碼來源:paint_curve.c

示例8: brush_curve_preset_exec

static int brush_curve_preset_exec(bContext *C, wmOperator *op)
{
	Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));

	if (br) {
		Scene *scene = CTX_data_scene(C);
		BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
		BKE_paint_invalidate_cursor_overlay(scene, br->curve);
	}

	return OPERATOR_FINISHED;
}
開發者ID:sftd,項目名稱:blender,代碼行數:12,代碼來源:paint_utils.c

示例9: palette_color_delete_exec

static int palette_color_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
	Paint *paint = BKE_paint_get_active_from_context(C);
	Palette *palette = paint->palette;
	PaletteColor *color = BLI_findlink(&palette->colors, palette->active_color);

	if (color) {
		BKE_palette_color_remove(palette, color);
	}

	return OPERATOR_FINISHED;
}
開發者ID:Moguri,項目名稱:blender,代碼行數:12,代碼來源:paint_ops.c

示例10: palette_new_exec

static int palette_new_exec(bContext *C, wmOperator *UNUSED(op))
{
	Paint *paint = BKE_paint_get_active_from_context(C);
	Main *bmain = CTX_data_main(C);
	Palette *palette;

	palette = BKE_palette_add(bmain, "Palette");

	BKE_paint_palette_set(paint, palette);

	return OPERATOR_FINISHED;
}
開發者ID:Moguri,項目名稱:blender,代碼行數:12,代碼來源:paint_ops.c

示例11: paintcurve_new_exec

static int paintcurve_new_exec(bContext *C, wmOperator *UNUSED(op))
{
  Paint *p = BKE_paint_get_active_from_context(C);
  Main *bmain = CTX_data_main(C);

  if (p && p->brush) {
    p->brush->paint_curve = BKE_paint_curve_add(bmain, "PaintCurve");
  }

  WM_event_add_notifier(C, NC_PAINTCURVE | NA_ADDED, NULL);

  return OPERATOR_FINISHED;
}
開發者ID:dfelinto,項目名稱:blender,代碼行數:13,代碼來源:paint_curve.c

示例12: stencil_control_poll

static int stencil_control_poll(bContext *C)
{
	PaintMode mode = BKE_paintmode_get_active_from_context(C);

	Paint *paint;
	Brush *br;

	if (!paint_supports_texture(mode))
		return false;

	paint = BKE_paint_get_active_from_context(C);
	br = BKE_paint_brush(paint);
	return (br &&
	        (br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL ||
	         br->mask_mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL));
}
開發者ID:Moguri,項目名稱:blender,代碼行數:16,代碼來源:paint_ops.c

示例13: brush_reset_exec

static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
{
	Paint *paint = BKE_paint_get_active_from_context(C);
	Brush *brush = BKE_paint_brush(paint);
	Object *ob = CTX_data_active_object(C);

	if (!ob || !brush) return OPERATOR_CANCELLED;

	/* TODO: other modes */
	if (ob->mode & OB_MODE_SCULPT) {
		BKE_brush_sculpt_reset(brush);
	}
	else {
		return OPERATOR_CANCELLED;
	}
	WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);

	return OPERATOR_FINISHED;
}
開發者ID:mgschwan,項目名稱:blensor,代碼行數:19,代碼來源:paint_ops.c

示例14: brush_add_exec

/* Brush operators */
static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
{
	/*int type = RNA_enum_get(op->ptr, "type");*/
	Paint *paint = BKE_paint_get_active_from_context(C);
	Brush *br = BKE_paint_brush(paint);
	Main *bmain = CTX_data_main(C);
	ePaintMode mode = BKE_paintmode_get_active_from_context(C);

	if (br) {
		br = BKE_brush_copy(bmain, br);
	}
	else {
		br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paint_mode(mode));
		id_us_min(&br->id);  /* fake user only */
	}

	BKE_paint_brush_set(paint, br);

	return OPERATOR_FINISHED;
}
開發者ID:mgschwan,項目名稱:blensor,代碼行數:21,代碼來源:paint_ops.c

示例15: paint_draw_line_cursor

static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
{
  Paint *paint = BKE_paint_get_active_from_context(C);
  PaintStroke *stroke = customdata;

  GPU_line_smooth(true);

  uint shdr_pos = GPU_vertformat_attr_add(
      immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);

  immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);

  float viewport_size[4];
  GPU_viewport_size_get_f(viewport_size);
  immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);

  immUniform1i("colors_len", 2); /* "advanced" mode */
  const float alpha = (float)paint->paint_cursor_col[3] / 255.0f;
  immUniformArray4fv(
      "colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2);
開發者ID:dfelinto,項目名稱:blender,代碼行數:20,代碼來源:paint_stroke.c


注:本文中的BKE_paint_get_active_from_context函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。