2.5: Armature

* Bone Transform panel now works, using appropriate EditBone or
  PoseChannel properties.
* Bone name and parent are now editable.
* Some other tweaks to the UI layouts for Armature and Bone.
* Notifiers for armature/editbone properties.
This commit is contained in:
Brecht Van Lommel 2009-07-14 17:59:26 +00:00
parent 4b3dafcaa7
commit f1a745c436
10 changed files with 422 additions and 135 deletions

@ -42,11 +42,12 @@ class DATA_PT_skeleton(DataButtonsPanel):
if arm: if arm:
layout.itemR(arm, "rest_position")
split = layout.split() split = layout.split()
sub = split.column() col = split.column()
col.itemR(arm, "rest_position")
sub = col.column()
sub.itemL(text="Deform:") sub.itemL(text="Deform:")
sub.itemR(arm, "deform_vertexgroups", text="Vertes Groups") sub.itemR(arm, "deform_vertexgroups", text="Vertes Groups")
sub.itemR(arm, "deform_envelope", text="Envelopes") sub.itemR(arm, "deform_envelope", text="Envelopes")
@ -69,17 +70,14 @@ class DATA_PT_display(DataButtonsPanel):
layout = self.layout layout = self.layout
arm = context.armature arm = context.armature
split = layout.split() layout.row().itemR(arm, "drawtype", expand=True)
sub = split.column() sub = layout.column_flow()
sub.itemR(arm, "drawtype", text="Style")
sub.itemR(arm, "delay_deform", text="Delay Refresh")
sub = split.column()
sub.itemR(arm, "draw_names", text="Names") sub.itemR(arm, "draw_names", text="Names")
sub.itemR(arm, "draw_axes", text="Axes") sub.itemR(arm, "draw_axes", text="Axes")
sub.itemR(arm, "draw_custom_bone_shapes", text="Shapes") sub.itemR(arm, "draw_custom_bone_shapes", text="Shapes")
sub.itemR(arm, "draw_group_colors", text="Colors") sub.itemR(arm, "draw_group_colors", text="Colors")
sub.itemR(arm, "delay_deform", text="Delay Refresh")
class DATA_PT_paths(DataButtonsPanel): class DATA_PT_paths(DataButtonsPanel):
__idname__ = "DATA_PT_paths" __idname__ = "DATA_PT_paths"
@ -93,14 +91,15 @@ class DATA_PT_paths(DataButtonsPanel):
sub = split.column() sub = split.column()
sub.itemR(arm, "paths_show_around_current_frame", text="Around Frame") sub.itemR(arm, "paths_show_around_current_frame", text="Around Frame")
col = sub.column(align=True)
if (arm.paths_show_around_current_frame): if (arm.paths_show_around_current_frame):
sub.itemR(arm, "path_before_current", text="Before") col.itemR(arm, "path_before_current", text="Before")
sub.itemR(arm, "path_after_current", text="After") col.itemR(arm, "path_after_current", text="After")
else: else:
sub.itemR(arm, "path_start_frame", text="Start") col.itemR(arm, "path_start_frame", text="Start")
sub.itemR(arm, "path_end_frame", text="End") col.itemR(arm, "path_end_frame", text="End")
sub.itemR(arm, "path_size", text="Step") col.itemR(arm, "path_size", text="Step")
sub.itemR(arm, "paths_calculate_head_positions", text="Head") sub.itemR(arm, "paths_calculate_head_positions", text="Head")
sub = split.column() sub = split.column()
@ -121,13 +120,15 @@ class DATA_PT_ghost(DataButtonsPanel):
sub = split.column() sub = split.column()
sub.itemR(arm, "ghost_type", text="Scope") sub.itemR(arm, "ghost_type", text="Scope")
col = sub.column(align=True)
if arm.ghost_type == 'RANGE': if arm.ghost_type == 'RANGE':
sub.itemR(arm, "ghost_start_frame", text="Start") col.itemR(arm, "ghost_start_frame", text="Start")
sub.itemR(arm, "ghost_end_frame", text="End") col.itemR(arm, "ghost_end_frame", text="End")
sub.itemR(arm, "ghost_size", text="Step") col.itemR(arm, "ghost_size", text="Step")
elif arm.ghost_type == 'CURRENT_FRAME': elif arm.ghost_type == 'CURRENT_FRAME':
sub.itemR(arm, "ghost_step", text="Range") col.itemR(arm, "ghost_step", text="Range")
sub.itemR(arm, "ghost_size", text="Step") col.itemR(arm, "ghost_size", text="Step")
sub = split.column() sub = split.column()
sub.itemR(arm, "ghost_only_selected", text="Selected Only") sub.itemR(arm, "ghost_only_selected", text="Selected Only")

@ -23,22 +23,51 @@ class BONE_PT_context_bone(BoneButtonsPanel):
split.itemL(text="", icon="ICON_BONE_DATA") split.itemL(text="", icon="ICON_BONE_DATA")
split.itemR(bone, "name", text="") split.itemR(bone, "name", text="")
class BONE_PT_transform_bone(BoneButtonsPanel): class BONE_PT_transform(BoneButtonsPanel):
__idname__ = "BONE_PT_transform_bone" __idname__ = "BONE_PT_transform"
__label__ = "Transform" __label__ = "Transform"
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
ob = context.object
bone = context.bone bone = context.bone
if not bone: if not bone:
bone = context.edit_bone bone = context.edit_bone
#Seems to be missing from RNA? row = layout.row()
row = layout.row() row.column().itemR(bone, "head")
row.column().itemR(bone, "location") row.column().itemR(bone, "tail")
row.column().itemR(bone, "rotation")
row.column().itemR(bone, "scale")
col = row.column()
sub = col.column(align=True)
sub.itemL(text="Roll:")
sub.itemR(bone, "roll", text="")
sub.itemL()
sub.itemR(bone, "locked")
sub.itemS()
else:
pchan = ob.pose.pose_channels[context.bone.name]
layout.itemR(pchan, "rotation_mode")
row = layout.row()
col = row.column()
col.itemR(pchan, "location")
col.active = not (bone.parent and bone.connected)
col = row.column()
if pchan.rotation_mode == 'QUATERNION':
col.itemR(pchan, "rotation", text="Rotation")
else:
col.itemR(pchan, "euler_rotation", text="Rotation")
row.column().itemR(pchan, "scale")
if pchan.rotation_mode == 'QUATERNION':
col = layout.column(align=True)
col.itemL(text="Euler:")
col.row().itemR(pchan, "euler_rotation", text="")
class BONE_PT_bone(BoneButtonsPanel): class BONE_PT_bone(BoneButtonsPanel):
__idname__ = "BONE_PT_bone" __idname__ = "BONE_PT_bone"
@ -48,14 +77,21 @@ class BONE_PT_bone(BoneButtonsPanel):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
bone = context.bone bone = context.bone
arm = context.armature
if not bone: if not bone:
bone = context.edit_bone bone = context.edit_bone
split = layout.split() split = layout.split()
sub = split.column() sub = split.column()
sub.itemR(bone, "parent") sub.itemL(text="Parent:")
sub.itemR(bone, "connected") if context.bone:
sub.itemR(bone, "parent", text="")
else:
sub.item_pointerR(bone, "parent", arm, "edit_bones", text="")
row = sub.row()
row.itemR(bone, "connected")
row.active = bone.parent != None
sub.itemL(text="Layers:") sub.itemL(text="Layers:")
sub.template_layers(bone, "layer") sub.template_layers(bone, "layer")
@ -70,8 +106,6 @@ class BONE_PT_bone(BoneButtonsPanel):
sub.itemR(bone, "draw_wire", text="Wireframe") sub.itemR(bone, "draw_wire", text="Wireframe")
sub.itemR(bone, "hidden", text="Hide") sub.itemR(bone, "hidden", text="Hide")
class BONE_PT_deform(BoneButtonsPanel): class BONE_PT_deform(BoneButtonsPanel):
__idname__ = "BONE_PT_deform" __idname__ = "BONE_PT_deform"
__label__ = "Deform" __label__ = "Deform"
@ -94,22 +128,30 @@ class BONE_PT_deform(BoneButtonsPanel):
split = layout.split() split = layout.split()
sub = split.column() col = split.column()
sub.itemL(text="Envelope:") col.itemL(text="Envelope:")
sub = col.column(align=True)
sub.itemR(bone, "envelope_distance", text="Distance") sub.itemR(bone, "envelope_distance", text="Distance")
sub.itemR(bone, "envelope_weight", text="Weight") sub.itemR(bone, "envelope_weight", text="Weight")
sub.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply") col.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply")
sub = split.column()
sub.itemL(text="Curved Bones:") sub = col.column(align=True)
sub.itemL(text="Radius:")
sub.itemR(bone, "head_radius", text="Head")
sub.itemR(bone, "tail_radius", text="Tail")
col = split.column()
col.itemL(text="Curved Bones:")
sub = col.column(align=True)
sub.itemR(bone, "bbone_segments", text="Segments") sub.itemR(bone, "bbone_segments", text="Segments")
sub.itemR(bone, "bbone_in", text="Ease In") sub.itemR(bone, "bbone_in", text="Ease In")
sub.itemR(bone, "bbone_out", text="Ease Out") sub.itemR(bone, "bbone_out", text="Ease Out")
sub.itemR(bone, "cyclic_offset") col.itemL(text="Offset:")
col.itemR(bone, "cyclic_offset")
bpy.types.register(BONE_PT_context_bone) bpy.types.register(BONE_PT_context_bone)
bpy.types.register(BONE_PT_transform_bone) bpy.types.register(BONE_PT_transform)
bpy.types.register(BONE_PT_bone) bpy.types.register(BONE_PT_bone)
bpy.types.register(BONE_PT_deform) bpy.types.register(BONE_PT_deform)

