Armature: Add Display Axis Offset
Display the bone axes at the head (root) of the bone by default, instead of the tail (tip), and add a slider so that it's possible to adjust this position. Versioning code is in place to ensure existing files behave the same (axes shown at tail), whereas new Armatures will be using the new default (axes shown at head). Reviewed By: #animation_rigging, #user_interface, Severin, Sybren Differential Revision: https://developer.blender.org/D7685
This commit is contained in:
parent
0d65d27386
commit
74d5a93b2b
|
@ -86,12 +86,19 @@ class DATA_PT_display(ArmatureButtonsPanel, Panel):
|
|||
|
||||
col = layout.column(heading="Show")
|
||||
col.prop(arm, "show_names", text="Names")
|
||||
col.prop(arm, "show_axes", text="Axes")
|
||||
col.prop(arm, "show_bone_custom_shapes", text="Shapes")
|
||||
col.prop(arm, "show_group_colors", text="Group Colors")
|
||||
|
||||
if ob:
|
||||
col.prop(ob, "show_in_front", text="In Front")
|
||||
|
||||
col = layout.column(align=False, heading="Axes")
|
||||
row = col.row(align=True)
|
||||
row.prop(arm, "show_axes", text="")
|
||||
sub = row.row(align=True)
|
||||
sub.active = arm.show_axes
|
||||
sub.prop(arm, "axes_position", text="Position")
|
||||
|
||||
|
||||
class DATA_MT_bone_group_context_menu(Menu):
|
||||
bl_label = "Bone Group Specials"
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_cachefile_types.h"
|
||||
#include "DNA_collection_types.h"
|
||||
|
@ -1948,5 +1949,12 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "bArmature", "float", "axes_position")) {
|
||||
/* Convert the axes draw position to its old default (tip of bone). */
|
||||
LISTBASE_FOREACH (struct bArmature *, arm, &bmain->armatures) {
|
||||
arm->axes_position = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1293,11 +1293,15 @@ static void draw_axes(ArmatureDrawContext *ctx,
|
|||
float length = pchan->bone->length;
|
||||
copy_m4_m4(axis_mat, pchan->custom_tx ? pchan->custom_tx->pose_mat : pchan->pose_mat);
|
||||
rescale_m4(axis_mat, (float[3]){length, length, length});
|
||||
translate_m4(axis_mat, 0.0, arm->axes_position - 1.0, 0.0);
|
||||
|
||||
drw_shgroup_bone_axes(ctx, axis_mat, final_col);
|
||||
}
|
||||
else {
|
||||
drw_shgroup_bone_axes(ctx, BONE_VAR(eBone, pchan, disp_mat), final_col);
|
||||
float disp_mat[4][4];
|
||||
copy_m4_m4(disp_mat, BONE_VAR(eBone, pchan, disp_mat));
|
||||
translate_m4(disp_mat, 0.0, arm->axes_position - 1.0, 0.0);
|
||||
drw_shgroup_bone_axes(ctx, disp_mat, final_col);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ typedef struct bArmature {
|
|||
|
||||
/** ID data is older than edit-mode data (TODO: move to edit-mode struct). */
|
||||
char needs_flush_to_id;
|
||||
char _pad0[7];
|
||||
char _pad0[3];
|
||||
|
||||
int flag;
|
||||
int drawtype;
|
||||
|
@ -146,6 +146,9 @@ typedef struct bArmature {
|
|||
unsigned int layer_used;
|
||||
/** For buttons to work, both variables in this order together. */
|
||||
unsigned int layer, layer_protected;
|
||||
|
||||
/** Relative position of the axes on the bone, from head (0.0f) to tail (1.0f). */
|
||||
float axes_position;
|
||||
} bArmature;
|
||||
|
||||
/* armature->flag */
|
||||
|
|
|
@ -1537,6 +1537,16 @@ static void rna_def_armature(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
|
||||
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
|
||||
|
||||
prop = RNA_def_property(srna, "axes_position", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "axes_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,
|
||||
"Axes Position",
|
||||
"The position for the axes on the bone. Increasing the value moves it "
|
||||
"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, "show_names", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", ARM_DRAWNAMES);
|
||||
RNA_def_property_ui_text(prop, "Display Names", "Display bone names");
|
||||
|
|
Loading…
Reference in New Issue