GP: Add python api to create brush settings for grease pencil
This commit is contained in:
parent
2333717bb8
commit
75e34b9002
|
@ -49,6 +49,7 @@ void BKE_brush_system_exit(void);
|
|||
void BKE_brush_init(struct Brush *brush);
|
||||
struct Brush *BKE_brush_add(struct Main *bmain, const char *name, const eObjectMode ob_mode);
|
||||
struct Brush *BKE_brush_add_gpencil(struct Main *bmain, struct ToolSettings *ts, const char *name);
|
||||
void BKE_brush_init_gpencil_settings(struct Brush *brush);
|
||||
struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode);
|
||||
void BKE_brush_copy_data(struct Main *bmain, struct Brush *brush_dst, const struct Brush *brush_src, const int flag);
|
||||
struct Brush *BKE_brush_copy(struct Main *bmain, const struct Brush *brush);
|
||||
|
|
|
@ -167,20 +167,12 @@ Brush *BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode)
|
|||
return brush;
|
||||
}
|
||||
|
||||
/* add a new gp-brush */
|
||||
Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name)
|
||||
/* add grese pencil settings */
|
||||
void BKE_brush_init_gpencil_settings(Brush *brush)
|
||||
{
|
||||
Brush *brush;
|
||||
Paint *paint = BKE_brush_get_gpencil_paint(ts);
|
||||
brush = BKE_brush_add(bmain, name, OB_MODE_GPENCIL_PAINT);
|
||||
|
||||
BKE_paint_brush_set(paint, brush);
|
||||
id_us_min(&brush->id);
|
||||
|
||||
/* grease pencil basic settings */
|
||||
brush->size = 3;
|
||||
|
||||
brush->gpencil_settings = MEM_callocN(sizeof(BrushGpencilSettings), "BrushGpencilSettings");
|
||||
if (brush->gpencil_settings == NULL) {
|
||||
brush->gpencil_settings = MEM_callocN(sizeof(BrushGpencilSettings), "BrushGpencilSettings");
|
||||
}
|
||||
|
||||
brush->gpencil_settings->draw_smoothlvl = 1;
|
||||
brush->gpencil_settings->flag = 0;
|
||||
|
@ -195,6 +187,22 @@ Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name)
|
|||
brush->gpencil_settings->curve_sensitivity = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
brush->gpencil_settings->curve_strength = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
brush->gpencil_settings->curve_jitter = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
/* add a new gp-brush */
|
||||
Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name)
|
||||
{
|
||||
Brush *brush;
|
||||
Paint *paint = BKE_brush_get_gpencil_paint(ts);
|
||||
brush = BKE_brush_add(bmain, name, OB_MODE_GPENCIL_PAINT);
|
||||
|
||||
BKE_paint_brush_set(paint, brush);
|
||||
id_us_min(&brush->id);
|
||||
|
||||
brush->size = 3;
|
||||
|
||||
/* grease pencil basic settings */
|
||||
BKE_brush_init_gpencil_settings(brush);
|
||||
|
||||
/* return brush */
|
||||
return brush;
|
||||
|
|
|
@ -443,6 +443,14 @@ static Brush *rna_Main_brushes_new(Main *bmain, const char *name, int mode)
|
|||
return brush;
|
||||
}
|
||||
|
||||
static void rna_Main_brush_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ptr)
|
||||
{
|
||||
ID *id = id_ptr->data;
|
||||
Brush *brush = (Brush *)id;
|
||||
BKE_brush_init_gpencil_settings(brush);
|
||||
}
|
||||
|
||||
|
||||
static World *rna_Main_worlds_new(Main *bmain, const char *name)
|
||||
{
|
||||
char safe_name[MAX_ID_NAME - 2];
|
||||
|
@ -1272,6 +1280,11 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
|
|||
func = RNA_def_function(srna, "tag", "rna_Main_brushes_tag");
|
||||
parm = RNA_def_boolean(func, "value", 0, "Value", "");
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
|
||||
func = RNA_def_function(srna, "create_gpencil_data", "rna_Main_brush_gpencil_data");
|
||||
RNA_def_function_ui_description(func, "Add grease pencil brush settings");
|
||||
parm = RNA_def_pointer(func, "brush", "Brush", "", "Brush");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
||||
}
|
||||
|
||||
void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
|
|
Loading…
Reference in New Issue