Commit: b5a116dad49dfd2789eadbe54cf21e1eb98f9395
Author: Antonio Vazquez
Date:   Thu Aug 10 17:37:26 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb5a116dad49dfd2789eadbe54cf21e1eb98f9395

Merge branch 'blender2.8' into greasepencil-object

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



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

diff --cc source/blender/blenkernel/BKE_gpencil.h
index 5f00e326404,b6de922c245..78c4486a998
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@@ -79,11 -57,10 +79,12 @@@ struct bGPDframe *BKE_gpencil_frame_add
  struct bGPDframe *BKE_gpencil_frame_addcopy(struct bGPDlayer *gpl, int 
cframe);
  struct bGPDlayer *BKE_gpencil_layer_addnew(struct bGPdata *gpd, const char 
*name, bool setactive);
  struct bGPdata   *BKE_gpencil_data_addnew(const char name[]);
 +void BKE_gpencil_create_monkey(struct bContext *C, struct bGPdata *gpd);
  
  struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe 
*gpf_src);
 +struct bGPDframe *BKE_gpencil_frame_color_duplicate(const struct bGPDframe 
*gpf_src);
  struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer 
*gpl_src);
+ void BKE_gpencil_copy_data(struct Main *bmain, struct bGPdata *gpd_dst, const 
struct bGPdata *gpd_src, const int flag);
  struct bGPdata   *BKE_gpencil_data_duplicate(struct Main *bmain, const struct 
bGPdata *gpd, bool internal_copy);
  
  void BKE_gpencil_make_local(struct Main *bmain, struct bGPdata *gpd, const 
bool lib_local);
diff --cc source/blender/blenkernel/BKE_paint.h
index 8430a4c3625,e73e3800af0..db2f513d6cc
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@@ -101,24 -101,14 +101,26 @@@ void BKE_paint_set_overlay_override(enu
  /* palettes */
  void                 BKE_palette_free(struct Palette *palette);
  struct Palette      *BKE_palette_add(struct Main *bmain, const char *name);
 +struct Palette      *BKE_palette_add_gpencil(const struct bContext *C);
+ void BKE_palette_copy_data(
+         struct Main *bmain, struct Palette *palette_dst, const struct Palette 
*palette_src, const int flag);
  struct Palette      *BKE_palette_copy(struct Main *bmain, const struct 
Palette *palette);
  void                 BKE_palette_make_local(struct Main *bmain, struct 
Palette *palette, const bool lib_local);
 -struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
  bool                 BKE_palette_is_empty(const struct Palette *palette);
 -void                 BKE_palette_color_remove(struct Palette *palette, struct 
PaletteColor *color);
  void                 BKE_palette_clear(struct Palette *palette);
 +struct Palette      *BKE_palette_get_active_from_context(const struct 
bContext *C);
 +void                 BKE_palette_set_active_byname(const struct bContext *C, 
char *palname);
 +
 +struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
 +struct PaletteColor *BKE_palette_color_add_name(struct Palette *palette, 
const char *name);
 +struct PaletteColor *BKE_palette_color_getbyname(struct Palette *palette, 
char *name);
 +struct PaletteColor *BKE_gpencil_palettecolor_getbyrgb(struct Palette 
*palette, float rgb[3]);
 +struct PaletteColor *BKE_gpencil_palettecolor_getbyrgba(struct Palette 
*palette, float rgba[4]);
 +void                 BKE_palette_color_remove(struct Palette *palette, struct 
PaletteColor *color);
 +struct PaletteColor *BKE_palette_color_get_active(struct Palette *palette);
 +struct PaletteColor *BKE_palette_color_get_active_from_context(const struct 
bContext *C);
 +void                 BKE_palette_color_add_default_set(struct Palette 
*palette);
 +struct PaletteColor *BKE_palette_color_copy(struct Palette *palette, struct 
PaletteColor *palcolor);
  
  /* paint curves */
  struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
diff --cc source/blender/blenkernel/intern/gpencil.c
index 95629cc9363,ee0d0b41898..0b8210cd3ea
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@@ -937,39 -753,62 +937,62 @@@ bGPDlayer *BKE_gpencil_layer_duplicate(
        return gpl_dst;
  }
  
- /* make a copy of a given gpencil datablock */
- bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool 
internal_copy)
+ /**
+  * Only copy internal data of GreasePencil ID from source to already 
allocated/initialized destination.
+  * You probably nerver want to use that directly, use id_copy or 
BKE_id_copy_ex for typical needs.
+  *
+  * WARNING! This function will not handle ID user count!
+  *
+  * \param flag  Copying options (see BKE_library.h's LIB_ID_COPY_... flags 
for more).
+  */
+ void BKE_gpencil_copy_data(Main *UNUSED(bmain), bGPdata *gpd_dst, const 
bGPdata *gpd_src, const int UNUSED(flag))
  {
-       const bGPDlayer *gpl_src;
-       bGPDlayer *gpl_dst;
-       bGPdata *gpd_dst;
+       /* copy layers */
+       BLI_listbase_clear(&gpd_dst->layers);
+       for (const bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src 
= gpl_src->next) {
+               /* make a copy of source layer and its data */
+               bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);  /* 
TODO here too could add unused flags... */
+               BLI_addtail(&gpd_dst->layers, gpl_dst);
+       }
  
