[Bf-blender-cvs] [2b09062defa] blender2.8: COW Fix: The "layers used" display for armatures did not update after bones were moved between layers

Joshua Leung noreply at git.blender.org
Mon May 14 15:43:08 CEST 2018


Commit: 2b09062defa093a243b5fe64b099accb07b440a3
Author: Joshua Leung
Date:   Mon May 14 15:42:49 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2b09062defa093a243b5fe64b099accb07b440a3

COW Fix: The "layers used" display for armatures did not update after bones were moved between layers

Previously, the "layers_used" value was getting updated by the drawing code.
However, when using copy on write, the drawing code gets evaluated copies of
the armature data instead of the original data, so any updates here fail to
get flushed to the original data, hence the lack of updates in the UI.

Fixed by moving the calculation to RNA when setting bone layers, as it should
have been done originally. (The one downside to this is if we set individual
layer memberships one by one - this could be slower as the recalc would have to
happen each time this changes).

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

M	source/blender/draw/intern/draw_armature.c
M	source/blender/makesrna/intern/rna_armature.c

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

diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 5ad05da5cbf..d07febfdd22 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -1577,11 +1577,8 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
 	const bool show_relations = true; /* TODO get value from overlays settings. */
 
 	/* being set below */
-	arm->layer_used = 0;
-
 	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
 		bone = pchan->bone;
-		arm->layer_used |= bone->layer;
 
 		/* bone must be visible */
 		if ((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) {
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 48ce2f03db0..0819a5e828e 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -240,6 +240,18 @@ static IDProperty *rna_EditBone_idprops(PointerRNA *ptr, bool create)
 	return ebone->prop;
 }
 
+/* Update the layers_used variable after bones are moved between layer
+ * NOTE: Used to be done in drawing code in 2.7, but that won't work with
+ *       Copy-on-Write, as drawing uses evaluated copies.
+ */
+static void rna_Armature_layer_used_refresh(bArmature *arm, ListBase *bones)
+{
+	for (Bone *bone = bones->first; bone; bone = bone->next) {
+		arm->layer_used |= bone->layer;
+		rna_Armature_layer_used_refresh(arm, &bone->childbase);
+	}
+}
+
 static void rna_bone_layer_set(int *layer, const int *values)
 {
 	int i, tot = 0;
@@ -260,8 +272,13 @@ static void rna_bone_layer_set(int *layer, const int *values)
 
 static void rna_Bone_layer_set(PointerRNA *ptr, const int *values)
 {
+	bArmature *arm = (bArmature *)ptr->id.data;
 	Bone *bone = (Bone *)ptr->data;
+	
 	rna_bone_layer_set(&bone->layer, values);
+	
+	arm->layer_used = 0;
+	rna_Armature_layer_used_refresh(arm, &arm->bonebase);
 }
 
 static void rna_Armature_layer_set(PointerRNA *ptr, const int *values)



More information about the Bf-blender-cvs mailing list