[Bf-blender-cvs] [23018417d59] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

Antonio Vazquez noreply at git.blender.org
Wed Feb 5 16:00:23 CET 2020


Commit: 23018417d59c91ab32d41f62ab5261a6bee5d991
Author: Antonio Vazquez
Date:   Wed Feb 5 11:42:35 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB23018417d59c91ab32d41f62ab5261a6bee5d991

Merge branch 'greasepencil-object' into greasepencil-refactor

 Conflicts:
	source/blender/blenkernel/intern/gpencil_modifier.c
	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
	source/blender/draw/engines/gpencil/gpencil_engine.c
	source/blender/draw/engines/overlay/overlay_extra.c
	source/blender/editors/gpencil/gpencil_fill.c
	source/blender/editors/gpencil/gpencil_utils.c
	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
	source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
	source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
	source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c

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



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

diff --cc source/blender/blenkernel/intern/gpencil.c
index 6b2fcf8334d,c604502e87a..ee674001caf
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@@ -1126,9 -1129,9 +1126,9 @@@ Material *BKE_gpencil_object_material_e
      Material *ma = BKE_gpencil_brush_material_get(brush);
  
      /* check if the material is already on object material slots and add it if missing */
 -    if (ma && BKE_gpencil_object_material_get_index(ob, ma) < 0) {
 +    if (ma && BKE_gpencil_object_material_index_get(ob, ma) < 0) {
        BKE_object_material_slot_add(bmain, ob);
-       assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+       BKE_object_material_assign(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
      }
  
      return ma;
@@@ -1145,10 -1148,10 +1145,10 @@@ int BKE_gpencil_object_material_ensure(
    if (!material) {
      return -1;
    }
 -  int index = BKE_gpencil_object_material_get_index(ob, material);
 +  int index = BKE_gpencil_object_material_index_get(ob, material);
    if (index < 0) {
      BKE_object_material_slot_add(bmain, ob);
-     assign_material(bmain, ob, material, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+     BKE_object_material_assign(bmain, ob, material, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
      return ob->totcol - 1;
    }
    return index;
@@@ -2485,12 -2482,12 +2485,12 @@@ void BKE_gpencil_stats_update(bGPdata *
  }
  
  /* get material index (0-based like mat_nr not actcol) */
 -int BKE_gpencil_object_material_get_index(Object *ob, Material *ma)
 +int BKE_gpencil_object_material_index_get(Object *ob, Material *ma)
  {
-   short *totcol = give_totcolp(ob);
+   short *totcol = BKE_object_material_num(ob);
    Material *read_ma = NULL;
    for (short i = 0; i < *totcol; i++) {
-     read_ma = give_current_material(ob, i + 1);
+     read_ma = BKE_object_material_get(ob, i + 1);
      if (ma == read_ma) {
        return i;
      }
@@@ -3392,9 -3368,9 +3392,9 @@@ static void gpencil_convert_spline(Mai
      else if ((only_stroke) || (do_stroke)) {
        /* Also use the first color if the fill is none for stroke color. */
        if (ob_cu->totcol > 0) {
-         mat_curve = give_current_material(ob_cu, 1);
+         mat_curve = BKE_object_material_get(ob_cu, 1);
          if (mat_curve) {
 -          linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r);
 +          copy_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r);
            mat_gp->gp_style->stroke_rgba[3] = mat_curve->a;
            /* Set fill and stroke depending of curve type (3D or 2D). */
            if ((cu->flag & CU_3D) || ((cu->flag & (CU_FRONT | CU_BACK)) == 0)) {
diff --cc source/blender/blenloader/intern/versioning_defaults.c
index ecc87a72fc9,8dc71dd314e..1c0ea8d20ed
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@@ -614,16 -612,16 +614,16 @@@ void BLO_update_defaults_startup_blend(
      /* Dots Stroke. */
      ma = BLI_findstring(&bmain->materials, "Dots Stroke", offsetof(ID, name) + 2);
      if (ma == NULL) {
-       ma = BKE_material_add_gpencil(bmain, "Dots Stroke");
+       ma = BKE_gpencil_material_add(bmain, "Dots Stroke");
      }
 -    ma->gp_style->mode = GP_STYLE_MODE_DOTS;
 +    ma->gp_style->mode = GP_MATERIAL_MODE_DOT;
  
      /* Boxes Stroke. */
      ma = BLI_findstring(&bmain->materials, "Boxes Stroke", offsetof(ID, name) + 2);
      if (ma == NULL) {
-       ma = BKE_material_add_gpencil(bmain, "Boxes Stroke");
+       ma = BKE_gpencil_material_add(bmain, "Boxes Stroke");
      }
 -    ma->gp_style->mode = GP_STYLE_MODE_BOX;
 +    ma->gp_style->mode = GP_MATERIAL_MODE_SQUARE;
  
      /* Reset all grease pencil brushes. */
      Scene *scene = bmain->scenes.first;
diff --cc source/blender/editors/gpencil/drawgpencil.c
index 275089e0beb,d6e96c08fdc..b2b3670941f
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@@ -320,12 -390,18 +320,12 @@@ static void gp_draw_stroke_fill(bGPdat
                                  const float color[4])
  {
    BLI_assert(gps->totpoints >= 3);
 +  BLI_assert(gps->tot_triangles >= 1);
    const bool use_mat = (gpd->mat != NULL);
  
-   Material *ma = (use_mat) ? gpd->mat[gps->mat_nr] : BKE_material_gpencil_default_get();
+   Material *ma = (use_mat) ? gpd->mat[gps->mat_nr] : BKE_gpencil_material_default();
    MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL;
  
 -  /* Calculate triangles cache for filling area (must be done only after changes) */
 -  if ((gps->flag & GP_STROKE_RECALC_GEOMETRY) || (gps->tot_triangles == 0) ||
 -      (gps->triangles == NULL)) {
 -    gp_triangulate_stroke_fill(gps);
 -  }
 -  BLI_assert(gps->tot_triangles >= 1);
 -
    GPUVertFormat *format = immVertexFormat();
    uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
    uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@@ -762,12 -840,12 +762,12 @@@ static void gp_draw_strokes(tGPDdraw *t
        continue;
      }
      /* check if the color is visible */
-     Material *ma = (use_mat) ? tgpw->gpd->mat[gps->mat_nr] : BKE_material_gpencil_default_get();
+     Material *ma = (use_mat) ? tgpw->gpd->mat[gps->mat_nr] : BKE_gpencil_material_default();
      MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL;
  
 -    if ((gp_style == NULL) || (gp_style->flag & GP_STYLE_COLOR_HIDE) ||
 +    if ((gp_style == NULL) || (gp_style->flag & GP_MATERIAL_HIDE) ||
          /* if onion and ghost flag do not draw*/
 -        (tgpw->onion && (gp_style->flag & GP_STYLE_COLOR_ONIONSKIN))) {
 +        (tgpw->onion && (gp_style->flag & GP_MATERIAL_ONIONSKIN))) {
        continue;
      }
  
diff --cc source/blender/editors/gpencil/gpencil_data.c
index 6bc009bc683,a8e7c40c031..b708039018f
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@@ -1553,9 -1560,9 +1553,9 @@@ static int gp_stroke_lock_color_exec(bC
  
    /* first lock all colors */
    for (short i = 0; i < *totcol; i++) {
-     Material *tmp_ma = give_current_material(ob, i + 1);
+     Material *tmp_ma = BKE_object_material_get(ob, i + 1);
      if (tmp_ma) {
 -      tmp_ma->gp_style->flag |= GP_STYLE_COLOR_LOCKED;
 +      tmp_ma->gp_style->flag |= GP_MATERIAL_LOCKED;
        DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE);
      }
    }
@@@ -1572,9 -1579,9 +1572,9 @@@
              continue;
            }
            /* unlock color */
-           Material *tmp_ma = give_current_material(ob, gps->mat_nr + 1);
+           Material *tmp_ma = BKE_object_material_get(ob, gps->mat_nr + 1);
            if (tmp_ma) {
 -            tmp_ma->gp_style->flag &= ~GP_STYLE_COLOR_LOCKED;
 +            tmp_ma->gp_style->flag &= ~GP_MATERIAL_LOCKED;
              DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE);
            }
          }
@@@ -2615,10 -2592,10 +2615,10 @@@ int ED_gpencil_join_objects_exec(bConte
  
            Material *ma_src = NULL;
            for (bGPDframe *gpf = gpl_new->frames.first; gpf; gpf = gpf->next) {
 -            for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
 +            LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
  
                /* Reassign material. Look old material and try to find in destination. */
-               ma_src = BKE_material_gpencil_get(ob_src, gps->mat_nr + 1);
+               ma_src = BKE_gpencil_material(ob_src, gps->mat_nr + 1);
                gps->mat_nr = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma_src);
  
                bGPDspoint *pt;
@@@ -2727,11 -2704,11 +2727,11 @@@ static int gpencil_lock_layer_exec(bCon
    }
  
    for (short i = 0; i < *totcol; i++) {
-     ma = BKE_material_gpencil_get(ob, i + 1);
+     ma = BKE_gpencil_material(ob, i + 1);
      if (ma) {
        gp_style = ma->gp_style;
 -      gp_style->flag |= GP_STYLE_COLOR_LOCKED;
 -      gp_style->flag |= GP_STYLE_COLOR_HIDE;
 +      gp_style->flag |= GP_MATERIAL_LOCKED;
 +      gp_style->flag |= GP_MATERIAL_HIDE;
        DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
      }
    }
@@@ -2790,11 -2767,11 +2790,11 @@@ static int gpencil_color_isolate_exec(b
  {
    bGPdata *gpd = ED_gpencil_data_get_active(C);
    Object *ob = CTX_data_active_object(C);
-   Material *active_ma = BKE_material_gpencil_get(ob, ob->actcol);
-   MaterialGPencilStyle *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol);
+   Material *active_ma = BKE_gpencil_material(ob, ob->actcol);
+   MaterialGPencilStyle *active_color = BKE_gpencil_material_settings(ob, ob->actcol);
    MaterialGPencilStyle *gp_style;
  
 -  int flags = GP_STYLE_COLOR_LOCKED;
 +  int flags = GP_MATERIAL_LOCKED;
    bool isolate = false;
  
    if (RNA_boolean_get(op->ptr, "affect_visibility")) {
@@@ -2975,10 -2952,10 +2975,10 @@@ static int gpencil_color_reveal_exec(bC
    MaterialGPencilStyle *gp_style = NULL;
  
    for (short i = 0; i < *totcol; i++) {
-     ma = BKE_material_gpencil_get(ob, i + 1);
+     ma = BKE_gpencil_material(ob, i + 1);
      if (ma) {
        gp_style = ma->gp_style;
 -      gp_style->flag &= ~GP_STYLE_COLOR_HIDE;
 +      gp_style->flag &= ~GP_MATERIAL_HIDE;
        DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
      }
    }
@@@ -3028,10 -3005,10 +3028,10 @@@ static int gpencil_color_lock_all_exec(
    MaterialGPencilStyle *gp_style = NULL;
  
    for (short i = 0; i < *totcol; i++) {
-     ma = BKE_material_gpencil_get(ob, i + 1);
+     ma = BKE_gpencil_material(ob, i + 1);
      if (ma) {
        gp_style = ma->gp_style;
 -      gp_style->flag |= GP_STYLE_COLOR_LOCKED;
 +      gp_style->flag |= GP_MATERIAL_LOCKED;
        DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
      }
    }
@@@ -3081,10 -3058,10 +3081,10 @@@ static int gpencil_color_unlock_all_exe
    MaterialGPencilStyle *gp_style = NULL;
  
    for (short i = 0; i < *totcol; i++) {
-     ma = BKE_material_gpencil_get(ob, i + 1);
+     ma = BKE_gpencil_material(ob, i + 1);
      if (ma) {
        gp_style = ma->gp_style;
 -      gp_style->flag &= ~GP_STYLE_COLOR_LOCKED;
 +      gp_style->f

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list