[Bf-blender-cvs] [4bbfdce004f] temp-eevee-gpencil-rewrite: Move GPStyle pass_index to Material

Antonio Vazquez noreply at git.blender.org
Wed Oct 6 18:24:27 CEST 2021


Commit: 4bbfdce004fc88ba5d6fcf825d4c9b212c8ce21c
Author: Antonio Vazquez
Date:   Wed Oct 6 17:17:29 2021 +0200
Branches: temp-eevee-gpencil-rewrite
https://developer.blender.org/rB4bbfdce004fc88ba5d6fcf825d4c9b212c8ce21c

Move GPStyle pass_index to Material

This was duplicated

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

M	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index d7dace27c8c..3f11722f665 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -304,13 +304,6 @@ class MATERIAL_PT_gpencil_settings(GPMaterialButtonsPanel, Panel):
     def draw(self, context):
         draw_material_settings(self, context)
 
-        # TODO: Remove prop pass_index and move to material struct
-        layout = self.layout
-        layout.use_property_split = True
-        ma = context.material
-        gpcolor = ma.grease_pencil
-        layout.prop(gpcolor, "pass_index")
-
 
 class MATERIAL_PT_gpencil_material_presets(PresetPanel, Panel):
     """Material settings"""
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index e65fd3e6754..7becdcc2707 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1682,5 +1682,14 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
    */
   {
     /* Keep this block, even when empty. */
+    /* Fix grease pencil material index. */
+    {
+      LISTBASE_FOREACH (Material *, mat, &bmain->materials) {
+        if (mat->gp_style != NULL) {
+          mat->index = mat->gp_style->index;
+        }
+      }
+
+    }
   }
 }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index df78ac8110e..c61851b374e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -85,7 +85,6 @@ bool is_stroke_affected_by_modifier(Object *ob,
                                     const bool inv4)
 {
   Material *ma = BKE_gpencil_material(ob, gps->mat_nr + 1);
-  MaterialGPencilStyle *gp_style = ma->gp_style;
 
   /* omit if filter by layer */
   if (mlayername[0] != '\0') {
@@ -129,12 +128,12 @@ bool is_stroke_affected_by_modifier(Object *ob,
   /* verify material pass */
   if (mpassindex > 0) {
     if (inv2 == false) {
-      if (gp_style->index != mpassindex) {
+      if (material->index != mpassindex) {
         return false;
       }
     }
     else {
-      if (gp_style->index == mpassindex) {
+      if (material->index == mpassindex) {
         return false;
       }
     }
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 67cd68afb8a..81c458cfa36 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -67,7 +67,7 @@ typedef struct MaterialGPencilStyle {
   /** Settings. */
   short flag;
   /** Custom index for passes. */
-  short index;
+  short index DNA_DEPRECATED;
   /** Style for drawing strokes (used to select shader type). */
   short stroke_style;
   /** Style for filling areas (used to select shader type). */
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 22a75c0d992..94252feb4d6 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -610,12 +610,6 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
                            "Only applies in texture shading mode");
   RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
 
-  /* pass index for future compositing and editing tools */
-  prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
-  RNA_def_property_int_sdna(prop, NULL, "index");
-  RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Color Index\" pass");
-  RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
-
   /* mode type */
   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");



More information about the Bf-blender-cvs mailing list