Bone relation lines: draw between axis points #105427
|
@ -80,7 +80,9 @@ class DATA_PT_display(ArmatureButtonsPanel, Panel):
|
|||
sub = row.row(align=True)
|
||||
sub.active = arm.show_axes
|
||||
sub.prop(arm, "axes_position", text="Position")
|
||||
col.prop(arm, "relation_line_position", text="Relations")
|
||||
|
||||
sub = col.row(align=True)
|
||||
sub.prop(arm, "relation_line_position", text="Relations", expand=True)
|
||||
|
||||
|
||||
class DATA_MT_bone_group_context_menu(Menu):
|
||||
|
|
|
@ -3639,7 +3639,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
|
||||
arm->flag &= ~(ARM_FLAG_UNUSED_1 | ARM_FLAG_UNUSED_5 | ARM_FLAG_UNUSED_6 |
|
||||
arm->flag &= ~(ARM_FLAG_UNUSED_1 | ARM_DRAW_RELATION_FROM_HEAD | ARM_FLAG_UNUSED_6 |
|
||||
ARM_FLAG_UNUSED_7 | ARM_FLAG_UNUSED_12);
|
||||
}
|
||||
|
||||
|
|
|
@ -4027,13 +4027,6 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "bArmature", "float", "relation_line_position")) {
|
||||
/* Convert the axes draw position to its default (tip of parent bone). */
|
||||
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
|
||||
arm->relation_line_position = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2025,13 +2025,14 @@ static void draw_bone_bone_line(ArmatureDrawContext *ctx,
|
|||
const float /*bone_tail*/[3],
|
||||
const float parent_head[3],
|
||||
const float parent_tail[3],
|
||||
const float axes_position)
|
||||
const short armature_flags)
|
||||
{
|
||||
/* Only interpolate the parent position. */
|
||||
float parent_pos[3];
|
||||
interp_v3_v3v3(parent_pos, parent_head, parent_tail, axes_position);
|
||||
|
||||
drw_shgroup_bone_relationship_lines(ctx, bone_head, parent_pos);
|
||||
if (armature_flags & ARM_DRAW_RELATION_FROM_HEAD) {
|
||||
drw_shgroup_bone_relationship_lines(ctx, bone_head, parent_head);
|
||||
}
|
||||
else {
|
||||
drw_shgroup_bone_relationship_lines(ctx, bone_head, parent_tail);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_bone_relations(ArmatureDrawContext *ctx,
|
||||
|
@ -2047,12 +2048,8 @@ static void draw_bone_relations(ArmatureDrawContext *ctx,
|
|||
* since riggers will want to know about the links between bones
|
||||
*/
|
||||
if ((boneflag & BONE_CONNECTED) == 0) {
|
||||
draw_bone_bone_line(ctx,
|
||||
ebone->head,
|
||||
ebone->tail,
|
||||
ebone->parent->head,
|
||||
ebone->parent->tail,
|
||||
arm->relation_line_position);
|
||||
draw_bone_bone_line(
|
||||
ctx, ebone->head, ebone->tail, ebone->parent->head, ebone->parent->tail, arm->flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2068,7 +2065,7 @@ static void draw_bone_relations(ArmatureDrawContext *ctx,
|
|||
pchan->pose_tail,
|
||||
pchan->parent->pose_head,
|
||||
pchan->parent->pose_tail,
|
||||
arm->relation_line_position);
|
||||
arm->flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,12 +143,6 @@ typedef struct bArmature {
|
|||
|
||||
/** Relative position of the axes on the bone, from head (0.0f) to tail (1.0f). */
|
||||
float axes_position;
|
||||
|
||||
/** Relative position of the parent-child relation lines on the bone, from
|
||||
* head (0.0f) to tail (1.0f). Only controls the parent side of the line; the
|
||||
* child side is always drawn to the head of the bone. */
|
||||
float relation_line_position;
|
||||
char _pad2[4];
|
||||
} bArmature;
|
||||
|
||||
/* armature->flag */
|
||||
|
@ -160,9 +154,12 @@ typedef enum eArmature_Flag {
|
|||
ARM_DRAWAXES = (1 << 2),
|
||||
ARM_DRAWNAMES = (1 << 3),
|
||||
ARM_POSEMODE = (1 << 4),
|
||||
ARM_FLAG_UNUSED_5 = (1 << 5), /* cleared */
|
||||
ARM_FLAG_UNUSED_6 = (1 << 6), /* cleared */
|
||||
ARM_FLAG_UNUSED_7 = (1 << 7),
|
||||
/** Position of the parent-child relation lines on the bone (cleared = drawn
|
||||
* from the tail, set = drawn from the head). Only controls the parent side of
|
||||
* the line; the child side is always drawn to the head of the bone. */
|
||||
ARM_DRAW_RELATION_FROM_HEAD = (1 << 5), /* Cleared in versioning of pre-2.80 files. */
|
||||
ARM_FLAG_UNUSED_6 = (1 << 6), /* cleared */
|
||||
ARM_FLAG_UNUSED_7 = (1 << 7), /* cleared */
|
||||
ARM_MIRROR_EDIT = (1 << 8),
|
||||
ARM_FLAG_UNUSED_9 = (1 << 9),
|
||||
/** Made option negative, for backwards compatibility. */
|
||||
|
|
|
@ -653,6 +653,30 @@ static void rna_Armature_transform(bArmature *arm, float mat[16])
|
|||
ED_armature_transform(arm, (const float(*)[4])mat, true);
|
||||
}
|
||||
|
||||
static int rna_Armature_relation_line_position_get(PointerRNA *ptr)
|
||||
{
|
||||
bArmature *arm = (bArmature *)ptr->data;
|
||||
/* Translate the bitflag to an EnumPropertyItem prop_relation_lines_items item ID. */
|
||||
return (arm->flag & ARM_DRAW_RELATION_FROM_HEAD) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void rna_Armature_relation_line_position_set(PointerRNA *ptr, const int value)
|
||||
{
|
||||
bArmature *arm = (bArmature *)ptr->data;
|
||||
|
||||
/* Translate the EnumPropertyItem prop_relation_lines_items item ID to a bitflag */
|
||||
switch (value) {
|
||||
case 0:
|
||||
arm->flag &= ~ARM_DRAW_RELATION_FROM_HEAD;
|
||||
break;
|
||||
case 1:
|
||||
arm->flag |= ARM_DRAW_RELATION_FROM_HEAD;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone, bool is_editbone)
|
||||
|
@ -1460,6 +1484,11 @@ static void rna_def_armature(BlenderRNA *brna)
|
|||
"Show Armature in binding pose state (no posing possible)"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
static const EnumPropertyItem prop_relation_lines_items[] = {
|
||||
{0, "Tail", 0, "Tail", "Draw the relationship line from the parent tail to the child head"},
|
||||
{1, "HEAD", 0, "Head", "Draw the relationship line from the parent head to the child head"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "Armature", "ID");
|
||||
RNA_def_struct_ui_text(
|
||||
|
@ -1554,17 +1583,19 @@ static void rna_def_armature(BlenderRNA *brna)
|
|||
"closer to the tip; decreasing moves it closer to the root");
|
||||
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
|
||||
|
||||
prop = RNA_def_property(srna, "relation_line_position", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "relation_line_position");
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 1);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Relation Line Position",
|
||||
"The start position of the relation lines from parent to child bones. Increasing the value "
|
||||
"moves it "
|
||||
"closer to the tip of the parent; decreasing moves it closer to the root");
|
||||
RNA_define_verify_sdna(false); /* This property does not live in DNA. */
|
||||
prop = RNA_def_property(srna, "relation_line_position", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_relation_lines_items);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Relation Line Position",
|
||||
"The start position of the relation lines from parent to child bones");
|
||||
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
|
||||
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
|
||||
RNA_def_property_enum_funcs(prop,
|
||||
"rna_Armature_relation_line_position_get",
|
||||
"rna_Armature_relation_line_position_set",
|
||||
/*item function*/ NULL);
|
||||
RNA_define_verify_sdna(true); /* Restore default. */
|
||||
|
||||
prop = RNA_def_property(srna, "show_names", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES);
|
||||
|
|
Loading…
Reference in New Issue