[Bf-blender-cvs] [7fe46cd] gooseberry: Merge branch 'master' into gooseberry

Bastien Montagne noreply at git.blender.org
Mon Jun 8 15:41:20 CEST 2015


Commit: 7fe46cdecb96bb445e20e8c6e333285332126780
Author: Bastien Montagne
Date:   Mon Jun 8 15:28:25 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB7fe46cdecb96bb445e20e8c6e333285332126780

Merge branch 'master' into gooseberry

Conflicts:
	source/blender/blenkernel/intern/key.c
	source/blender/blenlib/intern/path_util.c
	source/blender/editors/object/object_shapekey.c

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



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

diff --cc source/blender/blenkernel/BKE_key.h
index 3335a6c,abe1228..1e9e392
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@@ -71,18 -64,8 +71,19 @@@ float *BKE_key_evaluate_object_ex
          float *arr, size_t arr_size);
  float *BKE_key_evaluate_object(
          struct Object *ob, int *r_totelem);
 +float *BKE_key_evaluate_strands_ex(
 +        struct Strands *strands, struct Key *key, struct KeyBlock *actkb, bool lock_shape,
 +        int *r_totelem, float *arr, size_t arr_size);
 +float *BKE_key_evaluate_strands(
 +        struct Strands *strand, struct Key *key, struct KeyBlock *actkbs, bool lock_shape,
 +        int *r_totelem, bool use_motion);
 +float *BKE_key_evaluate_particles_ex(
 +        struct Object *ob, struct ParticleSystem *psys, float cfra, int *r_totelem,
 +        float *arr, size_t arr_size);
 +float *BKE_key_evaluate_particles(
 +        struct Object *ob, struct ParticleSystem *psys, float cfra, int *r_totelem);
  
+ struct Key     **BKE_key_from_object_p(struct Object *ob);
  struct Key      *BKE_key_from_object(struct Object *ob);
  struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
  struct KeyBlock *BKE_keyblock_from_object_reference(struct Object *ob);
