diff options
-rw-r--r-- | source/blender/blenkernel/BKE_armature.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 37 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 5 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 21 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_armature_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 27 |
8 files changed, 69 insertions, 33 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 8f109034e3e..19c2662054b 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -72,8 +72,7 @@ extern "C" { struct bArmature *add_armature(char *name); struct bArmature *get_armature(struct Object *ob); -void free_boneChildren(struct Bone *bone); -void free_bones (struct bArmature *arm); +void free_bonelist (struct ListBase *lb); void free_armature(struct bArmature *arm); void make_local_armature(struct bArmature *arm); struct bArmature *copy_armature(struct bArmature *arm); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 504450e0334..139ff9d6b19 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -60,6 +60,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" +#include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_lattice.h" #include "BKE_main.h" @@ -93,43 +94,25 @@ bArmature *get_armature(Object *ob) return NULL; } -void free_boneChildren(Bone *bone) -{ - Bone *child; - - if (bone) { - - child=bone->childbase.first; - if (child){ - while (child){ - free_boneChildren (child); - child=child->next; - } - BLI_freelistN (&bone->childbase); - } - } -} - -void free_bones (bArmature *arm) +void free_bonelist (ListBase *lb) { Bone *bone; - /* Free children (if any) */ - bone= arm->bonebase.first; - if (bone) { - while (bone){ - free_boneChildren (bone); - bone=bone->next; + + for(bone=lb->first; bone; bone=bone->next) { + if(bone->prop) { + IDP_FreeProperty(bone->prop); + MEM_freeN(bone->prop); } + free_bonelist(&bone->childbase); } - - BLI_freelistN(&arm->bonebase); + BLI_freelistN(lb); } void free_armature(bArmature *arm) { if (arm) { - free_bones(arm); + free_bonelist(&arm->bonebase); /* free editmode data */ if (arm->edbo) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6ced440f5a5..5d6338af409 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2345,12 +2345,14 @@ static void direct_link_bones(FileData *fd, Bone* bone) Bone *child; bone->parent= newdataadr(fd, bone->parent); + bone->prop= newdataadr(fd, bone->prop); + if(bone->prop) + IDP_DirectLinkProperty(bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); link_list(fd, &bone->childbase); - for (child=bone->childbase.first; child; child=child->next) { + for(child=bone->childbase.first; child; child=child->next) direct_link_bones(fd, child); - } } static void direct_link_armature(FileData *fd, bArmature *arm) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 7368663f64a..ee84ae59974 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2131,6 +2131,11 @@ static void write_bone(WriteData *wd, Bone* bone) // Write this bone writestruct(wd, DATA, "Bone", 1, bone); + + /* Write ID Properties -- and copy this comment EXACTLY for easy finding + of library blocks that implement this.*/ + if (bone->prop) + IDP_WriteProperty(bone->prop, wd); // Write Children cbone= bone->childbase.first; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 266e4fbdbb4..1e94e1b440c 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -64,6 +64,7 @@ #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_idprop.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -186,6 +187,9 @@ void make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent) eBone->rad_tail= curBone->rad_tail; eBone->segments = curBone->segments; eBone->layer = curBone->layer; + + if(curBone->prop) + eBone->prop= IDP_CopyProperty(curBone->prop); BLI_addtail(edbo, eBone); @@ -251,7 +255,7 @@ void ED_armature_from_edit(Object *obedit) Object *obt; /* armature bones */ - free_bones(arm); + free_bonelist(&arm->bonebase); /* remove zero sized bones, this gives instable restposes */ for (eBone=arm->edbo->first; eBone; eBone= neBone) { @@ -294,6 +298,9 @@ void ED_armature_from_edit(Object *obedit) newBone->rad_tail= eBone->rad_tail; newBone->segments= eBone->segments; newBone->layer = eBone->layer; + + if(eBone->prop) + newBone->prop= IDP_CopyProperty(eBone->prop); } /* Fix parenting in a separate pass to ensure ebone->bone connections @@ -1902,11 +1909,21 @@ void mouse_armature(bContext *C, short mval[2], int extend) void ED_armature_edit_free(struct Object *ob) { bArmature *arm= ob->data; + EditBone *eBone; /* Clear the editbones list */ if (arm->edbo) { - if (arm->edbo->first) + if (arm->edbo->first) { + for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + if (eBone->prop) { + IDP_FreeProperty(eBone->prop); + MEM_freeN(eBone->prop); + } + } + BLI_freelistN(arm->edbo); + } + MEM_freeN(arm->edbo); arm->edbo= NULL; } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 0204acd6fbe..4898f70201e 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -41,10 +41,12 @@ struct View3D; struct ViewContext; struct RegionView3D; struct SK_Sketch; +struct IDProperty; typedef struct EditBone { struct EditBone *next, *prev; + struct IDProperty *prop; /* User-Defined Properties on this Bone */ struct EditBone *parent;/* Editbones have a one-way link (i.e. children refer to parents. This is converted to a two-way link for normal bones when leaving editmode. */ diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 590e7dadcdc..0f80fb4821f 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -44,6 +44,7 @@ struct AnimData; typedef struct Bone { struct Bone *next, *prev; /* Next/prev elements within this list */ + IDProperty *prop; /* User-Defined Properties on this Bone */ struct Bone *parent; /* Parent (ik parent if appropriate flag is set */ ListBase childbase; /* Children */ char name[32]; /* Name of the bone - must be unique within the armature */ diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 6c9d9263eeb..889f23e0d39 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -42,6 +42,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_idprop.h" #include "BKE_main.h" #include "ED_armature.h" @@ -67,6 +68,30 @@ static char *rna_Bone_path(PointerRNA *ptr) return BLI_sprintfN("bones[\"%s\"]", ((Bone*)ptr->data)->name); } +static IDProperty *rna_Bone_idproperties(PointerRNA *ptr, int create) +{ + Bone *bone= ptr->data; + + if(create && !bone->prop) { + IDPropertyTemplate val = {0}; + bone->prop= IDP_New(IDP_GROUP, val, "RNA_Bone ID properties"); + } + + return bone->prop; +} + +static IDProperty *rna_EditBone_idproperties(PointerRNA *ptr, int create) +{ + EditBone *ebone= ptr->data; + + if(create && !ebone->prop) { + IDPropertyTemplate val = {0}; + ebone->prop= IDP_New(IDP_GROUP, val, "RNA_EditBone ID properties"); + } + + return ebone->prop; +} + static void rna_bone_layer_set(short *layer, const int *values) { int i, tot= 0; @@ -442,6 +467,7 @@ static void rna_def_bone(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock."); RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); RNA_def_struct_path_func(srna, "rna_Bone_path"); + RNA_def_struct_idproperties_func(srna, "rna_Bone_idproperties"); /* pointers/collections */ /* parent (pointer) */ @@ -509,6 +535,7 @@ static void rna_def_edit_bone(BlenderRNA *brna) srna= RNA_def_struct(brna, "EditBone", NULL); RNA_def_struct_sdna(srna, "EditBone"); + RNA_def_struct_idproperties_func(srna, "rna_Bone_idproperties"); RNA_def_struct_ui_text(srna, "Edit Bone", "Editmode bone in an Armature datablock."); RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); |