-       /* error checking */
-       if (gpd_src == NULL) {
-               return NULL;
+       /* copy palettes */
+       BLI_listbase_clear(&gpd_dst->palettes);
+       for (const bGPDpalette *palette_src = gpd_src->palettes.first; 
palette_src; palette_src = palette_src->next) {
+               bGPDpalette *palette_dst = 
BKE_gpencil_palette_duplicate(palette_src);  /* TODO here too could add unused 
flags... */
+               BLI_addtail(&gpd_dst->palettes, palette_dst);
        }
-       
-       /* make a copy of the base-data */
+ }
+ 
+ /* make a copy of a given gpencil datablock */
+ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool 
internal_copy)
+ {
+       /* Yuck and super-uber-hyper yuck!!!
+        * Should be replaceable with a no-main copy (LIB_ID_COPY_NO_MAIN 
etc.), but not sure about it,
+        * so for now keep old code for that one. */
        if (internal_copy) {
+               const bGPDlayer *gpl_src;
+               bGPDlayer *gpl_dst;
+               bGPdata *gpd_dst;
+ 
                /* make a straight copy for undo buffers used during stroke 
drawing */
                gpd_dst = MEM_dupallocN(gpd_src);
 -
 -              /* copy layers */
 -              BLI_listbase_clear(&gpd_dst->layers);
 -              for (gpl_src = gpd_src->layers.first; gpl_src; gpl_src = 
gpl_src->next) {
 -                      /* make a copy of source layer and its data */
 -                      gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
 -                      BLI_addtail(&gpd_dst->layers, gpl_dst);
 -              }
 -
 -              /* return new */
 -              return gpd_dst;
        }
        else {
 -              bGPdata *gpd_copy;
 -              BKE_id_copy_ex(bmain, &gpd_src->id, (ID **)&gpd_copy, 0, false);
 -              return gpd_copy;
 +              /* make a copy when others use this */
 +              gpd_dst = BKE_libblock_copy(bmain, &gpd_src->id);
 +              gpd_dst->batch_cache_data = NULL;
        }
 +      
 +      /* copy layers */
 +      BLI_listbase_clear(&gpd_dst->layers);
 +      for (gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) 
{
 +              /* make a copy of source layer and its data */
 +              gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
 +              BLI_addtail(&gpd_dst->layers, gpl_dst);
 +      }
 +      
 +      /* return new */
 +      return gpd_dst;
  }
  
  void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const bool lib_local)
diff --cc source/blender/blenkernel/intern/object.c
index 9873cd1f2f2,e250459ba2c..a59cf894fe2
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@@ -1149,96 -1139,92 +1151,95 @@@ void BKE_object_transform_copy(Object *
        copy_v3_v3(ob_tar->size, ob_src->size);
  }
  
