[Bf-blender-cvs] [7779166] strand_editmode: Define hair edit settings and brush types in the RNA, similar to paint and sculpt settings.

Lukas Tönne noreply at git.blender.org
Mon Apr 20 14:23:22 CEST 2015


Commit: 7779166313f17db1c8175c27fb4d352e111e2174
Author: Lukas Tönne
Date:   Mon Dec 1 20:25:28 2014 +0100
Branches: strand_editmode
https://developer.blender.org/rB7779166313f17db1c8175c27fb4d352e111e2174

Define hair edit settings and brush types in the RNA, similar to paint
and sculpt settings.

Conflicts:
	source/blender/makesdna/DNA_brush_types.h

===================================================================

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/editors/screen/screen_context.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index b0da650..f315c94 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -38,10 +38,10 @@ class UnifiedPaintPanel:
         elif context.image_paint_object:
             if (toolsettings.image_paint and toolsettings.image_paint.detect_data()):
                 return toolsettings.image_paint
-
-            return None
         elif context.particle_edit_object:
             return toolsettings.particle_edit
+        elif context.hair_edit_object:
+            return toolsettings.hair_edit
 
         return None
 
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 3431ce9..0674e19 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -67,7 +67,7 @@ const char *screen_context_dir[] = {
 	"visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone",
 	"active_base", "active_object", "object", "edit_object",
 	"sculpt_object", "vertex_paint_object", "weight_paint_object",
-	"image_paint_object", "particle_edit_object",
+	"image_paint_object", "particle_edit_object", "hair_edit_object",
 	"sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */
 	"gpencil_data", "gpencil_data_owner", /* grease pencil data */
 	"visible_gpencil_layers", "editable_gpencil_layers", "editable_gpencil_strokes",
@@ -362,6 +362,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
 
 		return 1;
 	}
+	else if (CTX_data_equals(member, "hair_edit_object")) {
+		if (obact && (obact->mode & OB_MODE_HAIR_EDIT))
+			CTX_data_id_pointer_set(result, &obact->id);
+
+		return 1;
+	}
 	else if (CTX_data_equals(member, "sequences")) {
 		Editing *ed = BKE_sequencer_editing_get(scene, false);
 		if (ed) {
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index bb160a0..a799e85 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -102,7 +102,10 @@ typedef struct Brush {
 	char vertexpaint_tool;  /* active vertex/weight paint blend mode (poorly named) */
 	char imagepaint_tool;   /* active image paint tool */
 	char mask_tool;         /* enum BrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */
-	
+	char hair_tool;         /* active hair tool */
+	char pad2[3];
+	int pad3;
+
 	float autosmooth_factor;
 
 	float crease_pinch_factor;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index ca2edb5..df84871 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -994,6 +994,17 @@ typedef struct ParticleEditSettings {
 } ParticleEditSettings;
 
 /* ------------------------------------------- */
+/* Hair Edit */
+
+typedef struct HairEditSettings {
+	int flag;
+	int select_mode;
+	
+	struct Brush *brush;
+	struct Object *shape_object;
+} HairEditSettings;
+
+/* ------------------------------------------- */
 /* Sculpt */
 
 /* Sculpt */
@@ -1217,7 +1228,10 @@ typedef struct ToolSettings {
 
 	/* Particle Editing */
 	struct ParticleEditSettings particle;
-	
+
+	/* Hair Editing */
+	struct HairEditSettings hair_edit;
+
 	/* Transform Proportional Area of Effect */
 	float proportional_size;
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index a47a777..44f2013 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2124,6 +2124,10 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 	RNA_def_property_pointer_sdna(prop, NULL, "particle");
 	RNA_def_property_ui_text(prop, "Particle Edit", "");
 
+	prop = RNA_def_property(srna, "hair_edit", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "hair_edit");
+	RNA_def_property_ui_text(prop, "Hair Edit", "");
+
 	prop = RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1);
 	RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting");
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index a975ea3..43b4b23 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -221,6 +221,8 @@ static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value)
 		mode = OB_MODE_VERTEX_PAINT;
 	else if (ptr->data == ts->wpaint)
 		mode = OB_MODE_WEIGHT_PAINT;
+	else if (ptr->data == &ts->hair_edit)
+		mode = OB_MODE_HAIR_EDIT;
 
 	return brush->ob_mode & mode;
 }
@@ -359,6 +361,30 @@ static int rna_ImaPaint_detect_data(ImagePaintSettings *imapaint)
 {
 	return imapaint->missing_data == 0;
 }
+
+/* ==== Hair Edit ==== */
+
+static char *rna_HairEdit_path(PointerRNA *UNUSED(ptr))
+{
+	return BLI_strdup("tool_settings.hair_edit");
+}
+
+static void rna_HairEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+{
+	Object *ob = OBACT;
+
+	if (ob)
+		DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+}
+
+static void rna_Hair_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+	HairEditSettings *settings = ptr->data;
+	Brush *brush = settings->brush;
+	BKE_paint_invalidate_overlay_all();
+	WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
+}
+
 #else
 
 static void rna_def_paint_curve(BlenderRNA *brna)
@@ -915,6 +941,41 @@ static void rna_def_particle_edit(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Curve", "");
 }
 
+static void rna_def_hair_edit(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	static EnumPropertyItem select_mode_items[] = {
+		{SCE_SELECT_PATH, "PATH", ICON_PARTICLE_PATH, "Path", "Path edit mode"},
+		{SCE_SELECT_POINT, "POINT", ICON_PARTICLE_POINT, "Point", "Point select mode"},
+		{SCE_SELECT_END, "TIP", ICON_PARTICLE_TIP, "Tip", "Tip select mode"},
+		{0, NULL, 0, NULL, NULL}
+	};
+
+	srna = RNA_def_struct(brna, "HairEdit", NULL);
+	RNA_def_struct_sdna(srna, "HairEditSettings");
+	RNA_def_struct_path_func(srna, "rna_HairEdit_path");
+	RNA_def_struct_ui_text(srna, "Hair Edit", "Settings for hair editing mode");
+
+	prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Brush_mode_poll");
+	RNA_def_property_ui_text(prop, "Brush", "Active Brush");
+	RNA_def_property_update(prop, 0, "rna_Hair_brush_update");
+
+	prop = RNA_def_property(srna, "select_mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_bitflag_sdna(prop, NULL, "select_mode");
+	RNA_def_property_enum_items(prop, select_mode_items);
+	RNA_def_property_ui_text(prop, "Selection Mode", "Hair selection mode");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_HairEdit_update");
+
+	prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for tools");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_HairEdit_update");
+}
+
 void RNA_def_sculpt_paint(BlenderRNA *brna)
 {
 	/* *** Non-Animated *** */
@@ -926,6 +987,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna)
 	rna_def_vertex_paint(brna);
 	rna_def_image_paint(brna);
 	rna_def_particle_edit(brna);
+	rna_def_hair_edit(brna);
 	RNA_define_animate_sdna(true);
 }




More information about the Bf-blender-cvs mailing list