[Bf-blender-cvs] [55b31dd98ce] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Sun Dec 2 04:38:55 CET 2018


Commit: 55b31dd98ce592ef4e51a9f9edece9ade7c519db
Author: Campbell Barton
Date:   Sun Dec 2 14:32:31 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB55b31dd98ce592ef4e51a9f9edece9ade7c519db

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/blenkernel/BKE_armature.h
index 0e356c1557f,efd665b070a..bc91ffeb504
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@@ -142,38 -138,8 +142,48 @@@ typedef struct Mat4 
  	float mat[4][4];
  } Mat4;
  
 -void equalize_bbone_bezier(float *data, int desired);
 -void BKE_pchan_bbone_spline_setup(struct bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BBONE_SUBDIV]);
 +typedef struct BBoneSplineParameters {
 +	int segments;
 +	float length;
 +
 +	/* Non-uniform scale correction. */
 +	bool do_scale;
 +	float scale[3];
 +
 +	/* Handle control bone data. */
 +	bool use_prev, prev_bbone;
 +	bool use_next, next_bbone;
 +
 +	float prev_h[3], next_h[3];
 +	float prev_mat[4][4], next_mat[4][4];
 +
 +	/* Control values. */
 +	float ease1, ease2;
 +	float roll1, roll2;
 +	float scaleIn, scaleOut;
 +	float curveInX, curveInY, curveOutX, curveOutY;
 +} BBoneSplineParameters;
 +
- void BKE_pchan_get_bbone_handles(struct bPoseChannel *pchan, struct bPoseChannel **r_prev, struct bPoseChannel **r_next);
- void BKE_pchan_get_bbone_spline_parameters(struct bPoseChannel *pchan, const bool rest, struct BBoneSplineParameters *r_param);
- 
- void b_bone_spline_setup(struct bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV]);
- 
- void BKE_compute_b_bone_handles(const BBoneSplineParameters *param, float h1[3], float *r_roll1, float h2[3], float *r_roll2, bool ease, bool offsets);
- int BKE_compute_b_bone_spline(struct BBoneSplineParameters *param, Mat4 result_array[MAX_BBONE_SUBDIV]);
- 
- void BKE_pchan_cache_bbone_segments(struct bPoseChannel *pchan);
- void BKE_pchan_copy_bbone_segments_cache(struct bPoseChannel *pchan, struct bPoseChannel *pchan_from);
++void BKE_pchan_bbone_handles_get(
++        struct bPoseChannel *pchan, struct bPoseChannel **r_prev, struct bPoseChannel **r_next);
++void BKE_pchan_bbone_spline_params_get(
++        struct bPoseChannel *pchan, const bool rest, struct BBoneSplineParameters *r_param);
++
++void BKE_pchan_bbone_spline_setup(
++        struct bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV]);
++
++void BKE_pchan_bbone_handles_compute(
++        const BBoneSplineParameters *param,
++        float h1[3], float *r_roll1,
++        float h2[3], float *r_roll2,
++        bool ease, bool offsets);
++int  BKE_pchan_bbone_spline_compute(
++        struct BBoneSplineParameters *param, Mat4 result_array[MAX_BBONE_SUBDIV]);
++
++void BKE_pchan_bbone_segments_cache_compute(
++        struct bPoseChannel *pchan);
++void BKE_pchan_bbone_segments_cache_copy(
++        struct bPoseChannel *pchan, struct bPoseChannel *pchan_from);
  
  /* like EBONE_VISIBLE */
  #define PBONE_VISIBLE(arm, bone) ( \
diff --cc source/blender/blenkernel/intern/armature.c
index 9abd20679d8,0f9c79c5e3e..8c32bed4a3b
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@@ -435,35 -441,9 +435,35 @@@ static void equalize_bbone_bezier(floa
  	copy_qt_qt(fp, temp[MAX_BBONE_SUBDIV]);
  }
  
 -/* returns pointer to static array, filled with desired amount of bone->segments elements */
 -/* this calculation is done  within unit bone space */
 -void BKE_pchan_bbone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BBONE_SUBDIV])
 +/* Get "next" and "prev" bones - these are used for handle calculations. */
