[Bf-blender-cvs] [c6bda91482a] id_override_static: Add more BKE generic way to create an override, make Image mostly overridable, fix a bug in RNA.
Bastien Montagne
noreply at git.blender.org
Tue Jul 18 12:08:45 CEST 2017
Commit: c6bda91482ae06939d7aa08760396f87bc74a158
Author: Bastien Montagne
Date: Tue Jul 18 12:08:09 2017 +0200
Branches: id_override_static
https://developer.blender.org/rBc6bda91482ae06939d7aa08760396f87bc74a158
Add more BKE generic way to create an override, make Image mostly overridable, fix a bug in RNA.
===================================================================
M source/blender/blenkernel/BKE_library_override.h
M source/blender/blenkernel/intern/library_override.c
M source/blender/editors/object/object_relations.c
M source/blender/makesrna/intern/rna_ID.c
M source/blender/makesrna/intern/rna_image.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h
index 51de378b008..bbc1cd962e1 100644
--- a/source/blender/blenkernel/BKE_library_override.h
+++ b/source/blender/blenkernel/BKE_library_override.h
@@ -43,6 +43,8 @@ void BKE_override_copy(struct ID *dst_id, const struct ID *src_id);
void BKE_override_clear(struct IDOverride *override);
void BKE_override_free(struct IDOverride **override);
+struct ID *BKE_override_create_from(struct Main *bmain, struct ID *reference_id);
+
struct IDOverrideProperty *BKE_override_property_find(struct IDOverride *override, const char *rna_path);
struct IDOverrideProperty *BKE_override_property_get(struct IDOverride *override, const char *rna_path, bool *r_created);
void BKE_override_property_delete(struct IDOverride *override, struct IDOverrideProperty *override_property);
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 503ee198ad1..6585c388e21 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -142,6 +142,28 @@ void BKE_override_free(struct IDOverride **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);
+
+ /* Remapping *before* defining override (this will have to be fixed btw, remapping of ref pointer...). */
+ BKE_libblock_remap(bmain, reference_id, local_id, ID_REMAP_SKIP_INDIRECT_USAGE);
+
+ BKE_override_init(local_id, reference_id);
+ local_id->flag |= LIB_AUTOOVERRIDE;
+
+ return local_id;
+}
+
/**
* Find override property from given RNA path, if it exists.
*/
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index fdd91e86b35..ece60ab6cce 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2406,15 +2406,7 @@ static int make_override_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Object *locobj, *refobj = CTX_data_active_object(C);
- /* Note that we most likely want to do this in a more BKE generic function later, but for now will do for testing. */
-
- id_copy(bmain, &refobj->id, (ID **)&locobj, false);
-
- /* Remapping *before* defining override (this will have to be fixed btw, remapping of ref pointer...). */
- BKE_libblock_remap(bmain, refobj, locobj, ID_REMAP_SKIP_INDIRECT_USAGE);
-
- BKE_override_init(&locobj->id, &refobj->id);
- locobj->id.flag |= LIB_AUTOOVERRIDE;
+ locobj = (Object *)BKE_override_create_from(bmain, &refobj->id);
WM_event_add_notifier(C, NC_WINDOW, NULL);
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 7e545f9b215..14667594394 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -95,6 +95,7 @@ EnumPropertyItem rna_enum_id_type_items[] = {
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
+#include "BKE_library_override.h"
#include "BKE_library_remap.h"
#include "BKE_animsys.h"
#include "BKE_material.h"
@@ -177,7 +178,7 @@ short RNA_type_to_ID_code(StructRNA *type)
StructRNA *ID_code_to_RNA_type(short idcode)
{
- switch (idcode) {
+ switch ((ID_Type)(idcode)) {
case ID_AC: return &RNA_Action;
case ID_AR: return &RNA_Armature;
case ID_BR: return &RNA_Brush;
@@ -293,6 +294,15 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
return NULL;
}
+static ID *rna_ID_override_create(ID *id, Main *bmain)
+{
+ if (id->lib == NULL) {
+ return NULL;
+ }
+
+ return BKE_override_create_from(bmain, id);
+}
+
static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
{
/* XXX, new function for this! */
@@ -739,9 +749,9 @@ static PointerRNA rna_IDPreview_get(PointerRNA *ptr)
static PointerRNA rna_ID_override_reference_get(PointerRNA *ptr)
{
ID *id = (ID *)ptr->data;
- ID *reference = id->override ? id->override->reference : NULL;
+ ID *reference = (id && id->override) ? id->override->reference : NULL;
- return rna_pointer_inherit_refine(ptr, ID_code_to_RNA_type(GS(reference->name)), reference);
+ return reference ? rna_pointer_inherit_refine(ptr, ID_code_to_RNA_type(GS(reference->name)), reference) : PointerRNA_NULL;
}
#else
@@ -1023,6 +1033,12 @@ static void rna_def_ID(BlenderRNA *brna)
parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "override_create", "rna_ID_override_create");
+ RNA_def_function_ui_description(func, "Create an overridden local copy of this linked data-block (not supported for all data-blocks)");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
+ parm = RNA_def_pointer(func, "id", "ID", "", "New overridden local copy of the ID");
+ RNA_def_function_return(func, parm);
+
func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
RNA_def_function_ui_description(func, "Clear the user count of a data-block so its not saved, "
"on reload the data will be removed");
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index b6e84cf8ac3..05ccad543b3 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -661,6 +661,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_IMAGE_DATA);
prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "File Name", "Image/Movie file name");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
@@ -700,6 +701,7 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Packed Files", "Collection of packed images");
prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_field_order_items);
RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines are displayed first)");
@@ -707,6 +709,7 @@ static void rna_def_image(BlenderRNA *brna)
/* booleans */
prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS);
RNA_def_property_ui_text(prop, "Fields", "Use fields of the image");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update");
@@ -714,36 +717,43 @@ static void rna_def_image(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_view_as_render", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_VIEW_AS_RENDER);
RNA_def_property_ui_text(prop, "View as Render", "Apply render part of display transformation when displaying this image on the screen");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMA_IGNORE_ALPHA);
RNA_def_property_ui_text(prop, "Use Alpha", "Use the alpha channel information from the image or make image fully opaque");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_colormanage_update");
prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DEINTERLACE);
RNA_def_property_ui_text(prop, "Deinterlace", "Deinterlace movie file on load");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_reload_update");
prop = RNA_def_property(srna, "use_multiview", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_USE_VIEWS);
RNA_def_property_ui_text(prop, "Use Multi-View", "Use Multiple Views (when available)");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_views_format_update");
prop = RNA_def_property(srna, "is_stereo_3d", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_funcs(prop, "rna_Image_is_stereo_3d_get", NULL);
RNA_def_property_ui_text(prop, "Stereo 3D", "Image has left and right views");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_multiview", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_funcs(prop, "rna_Image_is_multiview_get", NULL);
RNA_def_property_ui_text(prop, "Multiple Views", "Image has more than one view");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Dirty", "Image has changed and is not saved");
@@ -787,12 +797,14 @@ static void rna_def_image(BlenderRNA *brna)
/* realtime properties */
prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_OVERRIDABLE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_mapping_items);
RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_f
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list