[Bf-blender-cvs] [a3a0841] soc-2016-pbvh-painting: Added mirror buttons to weight paint, and added pbvh leaf selection and mirrored symmetry code. Still need to create callbacks for pbvh leaf selection.

Nathan Vollmer noreply at git.blender.org
Sun Jul 10 00:24:31 CEST 2016


Commit: a3a084111041666f9464fc7d3339a8c8e528d964
Author: Nathan Vollmer
Date:   Sat Jul 9 16:23:15 2016 -0600
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rBa3a084111041666f9464fc7d3339a8c8e528d964

Added mirror buttons to weight paint, and added pbvh leaf selection and mirrored symmetry code. Still need to create callbacks for pbvh leaf selection.

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

M	release/scripts/addons
M	release/scripts/addons_contrib
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/release/scripts/addons b/release/scripts/addons
index 9dd1799..04138bd 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 9dd17998ca72cdc1abce8e9e9cff8b82798244e2
+Subproject commit 04138bdf09c5835273ab10177e99f2ffd3f1bc44
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 6176bf6..21462b9 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 6176bf658d03be565f7c82e2d2527c9c2aa1cf3b
+Subproject commit 21462b91fffb2a4693ef08cfee16a6fab32c4acb
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index c7fcc95..2e9d830 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1694,6 +1694,7 @@ class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
     bl_category = "Tools"
     bl_context = "weightpaint"
+    bl_options = {'DEFAULT_CLOSED'}
     bl_label = "Weight Tools"
 
     def draw(self, context):
@@ -1706,6 +1707,26 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
         props.use_reverse_transfer = True
         props.data_type = 'VGROUP_WEIGHTS'
 
+class VIEW3D_PT_weightpaint_symmetry(Panel, View3DPaintPanel):
+    bl_category = "Tools"
+    bl_context = "weightpaint"
+    bl_options = {'DEFAULT_CLOSED'}
+    bl_label = "Symmetry / Lock"
+    
+    def draw(self, context):
+        layout = self.layout
+        toolsettings = context.tool_settings
+        wpaint = toolsettings.weight_paint
+
+        col = layout.column(align=True)
+        col.label(text="Mirror:")
+        row = col.row(align=True)
+        
+        row.prop(wpaint, "use_symmetry_x", text="X", toggle=True)
+        row.prop(wpaint, "use_symmetry_y", text="Y", toggle=True)
+        row.prop(wpaint, "use_symmetry_z", text="Z", toggle=True)
+        
+        layout.column().prop(wpaint, "radial_symmetry", text="Radial")
 
 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
     bl_category = "Options"
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index e892107..fe4b6e4 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -30,6 +30,8 @@
 
 #include "ED_view3d.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BLI_stack.h"
 
 #ifndef __PAINT_INTERN_H__
 #define __PAINT_INTERN_H__
@@ -92,6 +94,56 @@ void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
 void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, int (*poll)(struct bContext *C));
 void paint_cursor_delete_textures(void);
 
+/**
+* Variables stored both for 'active' and 'mirror' sides.
+*/
+struct WeightPaintGroupData {
+  /** index of active group or its mirror
+  *
+  * - 'active' is always `ob->actdef`.
+  * - 'mirror' is -1 when 'ME_EDIT_MIRROR_X' flag id disabled,
+  *   otherwise this will be set to the mirror or the active group (if the group isn't mirrored).
+  */
+  int index;
+  /** lock that includes the 'index' as locked too
+  *
+  * - 'active' is set of locked or active/selected groups
+  * - 'mirror' is set of locked or mirror groups
+  */
+  const bool *lock;
+};
+
+typedef struct WPaintData {
+  ViewContext vc;
+  int *indexar;
+
+  struct WeightPaintGroupData active, mirror;
+
+  void *vp_handle;
+  DMCoNo *vertexcosnos;
+
+  float wpimat[3][3];
+
+  /* variables for auto normalize */
+  const bool *vgroup_validmap; /* stores if vgroups tie to deforming bones or not */
+  const bool *lock_flags;
+
+  /* variables for multipaint */
+  const bool *defbase_sel;      /* set of selected groups */
+  int defbase_tot_sel;          /* number of selected groups */
+  bool do_multipaint;           /* true if multipaint enabled and multiple groups selected */
+
+  /* variables for blur */
+  struct {
+    MeshElemMap *vmap;
+    int *vmap_mem;
+  } blur_data;
+
+  BLI_Stack *accumulate_stack;  /* for reuse (WPaintDefer) */
+
+  int defbase_tot;
+} WPaintData;
+
 /* paint_vertex.c */
 typedef struct VPaintData {
 	ViewContext vc;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 41d17e4..d7bfd01 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -35,7 +35,6 @@
 #include "BLI_math.h"
 #include "BLI_array_utils.h"
 #include "BLI_bitmap.h"
-#include "BLI_stack.h"
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
@@ -60,7 +59,6 @@
 #include "BKE_depsgraph.h"
 #include "BKE_deform.h"
 #include "BKE_mesh.h"
-#include "BKE_mesh_mapping.h"
 #include "BKE_modifier.h"
 #include "BKE_object_deform.h"
 #include "BKE_paint.h"
@@ -1480,25 +1478,6 @@ static void multipaint_apply_change(MDeformVert *dvert, const int defbase_tot, f
 	}
 }
 