@ -5095,9 +5095,9 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam
/* called by UI for renaming a bone */ /* called by UI for renaming a bone */
/* warning: make sure the original bone was not renamed yet! */ /* warning: make sure the original bone was not renamed yet! */
/* seems messy, but thats what you get with not using pointers but channel names :) */ /* seems messy, but thats what you get with not using pointers but channel names :) */
void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep) void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
{ {
bArmature *arm= ob->data; Object *ob;
char newname[MAXBONENAME]; char newname[MAXBONENAME];
char oldname[MAXBONENAME]; char oldname[MAXBONENAME];
@ -5242,7 +5242,7 @@ void armature_flip_names(Scene *scene)
if (ebone->flag & BONE_SELECTED) { if (ebone->flag & BONE_SELECTED) {
BLI_strncpy(newname, ebone->name, sizeof(newname)); BLI_strncpy(newname, ebone->name, sizeof(newname));
bone_flip_name(newname, 1); // 1 = do strip off number extensions bone_flip_name(newname, 1); // 1 = do strip off number extensions
armature_bone_rename(obedit, ebone->name, newname); ED_armature_bone_rename(arm, ebone->name, newname);
} }
} }
} }
@ -5263,7 +5263,7 @@ void armature_autoside_names(Scene *scene, short axis)
if (ebone->flag & BONE_SELECTED) { if (ebone->flag & BONE_SELECTED) {
BLI_strncpy(newname, ebone->name, sizeof(newname)); BLI_strncpy(newname, ebone->name, sizeof(newname));
bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]); bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]);
armature_bone_rename(obedit, ebone->name, newname); ED_armature_bone_rename(arm, ebone->name, newname);
} }
} }
} }

@ -1346,7 +1346,7 @@ void pose_flip_names(Scene *scene)
if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) { if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
BLI_strncpy(newname, pchan->name, sizeof(newname)); BLI_strncpy(newname, pchan->name, sizeof(newname));
bone_flip_name(newname, 1); // 1 = do strip off number extensions bone_flip_name(newname, 1); // 1 = do strip off number extensions
armature_bone_rename(ob, pchan->name, newname); ED_armature_bone_rename(arm, pchan->name, newname);
} }
} }
} }
@ -1375,7 +1375,7 @@ void pose_autoside_names(Scene *scene, short axis)
if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) { if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
BLI_strncpy(newname, pchan->name, sizeof(newname)); BLI_strncpy(newname, pchan->name, sizeof(newname));
bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]); bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]);
armature_bone_rename(ob, pchan->name, newname); ED_armature_bone_rename(arm, pchan->name, newname);
} }
} }
} }

@ -116,7 +116,7 @@ void docenter_armature (struct Scene *scene, struct View3D *v3d, struct Object *
void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode); void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode);
void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */ void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */
void armature_bone_rename(struct Object *ob, char *oldnamep, char *newnamep); void ED_armature_bone_rename(struct bArmature *arm, char *oldnamep, char *newnamep);
void undo_push_armature(struct bContext *C, char *name); void undo_push_armature(struct bContext *C, char *name);

@ -415,6 +415,8 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
break; break;
case BCONTEXT_BONE: case BCONTEXT_BONE:
found= buttons_context_path_bone(path); found= buttons_context_path_bone(path);
if(!found)
found= buttons_context_path_data(path, OB_ARMATURE);
break; break;
default: default:
found= 0; found= 0;