- void BKE_pchan_get_bbone_handles(bPoseChannel *pchan, bPoseChannel **r_prev, bPoseChannel **r_next)
++void BKE_pchan_bbone_handles_get(bPoseChannel *pchan, bPoseChannel **r_prev, bPoseChannel **r_next)
 +{
 +	if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO) {
 +		/* Use connected parent. */
 +		if (pchan->bone->flag & BONE_CONNECTED) {
 +			*r_prev = pchan->parent;
 +		}
 +		else {
 +			*r_prev = NULL;
 +		}
 +	}
 +	else {
 +		/* Use the provided bone as prev - leave blank to eliminate this effect altogether. */
 +		*r_prev = pchan->bbone_prev;
 +	}
 +
 +	if (pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO) {
 +		/* Use connected child. */
 +		*r_next = pchan->child;
 +	}
 +	else {
 +		/* Use the provided bone as next - leave blank to eliminate this effect altogether. */
 +		*r_next = pchan->bbone_next;
 +	}
 +}
 +
 +/* Compute B-Bone spline parameters for the given channel. */
- void BKE_pchan_get_bbone_spline_parameters(struct bPoseChannel *pchan, const bool rest, struct BBoneSplineParameters *param)
++void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan, const bool rest, struct BBoneSplineParameters *param)
  {
  	bPoseChannel *next, *prev;
  	Bone *bone = pchan->bone;
@@@ -487,9 -468,23 +487,9 @@@
  		}
  	}
  
- 	BKE_pchan_get_bbone_handles(pchan, &prev, &next);
 -	/* get "next" and "prev" bones - these are used for handle calculations */
 -	if (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) {
 -		/* use the provided bones as the next/prev - leave blank to eliminate this effect altogether */
 -		prev = pchan->bbone_prev;
 -		next = pchan->bbone_next;
 -	}
 -	else {
 -		/* evaluate next and prev bones */
 -		if (bone->flag & BONE_CONNECTED)
 -			prev = pchan->parent;
 -		else
 -			prev = NULL;
 -
 -		next = pchan->child;
 -	}
++	BKE_pchan_bbone_handles_get(pchan, &prev, &next);
  
 -	/* find the handle points, since this is inside bone space, the
 +	/* Find the handle points, since this is inside bone space, the
  	 * first point = (0, 0, 0)
  	 * last point =  (0, length, 0) */
  	if (rest) {
@@@ -583,126 -573,37 +583,126 @@@
  			}
  		}
  		else {
 -			/* Use bone tail as absolute position */
 -			if (rest)
 -				copy_v3_v3(h2, next->bone->arm_tail);
 -			else
 -				copy_v3_v3(h2, next->pose_tail);
 +			/* Apply special handling for smoothly joining B-Bone chains */
 +			param->next_bbone = (next->bone->segments > 1);
 +
 +			/* Use bone tail as absolute position. */
 +			copy_v3_v3(h2, rest ? next->bone->arm_tail : next->pose_tail);
  		}
 -		mul_m4_v3(imat, h2);
  
 -		/* if next bone is B-bone too, use average handle direction */
 -		if (next->bone->segments > 1) {
 -			/* pass */
 +		if (!done) {
 +			mul_v3_m4v3(param->next_h, imat, h2);
  		}
 -		else {
 -			h2[1] -= length;
 +
 +		/* Find the next roll to interpolate as well. */
 +		mul_m4_m4m4(param->next_mat, imat, rest ? next->bone->arm_mat : next->pose_mat);
 +	}
 +
 +	/* Add effects from bbone properties over the top
 +	 * - These properties allow users to hand-animate the
 +	 *   bone curve/shape, without having to resort to using
 +	 *   extra bones
 +	 * - The "bone" level offsets are for defining the restpose
 +	 *   shape of the bone (e.g. for curved eyebrows for example).
 +	 *   -> In the viewport, it's needed to define what the rest pose
 +	 *      looks like
 +	 *   -> For "rest == 0", we also still need to have it present
 +	 *      so that we can "cancel out" this restpose when it comes
 +	 *      time to deform some geometry, it won't cause double transforms.
 +	 * - The "pchan" level offsets are the ones that animators actually
 +	 *   end up animating
 +	 */
 +	{
 +		param->ease1 = bone->ease1 + (!rest ? pchan->ease1 : 0.0f);
 +		param->ease2 = bone->ease2 + (!rest ? pchan->ease2 : 0.0f);
 +
 +		param->roll1 = bone->roll1 + (!rest ? pchan->roll1 : 0.0f);
 +		param->roll2 = bone->roll2 + (!rest ? pchan->roll2 : 0.0f);
 +
 +		if (bone->flag & BONE_ADD_PARENT_END_ROLL) {
 +			if (prev) {
 +				if (prev->bone) {
 +					param->roll1 += prev->bone->roll2;
 +				}
 +
 +				if (!rest) {
 +					param->roll1 += prev->roll2;
 +				}
 +			}
  		}
 -		normalize_v3(h2);
  
 -		/* find the next roll to interpolate as well */
 -		if (rest)
 -			mul_m4_m4m4(difmat, imat, next->bone->arm_mat);
 -		else
 -			mul_m4_m4m4(difmat, imat, next->pose_mat);
 -		copy_m3_m4(result, difmat); /* the desired rotation at beginning of next bone */
 +		param->scaleIn = bone->scaleIn * (!rest ? pchan->scaleIn : 1.0f);
 +		param->scaleOut = bone->scaleOut * (!rest ? pchan->scaleOut : 1.0f);
 +
 +		/* Extra curve x / y */
 +		param->curveInX = bone->curveInX + (!rest ? pchan->curveInX : 0.0f);
 +		param->curveInY = bone->curveInY + (!rest ? pchan->curveInY : 0.0f);
 +
 +		param->curveOutX = bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f);
 +		param->curveOutY = bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f);
 +	}
 +}
 +
 +/* Fills the array with the desired amount of bone->segments elements.
 + * This calculation is done within unit bone space. */
