Beispiel #1
0
static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
                                  const size_t tool_offset, const int ob_mode,
                                  const char *tool_name, int create_missing,
                                  int toggle)
{
	Brush *brush, *brush_orig = BKE_paint_brush(paint);

	if (toggle)
		brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode);
	else
		brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);

	if (!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) {
		brush = BKE_brush_add(bmain, tool_name);
		brush_tool_set(brush, tool_offset, tool);
		brush->ob_mode = ob_mode;
		brush->toggle_brush = brush_orig;
	}

	if (brush) {
		BKE_paint_brush_set(paint, brush);
		BKE_paint_invalidate_overlay_all();
		WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
		return OPERATOR_FINISHED;
	}
	else {
		return OPERATOR_CANCELLED;
	}
}
static void rna_Paint_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
	Paint *paint = ptr->data;
	Brush *br = paint->brush;
	BKE_paint_invalidate_overlay_all();
	WM_main_add_notifier(NC_BRUSH | NA_SELECTED, br);
}
Beispiel #3
0
/* delete overlay cursor textures to preserve memory and invalidate all overlay flags */
void paint_cursor_delete_textures(void)
{
	if (primary_snap.overlay_texture)
		glDeleteTextures(1, &primary_snap.overlay_texture);
	if (secondary_snap.overlay_texture)
		glDeleteTextures(1, &secondary_snap.overlay_texture);
	if (cursor_snap.overlay_texture)
		glDeleteTextures(1, &cursor_snap.overlay_texture);

	memset(&primary_snap, 0, sizeof(TexSnapshot));
	memset(&secondary_snap, 0, sizeof(TexSnapshot));
	memset(&cursor_snap, 0, sizeof(CursorSnapshot));

	BKE_paint_invalidate_overlay_all();
}