[Bf-blender-cvs] [c618a6cf92e] greasepencil-object: WIP: New weight painting mode

Antonio Vazquez noreply at git.blender.org
Tue Aug 1 16:51:37 CEST 2017


Commit: c618a6cf92e9e242cefb300487f9a3e6674ef1f3
Author: Antonio Vazquez
Date:   Tue Aug 1 12:49:16 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc618a6cf92e9e242cefb300487f9a3e6674ef1f3

WIP: New weight painting mode

New mode to define the weights by stroke point.

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

M	release/scripts/modules/bpy_extras/keyconfig_utils.py
M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_geom.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_ops.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_select.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_select.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/util/undo.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_gpencil.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py
index 702024819a0..2ffd3cea120 100644
--- a/release/scripts/modules/bpy_extras/keyconfig_utils.py
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py
@@ -124,6 +124,7 @@ KM_HIERARCHY = [
         ('Grease Pencil Stroke Edit Mode', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint Mode', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Sculpt Mode', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Weight Mode', 'EMPTY', 'WINDOW', []),
     ]),
     ('Mask Editing', 'EMPTY', 'WINDOW', []),
     ('Frames', 'EMPTY', 'WINDOW', []),    # frame navigation (per region)
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index e75d3c7c07c..01f98694eac 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -388,7 +388,7 @@ class GreasePencilBrushPanel:
 class GreasePencilStrokeSculptPanel:
     # subclass must set
     # bl_space_type = 'IMAGE_EDITOR'
-    bl_label = "Sculpt Strokes"
+    bl_label = " "
     bl_category = "Tools"
     bl_region_type = 'TOOLS'
 
@@ -403,19 +403,31 @@ class GreasePencilStrokeSculptPanel:
             if not is_3d_view:
                 return bool(gpd.use_stroke_edit_mode)
             else:
-                return bool(gpd.is_stroke_sculpt_mode)
+                return bool(gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode)
 
         return False
 
     @staticmethod
-    def draw(self, context):
+    def draw_header(self, context):
         layout = self.layout
+        gpd = context.gpencil_data
+        if gpd is not None and gpd.is_stroke_weight_mode:
+            layout.label("Weight Paint")
+        else:
+            layout.label("Sculpt Strokes")
 
+    @staticmethod
+    def draw(self, context):
+        layout = self.layout
+        gpd = context.gpencil_data
         settings = context.tool_settings.gpencil_sculpt
         tool = settings.tool
         brush = settings.brush
 
-        layout.template_icon_view(settings, "tool", show_labels=True)
+        if gpd.is_stroke_sculpt_mode:
+            layout.template_icon_view(settings, "tool", show_labels=True)
+        if gpd.is_stroke_weight_mode:
+            layout.template_icon_view(settings, "weight_tool", show_labels=True)
 
         col = layout.column()
         col.prop(brush, "size", slider=True)
@@ -461,7 +473,8 @@ class GreasePencilAppearancePanel:
         if context.gpencil_data is None:
             return False
 
-        if context.active_object and context.active_object.mode in ('GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return True
         else:
             return False
@@ -479,7 +492,7 @@ class GreasePencilAppearancePanel:
             row = col.row(align=True)
             row.prop(drawingbrush, "cursor_color", text="Color")
 
-        if context.active_object.mode == 'GPENCIL_SCULPT':
+        if context.active_object.mode in ('GPENCIL_SCULPT', 'GPENCIL_WEIGHT'):
             col.prop(brush, "use_cursor", text="Show Brush")
             row = col.row(align=True)
             row.prop(brush, "cursor_color_add", text="Add")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 4d8048d0b69..837ed09d152 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -64,7 +64,8 @@ class VIEW3D_PT_tools_transform(View3DPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        if context.active_object and context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return False
         else:
             return True
@@ -88,7 +89,8 @@ class VIEW3D_PT_tools_object(View3DPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        if context.active_object and context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return False
         else:
             return True
@@ -142,7 +144,8 @@ class VIEW3D_PT_tools_add_object(View3DPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        if context.active_object and context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return False
         else:
             return True
@@ -245,7 +248,8 @@ class VIEW3D_PT_tools_relations(View3DPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        if context.active_object and context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return False
         else:
             return True
@@ -287,7 +291,8 @@ class VIEW3D_PT_tools_animation(View3DPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        if context.active_object and context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return False
         else:
             return True
@@ -321,7 +326,8 @@ class VIEW3D_PT_tools_rigid_body(View3DPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        if context.active_object and context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT'):
+        is_gpmode = context.active_object.mode in ('GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT')
+        if context.active_object and is_gpmode:
             return False
         else:
             return True
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 23ac7774704..a051d100b52 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4895,6 +4895,7 @@ static void lib_link_object(FileData *fd, Main *main)
 					ob->gpd->flag &= ~GP_DATA_STROKE_EDITMODE;
 					ob->gpd->flag &= ~GP_DATA_STROKE_PAINTMODE;
 					ob->gpd->flag &= ~GP_DATA_STROKE_SCULPTMODE;
+					ob->gpd->flag &= ~GP_DATA_STROKE_WEIGHTMODE;
 				}
 			}
 			ob->duplilist = NULL;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index b178396dbf5..5e225d1fe24 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -501,6 +501,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 		}
 
 		/* grease pencil sculpt and paint cursors */
+		if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "int", "weighttype")) {
+			for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+				/* sculpt brushes */
+				GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+				if (gset) {
+					gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT;
+				}
+			}
+		}
+
 		if (!DNA_struct_elem_find(fd->filesdna, "bGPDbrush", "float", "curcolor[3]")) {
 			float curcolor[3], curcolor_add[3], curcolor_sub[3];
 			ARRAY_SET_ITEMS(curcolor, 1.0f, 1.0f, 1.0f);
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 121cb5f09d1..2c8b0a0f1e5 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -148,76 +148,73 @@ void BLO_update_defaults_startup_blend(Main *bmain)
 				ARRAY_SET_ITEMS(curcolor_add, 1.0f, 0.6f, 0.6f);
 				ARRAY_SET_ITEMS(curcolor_sub, 0.6f, 0.6f, 1.0f);
 
-				
+				/* edit points alpha color */
+				gset->alpha = 1.0f;
+				/* default sculpt brush */
+				gset->brushtype = GP_EDITBRUSH_TYPE_SMOOTH;
+				/* default weight paint brush */
+				gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT;
+
 				brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH];
 				brush->size = 25;
 				brush->strength = 0.3f;
-				brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE;
-				brush->flag |= GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+				brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
 				copy_v3_v3(brush->curcolor_add, curcolor_add);
 				copy_v3_v3(brush->curcolor_sub, curcolor_sub);
 
 				brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS];
 				brush->size = 25;
 				brush->strength = 0.5f;
-				brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
-				brush->flag |= GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+				brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
 				copy_v3_v3(brush->curcolor_add, curcolor_add);
 				copy_v3_v3(brush->curcolor_sub, curcolor_sub);
 
 				brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
 				brush->size = 25;
 				brush->strength = 0.5f;
-				brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
-				brush->flag |= GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
+				brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
 				copy_v3_v3(brush->curcolor_add, curcolor_add);
 				copy_v3_v3(brush->curcolor_sub, curcolor_sub);
 
 				brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB];
 				brush->size = 50;
 				brush->strength = 0.3f;
-				b

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list