- Object *BKE_object_copy_ex(Main *bmain, const Object *ob, bool copy_caches)
+ /**
+  * Only copy internal data of Object ID from source to already 
allocated/initialized destination.
+  * You probably nerver want to use that directly, use id_copy or 
BKE_id_copy_ex for typical needs.
+  *
+  * WARNING! This function will not handle ID user count!
+  *
+  * \param flag  Copying options (see BKE_library.h's LIB_ID_COPY_... flags 
for more).
+  */
+ void BKE_object_copy_data(Main *UNUSED(bmain), Object *ob_dst, const Object 
*ob_src, const int flag)
  {
-       Object *obn;
        ModifierData *md;
-       int a;
  
-       obn = BKE_libblock_copy(bmain, &ob->id);
-       
-       if (ob->totcol) {
-               obn->mat = MEM_dupallocN(ob->mat);
-               obn->matbits = MEM_dupallocN(ob->matbits);
-               obn->totcol = ob->totcol;
+       /* We never handle usercount here for own data. */
+       const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
+ 
+       if (ob_src->totcol) {
+               ob_dst->mat = MEM_dupallocN(ob_src->mat);
+               ob_dst->matbits = MEM_dupallocN(ob_src->matbits);
+               ob_dst->totcol = ob_src->totcol;
        }
  
-       if (ob->iuser) obn->iuser = MEM_dupallocN(ob->iuser);
+       if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
        
-       if (ob->bb) obn->bb = MEM_dupallocN(ob->bb);
-       obn->flag &= ~OB_FROMGROUP;
+       if (ob_src->bb) ob_dst->bb = MEM_dupallocN(ob_src->bb);
+       ob_dst->flag &= ~OB_FROMGROUP;
        
-       BLI_listbase_clear(&obn->modifiers);
+       BLI_listbase_clear(&ob_dst->modifiers);
        
-       for (md = ob->modifiers.first; md; md = md->next) {
+       for (md = ob_src->modifiers.first; md; md = md->next) {
                ModifierData *nmd = modifier_new(md->type);
                BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
-               modifier_copyData(md, nmd);
-               BLI_addtail(&obn->modifiers, nmd);
+               modifier_copyData_ex(md, nmd, flag_subdata);
+               BLI_addtail(&ob_dst->modifiers, nmd);
        }
  
-       BLI_listbase_clear(&obn->prop);
-       BKE_bproperty_copy_list(&obn->prop, &ob->prop);
+       BLI_listbase_clear(&ob_dst->prop);
+       BKE_bproperty_copy_list(&ob_dst->prop, &ob_src->prop);
  
-       BKE_sca_logic_copy(obn, ob);
+       BKE_sca_logic_copy(ob_dst, ob_src, flag_subdata);
  
-       if (ob->pose) {
-               copy_object_pose(obn, ob);
+       if (ob_src->pose) {
+               copy_object_pose(ob_dst, ob_src, flag_subdata);
                /* backwards compat... non-armatures can get poses in older 
files? */
-               if (ob->type == OB_ARMATURE)
-                       BKE_pose_rebuild(obn, obn->data);
+               if (ob_src->type == OB_ARMATURE)
+                       BKE_pose_rebuild(ob_dst, ob_dst->data);
        }
-       defgroup_copy_list(&obn->defbase, &ob->defbase);
-       BKE_object_facemap_copy_list(&obn->fmaps, &ob->fmaps);
-       BKE_constraints_copy(&obn->constraints, &ob->constraints, true);
+       defgroup_copy_list(&ob_dst->defbase, &ob_src->defbase);
+       BKE_object_facemap_copy_list(&ob_dst->fmaps, &ob_src->fmaps);
+       BKE_constraints_copy_ex(&ob_dst->constraints, &ob_src->constraints, 
flag_subdata, true);
  
-       obn->mode = OB_MODE_OBJECT;
-       obn->sculpt = NULL;
+       ob_dst->mode = OB_MODE_OBJECT

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to