@ -1559,7 +1559,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot)
{ {
/* identifiers */ /* identifiers */
ot->name= "Toggle Renderability"; ot->name= "Toggle Renderability";
ot->idname= "OUTLINER_OT_renederability_toggle"; ot->idname= "OUTLINER_OT_renderability_toggle";
ot->description= "Toggle the renderbility of selected items."; ot->description= "Toggle the renderbility of selected items.";
/* callbacks */ /* callbacks */

@ -481,7 +481,7 @@ static void validate_bonebutton_cb(bContext *C, void *bonev, void *namev)
/* restore */ /* restore */
BLI_strncpy(bone->name, oldname, 32); BLI_strncpy(bone->name, oldname, 32);
armature_bone_rename(ob, oldname, newname); // editarmature.c ED_armature_bone_rename(ob->data, oldname, newname); // editarmature.c
} }
} }
@ -553,7 +553,7 @@ void validate_editbonebutton_cb(bContext *C, void *bonev, void *namev)
/* restore */ /* restore */
BLI_strncpy(eBone->name, oldname, 32); BLI_strncpy(eBone->name, oldname, 32);
armature_bone_rename(CTX_data_edit_object(C), oldname, newname); // editarmature.c ED_armature_bone_rename(CTX_data_edit_object(C)->data, oldname, newname); // editarmature.c
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, CTX_data_edit_object(C)); // XXX fix WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, CTX_data_edit_object(C)); // XXX fix
} }
@ -1215,7 +1215,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
Scene *scene= CTX_data_scene(C); Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C); Object *obedit= CTX_data_edit_object(C);
View3D *v3d= CTX_wm_view3d(C); View3D *v3d= CTX_wm_view3d(C);
uiBut *bt; //uiBut *bt;
Object *ob= OBACT; Object *ob= OBACT;
TransformProperties *tfp; TransformProperties *tfp;
float lim; float lim;
@ -1764,7 +1764,7 @@ void view3d_buttons_register(ARegionType *art)
pt->draw= view3d_panel_transform_spaces; pt->draw= view3d_panel_transform_spaces;
BLI_addtail(&art->paneltypes, pt); BLI_addtail(&art->paneltypes, pt);
/*pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel gpencil"); pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel gpencil");
strcpy(pt->idname, "VIEW3D_PT_gpencil"); strcpy(pt->idname, "VIEW3D_PT_gpencil");
strcpy(pt->label, "Greas Pencil"); strcpy(pt->label, "Greas Pencil");
pt->draw= view3d_panel_gpencil; pt->draw= view3d_panel_gpencil;

@ -30,14 +30,49 @@
#include "rna_internal.h" #include "rna_internal.h"
#include "DNA_armature_types.h" #include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#ifdef RNA_RUNTIME #ifdef RNA_RUNTIME
#include "BLI_arithb.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_main.h"
#include "ED_armature.h" #include "ED_armature.h"
static void rna_Armature_update_data(bContext *C, PointerRNA *ptr)
{
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
ID *id= ptr->id.data;
Object *ob;
for(ob=bmain->object.first; ob; ob= ob->id.next) {
if(ob->data == id) {
/* XXX this will loop over all objects again (slow) */
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
}
}
}
static void rna_Armature_redraw_data(bContext *C, PointerRNA *ptr)
{
Main *bmain= CTX_data_main(C);
ID *id= ptr->id.data;
Object *ob;
for(ob=bmain->object.first; ob; ob= ob->id.next)
if(ob->data == id)
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
}
static void rna_bone_layer_set(short *layer, const int *values) static void rna_bone_layer_set(short *layer, const int *values)
{ {
int i, tot= 0; int i, tot= 0;
@ -109,73 +144,81 @@ static void rna_Armature_path_end_frame_set(PointerRNA *ptr, int value)
data->pathef= value; data->pathef= value;
} }
PointerRNA rna_EditBone_rna_type_get(PointerRNA *ptr) static void rna_EditBone_name_get(PointerRNA *ptr, char *value)
{
return rna_builtin_type_get(ptr);
}
void rna_EditBone_name_get(PointerRNA *ptr, char *value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
BLI_strncpy(value, data->name, sizeof(data->name)); BLI_strncpy(value, data->name, sizeof(data->name));
} }
int rna_EditBone_name_length(PointerRNA *ptr) static int rna_EditBone_name_length(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return strlen(data->name); return strlen(data->name);
} }
int rna_EditBone_active_get(PointerRNA *ptr) static void rna_EditBone_name_set(PointerRNA *ptr, const char *value)
{
bArmature *arm= (bArmature*)ptr->id.data;
EditBone *ebone= (EditBone*)ptr->data;
char oldname[32], newname[32];
/* need to be on the stack */
BLI_strncpy(newname, value, 32);
BLI_strncpy(oldname, ebone->name, 32);
ED_armature_bone_rename(arm, oldname, newname);
}
static int rna_EditBone_active_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_ACTIVE) != 0); return (((data->flag) & BONE_ACTIVE) != 0);
} }
void rna_EditBone_active_set(PointerRNA *ptr, int value) static void rna_EditBone_active_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_ACTIVE; if(value) data->flag |= BONE_ACTIVE;
else data->flag &= ~BONE_ACTIVE; else data->flag &= ~BONE_ACTIVE;
} }
float rna_EditBone_bbone_in_get(PointerRNA *ptr) static float rna_EditBone_bbone_in_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->ease1); return (float)(data->ease1);
} }
void rna_EditBone_bbone_in_set(PointerRNA *ptr, float value) static void rna_EditBone_bbone_in_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->ease1= CLAMPIS(value, 0.0f, 2.0f); data->ease1= CLAMPIS(value, 0.0f, 2.0f);
} }
float rna_EditBone_bbone_out_get(PointerRNA *ptr) static float rna_EditBone_bbone_out_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->ease2); return (float)(data->ease2);
} }
void rna_EditBone_bbone_out_set(PointerRNA *ptr, float value) static void rna_EditBone_bbone_out_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->ease2= CLAMPIS(value, 0.0f, 2.0f); data->ease2= CLAMPIS(value, 0.0f, 2.0f);
} }
int rna_EditBone_bbone_segments_get(PointerRNA *ptr) static int rna_EditBone_bbone_segments_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (int)(data->segments); return (int)(data->segments);
} }
void rna_EditBone_bbone_segments_set(PointerRNA *ptr, int value) static void rna_EditBone_bbone_segments_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->segments= CLAMPIS(value, 1, 32); data->segments= CLAMPIS(value, 1, 32);
} }
void rna_EditBone_layer_get(PointerRNA *ptr, int values[16]) static void rna_EditBone_layer_get(PointerRNA *ptr, int values[16])
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
values[0]= ((data->layer & (1<<0)) != 0); values[0]= ((data->layer & (1<<0)) != 0);
@ -196,113 +239,135 @@ void rna_EditBone_layer_get(PointerRNA *ptr, int values[16])
values[15]= ((data->layer & (1<<15)) != 0); values[15]= ((data->layer & (1<<15)) != 0);
} }
void rna_EditBone_layer_set(PointerRNA *ptr, const int values[16]) static void rna_EditBone_layer_set(PointerRNA *ptr, const int values[16])
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
rna_bone_layer_set(&data->layer, values); rna_bone_layer_set(&data->layer, values);
} }
int rna_EditBone_connected_get(PointerRNA *ptr) static void rna_EditBone_connected_check(EditBone *ebone)
{
if(ebone->parent) {
if(ebone->flag & BONE_CONNECTED) {
/* Attach this bone to its parent */
VECCOPY(ebone->head, ebone->parent->tail);
if(ebone->flag & BONE_ROOTSEL)
ebone->parent->flag |= BONE_TIPSEL;
}
else if(!(ebone->parent->flag & BONE_ROOTSEL)) {
ebone->parent->flag &= ~BONE_TIPSEL;
}
}
}
static int rna_EditBone_connected_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_CONNECTED) != 0); return (((data->flag) & BONE_CONNECTED) != 0);
} }
void rna_EditBone_connected_set(PointerRNA *ptr, int value) static void rna_EditBone_connected_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *ebone= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_CONNECTED;
else data->flag &= ~BONE_CONNECTED; if(value) ebone->flag |= BONE_CONNECTED;
else ebone->flag &= ~BONE_CONNECTED;
rna_EditBone_connected_check(ebone);
} }
int rna_EditBone_cyclic_offset_get(PointerRNA *ptr) static int rna_EditBone_cyclic_offset_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (!((data->flag) & BONE_NO_CYCLICOFFSET) != 0); return (!((data->flag) & BONE_NO_CYCLICOFFSET) != 0);
} }
void rna_EditBone_cyclic_offset_set(PointerRNA *ptr, int value) static void rna_EditBone_cyclic_offset_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(!value) data->flag |= BONE_NO_CYCLICOFFSET; if(!value) data->flag |= BONE_NO_CYCLICOFFSET;
else data->flag &= ~BONE_NO_CYCLICOFFSET; else data->flag &= ~BONE_NO_CYCLICOFFSET;
} }
int rna_EditBone_deform_get(PointerRNA *ptr) static int rna_EditBone_deform_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (!((data->flag) & BONE_NO_DEFORM) != 0); return (!((data->flag) & BONE_NO_DEFORM) != 0);
} }
void rna_EditBone_deform_set(PointerRNA *ptr, int value) static void rna_EditBone_deform_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(!value) data->flag |= BONE_NO_DEFORM; if(!value) data->flag |= BONE_NO_DEFORM;
else data->flag &= ~BONE_NO_DEFORM; else data->flag &= ~BONE_NO_DEFORM;
} }
int rna_EditBone_draw_wire_get(PointerRNA *ptr) static int rna_EditBone_draw_wire_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_DRAWWIRE) != 0); return (((data->flag) & BONE_DRAWWIRE) != 0);
} }
void rna_EditBone_draw_wire_set(PointerRNA *ptr, int value) static void rna_EditBone_draw_wire_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_DRAWWIRE; if(value) data->flag |= BONE_DRAWWIRE;
else data->flag &= ~BONE_DRAWWIRE; else data->flag &= ~BONE_DRAWWIRE;
} }
float rna_EditBone_envelope_distance_get(PointerRNA *ptr) static float rna_EditBone_envelope_distance_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->dist); return (float)(data->dist);
} }
void rna_EditBone_envelope_distance_set(PointerRNA *ptr, float value) static void rna_EditBone_envelope_distance_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->dist= CLAMPIS(value, 0.0f, 1000.0f); data->dist= CLAMPIS(value, 0.0f, 1000.0f);
} }
float rna_EditBone_envelope_weight_get(PointerRNA *ptr) static float rna_EditBone_envelope_weight_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->weight); return (float)(data->weight);
} }
void rna_EditBone_envelope_weight_set(PointerRNA *ptr, float value) static void rna_EditBone_envelope_weight_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->weight= CLAMPIS(value, 0.0f, 1000.0f); data->weight= CLAMPIS(value, 0.0f, 1000.0f);
} }
float rna_EditBone_radius_head_get(PointerRNA *ptr) static float rna_EditBone_radius_head_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->rad_head); return (float)(data->rad_head);
} }
void rna_EditBone_radius_head_set(PointerRNA *ptr, float value) static void rna_EditBone_radius_head_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->rad_head= value; if(data->parent)
data->parent->rad_tail= value;
else
data->rad_head= value;
} }
float rna_EditBone_radius_tail_get(PointerRNA *ptr) static float rna_EditBone_radius_tail_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->rad_tail); return (float)(data->rad_tail);
} }
void rna_EditBone_radius_tail_set(PointerRNA *ptr, float value) static void rna_EditBone_radius_tail_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->rad_tail= value; data->rad_tail= value;
} }
void rna_EditBone_head_get(PointerRNA *ptr, float values[3]) static void rna_EditBone_head_get(PointerRNA *ptr, float values[3])
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
values[0]= (float)(((float*)data->head)[0]); values[0]= (float)(((float*)data->head)[0]);
@ -310,7 +375,7 @@ void rna_EditBone_head_get(PointerRNA *ptr, float values[3])
values[2]= (float)(((float*)data->head)[2]); values[2]= (float)(((float*)data->head)[2]);
} }
void rna_EditBone_head_set(PointerRNA *ptr, const float values[3]) static void rna_EditBone_head_set(PointerRNA *ptr, const float values[3])
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
((float*)data->head)[0]= values[0]; ((float*)data->head)[0]= values[0];
@ -318,103 +383,133 @@ void rna_EditBone_head_set(PointerRNA *ptr, const float values[3])
((float*)data->head)[2]= values[2]; ((float*)data->head)[2]= values[2];
} }
int rna_EditBone_head_selected_get(PointerRNA *ptr) static int rna_EditBone_head_selected_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_ROOTSEL) != 0); return (((data->flag) & BONE_ROOTSEL) != 0);
} }
void rna_EditBone_head_selected_set(PointerRNA *ptr, int value) static void rna_EditBone_head_selected_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_ROOTSEL; if(value) data->flag |= BONE_ROOTSEL;
else data->flag &= ~BONE_ROOTSEL; else data->flag &= ~BONE_ROOTSEL;
} }
int rna_EditBone_hidden_get(PointerRNA *ptr) static int rna_EditBone_hidden_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_HIDDEN_A) != 0); return (((data->flag) & BONE_HIDDEN_A) != 0);
} }
void rna_EditBone_hidden_set(PointerRNA *ptr, int value) static void rna_EditBone_hidden_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_HIDDEN_A; if(value) data->flag |= BONE_HIDDEN_A;
else data->flag &= ~BONE_HIDDEN_A; else data->flag &= ~BONE_HIDDEN_A;
} }
int rna_EditBone_hinge_get(PointerRNA *ptr) static int rna_EditBone_hinge_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (!((data->flag) & BONE_HINGE) != 0); return (!((data->flag) & BONE_HINGE) != 0);
} }
void rna_EditBone_hinge_set(PointerRNA *ptr, int value) static void rna_EditBone_hinge_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(!value) data->flag |= BONE_HINGE; if(!value) data->flag |= BONE_HINGE;
else data->flag &= ~BONE_HINGE; else data->flag &= ~BONE_HINGE;
} }
int rna_EditBone_inherit_scale_get(PointerRNA *ptr) static int rna_EditBone_inherit_scale_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (!((data->flag) & BONE_NO_SCALE) != 0); return (!((data->flag) & BONE_NO_SCALE) != 0);
} }
void rna_EditBone_inherit_scale_set(PointerRNA *ptr, int value) static void rna_EditBone_inherit_scale_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(!value) data->flag |= BONE_NO_SCALE; if(!value) data->flag |= BONE_NO_SCALE;
else data->flag &= ~BONE_NO_SCALE; else data->flag &= ~BONE_NO_SCALE;
} }
int rna_EditBone_locked_get(PointerRNA *ptr) static int rna_EditBone_locked_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_EDITMODE_LOCKED) != 0); return (((data->flag) & BONE_EDITMODE_LOCKED) != 0);
} }
void rna_EditBone_locked_set(PointerRNA *ptr, int value) static void rna_EditBone_locked_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_EDITMODE_LOCKED; if(value) data->flag |= BONE_EDITMODE_LOCKED;
else data->flag &= ~BONE_EDITMODE_LOCKED; else data->flag &= ~BONE_EDITMODE_LOCKED;
} }
int rna_EditBone_multiply_vertexgroup_with_envelope_get(PointerRNA *ptr) static int rna_EditBone_multiply_vertexgroup_with_envelope_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_MULT_VG_ENV) != 0); return (((data->flag) & BONE_MULT_VG_ENV) != 0);
} }
void rna_EditBone_multiply_vertexgroup_with_envelope_set(PointerRNA *ptr, int value) static void rna_EditBone_multiply_vertexgroup_with_envelope_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_MULT_VG_ENV; if(value) data->flag |= BONE_MULT_VG_ENV;
else data->flag &= ~BONE_MULT_VG_ENV; else data->flag &= ~BONE_MULT_VG_ENV;
} }
PointerRNA rna_EditBone_parent_get(PointerRNA *ptr) static PointerRNA rna_EditBone_parent_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->parent); return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->parent);
} }
float rna_EditBone_roll_get(PointerRNA *ptr) static void rna_EditBone_parent_set(PointerRNA *ptr, PointerRNA value)
{
EditBone *ebone= (EditBone*)(ptr->data);
EditBone *pbone, *parbone= (EditBone*)value.data;
/* within same armature */
if(value.id.data != ptr->id.data)
return;
if(parbone == NULL) {
if(ebone->parent && !(ebone->parent->flag & BONE_ROOTSEL))
ebone->parent->flag &= ~BONE_TIPSEL;
ebone->parent = NULL;
ebone->flag &= ~BONE_CONNECTED;
}
else {
/* make sure this is a valid child */
if(parbone == ebone)
return;
for(pbone= parbone->parent; pbone; pbone=pbone->parent)
if(pbone == ebone)
return;
ebone->parent = parbone;
rna_EditBone_connected_check(ebone);
}
}
static float rna_EditBone_roll_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (float)(data->roll); return (float)(data->roll);
} }
void rna_EditBone_roll_set(PointerRNA *ptr, float value) static void rna_EditBone_roll_set(PointerRNA *ptr, float value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
data->roll= value; data->roll= value;
} }
void rna_EditBone_tail_get(PointerRNA *ptr, float values[3]) static void rna_EditBone_tail_get(PointerRNA *ptr, float values[3])
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
values[0]= (float)(((float*)data->tail)[0]); values[0]= (float)(((float*)data->tail)[0]);
@ -422,7 +517,7 @@ void rna_EditBone_tail_get(PointerRNA *ptr, float values[3])
values[2]= (float)(((float*)data->tail)[2]); values[2]= (float)(((float*)data->tail)[2]);
} }
void rna_EditBone_tail_set(PointerRNA *ptr, const float values[3]) static void rna_EditBone_tail_set(PointerRNA *ptr, const float values[3])
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
((float*)data->tail)[0]= values[0]; ((float*)data->tail)[0]= values[0];
@ -430,19 +525,57 @@ void rna_EditBone_tail_set(PointerRNA *ptr, const float values[3])
((float*)data->tail)[2]= values[2]; ((float*)data->tail)[2]= values[2];
} }
int rna_EditBone_tail_selected_get(PointerRNA *ptr) static int rna_EditBone_tail_selected_get(PointerRNA *ptr)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
return (((data->flag) & BONE_TIPSEL) != 0); return (((data->flag) & BONE_TIPSEL) != 0);
} }
void rna_EditBone_tail_selected_set(PointerRNA *ptr, int value) static void rna_EditBone_tail_selected_set(PointerRNA *ptr, int value)
{ {
EditBone *data= (EditBone*)(ptr->data); EditBone *data= (EditBone*)(ptr->data);
if(value) data->flag |= BONE_TIPSEL; if(value) data->flag |= BONE_TIPSEL;
else data->flag &= ~BONE_TIPSEL; else data->flag &= ~BONE_TIPSEL;
} }
static void rna_Armature_editbone_transform_update(bContext *C, PointerRNA *ptr)
{
bArmature *arm= (bArmature*)ptr->id.data;
EditBone *ebone= (EditBone*)ptr->data;
EditBone *child, *eboflip;
/* update our parent */
if(ebone->parent && ebone->flag & BONE_CONNECTED)
VECCOPY(ebone->parent->tail, ebone->head)
/* update our children if necessary */
for(child = arm->edbo->first; child; child=child->next)
if(child->parent == ebone && (child->flag & BONE_CONNECTED))
VECCOPY(child->head, ebone->tail);
if(arm->flag & ARM_MIRROR_EDIT) {
eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebone);
if(eboflip) {
eboflip->roll= -ebone->roll;
eboflip->head[0]= -ebone->head[0];
eboflip->tail[0]= -ebone->tail[0];
/* update our parent */
if(eboflip->parent && eboflip->flag & BONE_CONNECTED)
VECCOPY(eboflip->parent->tail, eboflip->head);
/* update our children if necessary */
for(child = arm->edbo->first; child; child=child->next)
if(child->parent == eboflip && (child->flag & BONE_CONNECTED))
VECCOPY (child->head, eboflip->tail);
}
}
rna_Armature_update_data(C, ptr);
}
static void rna_Armature_bones_next(CollectionPropertyIterator *iter) static void rna_Armature_bones_next(CollectionPropertyIterator *iter)
{ {
ListBaseIterator *internal= iter->internal; ListBaseIterator *internal= iter->internal;
@ -475,60 +608,75 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
/* strings */ /* strings */
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* must be unique */
RNA_def_property_ui_text(prop, "Name", ""); RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop); RNA_def_struct_name_property(srna, prop);
if(editbone) RNA_def_property_string_funcs(prop, "rna_EditBone_name_get", "rna_EditBone_name_length", "rna_EditBone_name_set"); if(editbone) RNA_def_property_string_funcs(prop, "rna_EditBone_name_get", "rna_EditBone_name_length", "rna_EditBone_name_set");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* flags */ /* flags */
prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_array(prop, 16); if(editbone) {
RNA_def_property_ui_text(prop, "Bone Layers", "Layers bone exists in"); RNA_def_property_array(prop, 16);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_layer_get", "rna_EditBone_layer_set"); RNA_def_property_boolean_funcs(prop, "rna_EditBone_layer_get", "rna_EditBone_layer_set");
else {
RNA_def_property_boolean_funcs(prop, NULL, "rna_Bone_layer_set");
RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
} }
else {
RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
RNA_def_property_array(prop, 16);
RNA_def_property_boolean_funcs(prop, NULL, "rna_Bone_layer_set");
}
RNA_def_property_ui_text(prop, "Layers", "Layers bone exists in");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "connected", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "connected", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_connected_get", "rna_EditBone_connected_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_connected_get", "rna_EditBone_connected_set");
else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED); else {
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
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_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); prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_active_get", "rna_EditBone_active_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_active_get", "rna_EditBone_active_set");
else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ACTIVE); else 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_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); prop= RNA_def_property(srna, "hinge", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_hinge_get", "rna_EditBone_hinge_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_hinge_get", "rna_EditBone_hinge_set");
else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_HINGE); else 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."); RNA_def_property_ui_text(prop, "Inherit Rotation", "Bone doesn't inherit rotation or scale from parent bone.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "multiply_vertexgroup_with_envelope", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "multiply_vertexgroup_with_envelope", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_multiply_vertexgroup_with_envelope_get", "rna_EditBone_multiply_vertexgroup_with_envelope_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_multiply_vertexgroup_with_envelope_get", "rna_EditBone_multiply_vertexgroup_with_envelope_set");
else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_MULT_VG_ENV); else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_MULT_VG_ENV);
RNA_def_property_ui_text(prop, "Multiply Vertex Group with Envelope", "When deforming bone, multiply effects of Vertex Group weights with Envelope influence."); RNA_def_property_ui_text(prop, "Multiply Vertex Group with Envelope", "When deforming bone, multiply effects of Vertex Group weights with Envelope influence.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "deform", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "deform", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_deform_get", "rna_EditBone_deform_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_deform_get", "rna_EditBone_deform_set");
else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_DEFORM); else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_DEFORM);
RNA_def_property_ui_text(prop, "Deform", "Bone does not deform any geometry."); RNA_def_property_ui_text(prop, "Deform", "Bone does not deform any geometry.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "inherit_scale", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "inherit_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Inherit Scale", "Bone inherits scaling from parent bone."); RNA_def_property_ui_text(prop, "Inherit Scale", "Bone inherits scaling from parent bone.");
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_inherit_scale_get", "rna_EditBone_inherit_scale_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_inherit_scale_get", "rna_EditBone_inherit_scale_set");
else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_SCALE); else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_SCALE);
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "draw_wire", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "draw_wire", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_draw_wire_get", "rna_EditBone_draw_wire_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_draw_wire_get", "rna_EditBone_draw_wire_set");
else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE); else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE);
RNA_def_property_ui_text(prop, "Draw Wire", "Bone is always drawn as Wireframe regardless of viewport draw mode. Useful for non-obstructive custom bone shapes."); RNA_def_property_ui_text(prop, "Draw Wire", "Bone is always drawn as Wireframe regardless of viewport draw mode. Useful for non-obstructive custom bone shapes.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "cyclic_offset", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "cyclic_offset", PROP_BOOLEAN, PROP_NONE);
if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_cyclic_offset_get", "rna_EditBone_cyclic_offset_set"); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_cyclic_offset_get", "rna_EditBone_cyclic_offset_set");
else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_CYCLICOFFSET); else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_CYCLICOFFSET);
RNA_def_property_ui_text(prop, "Cyclic Offset", "When bone doesn't have a parent, it receives cyclic offset effects."); RNA_def_property_ui_text(prop, "Cyclic Offset", "When bone doesn't have a parent, it receives cyclic offset effects.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
/* Number values */ /* Number values */
/* envelope deform settings */ /* envelope deform settings */
@ -537,24 +685,32 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
else RNA_def_property_float_sdna(prop, NULL, "dist"); else RNA_def_property_float_sdna(prop, NULL, "dist");
RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Envelope Deform Distance", "Bone deformation distance (for Envelope deform only)."); RNA_def_property_ui_text(prop, "Envelope Deform Distance", "Bone deformation distance (for Envelope deform only).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "envelope_weight", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "envelope_weight", PROP_FLOAT, PROP_NONE);
if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_envelope_weight_get", "rna_EditBone_envelope_weight_set", NULL); if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_envelope_weight_get", "rna_EditBone_envelope_weight_set", NULL);
else RNA_def_property_float_sdna(prop, NULL, "weight"); else RNA_def_property_float_sdna(prop, NULL, "weight");
RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only)."); RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "radius_head", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_NONE);
if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_radius_head_get", "rna_EditBone_radius_head_set", NULL); if(editbone) {
RNA_def_property_float_funcs(prop, "rna_EditBone_radius_head_get", "rna_EditBone_radius_head_set", NULL);
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
}
else RNA_def_property_float_sdna(prop, NULL, "rad_head"); else RNA_def_property_float_sdna(prop, NULL, "rad_head");
//RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); //RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid);
RNA_def_property_ui_text(prop, "Envelope Radius Head", "Radius of head of bone (for Envelope deform only)."); RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only).");
prop= RNA_def_property(srna, "radius_tail", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_NONE);
if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_radius_tail_get", "rna_EditBone_radius_tail_set", NULL); if(editbone) {
RNA_def_property_float_funcs(prop, "rna_EditBone_radius_tail_get", "rna_EditBone_radius_tail_set", NULL);
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
}
else RNA_def_property_float_sdna(prop, NULL, "rad_tail"); else RNA_def_property_float_sdna(prop, NULL, "rad_tail");
//RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); //RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid);
RNA_def_property_ui_text(prop, "Envelope Radius Tail", "Radius of tail of bone (for Envelope deform only)."); RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only).");
/* b-bones deform settings */ /* b-bones deform settings */
prop= RNA_def_property(srna, "bbone_segments", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "bbone_segments", PROP_INT, PROP_NONE);
@ -562,18 +718,21 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
else RNA_def_property_int_sdna(prop, NULL, "segments"); else RNA_def_property_int_sdna(prop, NULL, "segments");
RNA_def_property_range(prop, 1, 32); RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only)."); RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "bbone_in", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "bbone_in", PROP_FLOAT, PROP_NONE);
if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_in_get", "rna_EditBone_bbone_in_set", NULL); if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_in_get", "rna_EditBone_bbone_in_set", NULL);
else RNA_def_property_float_sdna(prop, NULL, "ease1"); else RNA_def_property_float_sdna(prop, NULL, "ease1");
RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only)."); RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "bbone_out", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "bbone_out", PROP_FLOAT, PROP_NONE);
if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_out_get", "rna_EditBone_bbone_out_set", NULL); if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_out_get", "rna_EditBone_bbone_out_set", NULL);
else RNA_def_property_float_sdna(prop, NULL, "ease2"); else RNA_def_property_float_sdna(prop, NULL, "ease2");
RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only)."); RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
} }
// err... bones should not be directly edited (only editbones should be...) // err... bones should not be directly edited (only editbones should be...)
@ -592,6 +751,7 @@ static void rna_def_bone(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Bone"); RNA_def_property_struct_type(prop, "Bone");
RNA_def_property_pointer_sdna(prop, NULL, "parent"); RNA_def_property_pointer_sdna(prop, NULL, "parent");
RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature)."); RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* children (collection) */ /* children (collection) */
prop= RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE); prop= RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE);
@ -605,10 +765,12 @@ static void rna_def_bone(BlenderRNA *brna)
prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_P); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_P);
RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes)."); RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED);
RNA_def_property_ui_text(prop, "Selected", ""); RNA_def_property_ui_text(prop, "Selected", "");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
} }
static void rna_def_edit_bone(BlenderRNA *brna) static void rna_def_edit_bone(BlenderRNA *brna)
@ -622,40 +784,49 @@ static void rna_def_edit_bone(BlenderRNA *brna)
prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EditBone"); RNA_def_property_struct_type(prop, "EditBone");
RNA_def_property_pointer_funcs(prop, "rna_EditBone_parent_get", NULL, NULL); RNA_def_property_pointer_funcs(prop, "rna_EditBone_parent_get", "rna_EditBone_parent_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature)."); RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_funcs(prop, "rna_EditBone_roll_get", "rna_EditBone_roll_set", NULL); RNA_def_property_float_funcs(prop, "rna_EditBone_roll_get", "rna_EditBone_roll_set", NULL);
RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis."); RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis.");
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR); prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_EditBone_head_get", "rna_EditBone_head_set", NULL); RNA_def_property_float_funcs(prop, "rna_EditBone_head_get", "rna_EditBone_head_set", NULL);
RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone."); RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone.");
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR); prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_array(prop, 3); RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_EditBone_tail_get", "rna_EditBone_tail_set", NULL); RNA_def_property_float_funcs(prop, "rna_EditBone_tail_get", "rna_EditBone_tail_set", NULL);
RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone."); RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone.");
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
rna_def_bone_common(srna, 1); rna_def_bone_common(srna, 1);
prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_EditBone_hidden_get", "rna_EditBone_hidden_set"); RNA_def_property_boolean_funcs(prop, "rna_EditBone_hidden_get", "rna_EditBone_hidden_set");
RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when in Edit Mode"); RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when in Edit Mode");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_EditBone_locked_get", "rna_EditBone_locked_set"); RNA_def_property_boolean_funcs(prop, "rna_EditBone_locked_get", "rna_EditBone_locked_set");
RNA_def_property_ui_text(prop, "Locked", "Bone is not able to be transformed when in Edit Mode."); RNA_def_property_ui_text(prop, "Locked", "Bone is not able to be transformed when in Edit Mode.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "head_selected", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "head_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_EditBone_head_selected_get", "rna_EditBone_head_selected_set"); RNA_def_property_boolean_funcs(prop, "rna_EditBone_head_selected_get", "rna_EditBone_head_selected_set");
RNA_def_property_ui_text(prop, "Head Selected", ""); RNA_def_property_ui_text(prop, "Head Selected", "");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "tail_selected", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "tail_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_EditBone_tail_selected_get", "rna_EditBone_tail_selected_set"); RNA_def_property_boolean_funcs(prop, "rna_EditBone_tail_selected_get", "rna_EditBone_tail_selected_set");
RNA_def_property_ui_text(prop, "Tail Selected", ""); RNA_def_property_ui_text(prop, "Tail Selected", "");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
} }
void rna_def_armature(BlenderRNA *brna) void rna_def_armature(BlenderRNA *brna)
@ -697,11 +868,13 @@ void rna_def_armature(BlenderRNA *brna)
prop= RNA_def_property(srna, "drawtype", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "drawtype", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_drawtype_items); RNA_def_property_enum_items(prop, prop_drawtype_items);
RNA_def_property_ui_text(prop, "Draw Type", ""); RNA_def_property_ui_text(prop, "Draw Type", "");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "ghost_type", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "ghost_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "ghosttype"); RNA_def_property_enum_sdna(prop, NULL, "ghosttype");
RNA_def_property_enum_items(prop, prop_ghost_type_items); RNA_def_property_enum_items(prop, prop_ghost_type_items);
RNA_def_property_ui_text(prop, "Ghost Drawing", "Method of Onion-skinning for active Action"); RNA_def_property_ui_text(prop, "Ghost Drawing", "Method of Onion-skinning for active Action");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* Boolean values */ /* Boolean values */
/* layer */ /* layer */
@ -717,85 +890,105 @@ void rna_def_armature(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "layer_protected", 1); RNA_def_property_boolean_sdna(prop, NULL, "layer_protected", 1);
RNA_def_property_array(prop, 16); RNA_def_property_array(prop, 16);
RNA_def_property_ui_text(prop, "Layer Proxy Protection", "Protected layers in Proxy Instances are restored to Proxy settings on file reload and undo."); RNA_def_property_ui_text(prop, "Layer Proxy Protection", "Protected layers in Proxy Instances are restored to Proxy settings on file reload and undo.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* flag */ /* flag */
prop= RNA_def_property(srna, "rest_position", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "rest_position", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_RESTPOS); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_RESTPOS);
RNA_def_property_ui_text(prop, "Rest Position", "Show Armature in Rest Position. No posing possible."); RNA_def_property_ui_text(prop, "Rest Position", "Show Armature in Rest Position. No posing possible.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "draw_axes", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "draw_axes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWAXES); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWAXES);
RNA_def_property_ui_text(prop, "Draw Axes", "Draw bone axes."); RNA_def_property_ui_text(prop, "Draw Axes", "Draw bone axes.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "draw_names", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "draw_names", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES);
RNA_def_property_ui_text(prop, "Draw Names", "Draw bone names."); RNA_def_property_ui_text(prop, "Draw Names", "Draw bone names.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "delay_deform", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "delay_deform", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DELAYDEFORM); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DELAYDEFORM);
RNA_def_property_ui_text(prop, "Delay Deform", "Don't deform children when manipulating bones in Pose Mode"); RNA_def_property_ui_text(prop, "Delay Deform", "Don't deform children when manipulating bones in Pose Mode");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "x_axis_mirror", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "x_axis_mirror", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_MIRROR_EDIT); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_MIRROR_EDIT);
RNA_def_property_ui_text(prop, "X-Axis Mirror", "Apply changes to matching bone on opposite side of X-Axis."); RNA_def_property_ui_text(prop, "X-Axis Mirror", "Apply changes to matching bone on opposite side of X-Axis.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "auto_ik", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "auto_ik", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_AUTO_IK); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_AUTO_IK);
RNA_def_property_ui_text(prop, "Auto IK", "Add temporaral IK constraints while grabbing bones in Pose Mode."); RNA_def_property_ui_text(prop, "Auto IK", "Add temporaral IK constraints while grabbing bones in Pose Mode.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "draw_custom_bone_shapes", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "draw_custom_bone_shapes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_NO_CUSTOM); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_NO_CUSTOM);
RNA_def_property_ui_text(prop, "Draw Custom Bone Shapes", "Draw bones with their custom shapes."); RNA_def_property_ui_text(prop, "Draw Custom Bone Shapes", "Draw bones with their custom shapes.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "draw_group_colors", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "draw_group_colors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_COL_CUSTOM); RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_COL_CUSTOM);
RNA_def_property_ui_text(prop, "Draw Bone Group Colors", "Draw bone group colors."); RNA_def_property_ui_text(prop, "Draw Bone Group Colors", "Draw bone group colors.");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "ghost_only_selected", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "ghost_only_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_GHOST_ONLYSEL); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ARM_GHOST_ONLYSEL);
RNA_def_property_ui_text(prop, "Draw Ghosts on Selected Keyframes Only", ""); RNA_def_property_ui_text(prop, "Draw Ghosts on Selected Keyframes Only", "");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* deformflag */ /* deformflag */
prop= RNA_def_property(srna, "deform_vertexgroups", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "deform_vertexgroups", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
RNA_def_property_ui_text(prop, "Deform Vertex Groups", "Enable Vertex Groups when defining deform"); RNA_def_property_ui_text(prop, "Deform Vertex Groups", "Enable Vertex Groups when defining deform");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "deform_envelope", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "deform_envelope", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE);
RNA_def_property_ui_text(prop, "Deform Envelopes", "Enable Bone Envelopes when defining deform"); RNA_def_property_ui_text(prop, "Deform Envelopes", "Enable Bone Envelopes when defining deform");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "deform_quaternion", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "deform_quaternion", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
RNA_def_property_ui_text(prop, "Use Dual Quaternion Deformation", "Enable deform rotation with Quaternions"); RNA_def_property_ui_text(prop, "Use Dual Quaternion Deformation", "Enable deform rotation with Quaternions");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "deform_bbone_rest", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "deform_bbone_rest", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_B_BONE_REST); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_B_BONE_REST);
RNA_def_property_ui_text(prop, "B-Bones Deform in Rest Position", "Make B-Bones deform already in Rest Position"); RNA_def_property_ui_text(prop, "B-Bones Deform in Rest Position", "Make B-Bones deform already in Rest Position");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
//prop= RNA_def_property(srna, "deform_invert_vertexgroups", PROP_BOOLEAN, PROP_NONE); //prop= RNA_def_property(srna, "deform_invert_vertexgroups", PROP_BOOLEAN, PROP_NONE);
//RNA_def_property_boolean_negative_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); //RNA_def_property_boolean_negative_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP);
//RNA_def_property_ui_text(prop, "Invert Vertex Group Influence", "Invert Vertex Group influence (only for Modifiers)"); //RNA_def_property_ui_text(prop, "Invert Vertex Group Influence", "Invert Vertex Group influence (only for Modifiers)");
//RNA_def_property_update(prop, 0, "rna_Armature_update_data");
/* pathflag */ /* pathflag */
prop= RNA_def_property(srna, "paths_show_frame_numbers", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "paths_show_frame_numbers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_FNUMS); RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_FNUMS);
RNA_def_property_ui_text(prop, "Bone Paths Show Frame Numbers", "When drawing Armature in Pose Mode, show frame numbers on Bone Paths"); RNA_def_property_ui_text(prop, "Paths Show Frame Numbers", "When drawing Armature in Pose Mode, show frame numbers on Bone Paths");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "paths_highlight_keyframes", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "paths_highlight_keyframes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_KFRAS); RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_KFRAS);
RNA_def_property_ui_text(prop, "Bone Paths Highlight Keyframes", "When drawing Armature in Pose Mode, emphasize position of keyframes on Bone Paths"); RNA_def_property_ui_text(prop, "Paths Highlight Keyframes", "When drawing Armature in Pose Mode, emphasize position of keyframes on Bone Paths");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "paths_show_keyframe_numbers", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "paths_show_keyframe_numbers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_KFNOS); RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_KFNOS);
RNA_def_property_ui_text(prop, "Bone Paths Show Keyframe Numbers", "When drawing Armature in Pose Mode, show frame numbers of Keyframes on Bone Paths"); RNA_def_property_ui_text(prop, "Paths Show Keyframe Numbers", "When drawing Armature in Pose Mode, show frame numbers of Keyframes on Bone Paths");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "paths_show_around_current_frame", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "paths_show_around_current_frame", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_ACFRA); RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_ACFRA);
RNA_def_property_ui_text(prop, "Bone Paths Around Current Frame", "When drawing Armature in Pose Mode, only show section of Bone Paths that falls around current frame"); RNA_def_property_ui_text(prop, "Paths Around Current Frame", "When drawing Armature in Pose Mode, only show section of Bone Paths that falls around current frame");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "paths_calculate_head_positions", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "paths_calculate_head_positions", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_HEADS); RNA_def_property_boolean_sdna(prop, NULL, "pathflag", ARM_PATH_HEADS);
RNA_def_property_ui_text(prop, "Bone Paths Use Heads", "When calculating Bone Paths, use Head locations instead of Tips"); RNA_def_property_ui_text(prop, "Paths Use Heads", "When calculating Bone Paths, use Head locations instead of Tips");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* Number fields */ /* Number fields */
/* ghost/onionskining settings */ /* ghost/onionskining settings */
@ -803,47 +996,56 @@ void rna_def_armature(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "ghostep"); RNA_def_property_int_sdna(prop, NULL, "ghostep");
RNA_def_property_range(prop, 0, 30); RNA_def_property_range(prop, 0, 30);
RNA_def_property_ui_text(prop, "Ghosting Step", "Number of frame steps on either side of current frame to show as ghosts (only for 'Around Current Frame' Onion-skining method)."); RNA_def_property_ui_text(prop, "Ghosting Step", "Number of frame steps on either side of current frame to show as ghosts (only for 'Around Current Frame' Onion-skining method).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "ghost_size", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "ghost_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "ghostsize"); RNA_def_property_int_sdna(prop, NULL, "ghostsize");
RNA_def_property_range(prop, 1, 20); RNA_def_property_range(prop, 1, 20);
RNA_def_property_ui_text(prop, "Ghosting Frame Step", "Frame step for Ghosts (not for 'On Keyframes' Onion-skining method)."); RNA_def_property_ui_text(prop, "Ghosting Frame Step", "Frame step for Ghosts (not for 'On Keyframes' Onion-skining method).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "ghost_start_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "ghostsf"); RNA_def_property_int_sdna(prop, NULL, "ghostsf");
RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_start_frame_set", NULL); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_start_frame_set", NULL);
RNA_def_property_ui_text(prop, "Ghosting Start Frame", "Starting frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)."); RNA_def_property_ui_text(prop, "Ghosting Start Frame", "Starting frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "ghost_end_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "ghostef"); RNA_def_property_int_sdna(prop, NULL, "ghostef");
RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_end_frame_set", NULL); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_ghost_end_frame_set", NULL);
RNA_def_property_ui_text(prop, "Ghosting End Frame", "End frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method)."); RNA_def_property_ui_text(prop, "Ghosting End Frame", "End frame of range of Ghosts to display (not for 'Around Current Frame' Onion-skinning method).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
/* bone path settings */ /* bone path settings */
prop= RNA_def_property(srna, "path_size", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "path_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pathsize"); RNA_def_property_int_sdna(prop, NULL, "pathsize");
RNA_def_property_range(prop, 1, 100); RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Bone Paths Frame Step", "Number of frames between 'dots' on Bone Paths (when drawing)."); RNA_def_property_ui_text(prop, "Paths Frame Step", "Number of frames between 'dots' on Bone Paths (when drawing).");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_int_sdna(prop, NULL, "pathsf");
RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_start_frame_set", NULL); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_start_frame_set", NULL);
RNA_def_property_ui_text(prop, "Bone Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations."); RNA_def_property_ui_text(prop, "Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pathef"); RNA_def_property_int_sdna(prop, NULL, "pathef");
RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_end_frame_set", NULL); RNA_def_property_int_funcs(prop, NULL, "rna_Armature_path_end_frame_set", NULL);
RNA_def_property_ui_text(prop, "Bone Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); RNA_def_property_ui_text(prop, "Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations.");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "path_before_current", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "path_before_current", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pathbc"); RNA_def_property_int_sdna(prop, NULL, "pathbc");
RNA_def_property_range(prop, 1, MAXFRAMEF/2); RNA_def_property_range(prop, 1, MAXFRAMEF/2);
RNA_def_property_ui_text(prop, "Bone Paths Frames Before Current", "Number of frames before current frame to show on Bone Paths (only for 'Around Current' option)."); RNA_def_property_ui_text(prop, "Paths Frames Before Current", "Number of frames before current frame to show on Bone Paths (only for 'Around Current' option).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop= RNA_def_property(srna, "path_after_current", PROP_INT, PROP_NONE); prop= RNA_def_property(srna, "path_after_current", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pathac"); RNA_def_property_int_sdna(prop, NULL, "pathac");
RNA_def_property_range(prop, 1, MAXFRAMEF/2); RNA_def_property_range(prop, 1, MAXFRAMEF/2);
RNA_def_property_ui_text(prop, "Bone Paths Frames After Current", "Number of frames after current frame to show on Bone Paths (only for 'Around Current' option)."); RNA_def_property_ui_text(prop, "Paths Frames After Current", "Number of frames after current frame to show on Bone Paths (only for 'Around Current' option).");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
} }
void RNA_def_armature(BlenderRNA *brna) void RNA_def_armature(BlenderRNA *brna)

