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/sculpt_paint/paint_ops.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 123a70d5044..9d571fc12fe 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -44,6 +44,7 @@
#include "ED_screen.h"
#include "ED_image.h"
#include "UI_resources.h"
+#include "UI_interface.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -60,20 +61,40 @@
#include <stddef.h>
/* 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);
PaintMode mode = BKE_paintmode_get_active_from_context(C);
-
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ Paint *paint = NULL;
+ HairEditSettings *hair_edit = NULL;
+ Brush *br = NULL;
+
+ /* get active brush context */
+ if (ob->mode == OB_MODE_HAIR_EDIT) {
+ hair_edit = &scene->toolsettings->hair_edit;
+ br = hair_edit->brush;
+ }
+ else {
+ paint = BKE_paint_get_active_from_context(C);
+ br = BKE_paint_brush(paint);
+ }
+
if (br)
br = BKE_brush_copy(bmain, br);
else
br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paint_mode(mode));
- BKE_paint_brush_set(paint, br);
+ /* set new brush pointer in the context */
+ if (ob->mode == OB_MODE_HAIR_EDIT) {
+ hair_edit->brush = br;
+ }
+ else {
+ BKE_paint_brush_set(paint, br);
+ }
return OPERATOR_FINISHED;
}
@@ -96,11 +117,20 @@ static void BRUSH_OT_add(wmOperatorType *ot)
static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Paint *paint = BKE_paint_get_active_from_context(C);
- Brush *brush = BKE_paint_brush(paint);
- // Object *ob = CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
+ Brush *brush;
float scalar = RNA_float_get(op->ptr, "scalar");
+ /* get active brush context */
+ if (ob->mode == OB_MODE_HAIR_EDIT) {
+ HairEditSettings *hair_edit = &scene->toolsettings->hair_edit;
+ brush = hair_edit->brush;
+ }
+ else {
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ brush = BKE_paint_brush(paint);
+ }
+
if (brush) {
// pixel radius
{
@@ -699,7 +729,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (ob) {
/* select current paint mode */
- paint_mode = ob->mode & OB_MODE_ALL_PAINT;
+ paint_mode = ob->mode & OB_MODE_ALL_BRUSH;
}
else {
return OPERATOR_CANCELLED;