- void b_bone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV])
++void BKE_pchan_bbone_spline_setup(bPoseChannel *pchan, const bool rest, Mat4 result_array[MAX_BBONE_SUBDIV])
 +{
 +	BBoneSplineParameters param;
 +
- 	BKE_pchan_get_bbone_spline_parameters(pchan, rest, &param);
++	BKE_pchan_bbone_spline_params_get(pchan, rest, &param);
 +
- 	pchan->bone->segments = BKE_compute_b_bone_spline(&param, result_array);
++	pchan->bone->segments = BKE_pchan_bbone_spline_compute(&param, result_array);
 +}
 +
 +/* Computes the bezier handle vectors and rolls coming from custom handles. */
- void BKE_compute_b_bone_handles(const BBoneSplineParameters *param, float h1[3], float *r_roll1, float h2[3], float *r_roll2, bool ease, bool offsets)
++void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param, float h1[3], float *r_roll1, float h2[3], float *r_roll2, bool ease, bool offsets)
 +{
 +	float mat3[3][3];
 +	float length = param->length;
  
 -		vec_roll_to_mat3(h2, 0.0f, mat3); /* the result of vec_roll without roll */
 +	if (param->do_scale) {
 +		length *= param->scale[1];
 +	}
  
 -		invert_m3_m3(imat3, mat3);
 -		mul_m3_m3m3(mat3, imat3, result); /* the matrix transforming vec_roll to desired roll */
 +	*r_roll1 = *r_roll2 = 0.0f;
  
 -		roll2 = atan2f(mat3[2][0], mat3[2][2]);
 +	if (param->use_prev) {
 +		copy_v3_v3(h1, param->prev_h);
  
 +		if (param->prev_bbone) {
 +			/* If previous bone is B-bone too, use average handle direction. */
 +			h1[1] -= length;
 +		}
 +
 +		normalize_v3(h1);
 +		negate_v3(h1);
 +
 +		if (!param->prev_bbone) {
 +			/* Find the previous roll to interpolate. */
 +			copy_m3_m4(mat3, param->prev_mat);
 +			mat3_vec_to_roll(mat3, h1, r_roll1);
 +		}
 +	}
 +	else {
 +		h1[0] = 0.0f; h1[1] = 1.0; h1[2] = 0.0

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list