- added editbone.matrix, readonly, utility property that calculates the matrix from the bone roll
- spine fixes - arm now uses the average Z axis to place the poll target
This commit is contained in:
@@ -359,11 +359,18 @@ def add_pole_target_bone(obj, base_name, name, mode='CROSS'):
|
||||
parent_dir = parent_head - parent_tail
|
||||
|
||||
distance = (base_dir.length + parent_dir.length)
|
||||
|
||||
|
||||
if mode == 'CROSS':
|
||||
# direction from the angle of the joint
|
||||
offset = base_dir.copy().normalize() - parent_dir.copy().normalize()
|
||||
offset.length = distance
|
||||
elif mode == 'ZAVERAGE':
|
||||
# between both bones Z axis
|
||||
z_axis_a = base_ebone.matrix.copy().rotationPart() * Vector(0.0, 0.0, -1.0)
|
||||
z_axis_b = parent_ebone.matrix.copy().rotationPart() * Vector(0.0, 0.0, -1.0)
|
||||
offset = (z_axis_a + z_axis_b).normalize() * distance
|
||||
else:
|
||||
# preset axis
|
||||
offset = Vector(0, 0, 0)
|
||||
if mode[0] == "+":
|
||||
val = distance
|
||||
|
||||
@@ -111,7 +111,7 @@ def ik(obj, definitions, base_names):
|
||||
ik_chain.arm_e.parent = mt.shoulder_e
|
||||
|
||||
# Add the bone used for the arms poll target
|
||||
ik.pole = add_pole_target_bone(obj, mt.forearm, "elbow_poll", mode='+Z')
|
||||
ik.pole = add_pole_target_bone(obj, mt.forearm, "elbow_poll", mode='ZAVERAGE')
|
||||
|
||||
# update bones after this!
|
||||
ik.hand_vis = add_stretch_to(obj, mt.hand, ik_chain.hand, "VIS-%s_ik" % base_names[mt.hand])
|
||||
|
||||
@@ -178,16 +178,16 @@ def main(obj, bone_definition, base_names):
|
||||
df.ribcage_e = copy_bone_simple(arm, child.name, "DEF-wgt_%s" % base_names[mt.ribcage])
|
||||
df.ribcage = df.ribcage_e.name
|
||||
df.ribcage_e.translate(Vector(spine_chain_segment_length * 2.0, - df.ribcage_e.length / 2.0, 0.0))
|
||||
|
||||
ex.ribcage_copy_e = copy_bone_simple(arm, mt.ribcage, base_names[mt.ribcage])
|
||||
ex.ribcage_copy = ex.ribcage_copy_e.name
|
||||
ex.ribcage_copy_e.connected = False
|
||||
ex.ribcage_copy_e.parent = ex.ribcage_hinge_e
|
||||
|
||||
ex.ribcage_e = copy_bone_simple(arm, child.name, "MCH-wgt_%s" % base_names[mt.ribcage])
|
||||
ex.ribcage = ex.ribcage_e.name
|
||||
ex.ribcage_e.translate(Vector(0.0, - ex.ribcage_e.length / 2.0, 0.0))
|
||||
ex.ribcage_e.parent = mt.ribcage_e
|
||||
|
||||
ex.ribcage_copy_e = copy_bone_simple(arm, child.name, base_names[mt.ribcage])
|
||||
ex.ribcage_copy = ex.ribcage_copy_e.name
|
||||
ex.ribcage_copy_e.connected = False
|
||||
ex.ribcage_copy_e.parent = ex.ribcage_hinge_e
|
||||
ex.ribcage_e.parent = ex.ribcage_copy_e
|
||||
|
||||
spine_chain = [child.name for child in spine_chain]
|
||||
|
||||
@@ -294,6 +294,8 @@ def main(obj, bone_definition, base_names):
|
||||
con.target_space = 'LOCAL'
|
||||
|
||||
# df.ribcage_p / DEF-wgt_rib_cage
|
||||
df.ribcage_p.lock_location = True, True, True
|
||||
|
||||
con = df.ribcage_p.constraints.new('COPY_ROTATION')
|
||||
con.target = obj
|
||||
con.subtarget = ex.ribcage
|
||||
@@ -329,7 +331,7 @@ def main(obj, bone_definition, base_names):
|
||||
|
||||
con = ex.spine_rotate_p.constraints.new('COPY_ROTATION')
|
||||
con.target = obj
|
||||
con.subtarget = mt.ribcage
|
||||
con.subtarget = ex.ribcage_copy
|
||||
|
||||
|
||||
# ex.pelvis_p / MCH-wgt_pelvis
|
||||
|
||||
@@ -43,9 +43,10 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_main.h""
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "BKE_armature.h"
|
||||
|
||||
static void rna_Armature_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
@@ -304,6 +305,21 @@ static void rna_EditBone_parent_set(PointerRNA *ptr, PointerRNA value)
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_EditBone_matrix_get(PointerRNA *ptr, float *values)
|
||||
{
|
||||
EditBone *ebone= (EditBone*)(ptr->data);
|
||||
|
||||
float delta[3], tmat[3][3], mat[4][4];
|
||||
|
||||
/* Find the current bone matrix */
|
||||
sub_v3_v3v3(delta, ebone->tail, ebone->head);
|
||||
vec_roll_to_mat3(delta, ebone->roll, tmat);
|
||||
copy_m4_m3(mat, tmat);
|
||||
VECCOPY(mat[3], ebone->head);
|
||||
|
||||
memcpy(values, mat, 16 * sizeof(float));
|
||||
}
|
||||
|
||||
static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
bArmature *arm= (bArmature*)ptr->id.data;
|
||||
@@ -618,6 +634,14 @@ static void rna_def_edit_bone(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Tail Selected", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
|
||||
|
||||
/* calculated and read only, not actual data access */
|
||||
prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
|
||||
//RNA_def_property_float_sdna(prop, NULL, ""); // doesnt access any real data
|
||||
RNA_def_property_array(prop, 16);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Editbone Matrix", "Read-only matrix calculated from the roll (armature space).");
|
||||
RNA_def_property_float_funcs(prop, "rna_EditBone_matrix_get", NULL, NULL); // TODO - this could be made writable also
|
||||
|
||||
RNA_api_armature_edit_bone(srna);
|
||||
|
||||
RNA_define_verify_sdna(1);
|
||||
|
||||
@@ -192,7 +192,9 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
}
|
||||
|
||||
fprintf(stderr, "\tBPY_pydriver_eval() - couldn't add variable '%s' to namespace \n", dtar->name);
|
||||
BPy_errors_to_report(NULL); // TODO - reports
|
||||
// BPy_errors_to_report(NULL); // TODO - reports
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user