minor code cleanup
This commit is contained in:
		@@ -68,7 +68,7 @@ def bake_action(frame_start,
 | 
			
		||||
    # Helper Functions
 | 
			
		||||
 | 
			
		||||
    def pose_frame_info(obj):
 | 
			
		||||
        from mathutils import Matrix, Euler
 | 
			
		||||
        from mathutils import Matrix
 | 
			
		||||
 | 
			
		||||
        info = {}
 | 
			
		||||
 | 
			
		||||
@@ -201,14 +201,14 @@ def bake_action(frame_start,
 | 
			
		||||
            elif rotation_mode == 'AXIS_ANGLE':
 | 
			
		||||
                pbone.keyframe_insert("rotation_axis_angle", -1, f, name)
 | 
			
		||||
            else:  # euler, XYZ, ZXY etc
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                if euler_prev is not None:
 | 
			
		||||
                    euler = pbone.rotation_euler.copy()
 | 
			
		||||
                    euler.make_compatible(euler_prev)
 | 
			
		||||
                    pbone.rotation_euler = euler
 | 
			
		||||
                    euler_prev = euler
 | 
			
		||||
                    del euler
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                pbone.keyframe_insert("rotation_euler", -1, f, name)
 | 
			
		||||
 | 
			
		||||
                if euler_prev is None:
 | 
			
		||||
 
 | 
			
		||||
@@ -1514,7 +1514,7 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
 | 
			
		||||
			/* end drot correction */
 | 
			
		||||
 | 
			
		||||
			if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
 | 
			
		||||
			else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
 | 
			
		||||
			else            mat3_to_eulO(ob->rot, ob->rotmode, tmat);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -151,10 +151,10 @@ void mat3_to_eulO(float eul[3], const short order, float mat[3][3]);
 | 
			
		||||
void mat4_to_eulO(float eul[3], const short order, float mat[4][4]);
 | 
			
		||||
void axis_angle_to_eulO(float eul[3], const short order, const float axis[3], const float angle);
 | 
			
		||||
 | 
			
		||||
void mat3_to_compatible_eulO(float eul[3], float old[3], short order, float mat[3][3]);
 | 
			
		||||
void mat4_to_compatible_eulO(float eul[3], float old[3], short order, float mat[4][4]);
 | 
			
		||||
void mat3_to_compatible_eulO(float eul[3], float old[3], const short order, float mat[3][3]);
 | 
			
		||||
void mat4_to_compatible_eulO(float eul[3], float old[3], const short order, float mat[4][4]);
 | 
			
		||||
 | 
			
		||||
void rotate_eulO(float eul[3], short order, char axis, float angle);
 | 
			
		||||
void rotate_eulO(float eul[3], const short order, char axis, float angle);
 | 
			
		||||
 | 
			
		||||
/******************************* Dual Quaternions ****************************/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1231,7 +1231,7 @@ void eulO_to_mat3(float M[3][3], const float e[3], const short order)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* returns two euler calculation methods, so we can pick the best */
 | 
			
		||||
static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order)
 | 
			
		||||
static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, const short order)
 | 
			
		||||
{
 | 
			
		||||
	RotOrderInfo *R = GET_ROTATIONORDER_INFO(order);
 | 
			
		||||
	short i = R->axis[0], j = R->axis[1], k = R->axis[2];
 | 
			
		||||
@@ -1311,7 +1311,7 @@ void mat4_to_eulO(float e[3], const short order, float M[4][4])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* uses 2 methods to retrieve eulers, and picks the closest */
 | 
			
		||||
void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order, float mat[3][3])
 | 
			
		||||
void mat3_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float mat[3][3])
 | 
			
		||||
{
 | 
			
		||||
	float eul1[3], eul2[3];
 | 
			
		||||
	float d1, d2;
 | 
			
		||||
@@ -1331,7 +1331,7 @@ void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order, float m
 | 
			
		||||
		copy_v3_v3(eul, eul1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order, float M[4][4])
 | 
			
		||||
void mat4_to_compatible_eulO(float eul[3], float oldrot[3], const short order, float M[4][4])
 | 
			
		||||
{
 | 
			
		||||
	float m[3][3];
 | 
			
		||||
 | 
			
		||||
@@ -1343,7 +1343,7 @@ void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order, float M
 | 
			
		||||
/* rotate the given euler by the given angle on the specified axis */
 | 
			
		||||
// NOTE: is this safe to do with different axis orders?
 | 
			
		||||
 | 
			
		||||
void rotate_eulO(float beul[3], short order, char axis, float ang)
 | 
			
		||||
void rotate_eulO(float beul[3], const short order, char axis, float ang)
 | 
			
		||||
{
 | 
			
		||||
	float eul[3], mat1[3][3], mat2[3][3], totmat[3][3];
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -369,7 +369,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
 | 
			
		||||
 | 
			
		||||
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop,
 | 
			
		||||
                                                  Py_ssize_t start, Py_ssize_t stop, Py_ssize_t length);
 | 
			
		||||
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback);
 | 
			
		||||
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, const short order_fallback);
 | 
			
		||||
 | 
			
		||||
/* bpyrna vector/euler/quat callbacks */
 | 
			
		||||
static unsigned char mathutils_rna_array_cb_index = -1; /* index for our callbacks */
 | 
			
		||||
@@ -571,7 +571,7 @@ static Mathutils_Callback mathutils_rna_matrix_cb = {
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback)
 | 
			
		||||
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, const short order_fallback)
 | 
			
		||||
{
 | 
			
		||||
	/* attempt to get order */
 | 
			
		||||
	if (*prop_eul_order == NULL)
 | 
			
		||||
 
 | 
			
		||||
@@ -701,7 +701,7 @@ PyTypeObject euler_Type = {
 | 
			
		||||
 * (i.e. it was allocated elsewhere by MEM_mallocN())
 | 
			
		||||
 * pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
 | 
			
		||||
 * (i.e. it must be created here with PyMEM_malloc())*/
 | 
			
		||||
PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *base_type)
 | 
			
		||||
PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type)
 | 
			
		||||
{
 | 
			
		||||
	EulerObject *self;
 | 
			
		||||
 | 
			
		||||
@@ -738,7 +738,7 @@ PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *
 | 
			
		||||
	return (PyObject *)self;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order,
 | 
			
		||||
PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order,
 | 
			
		||||
                                  unsigned char cb_type, unsigned char cb_subtype)
 | 
			
		||||
{
 | 
			
		||||
	EulerObject *self = (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL);
 | 
			
		||||
 
 | 
			
		||||
@@ -48,8 +48,8 @@ typedef struct {
 | 
			
		||||
 * blender (stored in blend_data). This is an either/or struct not both */
 | 
			
		||||
 | 
			
		||||
//prototypes
 | 
			
		||||
PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *base_type);
 | 
			
		||||
PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order,
 | 
			
		||||
PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type);
 | 
			
		||||
PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order,
 | 
			
		||||
                                  unsigned char cb_type, unsigned char cb_subtype);
 | 
			
		||||
 | 
			
		||||
short euler_order_from_string(const char *str, const char *error_prefix);
 | 
			
		||||
 
 | 
			
		||||
@@ -995,7 +995,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
 | 
			
		||||
 | 
			
		||||
	if (eul_compat) {
 | 
			
		||||
		if (order == 1) mat3_to_compatible_eul(eul, eul_compatf, mat);
 | 
			
		||||
		else mat3_to_compatible_eulO(eul, eul_compatf, order, mat);
 | 
			
		||||
		else            mat3_to_compatible_eulO(eul, eul_compatf, order, mat);
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		if (order == 1) mat3_to_eul(eul, mat);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user