-/**
- * Variables stored both for 'active' and 'mirror' sides.
- */
-struct WeightPaintGroupData {
-	/** index of active group or its mirror 
-	 *
-	 * - 'active' is always `ob->actdef`.
-	 * - 'mirror' is -1 when 'ME_EDIT_MIRROR_X' flag id disabled,
-	 *   otherwise this will be set to the mirror or the active group (if the group isn't mirrored).
-	 */
-	int index;
-	/** lock that includes the 'index' as locked too
-	 *
-	 * - 'active' is set of locked or active/selected groups
-	 * - 'mirror' is set of locked or mirror groups
-	 */
-	const bool *lock;
-};
-
 /* struct to avoid passing many args each call to do_weight_paint_vertex()
  * this _could_ be made a part of the operators 'WPaintData' struct, or at
  * least a member, but for now keep its own struct, initialized on every
@@ -1821,6 +1800,7 @@ static void vertex_paint_init_session_average_arrays(Object *ob){
  */
 static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
 {		
+  //added
 	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;
@@ -1865,7 +1845,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
 
 		if (wp == NULL)
 			wp = scene->toolsettings->wpaint = new_vpaint(1);
-
+    wp->radial_symm[0] = wp->radial_symm[1] = wp->radial_symm[2] = 1;
 		paint_cursor_start(C, weight_paint_poll);
 
 		BKE_paint_init(scene, ePaintWeight, PAINT_CURSOR_WEIGHT_PAINT);
@@ -1874,6 +1854,11 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
 		ED_mesh_mirror_spatial_table(ob, NULL, NULL, NULL, 's');
 		ED_vgroup_sync_from_pose(ob);
 
+    /* Create vertex/weight paint mode session data */
+    if (ob->sculpt)
+      BKE_sculptsession_free(ob);
+
+    vertex_paint_init_session(scene, ob);
 
 		/* Cache needs to be initialized before mesh_build_data is called. */
 		ob->sculpt->cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
@@ -1932,37 +1917,6 @@ struct WPaintVGroupIndex {
 	int mirror;
 };
 
-struct WPaintData {
-	ViewContext vc;
-	int *indexar;
-
-	struct WeightPaintGroupData active, mirror;
-
-	void *vp_handle;
-	DMCoNo *vertexcosnos;
-
-	float wpimat[3][3];
-
-	/* variables for auto normalize */
-	const bool *vgroup_validmap; /* stores if vgroups tie to deforming bones or not */
-	const bool *lock_flags;
-
-	/* variables for multipaint */
-	const bool *defbase_sel;      /* set of selected groups */
-	int defbase_tot_sel;          /* number of selected groups */
-	bool do_multipaint;           /* true if multipaint enabled and multiple groups selected */
-
-	/* variables for blur */
-	struct {
-		MeshElemMap *vmap;
-		int *vmap_mem;
-	} blur_data;
-
-	BLI_Stack *accumulate_stack;  /* for reuse (WPaintDefer) */
-
-	int defbase_tot;
-};
-
 /* ensure we have data on wpaint start, add if needed */
 static bool wpaint_ensure_data(
         bContext *C, wmOperator *op,
@@ -2365,8 +2319,145 @@ static float wpaint_blur_weight_calc_from_connected(
 	return paintweight;
 }
 
+/* Flip all the editdata across the axis/axes specified by symm. Used to
+* calculate multiple modifications to the mesh when symmetry is enabled. */
+static void calc_brushdata_symm(VPaint *vd, StrokeCache *cache, const char symm,
+  const char axis, const float angle)
+{
+  (void)vd; /* unused */
+
+  flip_v3_v3(cache->location, cache->true_location, symm);
+  flip_v3_v3(cache->grab_delta_symmetry, cache->grab_delta, symm);
+  flip_v3_v3(cache->view_normal, cache->true_view_normal, symm);
+
+  /* XXX This reduces the length of the grab delta if it approaches the line of symmetry
+  * XXX However, a different approach appears to be needed */
+#if 0
+  if (sd->paint.symmetry_flags & SCULPT_SYMMETRY_FEATHER) {
+    float frac = 1.0f / max_overlap_count(sd);
+    float reduce = (feather - frac) / (1 - frac);
+
+    printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce);
+
+    if (frac < 1)
+      mul_v3_fl(cache->grab_delta_symmetry, reduce);
+  }
+#endif
+
+  unit_m4(cache->symm_rot_mat);
+  unit_m4(cache->symm_rot_mat_inv);
+  zero_v3(cache->plane_offset);
+
+  if (axis) { /* expects XYZ */
+    rotate_m4(cache->symm_rot_mat, axis, angle);
+    rotate_m4(cache->symm_rot_mat_inv, axis, -angle);
+  }
+
+  mul_m4_v3(cache->symm_rot_mat, cache->location);
+  mul_m4_v3(cache->symm_rot_mat, cache->grab_delta_symmetry);
+
+  if (cache->supports_gravity) {
+    flip_v3_v3(cache->gravity_direction, cache->true_gravity_direction, symm);
+    mul_m4_v3(cache->symm_rot_mat, cache->gravity_direction);
+  }
+
+  if (cache->is_rake_rotation_valid) {
+    flip_qt_qt(cache->rake_rotation_symmetry, cache->rake_rotation, symm);
+  }
+}
+
+static void wpaint_paint_leaves(Object *ob, Sculpt *sd, VPaint *vp, WPaintData *wpd, Mesh *me, PBVHNode **nodes, int totnode)
+{
+  Brush *brush = ob->sculpt->cache->brush;//BKE_paint_brush(&sd->paint);
+
+  /* threaded loop over nodes */
+  SculptThreadedTaskData data = {
+    .sd = sd, .ob = ob, .brush = brush, .nodes = nodes,
+  };
+
+  data.vp = vp;
+  data.wpd = wpd;
+  data.lcol = (unsigned int*)me->mloopcol;
+  data.me = me;
+
+  printf("Painting leaves\n");
+  //

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list