Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_ops.c
| Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | static void BRUSH_OT_add_gpencil(wmOperatorType *ot) | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int brush_scale_size_exec(bContext *C, wmOperator *op) | static int brush_scale_size_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Paint *paint = BKE_paint_get_active_from_context(C); | Paint *paint = BKE_paint_get_active_from_context(C); | ||||
| Brush *brush = BKE_paint_brush(paint); | Brush *brush = BKE_paint_brush(paint); | ||||
| const bool is_gpencil = (brush && brush->gpencil_settings != NULL); | |||||
| // Object *ob = CTX_data_active_object(C); | // Object *ob = CTX_data_active_object(C); | ||||
| float scalar = RNA_float_get(op->ptr, "scalar"); | float scalar = RNA_float_get(op->ptr, "scalar"); | ||||
| if (brush) { | if (brush) { | ||||
| /* pixel radius */ | /* pixel radius */ | ||||
| { | { | ||||
| const int old_size = BKE_brush_size_get(scene, brush); | const int old_size = (!is_gpencil) ? BKE_brush_size_get(scene, brush) : brush->size; | ||||
| int size = (int)(scalar * old_size); | int size = (int)(scalar * old_size); | ||||
| if (abs(old_size - size) < U.pixelsize) { | if (abs(old_size - size) < U.pixelsize) { | ||||
| if (scalar > 1) { | if (scalar > 1) { | ||||
| size += U.pixelsize; | size += U.pixelsize; | ||||
| } | } | ||||
| else if (scalar < 1) { | else if (scalar < 1) { | ||||
| size -= U.pixelsize; | size -= U.pixelsize; | ||||
| } | } | ||||
| } | } | ||||
| /* Grease Pencil does not use unified size. */ | |||||
| if (is_gpencil) { | |||||
| brush->size = max_ii(size, 1); | |||||
| WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| BKE_brush_size_set(scene, brush, size); | BKE_brush_size_set(scene, brush, size); | ||||
| } | } | ||||
| /* unprojected radius */ | /* unprojected radius */ | ||||
| { | { | ||||
| float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush); | float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush); | ||||
| ▲ Show 20 Lines • Show All 1,233 Lines • Show Last 20 Lines | |||||