[Bf-blender-cvs] [51260cb] alembic: Create a dummy weights array for strand keys, otherwise the eval function will exit early.

Lukas Tönne noreply at git.blender.org
Mon May 4 13:05:40 CEST 2015


Commit: 51260cbe71dcc4534dee43869e1f2feb3abf5f9b
Author: Lukas Tönne
Date:   Mon May 4 12:57:26 2015 +0200
Branches: alembic
https://developer.blender.org/rB51260cbe71dcc4534dee43869e1f2feb3abf5f9b

Create a dummy weights array for strand keys, otherwise the eval
function will exit early.

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

M	source/blender/blenkernel/BKE_key.h
M	source/blender/blenkernel/intern/key.c

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

diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 4292884..724e446 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -96,6 +96,7 @@ typedef struct WeightsArrayCache {
 } WeightsArrayCache;
 
 float **BKE_keyblock_get_per_block_weights(struct Object *ob, struct Key *key, struct WeightsArrayCache *cache);
+float **BKE_keyblock_strands_get_per_block_weights(struct Strands *strands, struct Key *key, struct WeightsArrayCache *cache);
 void BKE_keyblock_free_per_block_weights(struct Key *key, float **per_keyblock_weights, struct WeightsArrayCache *cache);
 void BKE_key_evaluate_relative(const int start, int end, const int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb,
                                float **per_keyblock_weights, const int mode);
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 29e71ec..c7ebdc2 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1123,6 +1123,12 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
 	return NULL;
 }
 
+static float *get_weights_array_strands(Strands *UNUSED(strands), const char *UNUSED(vgroup), WeightsArrayCache *UNUSED(cache))
+{
+	/* TODO no vgroup support for strands yet */
+	return NULL;
+}
+
 float **BKE_keyblock_get_per_block_weights(Object *ob, Key *key, WeightsArrayCache *cache)
 {
 	KeyBlock *keyblock;
@@ -1143,6 +1149,26 @@ float **BKE_keyblock_get_per_block_weights(Object *ob, Key *key, WeightsArrayCac
 	return per_keyblock_weights;
 }
 
+float **BKE_keyblock_strands_get_per_block_weights(Strands *strands, Key *key, WeightsArrayCache *cache)
+{
+	KeyBlock *keyblock;
+	float **per_keyblock_weights;
+	int keyblock_index;
+
+	per_keyblock_weights =
+		MEM_mallocN(sizeof(*per_keyblock_weights) * key->totkey,
+		            "per keyblock weights");
+
+	for (keyblock = key->block.first, keyblock_index = 0;
+	     keyblock;
+	     keyblock = keyblock->next, keyblock_index++)
+	{
+		per_keyblock_weights[keyblock_index] = get_weights_array_strands(strands, keyblock->vgroup, cache);
+	}
+
+	return per_keyblock_weights;
+}
+
 void BKE_keyblock_free_per_block_weights(Key *key, float **per_keyblock_weights, WeightsArrayCache *cache)
 {
 	int a;
@@ -1391,23 +1417,18 @@ float *BKE_key_evaluate_object(Object *ob, int *r_totelem)
 	return BKE_key_evaluate_object_ex(ob, r_totelem, NULL, 0);
 }
 
-static void do_strands_key(Strands *UNUSED(strands), Key *key, KeyBlock *actkb, char *out, const int tot)
+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) {
-		/* XXX weights not supported for strands yet */
-#if 0
 		WeightsArrayCache cache = {0, NULL};
 		float **per_keyblock_weights ;
-		per_keyblock_weights = BKE_keyblock_get_per_block_weights(ob, key, &cache);
+		per_keyblock_weights = BKE_keyblock_strands_get_per_block_weights(strands, key, &cache);
 		BKE_key_evaluate_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
-		BKE_key_evaluate_relative(0, tot, tot, (char *)out, key, actkb, NULL, KEY_MODE_DUMMY);
-#endif
 	}
 	else {
 		const float ctime_scaled = key->ctime / 100.0f;
@@ -1458,7 +1479,7 @@ float *BKE_key_evaluate_strands_ex(Strands *strands, Key *key, KeyBlock *actkb,
 			actkb = key->refkey;
 		
 		/* XXX weights not supported for strands yet */
-		weights = NULL /*get_weights_array(ob, actkb->vgroup, NULL)*/;
+		weights = get_weights_array_strands(strands, actkb->vgroup, NULL);
 		
 		cp_key(0, tot, tot, out, key, actkb, actkb, weights, 0);




More information about the Bf-blender-cvs mailing list