diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-01-22 16:05:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-05-17 17:27:25 +0300 |
commit | acd85889e244b149fe5ce14be831ea196fad6c44 (patch) | |
tree | 943e549c2ff826c39a8f8871886fa34281b82de5 /source | |
parent | d8ef9ec1a85f51db4ae56decd404352d8de9f8d8 (diff) |
Code Cleanup
* Roll angles should be stored in radians, and displayed using the appropriate
RNA type instead
* Some general code cleanup work (style, avoid type conversions, etc.)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 89 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 8 |
2 files changed, 47 insertions, 50 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0af69e8efac..5b87c1dc2da 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -602,12 +602,12 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB } /* add extra rolls */ - float extraRoll1 = bone->roll1 / (180 / M_PI); + float extraRoll1 = bone->roll1; if (bone->flag & BONE_ADD_PARENT_END_ROLL){ - extraRoll1 = extraRoll1 + prev->bone->roll2 / (180 / M_PI); + extraRoll1 = extraRoll1 + prev->bone->roll2; } - float extraRoll2 = bone->roll2 / (180 / M_PI); + float extraRoll2 = bone->roll2; roll1 = roll1 + extraRoll1; roll2 = roll2 + extraRoll2; @@ -742,10 +742,7 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D y = mat[0][1] * co[0] + mat[1][1] * co[1] + mat[2][1] * co[2] + mat[3][1]; z = mat[0][2] * co[0] + mat[1][2] * co[1] + mat[2][2] * co[2] + mat[3][2]; - float pos[3]; - pos[0] = x; - pos[1] = y; - pos[2] = z; + float pos[3] = {x, y, z}; //print_m4("mat",mat); //print_v3("pos", pos); @@ -765,20 +762,20 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D /* start scale in/out deform*/ - float scaleFactorIn = 1.0 + (bone->scaleIn - 1.0)*((1.0*(bone->segments - a - 1)) / (1.0*(bone->segments - 1)));; - float scaleFactorOut = 1.0 + (bone->scaleOut - 1.0)*((1.0*(a + 1)) / (1.0*(bone->segments - 1))); + float scaleFactorIn = 1.0f + (bone->scaleIn - 1.0f) * ((1.0f * (bone->segments - a - 1)) / (1.0f * (bone->segments - 1))); + float scaleFactorOut = 1.0f + (bone->scaleOut - 1.0f) * ((1.0f * (a + 1)) / (1.0f * (bone->segments - 1))); float bscalemat[4][4], ibscalemat[4][4]; float bscale[3]; - bscale[0] = 1.0*scaleFactorIn*scaleFactorOut; - bscale[1] = 1.0*scaleFactorIn*scaleFactorOut; - bscale[2] = 1.0; + bscale[0] = 1.0f * scaleFactorIn * scaleFactorOut; + bscale[1] = 1.0f * scaleFactorIn * scaleFactorOut; + bscale[2] = 1.0f; size_to_mat4(bscalemat, bscale); - bscalemat[3][0] = -1.0*bone->arm_head[0] * (bscale[0] - 1.0); - bscalemat[3][1] = -1.0*bone->arm_head[1] * (bscale[1] - 1.0); + bscalemat[3][0] = -1.0f * bone->arm_head[0] * (bscale[0] - 1.0f); + bscalemat[3][1] = -1.0f * bone->arm_head[1] * (bscale[1] - 1.0f); //bscalemat[3][3] = 1.0; @@ -794,31 +791,31 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D /* start extra roll deform*/ - float extraRoll1 = (bone->roll1 / (180 / M_PI))*((1.0*(bone->segments - a - 1)) / (1.0*(bone->segments - 1))); - float extraRoll2 = (bone->roll2 / (180 / M_PI))*((1.0*(a + 1)) / (1.0*(bone->segments - 1))); + float extraRoll1 = bone->roll1 * ((1.0f * (bone->segments - a - 1)) / (1.0f * (bone->segments - 1))); + float extraRoll2 = bone->roll2 * ((1.0f * (a + 1)) / (1.0f * (bone->segments - 1))); float extraRoll = extraRoll2 - extraRoll1; - float cosExtraRoll = cos(extraRoll); - float sinExtraRoll = sin(extraRoll); + float cosExtraRoll = cosf(extraRoll); + float sinExtraRoll = sinf(extraRoll); float matRot[4][4]; matRot[0][0] = cosExtraRoll; matRot[0][1] = -sinExtraRoll; - matRot[0][2] = 0.0; - matRot[0][3] = 0.0; + matRot[0][2] = 0.0f; + matRot[0][3] = 0.0f; matRot[1][0] = sinExtraRoll; matRot[1][1] = cosExtraRoll; - matRot[1][2] = 0.0; - matRot[1][3] = 0.0; - matRot[2][0] = 0.0; - matRot[2][1] = 0.0; - matRot[2][2] = 1.0; - matRot[2][3] = 0.0; - matRot[3][0] = 0.0; - matRot[3][1] = 0.0; - matRot[3][2] = 0.0; - matRot[3][3] = 1.0; + matRot[1][2] = 0.0f; + matRot[1][3] = 0.0f; + matRot[2][0] = 0.0f; + matRot[2][1] = 0.0f; + matRot[2][2] = 1.0f; + matRot[2][3] = 0.0f; + matRot[3][0] = 0.0f; + matRot[3][1] = 0.0f; + matRot[3][2] = 0.0f; + matRot[3][3] = 1.0f; //mul_m4_v3(matRot, co); @@ -828,22 +825,22 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D /* start x/y pos deform */ float matPos[4][4]; - matPos[0][0] = 1.0; - matPos[0][1] = 0.0; - matPos[0][2] = 0.0; - matPos[0][3] = 0.0; - matPos[1][0] = 0.0; - matPos[1][1] = 1.0; - matPos[1][2] = 0.0; - matPos[1][3] = 0.0; - matPos[2][0] = 0.0; - matPos[2][1] = 0.0; - matPos[2][2] = 1.0; - matPos[2][3] = 0.0; - matPos[3][0] = bone->curveInX*((0.5*(bone->segments - a - 1)) / (1.0*(bone->segments - 1))); - matPos[3][1] = -bone->curveInY*((0.5*(bone->segments - a - 1)) / (1.0*(bone->segments - 1))); - matPos[3][2] = 0.0; - matPos[3][3] = 1.0; + matPos[0][0] = 1.0f; + matPos[0][1] = 0.0f; + matPos[0][2] = 0.0f; + matPos[0][3] = 0.0f; + matPos[1][0] = 0.0f; + matPos[1][1] = 1.0f; + matPos[1][2] = 0.0f; + matPos[1][3] = 0.0f; + matPos[2][0] = 0.0f; + matPos[2][1] = 0.0f; + matPos[2][2] = 1.0f; + matPos[2][3] = 0.0f; + matPos[3][0] = bone->curveInX * ((0.5f * (bone->segments - a - 1)) / (1.0f * (bone->segments - 1))); + matPos[3][1] = -bone->curveInY * ((0.5f * (bone->segments - a - 1)) / (1.0f * (bone->segments - 1))); + matPos[3][2] = 0.0f; + matPos[3][3] = 1.0f; //mul_m4_v3(matPos, co); /* end x/y pos deform */ diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index b2ab6600bb0..183f4f58bfe 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -630,15 +630,15 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_ui_text(prop, "B-Bone Display Z Width", "B-Bone Z size"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - prop = RNA_def_property(srna, "bbone_rollin", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "bbone_rollin", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "roll1"); - RNA_def_property_range(prop, -360.0f, 360.0f); + RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); RNA_def_property_ui_text(prop, "B-Bone Roll In", "Extra roll in (for B-Bones only)"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - prop = RNA_def_property(srna, "bbone_rollout", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "bbone_rollout", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "roll2"); - RNA_def_property_range(prop, -360.0f, 360.0f); + RNA_def_property_range(prop, -M_PI * 2, M_PI * 2); RNA_def_property_ui_text(prop, "B-Bone Roll Out", "Extra roll out (for B-Bones only)"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); |