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).
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user