@ -39,12 +39,18 @@
#ifdef RNA_RUNTIME #ifdef RNA_RUNTIME
#include "BLI_arithb.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_depsgraph.h" #include "BKE_depsgraph.h"
#include "BKE_idprop.h" #include "BKE_idprop.h"
#include "ED_armature.h"
static void rna_Pose_update(bContext *C, PointerRNA *ptr) static void rna_Pose_update(bContext *C, PointerRNA *ptr)
{ {
// XXX when to use this? ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_DATA); DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_DATA);
} }
@ -60,6 +66,39 @@ IDProperty *rna_PoseChannel_idproperties(PointerRNA *ptr, int create)
return pchan->prop; return pchan->prop;
} }
static void rna_PoseChannel_euler_rotation_get(PointerRNA *ptr, float *value)
{
bPoseChannel *pchan= ptr->data;
if(pchan->rotmode == PCHAN_ROT_QUAT)
QuatToEul(pchan->quat, value);
else
VECCOPY(value, pchan->eul);
}
static void rna_PoseChannel_euler_rotation_set(PointerRNA *ptr, const float *value)
{
bPoseChannel *pchan= ptr->data;
if(pchan->rotmode == PCHAN_ROT_QUAT)
EulToQuat((float*)value, pchan->quat);
else
VECCOPY(pchan->eul, value);
}
static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
{
Object *ob= (Object*)ptr->id.data;
bPoseChannel *pchan= (bPoseChannel*)ptr->data;
char oldname[32], newname[32];
/* need to be on the stack */
BLI_strncpy(newname, value, 32);
BLI_strncpy(oldname, pchan->name, 32);
ED_armature_bone_rename(ob->data, oldname, newname);
}
#else #else
/* users shouldn't be editing pose channel data directly -- better to set ipos and let blender calc pose_channel stuff */ /* users shouldn't be editing pose channel data directly -- better to set ipos and let blender calc pose_channel stuff */
@ -86,7 +125,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel."); RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel.");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_PoseChannel_name_set");
RNA_def_property_ui_text(prop, "Name", ""); RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop); RNA_def_struct_name_property(srna, prop);
@ -165,6 +204,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop= RNA_def_property(srna, "euler_rotation", PROP_FLOAT, PROP_ROTATION); prop= RNA_def_property(srna, "euler_rotation", PROP_FLOAT, PROP_ROTATION);
RNA_def_property_float_sdna(prop, NULL, "eul"); RNA_def_property_float_sdna(prop, NULL, "eul");
RNA_def_property_float_funcs(prop, "rna_PoseChannel_euler_rotation_get", "rna_PoseChannel_euler_rotation_set", NULL);
RNA_def_property_ui_text(prop, "Rotation (Euler)", "Rotation in Eulers."); RNA_def_property_ui_text(prop, "Rotation (Euler)", "Rotation in Eulers.");
RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update"); RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");