[Bf-blender-cvs] [7f65ab86e59] master: Cleanup: sync vertex-paint and sculpt from 2.8

Campbell Barton noreply at git.blender.org
Mon Feb 19 05:52:52 CET 2018


Commit: 7f65ab86e59f25e718213287273705cfd34e1746
Author: Campbell Barton
Date:   Mon Feb 19 12:20:18 2018 +1100
Branches: master
https://developer.blender.org/rB7f65ab86e59f25e718213287273705cfd34e1746

Cleanup: sync vertex-paint and sculpt from 2.8

Sync API changes from 2.8 to master.

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

M	source/blender/editors/include/ED_object.h
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/editors/util/undo.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_files.c

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

diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 8456c15c79d..4baec6a58ef 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -127,6 +127,25 @@ bool ED_object_editmode_load(struct Object *obedit);
 
 bool ED_object_editmode_calc_active_center(struct Object *obedit, const bool select_only, float r_center[3]);
 
+
+void ED_object_vpaintmode_enter_ex(
+        struct wmWindowManager *wm,
+        struct Scene *scene, struct Object *ob);
+void ED_object_vpaintmode_enter(struct bContext *C);
+void ED_object_wpaintmode_enter_ex(
+        struct wmWindowManager *wm,
+        struct Scene *scene, struct Object *ob);
+void ED_object_wpaintmode_enter(struct bContext *C);
+
+void ED_object_vpaintmode_exit_ex(struct Object *ob);
+void ED_object_vpaintmode_exit(struct bContext *C);
+void ED_object_wpaintmode_exit_ex(struct Object *ob);
+void ED_object_wpaintmode_exit(struct bContext *C);
+
+void ED_object_sculptmode_exit_ex(
+        struct Scene *scene, struct Object *ob);
+void ED_object_sculptmode_exit(struct bContext *C);
+
 void ED_object_location_from_view(struct bContext *C, float loc[3]);
 void ED_object_rotation_from_view(struct bContext *C, float rot[3], const char align_axis);
 void ED_object_base_init_transform(struct bContext *C, struct Base *base, const float loc[3], const float rot[3]);
@@ -186,22 +205,25 @@ enum {
 	MODIFIER_APPLY_SHAPE
 };
 
-struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
-                                            struct Object *ob, const char *name, int type);
+struct ModifierData *ED_object_modifier_add(
+        struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+        struct Object *ob, const char *name, int type);
 bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain,
                                struct Object *ob, struct ModifierData *md);
 void ED_object_modifier_clear(struct Main *bmain, struct Object *ob);
 int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene,
-                               struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_convert(
+        struct ReportList *reports, struct Main *bmain, struct Scene *scene,
+        struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene,
                              struct Object *ob, struct ModifierData *md, int mode);
 int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
 
-bool ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, const bool include_orig,
-                          bool (*callback)(struct Object *ob, void *callback_data),
-                          void *callback_data);
+bool ED_object_iter_other(
+        struct Main *bmain, struct Object *orig_ob, const bool include_orig,
+        bool (*callback)(struct Object *ob, void *callback_data),
+        void *callback_data);
 
 bool ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v);
 
@@ -215,7 +237,8 @@ const struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(
         bool *r_free,
         const unsigned int selection_mask);
 
-void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object);
+void ED_object_check_force_modifiers(
+        struct Main *bmain, struct Scene *scene, struct Object *object);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index d085c6953da..a49fe9c929a 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -417,7 +417,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
 		MEM_freeN(nodes);
 	
 	/* end undo */
-	sculpt_undo_push_end(C);
+	sculpt_undo_push_end();
 
 	/* ensure that edges and faces get hidden as well (not used by
 	 * sculpt but it looks wrong when entering editmode otherwise) */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 9d960980f30..8e091bdf59c 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -168,7 +168,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
 	if (multires)
 		multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
 
-	sculpt_undo_push_end(C);
+	sculpt_undo_push_end();
 
 	if (nodes)
 		MEM_freeN(nodes);
@@ -323,7 +323,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
 	if (multires)
 		multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
 
-	sculpt_undo_push_end(C);
+	sculpt_undo_push_end();
 
 	ED_region_tag_redraw(ar);
 
@@ -509,7 +509,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
 		if (multires)
 			multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
 
-		sculpt_undo_push_end(C);
+		sculpt_undo_push_end();
 
 		ED_region_tag_redraw(vc.ar);
 		MEM_freeN((void *)mcords);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 490343ab1f2..e550ed66fc2 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1026,71 +1026,187 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
 
 }
 
-/* *************** set wpaint operator ****************** */
+/* -------------------------------------------------------------------- */
+/** \name Enter Vertex/Weight Paint Mode
+ * \{ */
 
