Commit: 731e848cffd9c1be2e0d0749999c1fcd6e8da9e5
Author: Bastien Montagne
Date:   Tue Nov 7 10:59:40 2017 +0100
Branches: id_override_static
https://developer.blender.org/rB731e848cffd9c1be2e0d0749999c1fcd6e8da9e5

Merge blender2.8 branch.

Means that from now on, we work based on blender2.8, no more master!

Conflicts:
        source/blender/blenloader/intern/readfile.c
        source/blender/blenloader/intern/writefile.c
        source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
        source/blender/editors/interface/interface_ops.c
        source/blender/makesdna/DNA_ID.h
        source/blender/makesrna/intern/rna_ID.c

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



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

diff --cc source/blender/blenkernel/intern/library.c
index 46d5a725959,ce168898d00..8585dfea316
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@@ -689,6 -677,69 +690,71 @@@ bool id_copy(Main *bmain, const ID *id
        return BKE_id_copy_ex(bmain, id, newid, 0, test);
  }
  
+ /** Does a mere memory swap over the whole IDs data (including type-specific 
memory).
+  *  \note Most internal ID data itself is not swapped (only IDProperties 
are). */
+ void BKE_id_swap(ID *id_a, ID *id_b)
+ {
+       BLI_assert(GS(id_a->name) == GS(id_b->name));
+ 
+       const ID id_a_back = *id_a;
+       const ID id_b_back = *id_b;
+ 
+ #define CASE_SWAP(_gs, _type) \
+       case _gs: \
+               SWAP(_type, *(_type *)id_a, *(_type *)id_b); \
+               break
+ 
+       switch ((ID_Type)GS(id_a->name)) {
+               CASE_SWAP(ID_SCE, Scene);
+               CASE_SWAP(ID_LI, Library);
+               CASE_SWAP(ID_OB, Object);
+               CASE_SWAP(ID_ME, Mesh);
+               CASE_SWAP(ID_CU, Curve);
+               CASE_SWAP(ID_MB, MetaBall);
+               CASE_SWAP(ID_MA, Material);
+               CASE_SWAP(ID_TE, Tex);
+               CASE_SWAP(ID_IM, Image);
+               CASE_SWAP(ID_LT, Lattice);
+               CASE_SWAP(ID_LA, Lamp);
++              CASE_SWAP(ID_LP, LightProbe);
+               CASE_SWAP(ID_CA, Camera);
+               CASE_SWAP(ID_KE, Key);
+               CASE_SWAP(ID_WO, World);
+               CASE_SWAP(ID_SCR, bScreen);
+               CASE_SWAP(ID_VF, VFont);
+               CASE_SWAP(ID_TXT, Text);
+               CASE_SWAP(ID_SPK, Speaker);
+               CASE_SWAP(ID_SO, bSound);
+               CASE_SWAP(ID_GR, Group);
+               CASE_SWAP(ID_AR, bArmature);
+               CASE_SWAP(ID_AC, bAction);
+               CASE_SWAP(ID_NT, bNodeTree);
+               CASE_SWAP(ID_BR, Brush);
+               CASE_SWAP(ID_PA, ParticleSettings);
+               CASE_SWAP(ID_WM, wmWindowManager);
++              CASE_SWAP(ID_WS, WorkSpace);
+               CASE_SWAP(ID_GD, bGPdata);
+               CASE_SWAP(ID_MC, MovieClip);
+               CASE_SWAP(ID_MSK, Mask);
+               CASE_SWAP(ID_LS, FreestyleLineStyle);
+               CASE_SWAP(ID_PAL, Palette);
+               CASE_SWAP(ID_PC, PaintCurve);
+               CASE_SWAP(ID_CF, CacheFile);
+               case ID_IP:
+                       break;  /* Deprecated. */
+       }
+ 
+ #undef CASE_SWAP
+ 
+       /* Restore original ID's internal data. */
+       *id_a = id_a_back;
+       *id_b = id_b_back;
+ 
+       /* Exception: IDProperties. */
+       id_a->properties = id_b_back.properties;
+       id_b->properties = id_a_back.properties;
+ }
+ 
  /** Does *not* set ID->newid pointer. */
  bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
  {
diff --cc source/blender/blenkernel/intern/library_override.c
index 00000000000,c6ad7deaf63..64ba06342cb
mode 000000,100644..100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@@ -1,0 -1,657 +1,657 @@@
+ /*
+  * ***** BEGIN GPL LICENSE BLOCK *****
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * as published by the Free Software Foundation; either version 2
+  * of the License, or (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software Foundation,
+  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  *
+  * The Original Code is Copyright (C) 2016 by Blender Foundation.
+  * All rights reserved.
+  *
+  * Contributor(s): Bastien Montagne.
+  *
+  * ***** END GPL LICENSE BLOCK *****
+  */
+ 
+ /** \file blender/blenkernel/intern/library_override.c
+  *  \ingroup bke
+  */
+ 
+ #include <stdlib.h>
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ #include "DNA_ID.h"
+ #include "DNA_object_types.h"
+ 
 -#include "BKE_depsgraph.h"
++#include "DEG_depsgraph.h"
+ #include "BKE_library.h"
+ #include "BKE_library_override.h"
+ #include "BKE_library_remap.h"
+ #include "BKE_main.h"
+ 
+ #include "BLI_utildefines.h"
+ #include "BLI_listbase.h"
+ #include "BLI_string.h"
+ 
+ #include "RNA_access.h"
+ #include "RNA_types.h"
+ 
+ #include "PIL_time.h"
+ #include "PIL_time_utildefines.h"
+ 
+ #define OVERRIDE_AUTO_CHECK_DELAY 0.2  /* 200ms between auto-override checks. 
*/
+ 
+ static void bke_override_property_copy(IDOverrideProperty *op_dst, 
IDOverrideProperty *op_src);
+ static void bke_override_property_operation_copy(IDOverridePropertyOperation 
*opop_dst, IDOverridePropertyOperation *opop_src);
+ 
+ static void bke_override_property_clear(IDOverrideProperty *op);
+ static void bke_override_property_operation_clear(IDOverridePropertyOperation 
*opop);
+ 
+ /** Initialize empty overriding of \a reference_id by \a local_id. */
+ IDOverride *BKE_override_init(ID *local_id, ID *reference_id)
+ {
+       /* If reference_id is NULL, we are creating an override template for 
purely local data.
+        * Else, reference *must* be linked data. */
+       BLI_assert(reference_id == NULL || reference_id->lib != NULL);
+       BLI_assert(local_id->override == NULL);
+ 
+       if (reference_id != NULL && reference_id->override != NULL && 
reference_id->override->reference == NULL) {
+               /* reference ID has an override template, use it! */
+               BKE_override_copy(local_id, reference_id);
+               return local_id->override;
+       }
+ 
+       /* Else, generate new empty override. */
+       local_id->override = MEM_callocN(sizeof(*local_id->override), __func__);
+       local_id->override->reference = reference_id;
+       id_us_plus(reference_id);
+       local_id->tag &= ~LIB_TAG_OVERRIDE_OK;
+       /* TODO do we want to add tag or flag to referee to mark it as such? */
+       return local_id->override;
+ }
+ 
+ /** Deep copy of a whole override from \a src_id to \a dst_id. */
+ void BKE_override_copy(ID *dst_id, const ID *src_id)
+ {
+       BLI_assert(src_id->override != NULL);
+ 
+       if (dst_id->override != NULL) {
+               if (src_id->override == NULL) {
+                       BKE_override_free(&dst_id->override);
+                       return;
+               }
+               else {
+                       BKE_override_clear(dst_id->override);
+               }
+       }
+       else if (src_id->override == NULL) {
+               return;
+       }
+       else {
+               BKE_override_init(dst_id, NULL);
+       }
+ 
+       /* Source is already overriding data, we copy it but reuse it's 
reference for dest ID.
+        * otherwise, source is only an override template, it then becomes 
reference of dest ID. */
+       dst_id->override->reference = src_id->override->reference ? 
src_id->override->reference : (ID *)src_id;
+       id_us_plus(dst_id->override->reference);
+ 
+       BLI_duplicatelist(&dst_id->override->properties, 
&src_id->override->properties);
+       for (IDOverrideProperty *op_dst = dst_id->override->properties.first, 
*op_src = src_id->override->properties.first;
+            op_dst;
+            op_dst = op_dst->next, op_src = op_src->next)
+       {
+               bke_override_property_copy(op_dst, op_src);
+       }
+ 
+       dst_id->tag &= ~LIB_TAG_OVERRIDE_OK;
+ }
+ 
+ /** Clear any overriding data from given \a override. */
+ void BKE_override_clear(IDOverride *override)
+ {
+       BLI_assert(override != NULL);
+ 
+       for (IDOverrideProperty *op = override->properties.first; op; op = 
op->next) {
+               bke_override_property_clear(op);
+       }
+       BLI_freelistN(&override->properties);
+ 
+       id_us_min(override->reference);
+       /* override->storage should never be refcounted... */
+ }
+ 
+ /** Free given \a override. */
+ void BKE_override_free(struct IDOverride **override)
+ {
+       BLI_assert(*override != NULL);
+ 
+       BKE_override_clear(*override);
+       MEM_freeN(*override);
+       *override = NULL;
+ }
+ 
+ /** Create an overriden local copy of linked reference. */
+ ID *BKE_override_create_from(Main *bmain, ID *reference_id)
+ {
+       BLI_assert(reference_id != NULL);
+       BLI_assert(reference_id->lib != NULL);
+ 
+       ID *local_id;
+ 
+       if (!id_copy(bmain, reference_id, (ID **)&local_id, false)) {
+               return NULL;
+       }
+       id_us_min(local_id);
+ 
+       BKE_override_init(local_id, reference_id);
+       local_id->flag |= LIB_AUTOOVERRIDE;
+ 
+       /* Remapping, we obviously only want to affect local data (and not our 
own reference pointer to overriden ID). */
+       BKE_libblock_remap(bmain, reference_id, local_id, 
ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_STATIC_OVERRIDE);
+ 
+       return local_id;
+ }
+ 
+ /**
+  * Find override property from given RNA path, if it exists.
+  */
+ IDOverrideProperty *BKE_override_property_find(IDOverride *override, const 
char *rna_path)
+ {
+       /* XXX TODO we'll most likely want a runtime ghash to store taht 
mapping at some point. */
+       return BLI_findstring_ptr(&override->properties, rna_path, 
offsetof(IDOverrideProperty, rna_path));
+ }
+ 
+ /**
+  * Find override property from given RNA path, or create it if it does not 
exist.
+  */
+ IDOverrideProperty *BKE_override_property_get(IDOverride *override, const 
char *rna_path, bool *r_created)
+ {
+       /* XXX TODO we'll most likely want a runtime ghash to store taht 
mapping at some point. */
+       IDOverrideProperty *op = BKE_override_property_find(override, rna_path);
+ 
+       if (op == NULL) {
+               op = MEM_callocN(sizeof(IDOverrideProperty), __func__);
+               op->rna_path = BLI_strdup(rna_path);
+               BLI_addtail(&override->properties, op);
+ 
+               if (r_created) {
+                       *r_created = true;
+               }
+       }
+       else if (r_created) {
+               *r_created = false;
+       }
+ 
+       return op;
+ }
+ 
+ void bke_override_property_copy(IDOverrideProperty *op_dst, 
IDOverrideProperty *op_src)
+ {
+       op_dst->rna_path = BLI_strdup(op_src->rna_path);
+       BLI_duplicatelist(&op_dst->operations, &op_src->operations);
+ 
+       for (IDOverridePropertyOperation *opop_dst = op_dst->operations.first, 
*opop_src = op_src->operations.first;
+            opop_dst;
+            opop_dst = opop_dst->next, opop_src = opop_src->next)
+       {
+               bke_override_property_operation_copy(opop_dst, opop_src);
+       }
+ }
+ 
+ void bke_override_property_clear(IDOverrideProperty *op)
+ {
+       BLI_assert(op->rna_path != NULL);
+ 
+       MEM_freeN(op->rna_path);
+ 
+       for (IDOverridePropertyOperation *opop = op->operations.first; opop; 
opop = opop->next) {
+               bke_override_property_operation_clear(opop);
+       }
+       BLI_freelistN(&op->operations);
+ }
+ 
+ /**
+  * Remove and free given \a override_property from given ID \a override.
+  */
+ void BKE_override_property_delete(IDOverride *override, IDOverrideProperty 
*override_property)
+ {
+ 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to