[Bf-blender-cvs] [7ae6492] strand_editmode: Lots of small fixes for paint system quirks to make hair brushes work in the UI.
Lukas Tönne
noreply at git.blender.org
Mon Apr 20 14:23:25 CEST 2015
Commit: 7ae6492c85c7c6da6e3d0f6e1239436a2fd3ce6e
Author: Lukas Tönne
Date: Tue Dec 2 11:30:53 2014 +0100
Branches: strand_editmode
https://developer.blender.org/rB7ae6492c85c7c6da6e3d0f6e1239436a2fd3ce6e
Lots of small fixes for paint system quirks to make hair brushes work
in the UI.
Conflicts:
release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/transform/manipulator_widget.c
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/intern/brush.c
M source/blender/editors/hair/hair_ops.c
M source/blender/editors/interface/interface_icons.c
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/transform/transform_orientations.c
M source/blender/makesdna/DNA_object_types.h
M source/blender/makesrna/intern/rna_brush.c
M source/blender/makesrna/intern/rna_context.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 4d8230e..0923cf6 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -139,7 +139,7 @@ class VIEW3D_MT_editor_menus(Menu):
layout.menu("VIEW3D_MT_select_paint_mask")
elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
layout.menu("VIEW3D_MT_select_paint_mask_vertex")
- elif mode_string != 'SCULPT':
+ elif mode_string not in {'SCULPT'}:
layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
if mode_string == 'OBJECT':
@@ -160,7 +160,7 @@ class VIEW3D_MT_editor_menus(Menu):
elif obj:
if mode_string != 'PAINT_TEXTURE':
layout.menu("VIEW3D_MT_%s" % mode_string.lower())
- if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
+ if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE', 'HAIR'}:
layout.menu("VIEW3D_MT_brush")
if mode_string == 'SCULPT':
layout.menu("VIEW3D_MT_hide_mask")
@@ -915,6 +915,13 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu):
layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
+class VIEW3D_MT_select_hair(Menu):
+ bl_label = "Select"
+
+ def draw(self, context):
+ layout = self.layout
+
+
class VIEW3D_MT_angle_control(Menu):
bl_label = "Angle Control"
@@ -1525,7 +1532,7 @@ class VIEW3D_MT_brush(Menu):
layout.separator()
# brush paint modes
- layout.menu("VIEW3D_MT_brush_paint_modes")
+ layout.menu("VIEW3D_MT_brush_object_modes")
# brush tool
if context.sculpt_object:
@@ -1535,6 +1542,8 @@ class VIEW3D_MT_brush(Menu):
layout.prop_menu_enum(brush, "image_tool")
elif context.vertex_paint_object or context.weight_paint_object:
layout.prop_menu_enum(brush, "vertex_tool")
+ elif context.hair_edit_object:
+ layout.prop_menu_enum(brush, "hair_tool")
# skip if no active brush
if not brush:
@@ -1562,7 +1571,7 @@ class VIEW3D_MT_brush(Menu):
layout.operator("sculpt.set_persistent_base")
-class VIEW3D_MT_brush_paint_modes(Menu):
+class VIEW3D_MT_brush_object_modes(Menu):
bl_label = "Enabled Modes"
def draw(self, context):
@@ -1575,6 +1584,7 @@ class VIEW3D_MT_brush_paint_modes(Menu):
layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
layout.prop(brush, "use_paint_weight", text="Weight Paint")
layout.prop(brush, "use_paint_image", text="Texture Paint")
+ layout.prop(brush, "use_hair_edit", text="Hair Edit")
# ********** Vertex paint menu **********
@@ -1827,6 +1837,14 @@ class VIEW3D_MT_particle_specials(Menu):
class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
_operator_name = "particle"
+# ********** Hair menu **********
+
+class VIEW3D_MT_hair(Menu):
+ bl_label = "Hair"
+
+ def draw(self, context):
+ layout = self.layout
+
# ********** Pose Menu **********
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 307f97f..d5c5fb5 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -68,7 +68,7 @@ static void brush_defaults(Brush *brush)
brush->blend = 0;
brush->flag = 0;
- brush->ob_mode = OB_MODE_ALL_PAINT;
+ brush->ob_mode = OB_MODE_ALL_BRUSH;
/* BRUSH SCULPT TOOL SETTINGS */
brush->weight = 1.0f; /* weight of brush 0 - 1.0 */
diff --git a/source/blender/editors/hair/hair_ops.c b/source/blender/editors/hair/hair_ops.c
index 8e4405a..3a1e350 100644
--- a/source/blender/editors/hair/hair_ops.c
+++ b/source/blender/editors/hair/hair_ops.c
@@ -70,5 +70,4 @@ void ED_keymap_hair(wmKeyConfig *keyconf)
keymap->poll = hair_poll;
kmi = WM_keymap_add_item(keymap, "HAIR_OT_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
- RNA_enum_set(kmi->ptr, "mode", BRUSH_STROKE_NORMAL);
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index d38ed25..d8a1ec8 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1233,6 +1233,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
mode = OB_MODE_VERTEX_PAINT;
else if (ob->mode & OB_MODE_TEXTURE_PAINT)
mode = OB_MODE_TEXTURE_PAINT;
+ else if (ob->mode & OB_MODE_HAIR_EDIT)
+ mode = OB_MODE_HAIR_EDIT;
}
else if ((sima = CTX_wm_space_image(C)) &&
(sima->mode == SI_MODE_PAINT))
@@ -1253,6 +1255,10 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
items = brush_image_tool_items;
tool = br->imagepaint_tool;
}
+ else if (mode == OB_MODE_HAIR_EDIT) {
+ items = brush_hair_tool_items;
+ tool = br->hair_tool;
+ }
if (!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id))
id->icon_id = 0;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index eebd498..0ac203c 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,19 +61,39 @@
#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);
-
+ 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(br);
else
br = BKE_brush_add(bmain, "Brush");
- 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;
}
@@ -467,7 +488,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;
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 2c1ed2f..b3a1bb7 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3944,7 +3944,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
{
if ((v3d->transp == false) && /* not when we draw the transparent pass */
- (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
+ (ob->mode & OB_MODE_ALL_BRUSH) == false) /* not when painting (its distracting) - campbell */
{
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
glDepthMask(0);
@@ -8170,7 +8170,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
/* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
- if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) {
+ if (!is_obact || !(ob->mode & OB_MODE_ALL_BRUSH)) {
int do_draw_center = -1; /* defines below are zero or positive... */
if (render_override) {
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 7fea8e1..030e29d 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -1010,7 +1010,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
result = ORIENTATION_EDGE;
}
}
- else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
+ else if (ob && (ob->mode & (OB_MODE_ALL_BRUSH | OB_MODE_PARTICLE_EDIT))) {
/* pass */
}
else {
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 9cf69ae..4491cfa 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -678,6 +678,7 @@ typedef enum ObjectMode {
/* any mode where the brush system is used */
#define OB_MODE_ALL_PAINT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)
+#define OB_MODE_ALL_BRUSH (OB_MODE_ALL_PAINT | OB_MODE_HAIR_EDIT)
#define MAX_DUPLI_RECUR 8
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 5145b41..19f7886 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -108,13 +108,13 @@ EnumPropertyItem brush_image_tool_items[] = {
};
EnumPropertyItem brush_hair_tool_items[] = {
- {HAIR_TOOL_COMB, "COMB", ICON_BRUSH_TEXDRAW, "Draw", ""},
- {HAIR_TOOL_CUT, "CUT", ICON_BRUSH_SOFTEN, "Soften", ""},
- {HAIR_TOOL_LENGTH, "LENGTH", ICON_BRUSH_SMEAR, "Smear", ""},
- {HAIR_TOOL_PUFF, "PUFF", ICON_BRUSH_CLONE, "Clone", ""},
- {HAIR_TOOL_ADD, "ADD", ICON_BRUSH_TEXFILL, "Fill", ""},
- {HAIR_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_TEXFILL, "Fill", ""},
- {HAIR_TOOL_WEIGHT, "WEIGHT", ICON_BRUSH_TEXMASK, "Mask", ""},
+ {HAIR_TOOL_COMB, "COMB", ICON_BRUSH_HAIR_COMB, "Comb", "Align hairs to the stroke direction"},
+ {HAIR_TOOL_CUT, "CUT", ICON_BRUSH_HAIR_CUT, "Cut", "Shorten and/or remove hairs"},
+ {HAIR_TOOL_LENGTH,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list