-/**
- * \note Keep in sync with #vpaint_mode_toggle_exec
- */
-static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
+static void ed_vwpaintmode_enter_generic(
+        wmWindowManager *wm,
+        Scene *scene,
+        Object *ob, const eObjectMode mode_flag)
 {
-	Object *ob = CTX_data_active_object(C);
-	const int mode_flag = OB_MODE_WEIGHT_PAINT;
-	const bool is_mode_set = (ob->mode & mode_flag) != 0;
-	Scene *scene = CTX_data_scene(C);
-	VPaint *wp = scene->toolsettings->wpaint;
-	Mesh *me;
+	ob->mode |= mode_flag;
+	Mesh *me = BKE_mesh_from_object(ob);
 
-	if (!is_mode_set) {
-		if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
-			return OPERATOR_CANCELLED;
+	if (mode_flag == OB_MODE_VERTEX_PAINT) {
+		const ePaintMode paint_mode = ePaintVertex;
+		ED_mesh_color_ensure(me, NULL);
+
+		if (scene->toolsettings->vpaint == NULL) {
+			scene->toolsettings->vpaint = new_vpaint();
 		}
+
+		Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
+		paint_cursor_start_explicit(paint, wm, vertex_paint_poll);
+		BKE_paint_init(scene, paint_mode, PAINT_CURSOR_VERTEX_PAINT);
 	}
+	else if (mode_flag == OB_MODE_WEIGHT_PAINT) {
+		const  ePaintMode paint_mode = ePaintWeight;
 
-	me = BKE_mesh_from_object(ob);
+		if (scene->toolsettings->wpaint == NULL) {
+			scene->toolsettings->wpaint = new_vpaint();
+		}
+
+		Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
+		paint_cursor_start_explicit(paint, wm, weight_paint_poll);
+		BKE_paint_init(scene, paint_mode, PAINT_CURSOR_WEIGHT_PAINT);
+
+		/* weight paint specific */
+		ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's');
+		ED_vgroup_sync_from_pose(ob);
+	}
+	else {
+		BLI_assert(0);
+	}
+
+	/* Create vertex/weight paint mode session data */
+	if (ob->sculpt) {
+		if (ob->sculpt->cache) {
+			sculpt_cache_free(ob->sculpt->cache);
+			ob->sculpt->cache = NULL;
+		}
+		BKE_sculptsession_free(ob);
+	}
+
+	vertex_paint_init_session(scene, ob);
+}
+
+void ED_object_vpaintmode_enter_ex(
+        wmWindowManager *wm,
+        Scene *scene, Object *ob)
+{
+	ed_vwpaintmode_enter_generic(
+	        wm, scene, ob, OB_MODE_VERTEX_PAINT);
+}
+void ED_object_vpaintmode_enter(struct bContext *C)
+{
+	wmWindowManager *wm = CTX_wm_manager(C);
+	Scene *scene = CTX_data_scene(C);
+	Object *ob = CTX_data_active_object(C);
+	ED_object_vpaintmode_enter_ex(wm, scene, ob);
+}
+
+void ED_object_wpaintmode_enter_ex(
+        wmWindowManager *wm,
+        Scene *scene, Object *ob)
+{
+	ed_vwpaintmode_enter_generic(
+	        wm, scene, ob, OB_MODE_WEIGHT_PAINT);
+}
+void ED_object_wpaintmode_enter(struct bContext *C)
+{
+	wmWindowManager *wm = CTX_wm_manager(C);
+	Scene *scene = CTX_data_scene(C);
+	Object *ob = CTX_data_active_object(C);
+	ED_object_wpaintmode_enter_ex(wm, scene, ob);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Exit Vertex/Weight Paint Mode
+ * \{ */
 
-	if (ob->mode & mode_flag) {
-		ob->mode &= ~mode_flag;
+static void ed_vwpaintmode_exit_generic(
+        Object *ob, const eObjectMode mode_flag)
+{
+	Mesh *me = BKE_mesh_from_object(ob);
+	ob->mode &= ~mode_flag;
 
+	if (mode_flag == OB_MODE_VERTEX_PAINT) {
+		if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
+			BKE_mesh_flush_select_from_polys(me);
+		}
+		else if (me->editflag & ME_EDIT_PAINT_VERT_SEL) {
+			BKE_mesh_flush_select_from_verts(me);
+		}
+	}
+	else if (mode_flag == OB_MODE_WEIGHT_PAINT) {
 		if (me->editflag & ME_EDIT_PAINT_VERT_SEL) {
 			BKE_mesh_flush_select_from_verts(me);
 		}
 		else if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
 			BKE_mesh_flush_select_from_polys(me);
 		}
+	}
+	else {
+		BLI_assert(0);
+	}
 
-		/* weight paint specific */
-		ED_mesh_mirror_spatial_table(NULL, NULL, NULL, NULL, 'e');
-		ED_mesh_mirror_topo_table(NULL, NULL, 'e');
+	/* If the cache is not released by a cancel or a done, free it now. */
+	if (ob->sculpt->cache) {
+		sculpt_cache_free(ob->sculpt->cache);
+		ob->sculpt->cache = NULL;
+	}
 
-		/* If the cache is not released by a cancel or a done, free it now. */
-		if (ob->sculpt->cache) {
-			sculpt_cache_free(ob->sculpt->cache);
-			ob->sculpt->cache = NULL

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list