diff --cc source/blender/blenkernel/intern/key.c
index 7afcfdb,8427b17..092dd90
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@@ -1932,203 -1392,14 +1932,204 @@@ float *BKE_key_evaluate_object(Object *
  	return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0);
  }
  
 +static void do_strands_key(Strands *strands, Key *key, KeyBlock *actkb, char *out, const int tot)
 +{
 +	KeyBlock *k[4];
 +	float t[4];
 +	int flag = 0;
 +
 +	if (key->type == KEY_RELATIVE) {
 +		WeightsArrayCache cache = {0, NULL};
 +		float **per_keyblock_weights ;
 +		per_keyblock_weights = BKE_keyblock_strands_get_per_block_weights(strands, key, &cache);
 +		BKE_key_evaluate_strands_relative(0, tot, tot, (char *)out, key, actkb, per_keyblock_weights, KEY_MODE_DUMMY);
 +		BKE_keyblock_free_per_block_weights(key, per_keyblock_weights, &cache);
 +	}
 +	else {
 +		const float ctime_scaled = key->ctime / 100.0f;
 +
 +		flag = setkeys(ctime_scaled, &key->block, k, t, 0);
 +
 +		if (flag == 0) {
 +			do_key_strands(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
 +		}
 +		else {
 +			cp_key_strands(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
 +		}
 +	}
 +}
 +
 +float *BKE_key_evaluate_strands_ex(Strands *strands, Key *key, KeyBlock *actkb, bool lock_shape, int *r_totelem, float *arr, size_t arr_size)
 +{
 +	char *out;
 +	int tot = 0, size = 0;
 +	
 +	if (key == NULL || BLI_listbase_is_empty(&key->block))
 +		return NULL;
 +	
 +	/* compute size of output array */
 +	tot = strands->totverts;
 +	size = tot * 3 * sizeof(float);
 +	/* if nothing to interpolate, cancel */
 +	if (tot == 0 || size == 0)
 +		return NULL;
 +	
 +	/* allocate array */
 +	if (arr == NULL) {
 +		out = MEM_callocN(size, "BKE_key_evaluate_strands out");
 +	}
 +	else {
 +		if (arr_size != size) {
 +			return NULL;
 +		}
 +		
 +		out = (char *)arr;
 +	}
 +	
 +	if (lock_shape && actkb) {
 +		/* shape locked, copy the locked shape instead of blending */
 +		float *weights;
 +		
 +		if (actkb->flag & KEYBLOCK_MUTE)
 +			actkb = key->refkey;
 +		
 +		/* XXX weights not supported for strands yet */
 +		weights = get_weights_array_strands(strands, actkb->vgroup, actkb == key->refkey, NULL);
 +		
 +		cp_key_strands(0, tot, tot, out, key, actkb, actkb, weights, 0);
 +		
 +		if (weights)
 +			MEM_freeN(weights);
 +	}
 +	else {
 +		do_strands_key(strands, key, actkb, out, tot);
 +	}
 +	
 +	if (r_totelem) {
 +		*r_totelem = tot;
 +	}
 +	return (float *)out;
 +}
 +
 +float *BKE_key_evaluate_strands(Strands *strands, Key *key, KeyBlock *actkb, bool lock_shape, int *r_totelem, bool use_motion)
 +{
 +	size_t size = sizeof(float) * 3 * strands->totverts;
 +	float *data = MEM_mallocN(size, "strands shape key data");
 +	float *result;
 +	float *fp;
 +	int i;
 +	
 +	if (use_motion && strands->state) {
 +		for (i = 0, fp = data; i < strands->totverts; ++i, fp += 3)
 +			copy_v3_v3(fp, strands->state[i].co);
 +	}
 +	else {
 +		for (i = 0, fp = data; i < strands->totverts; ++i, fp += 3)
 +			copy_v3_v3(fp, strands->verts[i].co);
 +	}
 +	
 +	result = BKE_key_evaluate_strands_ex(strands, key, actkb, lock_shape, r_totelem, data, size);
 +	if (result != data)
 +		MEM_freeN(data);
 +	
 +	return result;
 +}
 +
 +/* returns key coordinates when key applied, NULL otherwise */
 +float *BKE_key_evaluate_particles_ex(Object *ob, ParticleSystem *psys, float cfra, int *r_totelem,
 +                                     float *arr, size_t arr_size)
 +{
 +	const bool use_editmode = (ob->mode & OB_MODE_PARTICLE_EDIT) && psys == psys_get_current(ob) && (psys->edit || psys->pointcache->edit) && !psys->renderdata;
 +	Key *key = psys->key;
 +	KeyBlock *actkb = BKE_keyblock_from_particles(psys);
 +	char *out;
 +	int tot = 0, size = 0;
 +	int i;
 +	
 +	if (key == NULL || BLI_listbase_is_empty(&key->block))
 +		return NULL;
 +	
 +	/* compute size of output array */
 +	tot = 0;
 +	for (i = 0; i < psys->totpart; ++i)
 +		tot += psys->particles[i].totkey;
 +	size = tot * 3 * sizeof(float);
 +	
 +	/* if nothing to interpolate, cancel */
 +	if (tot == 0 || size == 0)
 +		return NULL;
 +	
 +	/* allocate array */
 +	if (arr == NULL) {
 +		out = MEM_callocN(size, "BKE_key_evaluate_object out");
 +	}
 +	else {
 +		if (arr_size != size) {
 +			return NULL;
 +		}
 +		
 +		out = (char *)arr;
 +	}
 +	
 +	/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
 +	BKE_key_set_from_particles(key, ob, psys);
 +	
 +	if (use_editmode) {
 +		/* in edit mode, only evaluate the active shape */
 +		KeyBlock *kb = BLI_findlink(&key->block, psys->shapenr - 1);
 +		
 +		if (kb && (kb->flag & KEYBLOCK_MUTE))
 +			kb = key->refkey;
 +		
 +		if (kb == NULL) {
 +			kb = key->block.first;
 +			psys->shapenr = 1;
 +		}
 +		
 +		cp_key(0, tot, tot, out, key, actkb, kb, NULL, 0);
 +	}
 +	else if (ob->shapeflag & OB_SHAPE_LOCK) {
 +		/* shape locked, copy the locked shape instead of blending */
 +		KeyBlock *kb = BLI_findlink(&key->block, psys->shapenr - 1);
 +		float *weights;
 +		
 +		if (kb && (kb->flag & KEYBLOCK_MUTE))
 +			kb = key->refkey;
 +		
 +		if (kb == NULL) {
 +			kb = key->block.first;
 +			psys->shapenr = 1;
 +		}
 +		
 +		weights = get_particle_weights_array(ob, psys, kb->name, cfra);
 +		
 +		cp_key(0, tot, tot, out, key, actkb, kb, weights, 0);
 +		
 +		if (weights) MEM_freeN(weights);
 +	}
 +	else {
 +		do_psys_key(ob, psys, cfra, key, out, tot);
 +	}
 +	
 +	if (r_totelem) {
 +		*r_totelem = tot;
 +	}
 +	return (float *)out;
 +}
 +
 +float *BKE_key_evaluate_particles(Object *ob, ParticleSystem *psys, float cfra, int *r_totelem)
 +{
 +	return BKE_key_evaluate_particles_ex(ob, psys, cfra, r_totelem, NULL, 0);
 +}
 +
- Key *BKE_key_from_object(Object *ob)
+ Key **BKE_key_from_object_p(Object *ob)
  {
- 	if (ob == NULL) return NULL;
- 	
+ 	if (ob == NULL)
+ 		return NULL;
+ 
  	if (ob->type == OB_MESH) {
  		Mesh *me = ob->data;
- 		return me->key;
+ 		return &me->key;
  	}
  	else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
  		Curve *cu = ob->data;
diff --cc source/blender/editors/space_view3d/view3d_edit.c
index 0078504,d2f53a2..b8add39
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@@ -4607,10 -4607,10 +4607,10 @@@ void ED_view3d_cursor3d_position(bConte
  	Scene *scene = CTX_data_scene(C);
  	ARegion *ar = CTX_wm_region(C);
  	View3D *v3d = CTX_wm_view3d(C);
- 	RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ 	RegionView3D *rv3d = ar->regiondata;
  	bool flip;
  	bool depth_used = false;
 -	
 +
  	/* normally the caller should ensure this,
  	 * but this is called from areas that aren't already dealing with the viewport */
  	if (rv3d == NULL)




More information about the Bf-blender-cvs mailing list