Anim: move creation of default bone collection to the Shift+A operator
Instead of adding the default "Bones" bone collection to every Armature data-block, only add it for Armatures that are added in the 3D View with Shift+A > Armature. This simplifies things like importers, which otherwise would have needed to remove that default collection before creating the imported ones. Additionally, this also ensures that the one bone you get by default is actually assigned to the default bone collection.
This commit is contained in:
parent
004a348efc
commit
f0c89afb76
@ -83,11 +83,6 @@ static void armature_init_data(ID *id)
|
||||
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(armature, id));
|
||||
|
||||
MEMCPY_STRUCT_AFTER(armature, DNA_struct_default_get(bArmature), id);
|
||||
|
||||
/* Give the Armature its default bone collection. */
|
||||
BoneCollection *default_bonecoll = ANIM_bonecoll_new("");
|
||||
BLI_addhead(&armature->collections, default_bonecoll);
|
||||
ANIM_armature_bonecoll_active_set(armature, default_bonecoll);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,6 +104,10 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool
|
||||
|
||||
bone->tail[view_aligned ? 1 : 2] = length;
|
||||
|
||||
if (arm->runtime.active_collection) {
|
||||
ANIM_armature_bonecoll_assign_editbone(arm->runtime.active_collection, bone);
|
||||
}
|
||||
|
||||
return bone;
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,8 @@
|
||||
#include "ED_transform.hh"
|
||||
#include "ED_view3d.hh"
|
||||
|
||||
#include "ANIM_bone_collections.h"
|
||||
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "object_intern.h"
|
||||
@ -1144,6 +1146,11 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* Give the Armature its default bone collection. */
|
||||
bArmature *armature = static_cast<bArmature *>(obedit->data);
|
||||
BoneCollection *default_bonecoll = ANIM_armature_bonecoll_new(armature, "");
|
||||
ANIM_armature_bonecoll_active_set(armature, default_bonecoll);
|
||||
|
||||
dia = RNA_float_get(op->ptr, "radius");
|
||||
ED_armature_ebone_add_primitive(obedit, dia, view_aligned);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user