[Bf-blender-cvs] [9505209b1db] id_override_static: Fix various issues in RNA diff handling, and make some more props overridable.

Bastien Montagne noreply at git.blender.org
Wed May 31 18:01:59 CEST 2017


Commit: 9505209b1dbe98e7df5964856002bf2b26f7ede4
Author: Bastien Montagne
Date:   Wed May 31 17:55:08 2017 +0200
Branches: id_override_static
https://developer.blender.org/rB9505209b1dbe98e7df5964856002bf2b26f7ede4

Fix various issues in RNA diff handling, and make some more props overridable.

Namely, those allowing to link an object to an armature.

Thing is, we cannnot and absolutely do not want to use same trick as
armature proxies regarding deforming their related geometries.

So instead, we'll automatically make override of objects using
overridden armature as deformer, ultimately. This also allows for
several overrides of a same linked data.

Not sure how much good/bad this is, will have to ask artists once it's
ready for testing (cannot think of any non-ugly way to do that 'magic
trick' tbh).

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

M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_object.c

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

diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 30202a2f572..f91532b122f 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -6885,11 +6885,30 @@ static bool rna_property_override_equals_propptr(
         IDOverride *override, const char *rna_path, bool *r_override_changed,
         const bool ignore_non_overridable, const bool ignore_overridden)
 {
-	if (RNA_struct_is_ID(propptr_a->type)) {
+	bool is_id = false;
+	bool is_type_null = false;
+
+	/* Beware, PointerRNA_NULL has no type and is considered a 'blank page'! */
+	if (propptr_a->type == NULL) {
+		if (propptr_b->type == NULL) {
+			if (r_override_changed) {
+				*r_override_changed = false;
+			}
+			return true;
+		}
+		is_id = RNA_struct_is_ID(propptr_b->type);
+		is_type_null = true;
+	}
+	else {
+		is_id = RNA_struct_is_ID(propptr_a->type);
+		is_type_null = (propptr_b->type == NULL);
+	}
+
+	if (is_id) {
 		/* In case this is an ID, do not compare structs!
 		 * This is a quite safe path to infinite loop.
 		 * Instead, just compare ID pointers themselves (we assume sub-ID structs cannot loop). */
-		const bool equals = propptr_a->id.data != propptr_b->id.data;
+		const bool equals = (propptr_a->id.data == propptr_b->id.data);
 
 		if (!equals && rna_path) {
 			bool created = false;
@@ -6898,14 +6917,14 @@ static bool rna_property_override_equals_propptr(
 			if (op != NULL && created) {  /* If not yet overridden... */
 				BKE_override_property_operation_get(op, IDOVERRIDE_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL);
 				if (r_override_changed) {
-					*r_override_changed = *r_override_changed || created;
+					*r_override_changed = created;
 				}
 			}
 		}
 
 		return equals;
 	}
-	else if (override) {
+	else if (!is_type_null && override) {  /* We cannot override struct if one is NULL pointer... */
 		if (rna_path) {
 			const bool changed = RNA_struct_auto_override(propptr_a, propptr_b, override, rna_path);
 			if (r_override_changed) {
@@ -7269,7 +7288,7 @@ static bool rna_property_override_operation_apply(
 	PropertyRNA *storageprop = prop;
 
 	if (override_op == IDOVERRIDE_NOOP) {
-		return false;
+		return true;
 	}
 
 	if (ELEM(override_op, IDOVERRIDE_ADD, IDOVERRIDE_SUBTRACT, IDOVERRIDE_MULTIPLY) && !storage) {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 1a8dd05a7b5..0bc6ac769d5 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1801,7 +1801,7 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Object", "Armature object to deform with");
 	RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set", NULL, "rna_Armature_object_poll");
-	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_OVERRIDABLE);
 	RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
 	prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 0b2a8ccb118..1e478b1ffb8 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2264,7 +2264,7 @@ static void rna_def_object(BlenderRNA *brna)
 	/* parent */
 	prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL, NULL);
-	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+	RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_OVERRIDABLE);
 	RNA_def_property_ui_text(prop, "Parent", "Parent Object");
 	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
 	
@@ -2511,6 +2511,7 @@ static void rna_def_object(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_struct_type(prop, "Modifier");
 	RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object");
+	RNA_def_property_flag(prop, PROP_OVERRIDABLE);
 	rna_def_object_modifiers(brna, prop);
 
 	/* constraints */




More information about the Bf-blender-cvs mailing list