[Bf-blender-cvs] [d96c692] BendyBones: Bendy Bones: Fix for "flattening out" glitch when scaling up the bone

Joshua Leung noreply at git.blender.org
Tue May 17 16:40:51 CEST 2016


Commit: d96c69259f8c299bca36fcd3366756a8c8ce0d03
Author: Joshua Leung
Date:   Mon May 16 16:40:49 2016 +1200
Branches: BendyBones
https://developer.blender.org/rBd96c69259f8c299bca36fcd3366756a8c8ce0d03

Bendy Bones: Fix for "flattening out" glitch when scaling up the bone

The fix here is to apply a scaling correction to the offsets we're applying
if the do_scale flag gets set. For whatever reason (I'm guessing floating point
precision errors), when the scale factor gets to around 8.15/8.16, there's a bit
more of a difference between x/y or y/z scale factors, leading to everything
needing to get scaled up 8 times (i.e. the bone length for the calculations is
8.16 not 1.0 as per usual). If we don't scale the offsets being applied to
compensate for this, the effect of the offsets will be less (i.e. the handles move
less), hence the bbone flattening out.

===================================================================

M	source/blender/blenkernel/intern/armature.c

===================================================================

diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 592965f..6cf7be2 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -631,11 +631,18 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
 		}
 		
 		/* extra curve x / y */
-		h1[0] += bone->curveInX + (!rest ? pchan->curveInX : 0.0f);
-		h1[2] += bone->curveInY + (!rest ? pchan->curveInY : 0.0f);
+		/* NOTE: Scale correction factors here are to compensate for some random floating-point glitches
+		 *       when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
+		 *       in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
+		 */
+		const float xscale_correction = (do_scale) ? scale[0] : 1.0f;
+		const float yscale_correction = (do_scale) ? scale[2] : 1.0f;
+		
+		h1[0] += (bone->curveInX + (!rest ? pchan->curveInX : 0.0f)) * xscale_correction;
+		h1[2] += (bone->curveInY + (!rest ? pchan->curveInY : 0.0f)) * yscale_correction;
 		
-		h2[0] += bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f);
-		h2[2] += bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f);
+		h2[0] += (bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f)) * xscale_correction;
+		h2[2] += (bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f)) * yscale_correction;
 	}
 	
 	/* make curve */




More information about the Bf-blender-cvs mailing list