Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-10 00:03:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-10 00:03:54 +0300
commit5935ef004935b27fc5795349aed32f87cf637049 (patch)
treef36022abb03938420606405e9afc841b14d4bd81 /source/blender/makesrna/intern/rna_armature.c
parent3e2766bc2ee7523ea68caedc5b11e9498ddcbbc1 (diff)
use armature active bone as a pointer rather then a flag for each bone that needs looking up.
- rna vars arm.bones.active & rna.edit_bones.active - needed special undo support. - readfile.c loads. - duplicate and copy_armature support. - keep the draw flag, renamed to BONE_DRAW_ACTIVE, only use for openGL drawing. Note: it may be better to allow active/unselected as with objects.
Diffstat (limited to 'source/blender/makesrna/intern/rna_armature.c')
-rw-r--r--source/blender/makesrna/intern/rna_armature.c68
1 files changed, 62 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 96dde186260..7d88745779d 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -56,6 +56,44 @@ static void rna_Armature_update_data(bContext *C, PointerRNA *ptr)
//WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
}
+
+static void rna_Armature_act_bone_set(PointerRNA *ptr, PointerRNA value)
+{
+ bArmature *arm= (bArmature*)ptr->data;
+
+ if(value.id.data==NULL && value.data==NULL) {
+ arm->act_bone= NULL;
+ }
+ else {
+ if(value.id.data != arm) {
+ /* raise an error! */
+ }
+ else {
+ arm->act_bone= value.data;
+ arm->act_bone->flag |= BONE_SELECTED;
+ }
+ }
+}
+
+static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value)
+{
+ bArmature *arm= (bArmature*)ptr->data;
+
+ if(value.id.data==NULL && value.data==NULL) {
+ arm->act_edbone= NULL;
+ }
+ else {
+ if(value.id.data != arm) {
+ /* raise an error! */
+ }
+ else {
+ arm->act_edbone= value.data;
+ ((EditBone *)arm->act_edbone)->flag |= BONE_SELECTED;
+ }
+ }
+}
+
+
static void rna_Armature_redraw_data(bContext *C, PointerRNA *ptr)
{
ID *id= ptr->id.data;
@@ -371,11 +409,6 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_ui_text(prop, "Connected", "When bone has a parent, bone's head is struck to the parent's tail.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
- prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ACTIVE);
- RNA_def_property_ui_text(prop, "Active", "Bone was the last bone clicked on (most operations are applied to only this bone)");
- RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
-
prop= RNA_def_property(srna, "hinge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_HINGE);
RNA_def_property_ui_text(prop, "Inherit Rotation", "Bone doesn't inherit rotation or scale from parent bone.");
@@ -593,7 +626,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
static void rna_def_armature(BlenderRNA *brna)
{
StructRNA *srna;
- PropertyRNA *prop;
+ PropertyRNA *prop, *prop_act;
static EnumPropertyItem prop_drawtype_items[] = {
{ARM_OCTA, "OCTAHEDRAL", 0, "Octahedral", "Display bones as octahedral shape (default)."},
@@ -634,11 +667,34 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Bone");
RNA_def_property_ui_text(prop, "Bones", "");
+ { /* Collection active property */
+ prop_act= RNA_def_property(srna, "bones_active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop_act, "Bone");
+ RNA_def_property_pointer_sdna(prop_act, NULL, "act_bone");
+ RNA_def_property_flag(prop_act, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop_act, "Active Bone", "Armatures active bone.");
+ RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_bone_set", NULL);
+
+ /* todo, redraw */
+ RNA_def_property_collection_active(prop, prop_act);
+ }
+
prop= RNA_def_property(srna, "edit_bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "edbo", NULL);
RNA_def_property_struct_type(prop, "EditBone");
RNA_def_property_ui_text(prop, "Edit Bones", "");
+ { /* Collection active property */
+ prop_act= RNA_def_property(srna, "edit_bones_active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop_act, "EditBone");
+ RNA_def_property_pointer_sdna(prop_act, NULL, "act_edbone");
+ RNA_def_property_flag(prop_act, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop_act, "Active EditBone", "Armatures active edit bone.");
+ //RNA_def_property_update(prop_act, 0, "rna_Armature_act_editbone_update");
+ RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_edit_bone_set", NULL);
+ RNA_def_property_collection_active(prop, prop_act);
+ }
+
/* Enum values */
// prop= RNA_def_property(srna, "rest_position", PROP_BOOLEAN, PROP_NONE);
// RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_RESTPOS);