Fixed remaining bugs with animating rotation modes:
* Removed the hack-functions to set euler rotations from the values set in the other rotation representations, even when euler rotations weren't being used. I pressume that this was added for being able to represent quats in terms of eulers for the UI, but really it would break animation evaluation (i.e. euler curves after quaternion curves would always block the quaternion curves). * Object rotation values in the transform properties panel now take into account rotation modes, so the appropriate rotations will get converted to quaternions before being drawn. * Fixed a few bugs with some of the conversion code (minor stuff left out).
This commit is contained in:
@@ -1314,7 +1314,7 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float *axis, float
|
||||
else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */
|
||||
if (oldMode > 0) {
|
||||
/* euler to axis angle */
|
||||
EulOToAxisAngle(eul, oldMode, &quat[1], &quat[0]);
|
||||
EulOToAxisAngle(eul, oldMode, axis, angle);
|
||||
}
|
||||
else if (oldMode == ROT_MODE_QUAT) {
|
||||
/* quat to axis angle */
|
||||
|
||||
@@ -520,7 +520,7 @@ static void v3d_posearmature_buts(uiBlock *block, View3D *v3d, Object *ob, float
|
||||
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
float quat[4];
|
||||
/* convert to euler, passing through quats... */
|
||||
AxisAngleToQuat(quat, &pchan->quat[1], pchan->quat[0]);
|
||||
AxisAngleToQuat(quat, pchan->rotAxis, pchan->rotAngle);
|
||||
QuatToEul(quat, tfp->ob_eul);
|
||||
}
|
||||
else if (pchan->rotmode == ROT_MODE_QUAT)
|
||||
@@ -689,10 +689,24 @@ static void do_view3d_region_buttons(bContext *C, void *arg, int event)
|
||||
|
||||
case B_OBJECTPANELROT:
|
||||
if(ob) {
|
||||
// TODO: need to support roation modes
|
||||
ob->rot[0]= M_PI*tfp->ob_eul[0]/180.0;
|
||||
ob->rot[1]= M_PI*tfp->ob_eul[1]/180.0;
|
||||
ob->rot[2]= M_PI*tfp->ob_eul[2]/180.0;
|
||||
float eul[3];
|
||||
|
||||
/* make a copy to eul[3], to allow TAB on buttons to work */
|
||||
eul[0]= M_PI*tfp->ob_eul[0]/180.0;
|
||||
eul[1]= M_PI*tfp->ob_eul[1]/180.0;
|
||||
eul[2]= M_PI*tfp->ob_eul[2]/180.0;
|
||||
|
||||
if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
||||
float quat[4];
|
||||
/* convert to axis-angle, passing through quats */
|
||||
EulToQuat(eul, quat);
|
||||
QuatToAxisAngle(quat, ob->rotAxis, &ob->rotAngle);
|
||||
}
|
||||
else if (ob->rotmode == ROT_MODE_QUAT)
|
||||
EulToQuat(eul, ob->quat);
|
||||
else
|
||||
VecCopyf(ob->rot, eul);
|
||||
|
||||
DAG_id_flush_update(&ob->id, OB_RECALC_OB);
|
||||
}
|
||||
break;
|
||||
@@ -1130,9 +1144,19 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
|
||||
uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, ICON_UNLOCKED, 125, 240, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Z Location value from being Transformed");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
tfp->ob_eul[0]= 180.0*ob->rot[0]/M_PI;
|
||||
tfp->ob_eul[1]= 180.0*ob->rot[1]/M_PI;
|
||||
tfp->ob_eul[2]= 180.0*ob->rot[2]/M_PI;
|
||||
if (ob->rotmode == ROT_MODE_AXISANGLE) {
|
||||
float quat[4];
|
||||
/* convert to euler, passing through quats... */
|
||||
AxisAngleToQuat(quat, ob->rotAxis, ob->rotAngle);
|
||||
QuatToEul(quat, tfp->ob_eul);
|
||||
}
|
||||
else if (ob->rotmode == ROT_MODE_QUAT)
|
||||
QuatToEul(ob->quat, tfp->ob_eul);
|
||||
else
|
||||
VecCopyf(tfp->ob_eul, ob->rot);
|
||||
tfp->ob_eul[0]*= 180.0/M_PI;
|
||||
tfp->ob_eul[1]*= 180.0/M_PI;
|
||||
tfp->ob_eul[2]*= 180.0/M_PI;
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
if ((ob->parent) && (ob->partype == PARBONE)) {
|
||||
|
||||
@@ -458,32 +458,6 @@ static void rna_Object_active_particle_system_index_set(struct PointerRNA *ptr,
|
||||
psys_set_current_num(ob, value);
|
||||
}
|
||||
|
||||
/* rotation - euler angles */
|
||||
static void rna_Object_rotation_euler_get(PointerRNA *ptr, float *value)
|
||||
{
|
||||
Object *ob= ptr->data;
|
||||
|
||||
if(ob->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
|
||||
AxisAngleToEulO(&ob->quat[1], ob->quat[0], value, EULER_ORDER_DEFAULT);
|
||||
else if(ob->rotmode == ROT_MODE_QUAT) /* default XYZ eulers */
|
||||
QuatToEul(ob->quat, value);
|
||||
else
|
||||
VECCOPY(value, ob->rot);
|
||||
}
|
||||
|
||||
/* rotation - euler angles */
|
||||
static void rna_Object_rotation_euler_set(PointerRNA *ptr, const float *value)
|
||||
{
|
||||
Object *ob= ptr->data;
|
||||
|
||||
if(ob->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
|
||||
EulOToAxisAngle((float *)value, EULER_ORDER_DEFAULT, &ob->quat[1], &ob->quat[0]);
|
||||
else if(ob->rotmode == ROT_MODE_QUAT) /* default XYZ eulers */
|
||||
EulToQuat((float*)value, ob->quat);
|
||||
else
|
||||
VECCOPY(ob->rot, value);
|
||||
}
|
||||
|
||||
/* rotation - axis-angle */
|
||||
static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
|
||||
{
|
||||
@@ -1271,7 +1245,6 @@ static void rna_def_object(BlenderRNA *brna)
|
||||
|
||||
prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
|
||||
RNA_def_property_float_sdna(prop, NULL, "rot");
|
||||
RNA_def_property_float_funcs(prop, "rna_Object_rotation_euler_get", "rna_Object_rotation_euler_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers.");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
|
||||
|
||||
|
||||
@@ -156,32 +156,6 @@ static void rna_Pose_ik_solver_update(bContext *C, PointerRNA *ptr)
|
||||
DAG_id_flush_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB);
|
||||
}
|
||||
|
||||
/* rotation - euler angles */
|
||||
static void rna_PoseChannel_rotation_euler_get(PointerRNA *ptr, float *value)
|
||||
{
|
||||
bPoseChannel *pchan= ptr->data;
|
||||
|
||||
if(pchan->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
|
||||
AxisAngleToEulO(pchan->rotAxis, pchan->rotAngle, value, EULER_ORDER_DEFAULT);
|
||||
else if(pchan->rotmode == ROT_MODE_QUAT) /* default XYZ eulers */
|
||||
QuatToEul(pchan->quat, value);
|
||||
else
|
||||
VECCOPY(value, pchan->eul);
|
||||
}
|
||||
|
||||
/* rotation - euler angles */
|
||||
static void rna_PoseChannel_rotation_euler_set(PointerRNA *ptr, const float *value)
|
||||
{
|
||||
bPoseChannel *pchan= ptr->data;
|
||||
|
||||
if(pchan->rotmode == ROT_MODE_AXISANGLE) /* default XYZ eulers */
|
||||
EulOToAxisAngle((float *)value, EULER_ORDER_DEFAULT, pchan->rotAxis, &pchan->rotAngle);
|
||||
else if(pchan->rotmode == ROT_MODE_QUAT) /* default XYZ eulers */
|
||||
EulToQuat((float*)value, pchan->quat);
|
||||
else
|
||||
VECCOPY(pchan->eul, value);
|
||||
}
|
||||
|
||||
/* rotation - axis-angle */
|
||||
static void rna_PoseChannel_rotation_axis_angle_get(PointerRNA *ptr, float *value)
|
||||
{
|
||||
@@ -607,7 +581,6 @@ static void rna_def_pose_channel(BlenderRNA *brna)
|
||||
|
||||
prop= RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
|
||||
RNA_def_property_float_sdna(prop, NULL, "eul");
|
||||
RNA_def_property_float_funcs(prop, "rna_PoseChannel_rotation_euler_get", "rna_PoseChannel_rotation_euler_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers.");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update");
|
||||
|
||||
@@ -617,15 +590,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
|
||||
RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Rotation Mode", "");
|
||||
RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
|
||||
|
||||
/* These three matrix properties await an implementation of the PROP_MATRIX subtype, which currently doesn't exist. */
|
||||
|
||||
/* transform matrices - should be read-only since these are set directly by AnimSys evaluation */
|
||||
prop= RNA_def_property(srna, "channel_matrix", PROP_FLOAT, PROP_MATRIX);
|
||||
RNA_def_property_float_sdna(prop, NULL, "chan_mat");
|
||||
RNA_def_property_array(prop, 16);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Channel Matrix", "4x4 matrix, before constraints.");
|
||||
|
||||
/* kaito says this should be not user-editable; I disagree; power users should be able to force this in python; he's the boss. */
|
||||
|
||||
prop= RNA_def_property(srna, "pose_matrix", PROP_FLOAT, PROP_MATRIX);
|
||||
RNA_def_property_float_sdna(prop, NULL, "pose_mat");
|
||||
RNA_def_property_array(prop, 16);
|
||||
|
||||
Reference in New Issue
Block a user