Math lib: simplify size_to_mat4 and use in b_bone_spline_setup

This commit is contained in:
2014-02-02 01:27:06 +11:00
parent 5fce3457b7
commit 798e684c7c
2 changed files with 20 additions and 13 deletions

View File

@@ -431,21 +431,17 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2;
float mat3[3][3], imat[4][4], posemat[4][4], scalemat[4][4], iscalemat[4][4];
float data[MAX_BBONE_SUBDIV + 1][4], *fp;
int a, do_scale = 0;
int a;
bool do_scale = false;
length = bone->length;
if (!rest) {
/* check if we need to take non-uniform bone scaling into account */
scale[0] = len_v3(pchan->pose_mat[0]);
scale[1] = len_v3(pchan->pose_mat[1]);
scale[2] = len_v3(pchan->pose_mat[2]);
mat4_to_size(scale, pchan->pose_mat);
if (fabsf(scale[0] - scale[1]) > 1e-6f || fabsf(scale[1] - scale[2]) > 1e-6f) {
unit_m4(scalemat);
scalemat[0][0] = scale[0];
scalemat[1][1] = scale[1];
scalemat[2][2] = scale[2];
size_to_mat4(scalemat, scale);
invert_m4_m4(iscalemat, scalemat);
length *= scale[1];

View File

@@ -1236,11 +1236,22 @@ void size_to_mat3(float mat[3][3], const float size[3])
void size_to_mat4(float mat[4][4], const float size[3])
{
float tmat[3][3];
size_to_mat3(tmat, size);
unit_m4(mat);
copy_m4_m3(mat, tmat);
mat[0][0] = size[0];
mat[0][1] = 0.0f;
mat[0][2] = 0.0f;
mat[0][3] = 0.0f;
mat[1][0] = 0.0f;
mat[1][1] = size[1];
mat[1][2] = 0.0f;
mat[1][3] = 0.0f;
mat[2][0] = 0.0f;
mat[2][1] = 0.0f;
mat[2][2] = size[2];
mat[2][3] = 0.0f;
mat[3][0] = 0.0f;
mat[3][1] = 0.0f;
mat[3][2] = 0.0f;
mat[3][3] = 1.0f;
}
void mat3_to_size(float size[3], float mat[3][3])